Can SVN copy and redefine the target branch or merge and save the source branch?

I am new to SVN. I found that when you merge branch A into branch B, SVN moves all the contents in branch A to B, rather than copying. And when you copy branch A to branch C, and when you do the same thing again, it gives you the error branch C already exists.

I want to do the following:

  • I have branch/dev - for development
  • then copy branch/dev to branch/test - to test the function
  • then copy branch/test to trunk - for stage
  • then tagged for production.

Since I cannot override the existing branch, when I want to copy branch/dev again, I need to delete the test first, which is inconvenient.

Is there any way to do this?

+4
source share
2 answers

svn merge does not "move all content". In fact, merging and copying are in Subversion for a wide variety of operations. The merge will accept the changes made to the branch and merge them into a working copy:

 $ cd my/working/copy $ svn merge ^/branches/myfeaturebranch . 

Merge all (unchecked) changes from ^/branches/myfeaturebranch to my/working/copy . This will leave you a working copy containing all the changes from /branches/myfeaturebranch that you are trying to merge. At this point, you may also have conflicts that must be resolved before committing. (Note that the final act of merging just makes a bunch of changes.)

Copying, on the other hand, is similar to cp -r SRC DST , where SRC and DST can be either local file paths or repository URLs. When copying repo-to-repo, Subversion will copy (not merge) everything from SRC to DST . For instance:

 $ svn copy ^/trunk ^/tags/1.0.0 

This will copy (or "tag") the current trunk to ^/tags/1.0.0 . If the destination already exists, Subversion will refuse to overwrite it.

So what you want to do is probably something like

 $ svn copy ^/trunk ^/branches/dev # create dev branch from trunk $ svn co ^/branches/dev # checkout dev branch $ cd dev $ .... hack away .... $ svn commit .... # commit your development changes $ svn copy ^/branches/dev/ ^/branches/test # create testing branch $ svn switch ^/branches/test # switch to testing branch $ .... perform tests .... $ svn commit .... # commit your changes in the testing branch $ svn switch ^/trunk # switch back to trunk $ svn merge ^/branches/test . # merge testing changes into working copy for trunk $ .... resolve any conflicts .... $ svn commit .... # commit merge $ svn copy ^/trunk ^/tags/1.0.0 # final production tag 

Hope this fixes a bit.

+4
source

If you copy from /a to /b when /b already exists, you will get /a/b .

If you need the equivalent of copy-with-overwrite, you will need to delete and then a copy, for example:

 svn delete https://myserver/myrepo/branch/test -m "Removing test prior to copy" svn copy https://myserver/myrepo/branch/dev -r HEAD https://myserver/myrepo/branch/test --parents -m "Copying dev branch to test" 

When users in the test branch perform svn update , svn is smart enough to download only changed files , rather than reload the entire project.

The disadvantage of this approach is that there is some time, even if it is only for a few seconds, where this branch will not exist, and users who are already in this branch will receive an error message if they try to update.

+4
source

Source: https://habr.com/ru/post/1347766/


All Articles