pick: factor our the abort function
This prepare the upcoming support for `hg pick` in `hg abort.
--- 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