evolve: de-duplicate some function calls
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 16 Mar 2018 17:00:01 +0530
changeset 3558 cec6e21b3bcf
parent 3557 77a400149758
child 3559 d166b3dc5e8a
evolve: de-duplicate some function calls _cleanup() was called in continueevolve() and evolve() function too. Let's call it at a single place for both the cases. Also call progresscb() outside of conditionals to call it both times.
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py	Fri Mar 16 16:11:22 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Mar 16 17:00:01 2018 +0530
@@ -1130,6 +1130,10 @@
             raise error.Abort('no evolve to continue')
         evolvestate.load()
         continueevolve(ui, repo, evolvestate, progresscb)
+        if evolvestate['command'] != 'evolve':
+            evolvestate.delete()
+            return
+        startnode = repo.unfiltered()[evolvestate['startnode']]
         evolvestate.delete()
     else:
         cmdutil.bailifchanged(repo)
@@ -1160,8 +1164,8 @@
                 evolvestate['replacements'][curctx.node()] = [ret[1]]
             else:
                 evolvestate['skippedrevs'].append(curctx.node())
-        progresscb()
-        _cleanup(ui, repo, startnode, showprogress)
+    progresscb()
+    _cleanup(ui, repo, startnode, showprogress)
 
 def continueevolve(ui, repo, evolvestate, progresscb):
     """logic for handling of `hg evolve --continue`"""
@@ -1227,7 +1231,6 @@
             evolvestate['replacements'][ctx.node()] = node
             category = evolvestate['category']
             confirm = evolvestate['confirm']
-            startnode = evolvestate['startnode']
             unfi = repo.unfiltered()
             for rev in evolvestate['revs']:
                 # XXX: prevent this lookup by storing nodes instead of revnums
@@ -1240,6 +1243,4 @@
                         evolvestate['replacements'][curctx.node()] = newnode[1]
                     else:
                         evolvestate['skippedrevs'].append(curctx.node())
-
-            _cleanup(ui, repo, unfi[startnode], True)
         return