evolve: fix `hg abort` when hg next --evolve leads to conflicts (issue5897)
Before this patch, if you do `hg next --evolve` and end up having conflicts and
then you try `hg abort`, it will throw a KeyError. This patch fixes that.
--- a/hgext3rd/evolve/evolvecmd.py Wed May 30 00:34:35 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Sun May 27 02:32:58 2018 +0530
@@ -1231,6 +1231,14 @@
if not evolvestate:
raise error.Abort(_('no interrupted evolve to stop'))
evolvestate.load()
+ # `hg next --evolve` in play
+ 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])
+ return 0
return abortevolve(ui, repo, evolvestate)
else:
cmdutil.bailifchanged(repo)
--- a/tests/test-evolve-abort.t Wed May 30 00:34:35 2018 +0530
+++ b/tests/test-evolve-abort.t Sun May 27 02:32:58 2018 +0530
@@ -515,41 +515,5 @@
[255]
$ hg evolve --abort
- ** unknown exception encountered, please report by visiting
- ** https://mercurial-scm.org/wiki/BugTracker
- ** Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]
- ** Mercurial Distributed SCM (version 4.6+314-8e5a61602459+20180530)
- ** Extensions loaded: evolve
- Traceback (most recent call last):
- File "/tmp/hgtests.B9AQfb/install/bin/hg", line 41, in <module>
- dispatch.run()
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 90, in run
- status = dispatch(req)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 213, in dispatch
- ret = _runcatch(req) or 0
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 354, in _runcatch
- return _callcatch(ui, _runcatchfunc)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 362, in _callcatch
- return scmutil.callcatch(ui, func)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/scmutil.py", line 161, in callcatch
- return func()
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 344, in _runcatchfunc
- return _dispatch(req)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 974, in _dispatch
- cmdpats, cmdoptions)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 730, in runcommand
- ret = _runcommand(ui, options, cmd, d)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 982, in _runcommand
- return cmdfunc()
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/dispatch.py", line 971, in <lambda>
- d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
- File "/tmp/hgtests.B9AQfb/install/lib/python/mercurial/util.py", line 1550, in check
- return func(*args, **kwargs)
- File "/home/foobar/repo/mutable-history/hgext3rd/evolve/evolvecmd.py", line 1234, in evolve
- return abortevolve(ui, repo, evolvestate)
- File "/home/foobar/repo/mutable-history/hgext3rd/evolve/evolvecmd.py", line 1289, in abortevolve
- startnode = evolvestate['startnode']
- File "/home/foobar/repo/mutable-history/hgext3rd/evolve/state.py", line 49, in __getitem__
- return self.opts[key]
- KeyError: 'startnode'
- [1]
+ evolve aborted
+ working directory is now at c1f4718020e3