# HG changeset patch # User Taapas Agrawal # Date 1565043365 -7200 # Node ID fa534a8c58634442662c3c141494de537248da47 # Parent 6f9e66433ff8972455b58c80800e88bff9a951da pick: added support for hg abort This patch isolates abort logic for `hg pick --abort` as `abortpick()`. For independent calls via `hg abort` `hgabortpick()` is created and registered to the state detection API. Results are shown as tests. diff -r 6f9e66433ff8 -r fa534a8c5863 CHANGELOG --- a/CHANGELOG Tue Aug 06 00:16:01 2019 +0200 +++ b/CHANGELOG Tue Aug 06 00:16:05 2019 +0200 @@ -6,6 +6,7 @@ * prune: clarify error message when no revision were passed, * evolve: avoid possible race conditions bu locking earlier + * abort: add support for `evolve` and `pick` to `hg abort` (hg-5.1+) 9.1.0 -- 2019-07-29 ------------------- diff -r 6f9e66433ff8 -r fa534a8c5863 hgext3rd/evolve/__init__.py --- a/hgext3rd/evolve/__init__.py Tue Aug 06 00:16:01 2019 +0200 +++ b/hgext3rd/evolve/__init__.py Tue Aug 06 00:16:05 2019 +0200 @@ -1364,7 +1364,8 @@ continueflag=True, stopflag=True, statushint=_msg, abortfunc=evolvecmd.hgabortevolve) - statemod.addunfinished('pick', fname='pickstate', continueflag=True) + statemod.addunfinished('pick', fname='pickstate', continueflag=True, + abortfunc=cmdrewrite.hgabortpick) else: # compat <= hg-5.0 (5f2f6912c9e6) estate = ('evolvestate', False, False, _('evolve in progress'), diff -r 6f9e66433ff8 -r fa534a8c5863 hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Tue Aug 06 00:16:01 2019 +0200 +++ b/hgext3rd/evolve/cmdrewrite.py Tue Aug 06 00:16:05 2019 +0200 @@ -1535,3 +1535,9 @@ hg.updaterepo(repo, pctxnode, True) pickstate.delete() return 0 + +def hgabortpick(ui, repo): + """logic to abort pick using 'hg abort'""" + with repo.wlock(), repo.lock(): + pickstate = state.cmdstate(repo, path='pickstate') + return abortpick(ui, repo, pickstate, abortcmd=True) diff -r 6f9e66433ff8 -r fa534a8c5863 tests/test-pick.t --- a/tests/test-pick.t Tue Aug 06 00:16:01 2019 +0200 +++ b/tests/test-pick.t Tue Aug 06 00:16:05 2019 +0200 @@ -1,3 +1,4 @@ +#testcases abortcommand abortflag Test for the pick command $ cat >> $HGRCPATH < EOF $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = pick --abort + > EOF +#endif + $ mkcommit() { > echo "$1" > "$1" > hg add "$1" @@ -79,6 +87,11 @@ $ hg pick --abort abort: no interrupted pick state exists [255] +#if abortcommand + $ hg abort + abort: no operation in progress + [255] +#endif Specifying both continue and revs @@ -235,7 +248,11 @@ unresolved merge conflicts (see hg help resolve) [1] - $ hg pick --abort +#if abortcommand + $ hg abort --dry-run + pick in progress, will be aborted +#endif + $ hg abort aborting pick, updating to c437988de89f $ hg glog