changeset 3630:2789c0ec2ad7

evolve: move logic to complete interrupted relocation to new fn This moves logic which completed the interrupted relocation to it's own separate function as we will need that function in continuing phase-divergence and content-divergence too.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 24 Mar 2018 13:17:05 +0530
parents f23946bf6625
children 8db32b33cdf1
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Sat Mar 24 12:58:12 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Sat Mar 24 13:17:05 2018 +0530
@@ -1262,6 +1262,28 @@
 def _completeorphan(ui, repo, evolvestate):
     """function to complete the interrupted orphan resolution"""
 
+    node = _completerelocation(ui, repo, evolvestate)
+    # resolving conflicts can lead to empty wdir and node can be None in
+    # those cases
+    ctx = repo[evolvestate['current']]
+    newctx = repo[node] if node is not None else repo['.']
+    compat.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
+
+    # make sure we are continuing evolve and not `hg next --evolve`
+    if evolvestate['command'] == 'evolve':
+        evolvestate['replacements'][ctx.node()] = node
+        if evolvestate['orphanmerge']:
+            # processing a merge changeset with both parents obsoleted,
+            # stabilized on second parent, insert in front of list to
+            # re-process to stabilize on first parent
+            evolvestate['revs'].insert(0, repo[node].rev())
+            evolvestate['orphanmerge'] = False
+
+def _completerelocation(ui, repo, evolvestate):
+    """function to complete the interrupted relocation of a commit
+    return the new node formed
+    """
+
     orig = repo[evolvestate['current']]
     ctx = orig
     source = ctx.extra().get('source')
@@ -1313,18 +1335,4 @@
     with repo.ui.configoverride(overrides, 'evolve-continue'):
         node = repo.commit(text=message, user=user,
                            date=date, extra=extra)
-
-    # resolving conflicts can lead to empty wdir and node can be None in
-    # those cases
-    newctx = repo[node] if node is not None else repo['.']
-    compat.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
-
-    # make sure we are continuing evolve and not `hg next --evolve`
-    if evolvestate['command'] == 'evolve':
-        evolvestate['replacements'][ctx.node()] = node
-        if evolvestate['orphanmerge']:
-            # processing a merge changeset with both parents obsoleted,
-            # stabilized on second parent, insert in front of list to
-            # re-process to stabilize on first parent
-            evolvestate['revs'].insert(0, repo[node].rev())
-            evolvestate['orphanmerge'] = False
+    return node