17

In a mercurial repo, the "default" branch has fallen very out of date to the point where it no longer makes sense to merge in the changes from "develop", a named branch which has the latest deployed version of the application.

Instead of merging develop into default, how can I close the current default branch and then create a new default branch using the head from develop?

I've seen a few other questions and answers which are similar, perhaps the same, but I am still having trouble understanding how this should work.

Thanks!

kgx
  • 1,195
  • 3
  • 15
  • 26
  • alternatively, you could `update` to default and `merge` with develop, but before committing the merge you make it an exact copy of develop. – Edward Feb 20 '13 at 17:59
  • That would actually work, but how can I do that? – kgx Feb 20 '13 at 18:42

3 Answers3

28

If default has diverged somewhat from develop and you want default to be exactly the same as develop after the merge, you need a slightly different set of commands from what Edward gave you (this will also work where develop is a direct descendant of default).

hg update -C default
hg -y merge --tool internal:fail develop
hg revert --all --no-backup -r develop
hg resolve --all --mark
hg commit -m "merge updating default to current develop"

This means that any conflicts will result in an unresolved merge. You then revert everything to be the same as on the develop branch (with no backup so you don't get lots of .orig files left over).

Tim Delaney
  • 5,535
  • 3
  • 24
  • 18
2

Based on your comment that it is not a requirement to close the branch, here's a series of steps that should get the default branch in tune with the develop branch:

  1. hg update default
  2. hg merge --tool internal:other -- to merge while privileging the develop branch
  3. hg diff -r develop -- compare with develop to ensure that you have an exact copy
  4. hg commit -m "merge updating default to current develop"

Once complete, you should have an updated default that mirrors the develop branch, bringing them back into sync.

Edward
  • 3,292
  • 1
  • 27
  • 38
  • Edward thank you for the answer. I tested out your process and got the following result on step 2: abort: branch 'default' has one head - please merge with an explicit rev. In my repo there are more then 2 heads due to several other active named branches. Anyways, this initial solution clearly got the ball rolling so thanks again. Also the hg diff -r is useful command which I have not seen before. – kgx Feb 21 '13 at 17:43
0

I think it is better to use a concept in Tortoisehg to explain how it works.

  • hg update to develop branch
  • choose the head of default branch, and choose merge with local
  • then choose discard all changes from merge target (other), thus default is merged into develop without affecting the develop
  • then branch to default from the head of develop, use hg branch default, default restarts again
ivzhh
  • 331
  • 5
  • 11