Read about our upcoming Code of Conduct on this issue

Commit e938cd8c authored by Taapas Agrawal's avatar Taapas Agrawal
Browse files

abort: added support for evolve to hg abort

This patch adds support of `hg evolve --abort` to `hg abort`
plan.

This involves creating a `hgabortevolve()` function under
`evolvecmd` which ensures abortion of evolve via `hg abort`.
This function is then registered using `addunfinished()` in
`__init__.py`.

Results are shown as tests.
parent 8c780c3eb116
......@@ -1362,7 +1362,8 @@ def setupevolveunfinished(ui):
'(also see `hg help evolve.interrupted`)')
statemod.addunfinished('evolve', fname='evolvestate',
continueflag=True, stopflag=True,
statushint=_msg)
statushint=_msg,
abortfunc=evolvecmd.hgabortevolve)
statemod.addunfinished('pick', fname='pickstate', continueflag=True)
else:
# compat <= hg-5.0 (5f2f6912c9e6)
......
......@@ -1912,6 +1912,21 @@ def abortevolve(ui, repo, evolvestate):
raise error.Abort(_("unable to abort interrupted evolve, use 'hg "
"evolve --stop' to stop evolve"))
def hgabortevolve(ui, repo):
"""logic for aborting evolve using 'hg abort'"""
with repo.wlock(), repo.lock():
evolvestate = state.cmdstate(repo)
evolvestate.load()
if evolvestate['command'] != 'evolve':
pctx = repo['.']
hg.updaterepo(repo, pctx.node(), True)
ui.status(_('evolve aborted\n'))
ui.status(_('working directory is now at %s\n')
% pctx.hex()[:12])
evolvestate.delete()
return 0
return abortevolve(ui, repo, evolvestate)
def continueevolve(ui, repo, evolvestate):
"""logic for handling of `hg evolve --continue`"""
......
......@@ -10,6 +10,7 @@ This test contains cases when `hg evolve` is doing orphan resolution.
Setup
=====
#testcases abortcommand abortflag
$ cat >> $HGRCPATH <<EOF
> [phases]
> publish = False
......@@ -19,6 +20,13 @@ Setup
> EOF
$ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
#if abortflag
$ cat >> $HGRCPATH <<EOF
> [alias]
> abort = evolve --abort
> EOF
#endif
$ hg init abortrepo
$ cd abortrepo
$ echo ".*\.orig" > .hgignore
......@@ -41,9 +49,15 @@ Setup
Testing --abort when no evolve is interrupted
=============================================
#if abortflag
$ hg evolve --abort
abort: no interrupted evolve to abort
[255]
#else
$ hg abort
abort: no operation in progress
[255]
#endif
Testing with wrong combination of flags
=======================================
......@@ -103,8 +117,13 @@ Normal testingw when no rev was evolved
instability: orphan
summary: added d
#if abortcommand
when in dry-run mode
$ hg abort --dry-run
evolve in progress, will be aborted
#endif
$ hg evolve --abort
$ hg abort
evolve aborted
working directory is now at e93a9161a274
......@@ -199,7 +218,7 @@ testing that interrupted evolve shows up in morestatus
o 0:8fa14d15e168 added hgignore
() draft
$ hg evolve --abort
$ hg abort
1 new orphan changesets
evolve aborted
working directory is now at 125af0ed8cae
......@@ -299,7 +318,7 @@ Testing when evolved revs are on multiple branches
o 0:8fa14d15e168 added hgignore
() draft
$ hg evolve --abort
$ hg abort
2 new orphan changesets
evolve aborted
working directory is now at 807e8e2ca559
......@@ -395,7 +414,7 @@ Testing when user created a new changesets on top of evolved revisions
adding file changes
added 1 changesets with 1 changes to 1 files
$ cd ../repotwo
$ hg evolve --abort
$ hg abort
warning: new changesets detected on destination branch
abort: unable to abort interrupted evolve, use 'hg evolve --stop' to stop evolve
[255]
......@@ -442,7 +461,7 @@ Testing when the evolved revision turned public due to some other user actions
$ hg phase -r 1c476940790a --public
$ hg evolve --abort
$ hg abort
cannot clean up public changesets: 1c476940790a
abort: unable to abort interrupted evolve, use 'hg evolve --stop' to stop evolve
[255]
......@@ -510,7 +529,7 @@ Testing that bookmark should be moved back when doing `hg evolve --abort`
o 0:8fa14d15e168 added hgignore
() draft
$ hg evolve --abort
$ hg abort
1 new orphan changesets
evolve aborted
working directory is now at a0086c17bfc7
......@@ -543,7 +562,7 @@ Testing `--abort` when conflicts are caused due to `hg next --evolve`
(see 'hg help evolve.interrupted')
[1]
$ hg evolve --abort
$ hg abort
evolve aborted
working directory is now at c1f4718020e3
......
......@@ -10,6 +10,7 @@ This test contains cases when `hg evolve` is doing phase-divergence resolution.
Setup
=====
#testcases abortcommand abortflag
$ cat >> $HGRCPATH <<EOF
> [phases]
> publish = False
......@@ -19,6 +20,13 @@ Setup
> EOF
$ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
#if abortflag
$ cat >> $HGRCPATH <<EOF
> [alias]
> abort = evolve --abort
> EOF
#endif
$ hg init abortrepo
$ cd abortrepo
$ echo ".*\.orig" > .hgignore
......@@ -124,7 +132,7 @@ testing that interrupted evolve shows up in morestatus
summary: added d
$ hg evolve --abort
$ hg abort
evolve aborted
working directory is now at ddba58020bc0
......@@ -218,7 +226,7 @@ in conflicts
(see 'hg help evolve.interrupted')
[1]
$ hg evolve --abort
$ hg abort
1 new phase-divergent changesets
evolve aborted
working directory is now at 28cd06b3f801
......@@ -304,7 +312,7 @@ after resolving one of them
(see 'hg help evolve.interrupted')
[1]
$ hg evolve --abort
$ hg abort
1 new phase-divergent changesets
evolve aborted
working directory is now at ef9b72b9b42c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment