Mercurial > hg-stable
changeset 38467:f4776f8b98e0
shelve: directly handle `--continue`
Shelve is currently sub-contracting some of its work to the rebase extension.
In order to make shelve more independent and flexible we would like shelve to
handle the parent alignment directly.
This changeset takes on the next step, handling the abort process. Same as for
--abort. It turns out we have all the necessary bits in the `shelvestate`
file. So we do not need anything from the interrupted rebase.
Differential Revision: https://phab.mercurial-scm.org/D3689
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 29 May 2018 00:13:48 +0200 |
parents | 61e4cf1be5b2 |
children | 920f69c0b549 |
files | hgext/shelve.py tests/test-shelve.t |
diffstat | 2 files changed, 29 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/shelve.py Mon May 28 18:15:21 2018 +0200 +++ b/hgext/shelve.py Tue May 29 00:13:48 2018 +0200 @@ -683,22 +683,37 @@ _("unresolved conflicts, can't continue"), hint=_("see 'hg resolve', then 'hg unshelve --continue'")) - repo.vfs.rename('unshelverebasestate', 'rebasestate') - try: - rebase.rebase(ui, repo, **{ - r'continue' : True - }) - except Exception: - repo.vfs.rename('rebasestate', 'unshelverebasestate') - raise + shelvectx = repo[state.parents[1]] + pendingctx = state.pendingctx + + overrides = {('phases', 'new-commit'): phases.secret} + with repo.ui.configoverride(overrides, 'unshelve'): + with repo.dirstate.parentchange(): + repo.setparents(state.parents[0], nodemod.nullid) + newnode = repo.commit(text=shelvectx.description(), + extra=shelvectx.extra(), + user=shelvectx.user(), + date=shelvectx.date()) - shelvectx = repo['tip'] - if state.pendingctx not in shelvectx.parents(): - # rebase was a no-op, so it produced no child commit + if newnode is None: + # If it ended up being a no-op commit, then the normal + # merge state clean-up path doesn't happen, so do it + # here. Fix issue5494 + merge.mergestate.clean(repo) shelvectx = state.pendingctx + msg = _('note: unshelved changes already existed ' + 'in the working copy\n') + ui.status(msg) else: - # only strip the shelvectx if the rebase produced it - state.nodestoremove.append(shelvectx.node()) + # only strip the shelvectx if we produced one + state.nodestoremove.append(newnode) + shelvectx = repo[newnode] + + hg.updaterepo(repo, pendingctx.node(), False) + + if repo.vfs.exists('unshelverebasestate'): + repo.vfs.rename('unshelverebasestate', 'rebasestate') + rebase.clearstatus(repo) mergefiles(ui, repo, state.wctx, shelvectx) restorebranch(ui, repo, state.branchtorestore)
--- a/tests/test-shelve.t Mon May 28 18:15:21 2018 +0200 +++ b/tests/test-shelve.t Tue May 29 00:13:48 2018 +0200 @@ -459,7 +459,6 @@ (continue: hg unshelve --continue) [255] $ hg unshelve -c - rebasing 5:32c69314e062 "changes to: [mq]: second.patch" (tip) unshelve of 'default' complete ensure the repo is as we hope @@ -901,8 +900,7 @@ (no more unresolved files) continue: hg unshelve --continue $ hg unshelve -c - rebasing 5:e42a7da90865 "changes to: second" (tip) - note: rebase of 5:e42a7da90865 created no changes to commit + note: unshelved changes already existed in the working copy unshelve of 'default' complete $ hg bookmark * test 4:33f7f61e6c5e @@ -1534,7 +1532,6 @@ (no more unresolved files) continue: hg unshelve --continue $ hg unshelve --continue - rebasing 2:425c97ef07f3 "changes to: a" (tip) marked working directory as branch test unshelve of 'default' complete $ cat a @@ -1618,7 +1615,6 @@ (no more unresolved files) continue: hg unshelve --continue $ hg unshelve --continue - rebasing 2:425c97ef07f3 "changes to: a" (tip) unshelve of 'default' complete $ cat a aaabbbccc @@ -1722,7 +1718,6 @@ (no more unresolved files) continue: hg unshelve --continue $ hg unshelve --continue - rebasing 2:3fbe6fbb0bef "changes to: 1" (tip) unshelve of 'default' complete $ hg shelve --list default (*s ago) * changes to: 1 (glob) @@ -1795,7 +1790,6 @@ continue: hg unshelve --continue mercurial does not crash $ hg unshelve --continue - rebasing 2:003d2d94241c "changes to: root" (tip) unshelve of 'ashelve' complete $ cd ..