changeset 5510:9fef6f8790a5

evolve: use evolvestate instead of populating a variable in functions
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Wed, 26 Aug 2020 17:25:02 +0530
parents 628215631e8e
children a8c21707e9c4
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 13 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Tue Aug 25 22:34:33 2020 -0700
+++ b/hgext3rd/evolve/evolvecmd.py	Wed Aug 26 17:25:02 2020 +0530
@@ -56,7 +56,7 @@
 abortmessage = _(b"see `hg help evolve.interrupted`\n")
 
 def _solveone(ui, repo, ctx, evolvestate, dryrun, confirm,
-              progresscb, category, lastsolved=None, stacktmplt=False):
+              progresscb, category, stacktmplt=False):
     """Resolve the troubles affecting one revision
 
     returns a tuple (bool, newnode) where,
@@ -75,8 +75,7 @@
                                               {b'template': template})
     if b'orphan' == category:
         result = _solveunstable(ui, repo, ctx, evolvestate, displayer,
-                                dryrun, confirm, progresscb,
-                                lastsolved=lastsolved)
+                                dryrun, confirm, progresscb)
     elif b'phasedivergent' == category:
         result = _solvephasedivergence(ui, repo, ctx, evolvestate,
                                        displayer, dryrun, confirm,
@@ -89,7 +88,7 @@
     return result
 
 def _solveunstable(ui, repo, orig, evolvestate, displayer, dryrun=False,
-                   confirm=False, progresscb=None, lastsolved=None):
+                   confirm=False, progresscb=None):
     """ Tries to stabilize the changeset orig which is orphan.
 
     returns a tuple (bool, newnode) where,
@@ -147,6 +146,9 @@
     if not ui.quiet or confirm:
         repo.ui.write(_(b'move:'), label=b'evolve.operation')
         displayer.show(orig)
+        # lastsolved: keep track of successor of last troubled cset we evolved
+        # to confirm that if atop msg should be suppressed to remove redundancy
+        lastsolved = evolvestate.get(b'lastsolved')
         if lastsolved is None or target != repo[lastsolved]:
             repo.ui.write(_(b'atop:'))
             displayer.show(target)
@@ -1750,18 +1752,13 @@
                      b'bookmarkchanges': [], b'temprevs': [], b'obsmarkers': [],
                      b'update': shouldupdate}
         evolvestate.addopts(stateopts)
-        # lastsolved: keep track of successor of last troubled cset we evolved
-        # to confirm that if atop msg should be suppressed to remove redundancy
-        lastsolved = None
 
         activetopic = getattr(repo, 'currenttopic', b'')
         tr = repo.transaction(b"evolve")
         with util.acceptintervention(tr):
             for rev in revs:
-                lastsolved = _solveonerev(ui, repo, rev, evolvestate,
-                                          activetopic, dryrunopt,
-                                          confirmopt, progresscb,
-                                          targetcat, lastsolved)
+                _solveonerev(ui, repo, rev, evolvestate, activetopic, dryrunopt,
+                             confirmopt, progresscb, targetcat)
                 seen += 1
 
         if showprogress:
@@ -1770,7 +1767,7 @@
     _cleanup(ui, repo, startnode, shouldupdate)
 
 def _solveonerev(ui, repo, rev, evolvestate, activetopic, dryrunopt, confirmopt,
-                 progresscb, targetcat, lastsolved):
+                 progresscb, targetcat):
     """solves one trouble, including orphan merges
 
     Like _solveone(), this solves one trouble. Unlike _solveone(), it
@@ -1787,10 +1784,10 @@
     progresscb()
     ret = _solveone(ui, repo, curctx, evolvestate, dryrunopt,
                     confirmopt, progresscb, targetcat,
-                    lastsolved=lastsolved, stacktmplt=stacktmplt)
+                    stacktmplt=stacktmplt)
     if ret[0]:
         evolvestate[b'replacements'][curctx.node()] = ret[1]
-        lastsolved = ret[1]
+        evolvestate[b'lastsolved'] = ret[1]
     else:
         evolvestate[b'skippedrevs'].append(curctx.node())
 
@@ -1802,12 +1799,11 @@
                         stacktmplt=stacktmplt)
         if ret[0]:
             evolvestate[b'replacements'][curctx.node()] = ret[1]
-            lastsolved = ret[1]
+            evolvestate[b'lastsolved'] = ret[1]
         else:
             evolvestate[b'skippedrevs'].append(curctx.node())
 
         evolvestate[b'orphanmerge'] = False
-    return lastsolved
 
 def solveobswdp(ui, repo, opts):
     """this function updates to the successor of obsolete wdir parent"""
@@ -2003,10 +1999,6 @@
     category = evolvestate[b'category']
     confirm = evolvestate[b'confirm']
     unfi = repo.unfiltered()
-    # lastsolved: keep track of successor of last troubled cset we
-    # evolved to confirm that if atop msg should be suppressed to remove
-    # redundancy
-    lastsolved = None
     activetopic = getattr(repo, 'currenttopic', b'')
     tr = repo.transaction(b"evolve")
     with util.acceptintervention(tr):
@@ -2026,11 +2018,10 @@
                 and curctx.node() not in evolvestate[b'skippedrevs']):
                 newnode = _solveone(ui, repo, curctx, evolvestate, False,
                                     confirm, progresscb, category,
-                                    lastsolved=lastsolved,
                                     stacktmplt=stacktmplt)
                 if newnode[0]:
                     evolvestate[b'replacements'][curctx.node()] = newnode[1]
-                    lastsolved = newnode[1]
+                    evolvestate[b'lastsolved'] = newnode[1]
                 else:
                     evolvestate[b'skippedrevs'].append(curctx.node())
             seen += 1