“Naive” svn merge from branch into trunk?

[亡魂溺海] 提交于 2020-01-01 07:58:26

问题


I am using TortoiseSVN for my C++ project, and am trying to "reintegrate a branch" back into the trunk.

My case is simple enough so that for every file which has changed in the branch, I would like it to completely overwrite the matching file in the trunk. Unfortunately, TortoiseSVN is smarter than me, so it merges each pair of files - resulting in some inconsistent code. For example, some code lines which have been deleted in the branch are restored in the merged version.

Is there any way to force TortoiseSVN to use the naive merge behaviour of overwriting all the modified files?

Thanks, Dan


回答1:


Here's how to do it just using SVN (no mucking about in the filesystem):

  1. Check out the trunk revision from which you created the branch (not the HEAD revision).
  2. Commit it to the repository (this undoes all subsequent trunk changes).
  3. Do your reintegrate-merge (your trunk working copy should now be identical to the branch.)
  4. Commit the merged trunk, and you're done!



回答2:


  1. update to the latest on a branch
  2. copy all files somewhere on your workstation
  3. switch branch to trunk
  4. overwrite using regular windows explorer (only changed files will be overwritten)
  5. commit



回答3:


A little amelioration to webwesen's answer, since I don't really see a simple way :

  • do a svn export of the branch in some dir
  • copy all files from this dir to the trunk dir
  • commit



回答4:


To the best of my knowledge, this is currently impossible in svn, so TortoiseSVN can't help you.

To simplify a little bit (okay, a lot), take the svn update command as an example. If there are modifications in your working copy as well as the repository, but no actual conflicts, svn update will simply merge the repository's changes into your working copy.

I don't think there's a way around this. If you had actual conflicts, you could use the --accept ACTION command-line option to keep only the local changes (for example). But if you want to specify an acceptance action for any file changed in both the repository and working copy, you're unfortunately Out Of Luck.

It occurs to me that asking svn developers for a command-line option for this case might be an idea, not that it would be released in time to help you here.

The conflict-resolution issue I mentioned suggests a hideously ugly hack, which I do not recommend. Using your favorite tools, get a list of the files that changed in the branch. Now, for each file in that list, modify it on the trunk by prepending an unusual character to each line. Commit the changes to the trunk. Merge to bring the branch up to date before reintegrating, but use --accept to prevent any of the horrible trunk files from making it in. Then, reintegrate, again using --accept to overwrite the horrible trunk files.

I should add that you can't do this with TortoiseSVN, at least not obviously, because it doesn't support --accept, at least not that I could find.

Well, I said it was hideously ugly. Don't try this at home! (I certainly haven't.)




回答5:


The "svn merge" command is designed for this purpose, and will allow you to merge in one step. Instructions here.



来源:https://stackoverflow.com/questions/2220570/naive-svn-merge-from-branch-into-trunk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!