merge 2 svn branches together
Asked Answered
C

2

5

I'm working with an svn setup I'm not used to and I need to merge new code from one branch to another.

There's no code in the trunk folder so I don't know if I should update the trunk to the code and update the second branch, OR if there is a way to just update one branch to the other. My last resort is going to be just updating the code manually.

Any ideas what the best route here is? I'm doing everything from a terminal.

Centennial answered 8/12, 2010 at 22:21 Comment(0)
M
7

No Don't update manually. Of course the difficulty will depend on how close those branches are.

You can always bring changes from a branch to another branch. Let's say you have two branch named branch1 and branch2 and you want to merge branch2 to branch1.

Say you are in branch1 (Try the dry run first to see if it results in conflicts)

svn merge -r LAST_MERGED_REVISION:HEAD_REVISION --dry-run url/to/branches/branch2 .

svn merge -r LAST_MERGED_REVISION:HEAD_REVISION url/to/branches/branch2 .
svn status | egrep '^C|^.C' <---Manual intervention is required for conflicts
svn update
svn ci -m "Merge changes from branch2"

And you can close out branch2

svn merge --reintegrate url/to/branches/branch2
svn update
svn ci -m "Merged branch2 to branch1"

This may fail in case the branches are very divergent.

Meticulous answered 8/12, 2010 at 22:41 Comment(5)
looks like this is going to work, though I get tree conflicts on older files I don't think I've changed. Any idea how to fix those? The files would have very minor changesCentennial
@wajiw: Did you try the dry run? This is good news, if there are only minor changes in some files. Some of them can be resolved manually after the automatic merge and resolve them using svn resolve command. But do this only after you have inspected the reason for merge failure.Meticulous
yup, that worked great. used 'svn resolve --accept working -R .' to resolve the conflicts because they should've been working in the first place. Thanks!Centennial
@wajiw: Thanks. :) Thats fine but make sure that you have not left behind any changes that you wanted from the older one. svn resolve manually lets you tell that this is the final resolution of merge output. It is like a dictum. We normally inspect the changes, incorporate them manually in case of conflicts only and then use svn resolve to resolve the merge conflict.Meticulous
sure thing. checked and looks like both repos are perfect and new merge is running through regression tests successfully. thanks again!Centennial
L
1

Depending on what subversion release you are using, I recommend to use svnmerge, or subversion's builtin merge tracking support. In any case, it is well possible to merge from one branch to another, without using the trunk (assuming that the branches have some relatively-close ancestor).

Lumbricoid answered 8/12, 2010 at 22:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.