Subversion merge local changes trunk to branch

me_and picture me_and · Dec 9, 2009 · Viewed 11.5k times · Source

In my local Subversion working copy, I have a copy of trunk and of a code branch. I've made changes in the trunk, and want to copy these changes to my (currently clean) local copy of the branch.

I know I can check in the code to trunk, then use svn merge to get the changes onto the branch, but is there some way of doing this without first checking the changes in?

Sadly, diff/patch won't work, as there are changes in the code surrounding my changes between trunk and branch. I know svn merge can cope with those, but as I say, I'd rather not have to check my changes in first.

Edited to add an example:

The trunk has a file containing the following:

File in trunk:                       File in branch:
apple                                apple
orange                               banana
pear                                 pear

In trunk, I add dragon fruit below pear in the trunk file on my working copy. Were I to check that change in and use merge to copy it to branch, Subversion would correctly add dragon fruit below pear in the branch version of the file.

svn diff on my copy of the trunk file produces something similar to the following:

Index: fruit.txt
===================================================================
--- fruit.txt  (revision 56)
+++ fruit.txt  (working copy)
@@ -1,3 +1,4 @@
 apple
 orange
 pear
+dragon fruit

Clearly using patch won't work, as it notices the difference between the non-changed texts.

What I want to happen, without having to check anything in, is to have dragon fruit listed after pear in both files, but not to have the orange/banana difference changed on either file.

Answer

moonshadow picture moonshadow · Dec 9, 2009

You could svn switch a copy of your working copy to the branch.

Your safest bet, though, is to commit your changes to a private branch and use svn merge to merge them wherever you need them.