How to update a SVN file without performing a checkout?

后端 未结 5 1466
故里飘歌
故里飘歌 2020-12-30 02:46

I am writing some scripts to update the Linux box\'s SVN repo with newer versions of xml files. The repo is huge, and there is no checkout version on the same box. The idea

相关标签:
5条回答
  • 2020-12-30 03:16

    There is a way to "update" a file without a working directory, but this is going to depend on what you want to do. I many cases where I do some automated checkins like this, I have found this solution good enough:

    You can use svn import to update the files

    Something like:

    svn import -m "updating the xml" local.xml http://server/path/to/repo/server.xml
    

    Catch is that you cannot import an already existing file, so you will have to issue a delete and then import:

    svn delete -m "deleting for update" http://server/path/to/repo/server.xml
    

    You lose the history, but is a very simple and lightweight way to update file and is completely dependent on what you are doing. If you are not comfortable with the deletion and loss of history, you have to use the methods suggested by other answers.

    0 讨论(0)
  • 2020-12-30 03:26

    If you have a Subversion 1.8 or later client, then you can add or update one or more existing files at a time without checking out the repository using the svnmucc put command. See http://svnbook.red-bean.com/en/1.8/svn.ref.svnmucc.re.html.

    0 讨论(0)
  • 2020-12-30 03:29

    You cannot update a file without checking out a folder locally. There's a shortcut however: in order not to checkout the whole repository, you could checkout only the sub-folder where the file you want to update is.

    If your rep is at https://your.domain/myrep, you could check out https://your.domain/myrep/myfolder

    That way, unless you have the XML file in the root folder, you would reduce the amount of files. If you have control over the repository, you could even create a sub-folder with the single purpose of storing that file.

    0 讨论(0)
  • 2020-12-30 03:34

    You cannot commit a change without a working copy. The reason is that svn does not send the file to the server, it sends the delta (ie the differences). This is designed to reduce network traffic, but obviously, it needs to know the previous version in order to calculate the diff.

    You can checkout a working copy using the sparse options, so you can create a WC with just that 1 file in it, there's no need to checkout the entire repository. Alternatviely, you can expose the repo using webdav, then you just copy the new file over the old one and the auto-commit option will calculate the diff and checkin the file.

    You could store a working copy in your temp location, then you just need to copy the files there and commit. There's no need to delete the WC, just make sure only a special svn user can access it and you can leave the WC there for the next time you need to do this.

    0 讨论(0)
  • 2020-12-30 03:36

    Is the issue that you don't want to bother with the checkout, or because you are afraid that if you do a checkout, you'll have to checkout a lot of files?

    You have to do a checkout in Subversion. You can't simply submit changes without a working copy. (Not entirely true, you can do svn delete and svn mkdir without a checkout.)

    However, you can limit the amount of files that do get checked out with the --depth switch. For example, you can do the following:

    $ svn co --depth=empty http://myserver/myrepos/mydirectory
    

    This will checkout the directory, but without any files in it. You can then do an svn update of just the files you want to modify, then commit those changes:

    $ cd mydirectory            #Enter the empty working copy just checked out
    $ svn update fileToChange   #Adds file you want to change to your working dir
    $ edit fileToChange.xml
    $ svn commit -m "Modified 'fileToChange.xml' with latest version"
    

    This will allow you to change the file fileToChange.xml without having to checkout the entire directory.

    0 讨论(0)
提交回复
热议问题