evolvecmd: pass evolvestate object to _solve* functions
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 22 Jan 2018 17:44:57 +0530
changeset 3478 4a1ccae58323
parent 3477 713e26a647f5
child 3479 4b9fc8c85ee4
evolvecmd: pass evolvestate object to _solve* functions This patchs adds an argument evolvestate to _solve* functions. This will help us in having one evolvestate object which we can pass around various functions and keep storing what's going on.
hgext3rd/evolve/__init__.py
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/__init__.py	Mon Jan 22 17:29:56 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Mon Jan 22 17:44:57 2018 +0530
@@ -1159,9 +1159,10 @@
                 return 1
             else:
                 cmdutil.bailifchanged(repo)
+                evolvestate = state.cmdstate(repo)
                 result = evolvecmd._solveone(ui, repo, repo[aspchildren[0]],
-                                             dryrunopt, False, lambda: None,
-                                             category='orphan')
+                                             evolvestate, dryrunopt, False,
+                                             lambda: None, category='orphan')
                 # making sure a next commit is formed
                 if result[0] and result[1]:
                     ui.status(_('working directory now at %s\n')
--- a/hgext3rd/evolve/evolvecmd.py	Mon Jan 22 17:29:56 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Jan 22 17:44:57 2018 +0530
@@ -47,7 +47,8 @@
 _bookmarksupdater = rewriteutil.bookmarksupdater
 mergetoolopts = cmdutil.mergetoolopts
 
-def _solveone(ui, repo, ctx, dryrun, confirm, progresscb, category):
+def _solveone(ui, repo, ctx, evolvestate, dryrun, confirm,
+              progresscb, category):
     """Resolve the troubles affecting one revision
 
     returns a tuple (bool, newnode) where,
@@ -62,12 +63,14 @@
         lock = repo.lock()
         tr = repo.transaction("evolve")
         if 'orphan' == category:
-            result = _solveunstable(ui, repo, ctx, dryrun, confirm, progresscb)
+            result = _solveunstable(ui, repo, ctx, evolvestate,
+                                    dryrun, confirm, progresscb)
         elif 'phasedivergent' == category:
-            result = _solvebumped(ui, repo, ctx, dryrun, confirm, progresscb)
+            result = _solvebumped(ui, repo, ctx, evolvestate,
+                                  dryrun, confirm, progresscb)
         elif 'contentdivergent' == category:
-            result = _solvedivergent(ui, repo, ctx, dryrun, confirm,
-                                     progresscb)
+            result = _solvedivergent(ui, repo, ctx, evolvestate,
+                                     dryrun, confirm, progresscb)
         else:
             assert False, "unknown trouble category: %s" % (category)
         tr.close()
@@ -75,7 +78,7 @@
     finally:
         lockmod.release(tr, lock, wlock)
 
-def _solveunstable(ui, repo, orig, dryrun=False, confirm=False,
+def _solveunstable(ui, repo, orig, evolvestate, dryrun=False, confirm=False,
                    progresscb=None):
     """ Tries to stabilize the changeset orig which is orphan.
 
@@ -162,7 +165,7 @@
                   " or use 'hg update -C .' to abort\n"))
             raise
 
-def _solvebumped(ui, repo, bumped, dryrun=False, confirm=False,
+def _solvebumped(ui, repo, bumped, evolvestate, dryrun=False, confirm=False,
                  progresscb=None):
     """Stabilize a bumped changeset
 
@@ -277,8 +280,8 @@
         repo.dirstate.setparents(newid, node.nullid)
     return (True, newid)
 
-def _solvedivergent(ui, repo, divergent, dryrun=False, confirm=False,
-                    progresscb=None):
+def _solvedivergent(ui, repo, divergent, evolvestate, dryrun=False,
+                    confirm=False, progresscb=None):
     """tries to solve content-divergence of a changeset
 
     returns a tuple (bool, newnode) where,
@@ -1155,7 +1158,7 @@
     for rev in revs:
         curctx = repo[rev]
         progresscb()
-        ret = _solveone(ui, repo, curctx, dryrunopt, confirmopt,
+        ret = _solveone(ui, repo, curctx, evolvestate, dryrunopt, confirmopt,
                         progresscb, targetcat)
         seen += 1
         if ret[0]: