Svn merging and automatically resolving conflicts
Asked Answered
V

2

6

I am new to svn and need to do a lot of merging from trunk to a branch we are working from. This is the sequence of svn commmands I take to merge

svn up
svn mergeinfo --show-revs eligible branch trunk (branch and trunk are actually svn urls)

I get the lowest revision of the eligible revisions from branch and the latest trunk revision, then do an svn merge.

svn merge -r lowest_eligible:latest_trunk trunk_url .

During the merge there are a few conflicts. However, they are not related to any changes we have made in the branch so I'm a little confused why they are conflicts. Any ideas? Anyway, I always just choose, theirs-full to resolve it

Finally, I need to do svn resolve before committing

svn resolve --accept working -R .

I have two questions. Is this the best sequence of commands to perform a merge from trunk to branch?

The merge tends to take a while so I would like to just leave it merging and let svn automatically resolve the conflict to theirs-full. Is there a way to do this?

Verticillaster answered 13/4, 2013 at 5:14 Comment(1)
Do I understand correctly that lowest_eligible is a revision from branch history and latest_trunk is a revision from trunk history?Excerpt
M
4
  1. If you merge from trunk to branch (in branch's WC) order of parameters in mergeinfo is incorrect (reversed): shortened correct form have to be svn mergeinfo --show-revs eligible trunk (first parameter is SOURCE of merge, second - TARGET /default "."/, i.e your WC)
  2. If you use Subversion, which has already support for mergeinfo, you can skip detecting range of "have to be merged" revisions - Subversion do it automagically on merge
  3. If you want in case of conflict always prefer changes from trunk, you can add it to merge command

As final result, your periodical sync-merge process will be single command inside WC of branch

svn merge <URL-OF-TRUNK> --accept "theirs-conflict"

Martica answered 13/4, 2013 at 16:8 Comment(0)
F
3

Usually, merging should be much simpler - especially if you are only merging from trunk to branch. In that case, just make sure that

A) you have no uncommitted changes in your branch working copy, and B) that you have a current version of the branch (which you were already doing by doing an 'svn up')

If you're ready to merge, just execute

svn merge ^/trunk 

in your branch working copy.

As for the conflicts: Sometimes svn botches the merge diff and reports conflicts where there are none. A good three-way merge tool such as kdiff3 can help wonders. Other than that, I recommend to NOT use automatic conflict resolution, as most conflicts will not grow easier to solve by just avoiding their resolution. Using the process described above, you should at least be able to avoid all unnecessary conflicts.

Fluctuation answered 13/4, 2013 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.