hgext/evolve.py
branchstable
changeset 1184 bc601c010185
parent 1183 58370c718183
child 1185 cc3e68120185
--- a/hgext/evolve.py	Sat Dec 13 17:47:09 2014 -0800
+++ b/hgext/evolve.py	Sat Dec 13 18:09:23 2014 -0800
@@ -808,20 +808,25 @@
         try:
             if repo['.'].rev() != dest.rev():
                 merge.update(repo, dest, False, True, False)
-            r = merge.graft(repo, orig, orig.p1(),
-                                   ['local', 'graft'])
-            if r[-1]: #some conflict
+            if keepbranch:
+                repo.dirstate.setbranch(orig.branch())
+            r = merge.graft(repo, orig, orig.p1(), ['local', 'graft'])
+            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)
+            if commitmsg is None:
+                commitmsg = orig.description()
+            extra = {'rebase_source': orig.hex()}
 
-            nodenew = rebase.concludenode(repo, orig.node(), dest.node(),
-                                          node.nullid, commitmsg,
-                                          extrafn=_extrafn)
+            backup = repo.ui.backupconfig('phases', 'new-commit')
+            try:
+                targetphase = max(orig.phase(), phases.draft)
+                repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
+                # Commit might fail if unresolved files exist
+                nodenew = repo.commit(text=commitmsg, user=orig.user(),
+                                      date=orig.date(), extra=extra)
+            finally:
+                repo.ui.restoreconfig(backup)
         except util.Abort, exc:
             repo.dirstate.beginparentchange()
             repo.setparents(repo['.'].node(), nullid)