Patchwork [1,of,7,evolve-ext] _relocatecommit

login
register
mail settings
Submitter Shusen LIU
Date Dec. 7, 2015, 1:46 a.m.
Message ID <3021c118e9b77a0332cb.1449452806@dev1221.lla1.facebook.com>
Download mbox | patch
Permalink /patch/11880/
State Rejected, archived
Delegated to: Laurent Charignon
Headers show

Comments

Shusen LIU - Dec. 7, 2015, 1:46 a.m.
# HG changeset patch
# User Shusen LIU <liushusen@fb.com>
# Date 1449450395 28800
#      Sun Dec 06 17:06:35 2015 -0800
# Node ID 3021c118e9b77a0332cbda182fa27277b9011c04
# Parent  ed63bf62ff02cf5a1c9c12841b3ed0dfa7eccf2c
_relocatecommit

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -953,22 +953,7 @@ 
             if r[-1]:  #some conflict
                 raise error.Abort(
                         'unresolved merge conflicts (see hg help resolve)')
-            if commitmsg is None:
-                commitmsg = orig.description()
-            extra = dict(orig.extra())
-            if 'branch' in extra:
-                del extra['branch']
-            extra['rebase_source'] = orig.hex()
-
-            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)
+            nodenew = _relocatecommit(repo, orig, commitmsg)
         except error.Abort as exc:
             repo.dirstate.beginparentchange()
             repo.setparents(repo['.'].node(), nullid)
@@ -3654,3 +3639,32 @@ 
         help.helptable.append((["evolution"], _("Safely Rewriting History"),
                       _helploader))
         help.helptable.sort()
+
+def _relocatecommit(repo, orig, commitmsg, continued=False):
+    if commitmsg is None:
+        commitmsg = orig.description()
+    extra = dict(orig.extra())
+    if 'branch' in extra:
+        del extra['branch']
+
+    if continued:
+        source = orig.extra().get('source')
+        if source:
+            extra['source'] = source
+            extra['intermediate-source'] = orig.hex()
+        else:
+            extra['source'] = orig.hex()
+        extra.pop('rebase_source', None)
+    else:
+        extra['rebase_source'] = orig.hex()
+
+    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)
+    return nodenew