[ACCEPTED]-Subversion: How to merge only specific revisions into trunk when multiple consecutive changes are made in a branch?-three-way-merge
Merging only revisions 4,7, and 11-15 with 1 svnmerge:
svnmerge.py merge -r4,7,11-15
And with regular svn:
svn merge -c4,7 -r10:15 http://.../branches/TRY-XX-Foo
The problem is that both svn
A <<<<<<< .working ======= B (unwanted change) C (important bug fix) >>>>>>> .merge-right.r341
and TortoiseSVN 7 is treating the situation as 2-way merge. I've 6 heard of the term 3-way merge, so I gave 5 Beyond Compare a shot. With quick set up with TortoiseSVN, Edit 4 Conflict now bring up the following screen. This 3 is not perfect, since it's still requiring 2 human intervention, but at least I can tell 1 which changes are coming from where.
I believe you are including the revisions 6 you want correctly, but the merge algorithm 5 is failing to find the place to insert the 4 wanted change and so including the line 3 above it also. Here are the same steps but 2 with a different set of changes, and I believe 1 it works as you expected originally:
$ svnadmin create repo $ svn mkdir -m '' file://`pwd`/repo/trunk Committed revision 1. $ svn mkdir -m '' file://`pwd`/repo/branches Committed revision 2. $ svn co file://`pwd`/repo/trunk co.trunk Checked out revision 2. $ cat > co.trunk/test.txt << EOF > A > B > C > EOF $ svn add co.trunk/test.txt A co.trunk/test.txt $ svn commit -m '' co.trunk Adding co.trunk/test.txt Transmitting file data . Committed revision 3. $ svn copy -m '' file://`pwd`/repo/trunk file://`pwd`/repo/branches/testbr Committed revision 4. $ svn co file://`pwd`/repo/branches/testbr co.testbr A co.testbr/test.txt Checked out revision 4. $ cat > co.testbr/test.txt << EOF > A > A1 unwanted > B > C > EOF $ svn commit -m '' co.testbr Sending co.testbr/test.txt Transmitting file data . Committed revision 5. $ cat > co.testbr/test.txt << EOF > A > A1 unwanted > B > B1 wanted > C > EOF $ svn commit -m '' co.testbr Sending co.testbr/test.txt Transmitting file data . Committed revision 6. $ svn merge -r 5:6 file://`pwd`/repo/branches/testbr co.trunk --- Merging r6 into 'co.trunk': U co.trunk/test.txt $ cat co.trunk/test.txt A B B1 wanted C
Well to clarify a thing about merge is that 7 it actually has 2 steps.
So that means that 6 after your merge is done, you can do a manual 5 diff against head and the other branch to 4 make sure that the merge was correct. And 3 if something was wrong with it, like in 2 your case, you can manually fix it before 1 the commit.
In TortoiseSVN, you must only specify the 17 revisions you want to merge. Unlike the 16 command line client where you have to specify 15 e.g. -r4:5 to merge the changes between 14 r4 and r5, you only have to specify '5' as 13 the revision number to merge in the TortoiseSVN 12 merge dialog. If you're not sure, always 11 use log dialog from the merge dialog and 10 select the revisions you want to merge in 9 that log dialog (then click OK and the selected 8 revisions will automatically get set in 7 the merge dialog).
As for resolving your 6 conflict in TortoiseMerge: According to 5 the screenshot in your question, TortoiseMerge 4 shows you two conflicted lines (the ones 3 shown as '????' in the bottom view). What 2 you want is to include the change 'C' but 1 not 'B'?
- left click on the first '???' line to select it, then right-click, choose 'use block from "mine"' from the context menu
- left click on the second '???' line to select it, then right-click, choose 'use block from "theirs"' from the context menu
- Click the save button (or File->Save)
- Optionally click on the "Mark as resolved" button
Another thing you could do would be to manually 18 undo the bad commit on the branch, which 17 would then allow you to merge the branch 16 back into the trunk as you would normally.
Using 15 TortoiseSVN you open up the log view on 14 a file, select the offending version, and 13 choose "Revert changes from this revision" from 12 the right click menu. Commit the changes 11 it makes on your working copy and then you 10 can merge the branch back in easily.
To do 9 this with the command line client you perform 8 a reverse merge, (This is taken from the 7 Pragmatic Source Control using Subversion 6 book) where you merge the changes between 5 the offending version and the previous 4 version into the working copy of the file. Then 3 as above you'd commit the changes and can 2 then branch normally. In your example you 1 would do something like:
svn merge -r 4:3 test.txt
As pointed out by other users (I won't take 13 credit for noticing it because I didn't), it 12 may be the trivial nature of this merge 11 (i.e. lack of context around the change) that 10 is confusing the tools.
I do a lot of merging 9 and, as you discovered, the merge tool provided 8 by Tortoise is awful. A three-way merge 7 tool is an absolute must if you do this 6 very often. Beyond Compare is my personal 5 favorite, but there are other that are free 4 (Meld, KDiff3) and ones that are not (Araxis).
You 3 will notice that Beyond Compare did the 2 right thing in the end, even if it makes 1 you manually verify it correctness!
If you don't want the unwanted change, do 3 not merge revision 4:5, but just revision 2 5. It means you merge the change committed 1 in revision 5.
More Related questions