changeset 4799:6f9e66433ff8

pick: factor our the abort function This prepare the upcoming support for `hg pick` in `hg abort.
author Taapas Agrawal <taapas2897@gmail.com>
date Tue, 06 Aug 2019 00:16:01 +0200
parents 2e14a9386316
children fa534a8c5863
files hgext3rd/evolve/cmdrewrite.py
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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