views:

629

answers:

5

Hi,

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 matchinf 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

A: 
  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
webwesen
Too cumbersome, and prone to missing files in step 4. (I will have to copy files selectively since copying EVERYTHING isn't an option - take the .svn folders themselves, for example).
Danra
A: 

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

Vanessa MacDougal
no, what he describes is the result of a svn merge, I think
Valentin Rocher
A: 

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
Valentin Rocher
Hrmph that's OK I guess.I ended up using something similar - Used the mirror functionality of Beyond Compare (http://www.scootersoftware.com/) to take just the modified files.Still, this is basic functionality which I would expect out of TortoiseSVN. At the least I should have an easy way to view the bad merge - the TortoiseSVN "reintegrate a branch" *Updates* the files with the *Merged* copies, so I can't even view the merge history.
Danra
A: 

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.)

JXG
+4  A: 
tzaman
I think that won't work.The reintegrate-merge itself is the problem. As far as I have seen, after step 3 the trunk working copy might *not* be identical to the branch - because the final file isn't just taken from the branch, it is the result of a merge between the trunk file and the branch file.
Danra
Nope, merging only combines changes made on both sides *after* the point of common ancestry. Here, since the trunk has no changes from the point where you branched off, it should work fine.
tzaman
Indeed it works. Thanks a lot!
Danra
You're welcome! Glad I could help.
tzaman