pick: factor our the abort function
authorTaapas Agrawal <taapas2897@gmail.com>
Tue, 06 Aug 2019 00:16:01 +0200
changeset 4799 6f9e66433ff8
parent 4798 2e14a9386316
child 4800 fa534a8c5863
pick: factor our the abort function This prepare the upcoming support for `hg pick` in `hg abort.
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Jul 11 22:56:46 2019 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Aug 06 00:16:01 2019 +0200
@@ -1491,15 +1491,7 @@
                                                    " (see hg help resolve)"))
 
         elif abort:
-            if not pickstate:
-                raise error.Abort(_("no interrupted pick state exists"))
-            pickstate.load()
-            pctxnode = pickstate['oldpctx']
-            ui.status(_("aborting pick, updating to %s\n") %
-                      node.hex(pctxnode)[:12])
-            hg.updaterepo(repo, pctxnode, True)
-            pickstate.delete()
-            return 0
+            return abortpick(ui, repo, pickstate)
 
         else:
             if revs:
@@ -1531,3 +1523,15 @@
             return 0
 
         return 0
+
+def abortpick(ui, repo, pickstate, abortcmd=False):
+    """logic to abort pick"""
+    if not pickstate and not abortcmd:
+        raise error.Abort(_("no interrupted pick state exists"))
+    pickstate.load()
+    pctxnode = pickstate['oldpctx']
+    ui.status(_("aborting pick, updating to %s\n") %
+              node.hex(pctxnode)[:12])
+    hg.updaterepo(repo, pctxnode, True)
+    pickstate.delete()
+    return 0