hgext/evolve.py
changeset 1141 ca17770d2ee9
parent 1140 b7d85cd8ec7b
child 1143 160fd06312fc
--- a/hgext/evolve.py	Sat Oct 25 22:25:42 2014 -0400
+++ b/hgext/evolve.py	Sat Nov 01 13:48:34 2014 +0000
@@ -758,7 +758,7 @@
 class MergeFailure(util.Abort):
     pass
 
-def relocate(repo, orig, dest):
+def relocate(repo, orig, dest, keepbranch=False):
     """rewrite <rev> on dest"""
     if orig.rev() == dest.rev():
         raise util.Abort(_('tried to relocate a node on top of itself'),
@@ -811,8 +811,15 @@
             if r[-1]: #some conflict
                 raise util.Abort(
                         'unresolved merge conflicts (see hg help resolve)')
+            if keepbranch:
+                def _extrafn(ctx, extra):
+                    extra['branch'] = ctx.branch()
+            else:
+                _extrafn = (lambda ctx, extra: None)
+
             nodenew = rebase.concludenode(repo, orig.node(), dest.node(),
-                                          node.nullid, commitmsg)
+                                          node.nullid, commitmsg,
+                                          extrafn=_extrafn)
         except util.Abort, exc:
             repo.dirstate.beginparentchange()
             repo.setparents(repo['.'].node(), nullid)
@@ -1341,8 +1348,9 @@
     else:
         repo.ui.note(todo)
         if progresscb: progresscb()
+        keepbranch = orig.p1().branch() != orig.branch()
         try:
-            relocate(repo, orig, target)
+            relocate(repo, orig, target, keepbranch)
         except MergeFailure:
             repo.opener.write('graftstate', orig.hex() + '\n')
             repo.ui.write_err(_('evolve failed!\n'))