# HG changeset patch # User Luke Granger-Brown # Date 1647361697 -10800 # Node ID 09754e40d2db590c97224079771ffd083ad91614 # Parent cc80747ef3c88c3540653bd3fc6c466e075c950e pick: factor _dopick() out of cmdpick() diff -r cc80747ef3c8 -r 09754e40d2db hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Mon Mar 14 18:00:00 2022 +0000 +++ b/hgext3rd/evolve/cmdrewrite.py Tue Mar 15 19:28:17 2022 +0300 @@ -1403,28 +1403,32 @@ pickstate.save() raise error.InterventionRequired(_(b"unresolved merge conflicts" b" (see hg help resolve)")) - overrides = {(b'phases', b'new-commit'): origctx.phase()} - with repo.ui.configoverride(overrides, b'pick'): - newnode = repo.commit(text=origctx.description(), - user=origctx.user(), - date=origctx.date(), extra=origctx.extra()) - repo.dirstate.setbranch(origctx.branch()) + return _dopick(ui, repo, pickstate, origctx) + +def _dopick(ui, repo, pickstate, origctx): + """shared logic for performing or continuing a pick""" + overrides = {(b'phases', b'new-commit'): origctx.phase()} + with repo.ui.configoverride(overrides, b'pick'): + newnode = repo.commit(text=origctx.description(), + user=origctx.user(), + date=origctx.date(), extra=origctx.extra()) + repo.dirstate.setbranch(origctx.branch()) - if pickstate: - pickstate.delete() - if newnode is None: - replacements = {(origctx.node(),): []} - else: - newctx = repo[newnode] - replacements = {(origctx.node(),): [newctx.node()]} - compat.cleanupnodes(repo, replacements, operation=b"pick") + if pickstate: + pickstate.delete() + if newnode is None: + replacements = {(origctx.node(),): []} + else: + newctx = repo[newnode] + replacements = {(origctx.node(),): [newctx.node()]} + compat.cleanupnodes(repo, replacements, operation=b"pick") - if newnode is None: - ui.warn(_(b"note: picking %d:%s created no changes to commit\n") % - (origctx.rev(), origctx)) - return 0 + if newnode is None: + ui.warn(_(b"note: picking %d:%s created no changes to commit\n") % + (origctx.rev(), origctx)) + return 0 - return 0 + return 0 def abortpick(ui, repo, pickstate, abortcmd=False): """logic to abort pick"""