Mercurial > evolve
changeset 3503:edabac9e9dc5
evolvecmd: fix broken `evolve --continue` ran after `next --evolve`
Recent series broke `evolve --continue`in cases when run after `hg next
--evolve`. The previous patch adds test demonstarting the broken behaviour, this
patch fixes that by storing the command which leads us to evolve --continue in
the evolvestate.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 07 Feb 2018 13:42:30 +0530 |
parents | 8cf1020bd4f9 |
children | 5dc34b857114 |
files | hgext3rd/evolve/__init__.py hgext3rd/evolve/evolvecmd.py tests/test-evolve-continue.t |
diffstat | 3 files changed, 22 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/__init__.py Wed Feb 07 22:41:30 2018 +0530 +++ b/hgext3rd/evolve/__init__.py Wed Feb 07 13:42:30 2018 +0530 @@ -1162,7 +1162,7 @@ return 1 else: cmdutil.bailifchanged(repo) - evolvestate = state.cmdstate(repo) + evolvestate = state.cmdstate(repo, opts={'command': 'next'}) result = evolvecmd._solveone(ui, repo, repo[aspchildren[0]], evolvestate, dryrunopt, False, lambda: None, category='orphan')
--- a/hgext3rd/evolve/evolvecmd.py Wed Feb 07 22:41:30 2018 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Wed Feb 07 13:42:30 2018 +0530 @@ -1144,24 +1144,27 @@ obsolete.createmarkers(repo, [(ctx, (repo[node],))]) else: obsolete.createmarkers(repo, [(ctx, (repo['.'],))]) - evolvestate['replacements'][ctx.node()] = node - category = evolvestate['category'] - confirm = evolvestate['confirm'] - startnode = evolvestate['startnode'] - unfi = repo.unfiltered() - for rev in evolvestate['revs']: - # XXX: prevent this lookup by storing nodes instead of revnums - curctx = unfi[rev] - if (curctx.node() not in evolvestate['replacements'] and - curctx.node() not in evolvestate['skippedrevs']): - newnode = _solveone(ui, repo, curctx, evolvestate, False, - confirm, progresscb, category) - if newnode[0]: - evolvestate['replacements'][curctx.node()] = newnode[1] - else: - evolvestate['skippedrevs'].append(curctx.node()) - _cleanup(ui, repo, unfi[startnode], True) + # make sure we are continuing evolve and not `hg next --evolve` + if evolvestate['command'] == 'evolve': + evolvestate['replacements'][ctx.node()] = node + category = evolvestate['category'] + confirm = evolvestate['confirm'] + startnode = evolvestate['startnode'] + unfi = repo.unfiltered() + for rev in evolvestate['revs']: + # XXX: prevent this lookup by storing nodes instead of revnums + curctx = unfi[rev] + if (curctx.node() not in evolvestate['replacements'] and + curctx.node() not in evolvestate['skippedrevs']): + newnode = _solveone(ui, repo, curctx, evolvestate, False, + confirm, progresscb, category) + if newnode[0]: + evolvestate['replacements'][curctx.node()] = newnode[1] + else: + evolvestate['skippedrevs'].append(curctx.node()) + + _cleanup(ui, repo, unfi[startnode], True) evolvestate.delete() return @@ -1181,7 +1184,7 @@ # cbor does not know how to serialize sets, using list for skippedrevs stateopts = {'category': targetcat, 'replacements': {}, 'revs': revs, 'confirm': confirmopt, 'startnode': startnode.node(), - 'skippedrevs': []} + 'skippedrevs': [], 'command': 'evolve'} evolvestate.addopts(stateopts) for rev in revs: curctx = repo[rev]
--- a/tests/test-evolve-continue.t Wed Feb 07 22:41:30 2018 +0530 +++ b/tests/test-evolve-continue.t Wed Feb 07 13:42:30 2018 +0530 @@ -373,41 +373,3 @@ continue: hg evolve --continue $ hg evolve --continue evolving 22:d2c94a8f44bd "added g" - ** Unknown exception encountered with possibly-broken third-party extension evolve - ** which supports versions 4.4 of Mercurial. - ** Please disable evolve and try your action again. - ** If that fixes the bug please report it to https://bz.mercurial-scm.org/ - ** Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] - ** Mercurial Distributed SCM (version 4.5+71-2e11b6cd6953) - ** Extensions loaded: rebase, evolve - Traceback (most recent call last): - File "/tmp/hgtests.NSvQmE/install/bin/hg", line 41, in <module> - dispatch.run() - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 88, in run - status = (dispatch(req) or 0) & 255 - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 183, in dispatch - ret = _runcatch(req) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 324, in _runcatch - return _callcatch(ui, _runcatchfunc) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 332, in _callcatch - return scmutil.callcatch(ui, func) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/scmutil.py", line 154, in callcatch - return func() - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 314, in _runcatchfunc - return _dispatch(req) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 918, in _dispatch - cmdpats, cmdoptions) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 673, in runcommand - ret = _runcommand(ui, options, cmd, d) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 926, in _runcommand - return cmdfunc() - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/dispatch.py", line 915, in <lambda> - d = lambda: util.checksignature(func)(ui, *args, **strcmdopt) - File "/tmp/hgtests.NSvQmE/install/lib/python/mercurial/util.py", line 1195, in check - return func(*args, **kwargs) - File "/home/foobar/repo/mutable-history/hgext3rd/evolve/evolvecmd.py", line 1147, in evolve - evolvestate['replacements'][ctx.node()] = node - File "/home/foobar/repo/mutable-history/hgext3rd/evolve/state.py", line 49, in __getitem__ - return self.opts[key] - KeyError: 'replacements' - [1]