changeset 3632:8d38b88233cb

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.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 24 Mar 2018 16:41:14 +0530
parents 8db32b33cdf1
children ed3032ee53eb
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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()