evolve: move logic to resolve phase-divergence in a new function
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 24 Mar 2018 16:41:14 +0530
changeset 3632 8d38b88233cb
parent 3631 8db32b33cdf1
child 3633 ed3032ee53eb
evolve: move logic to resolve phase-divergence in a new function This patch moves logic which does the revert and create a commit on top of public changeset because we need to repeat that logic while handling continuation of `hg evolve` when there are conflicts while rebasing the phase-divergent changeset.
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py	Sat Mar 24 16:38:03 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Sat Mar 24 16:41:14 2018 +0530
@@ -223,14 +223,7 @@
         return (False, '')
     if progresscb:
         progresscb()
-    newid = tmpctx = None
     tmpctx = bumped
-    tr = repo.currenttransaction()
-    assert tr is not None
-    bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
-    # function to update the bookmark from the rebased changeset to new resolved
-    # changeset
-    rebasedbmupdate = None
 
     # Checking for whether the phase-divergent changeset has common parents as
     # it's precursors. Phase-divergent changeset and precursor having different
@@ -248,10 +241,6 @@
                 tmpctx = repo[tmpid]
                 compat.createmarkers(repo, [(bumped, (tmpctx,))],
                                      operation='evolve')
-                # after rebasing, the changeset against which revert should
-                # happen should be the new rebased changeset
-                bumped = tmpctx
-                rebasedbmupdate = _bookmarksupdater(repo, bumped.node(), tr)
         except MergeFailure:
             evolvestate['current'] = bumped.hex()
             evolvestate['precursor'] = prec.hex()
@@ -261,6 +250,22 @@
             repo.ui.write_err(msg)
             raise
 
+    return _resolvephasedivergent(ui, repo, prec, bumped, tmpctx)
+
+def _resolvephasedivergent(ui, repo, prec, bumped, tmpctx=None):
+
+    tr = repo.currenttransaction()
+    assert tr is not None
+    bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
+    newid = None
+
+    # function to update the bookmark from the rebased changeset to new resolved
+    # changeset
+    rebasedbmupdate = None
+    if tmpctx and tmpctx.node() != bumped.node():
+        rebasedbmupdate = _bookmarksupdater(repo, tmpctx.node(), tr)
+        bumped = tmpctx
+
     # Create the new commit context
     repo.ui.status(_('computing new diff\n'))
     files = set()