hgext/evolve.py
changeset 1187 253293df84a6
parent 1181 ad7a31a7a413
parent 1185 cc3e68120185
child 1192 a556fff7adcf
--- a/hgext/evolve.py	Sun Nov 30 00:11:06 2014 -0800
+++ b/hgext/evolve.py	Sun Dec 14 12:14:45 2014 -0800
@@ -768,8 +768,6 @@
                                 "manually with nothing to rebase - working "
                                 "directory parent is also destination"))
 
-    rebase = extensions.find('rebase')
-    # dummy state to trick rebase node
     if not orig.p2().rev() == node.nullrev:
         raise util.Abort(
             'no support for evolving merge changesets yet',
@@ -806,21 +804,27 @@
     tr = repo.transaction('relocate')
     try:
         try:
-            r = rebase.rebasenode(repo, orig.node(), dest.node(),
-                                  {node.nullrev: node.nullrev}, False,
-                                  orig.p1().node())
-            if r[-1]: #some conflict
+            if repo['.'].rev() != dest.rev():
+                merge.update(repo, dest, False, True, False)
+            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)
@@ -2247,11 +2251,6 @@
 
 @eh.extsetup
 def oldevolveextsetup(ui):
-    try:
-        rebase = extensions.find('rebase')
-    except KeyError:
-        raise error.Abort(_('evolution extension requires rebase extension.'))
-
     for cmd in ['kill', 'uncommit', 'touch', 'fold']:
         entry = extensions.wrapcommand(cmdtable, cmd,
                                        warnobserrors)