changeset 4466:cc4506838589

evolve: remove tmpctx arg from _resolvephasedivergent() Before this patch, in _resolvephasedivergent() function we were passing an optional argument "tmpctx" which was used to store a rebased version of bumped if required. But for sake of simplicity we can achieve the same results even without passing this "tmpctx" into that function. No changes in test files demonstrate that this patch don't break anything.
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Tue, 02 Apr 2019 18:01:43 +0530
parents 6feeaf00db44
children 6fc5e162ea84
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 18 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Fri Mar 29 11:48:36 2019 +0100
+++ b/hgext3rd/evolve/evolvecmd.py	Tue Apr 02 18:01:43 2019 +0530
@@ -229,7 +229,6 @@
         return (False, ".")
     if progresscb:
         progresscb()
-    tmpctx = bumped
 
     # Checking for whether the phase-divergent changeset has common parents as
     # it's precursors. Phase-divergent changeset and precursor having different
@@ -242,13 +241,14 @@
         repo.ui.status(
             _('rebasing to destination parent: %s\n') % prec.p1())
         try:
-            tmpid = relocate(repo, bumped, prec.p1(), evolvestate,
-                             category='phasedivergent')
-            if tmpid is not None:
-                tmpctx = repo[tmpid]
-                obsolete.createmarkers(repo, [(bumped, (tmpctx,))],
+            newnode = relocate(repo, bumped, prec.p1(), evolvestate,
+                               category='phasedivergent')
+            if newnode is not None:
+                new = repo[newnode]
+                obsolete.createmarkers(repo, [(bumped, (new,))],
                                        operation='evolve')
-                evolvestate['temprevs'].append(tmpid)
+                bumped = new
+                evolvestate['temprevs'].append(newnode)
         except MergeFailure:
             evolvestate['current'] = bumped.hex()
             evolvestate['precursor'] = prec.hex()
@@ -256,36 +256,26 @@
             raise error.InterventionRequired(_("fix conflicts and see `hg help "
                                                "evolve.interrupted`"))
 
-    return _resolvephasedivergent(ui, repo, prec, bumped, tmpctx)
+    return _resolvephasedivergent(ui, repo, prec, bumped)
 
-def _resolvephasedivergent(ui, repo, prec, bumped, tmpctx=None):
+def _resolvephasedivergent(ui, repo, prec, bumped):
     """final step of a phase divergence resolution
 
     This will create a new changesets (or nothing when applicable), the two
     changesets needs to be on the same parents.
-
-    XXX we should deal with all tmpctx business before callin this function and
-    pass tmpctx as bumped directly
     """
-
     tr = repo.currenttransaction()
     assert tr is not None
-    bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
-    newid = None
-    replacementnode = 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
 
     cl = repo.changelog
     prec_parent = cl.parentrevs(prec.rev())
     bump_parent = cl.parentrevs(bumped.rev())
     assert prec_parent == bump_parent, (prec_parent, bump_parent)
 
+    bmupdate = _bookmarksupdater(repo, bumped.node(), tr)
+    newid = None
+    replacementnode = None
+
     # Create the new commit context
     files = set()
     copied = copies.pathcopies(prec, bumped)
@@ -326,17 +316,14 @@
         replacementnode = newid
     if newid is None:
         repo.ui.status(_('no changes to commit\n'))
-        obsolete.createmarkers(repo, [(tmpctx, ())], operation='evolve')
+        obsolete.createmarkers(repo, [(bumped, ())], operation='evolve')
         newid = prec.node()
     else:
         repo.ui.status(_('committed as %s\n') % nodemod.short(newid))
         phases.retractboundary(repo, tr, bumped.phase(), [newid])
-        obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))],
+        obsolete.createmarkers(repo, [(bumped, (repo[newid],))],
                                flag=obsolete.bumpedfix, operation='evolve')
     bmupdate(newid)
-    # if rebased happened, update bookmarks from there too
-    if rebasedbmupdate:
-        rebasedbmupdate(newid)
     # reroute the working copy parent to the new changeset
     with repo.dirstate.parentchange():
         repo.dirstate.setparents(newid, nodemod.nullid)
@@ -580,8 +567,7 @@
             return (res, newnode)
         prec = publicdiv
         bumped = repo[newnode]
-        return _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped,
-                                      tmpctx=bumped)
+        return _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped)
 
 def _mergecontentdivergents(repo, progresscb, divergent, other, base,
                             evolvestate):
@@ -1996,8 +1982,7 @@
             else:
                 prec = repo[publicnode]
                 bumped = repo[newnode]
-                ret = _resolvephasedivergent(ui, repo, prec=prec,
-                                             bumped=bumped, tmpctx=bumped)
+                ret = _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped)
         tr.close()
         return ret
     finally:
@@ -2023,7 +2008,7 @@
 
         # now continuing the phase-divergence resolution part
         prec = repo[evolvestate['precursor']]
-        retvalue = _resolvephasedivergent(ui, repo, prec, ctx, newctx)
+        retvalue = _resolvephasedivergent(ui, repo, prec, newctx)
         evolvestate['replacements'][ctx.node()] = retvalue[1]
         tr.close()
     finally: