diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -499,14 +499,19 @@ def _docreatecmd(ui, repo, pats, opts): return 1 # Create a matcher so that prefetch doesn't attempt to fetch - # the entire repository pointlessly + # the entire repository pointlessly, and as an optimisation + # for movedirstate, if needed. match = scmutil.matchfiles(repo, repo[node].files()) _shelvecreatedcommit(repo, node, name, match) if ui.formatted(): desc = stringutil.ellipsis(desc, ui.termwidth()) ui.status(_('shelved as %s\n') % name) - hg.update(repo, parent.node()) + if opts['keep']: + with repo.dirstate.parentchange(): + scmutil.movedirstate(repo, parent, match) + else: + hg.update(repo, parent.node()) if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts): repo.dirstate.setbranch(origbranch) diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -928,6 +928,20 @@ with general delta Stream params: {Compression: BZ} changegroup -- {nbchanges: 1, version: 02} (mandatory: True) 330882a04d2ce8487636b1fb292e5beea77fa1e3 + +Test shelve --keep + + $ hg unshelve + unshelving change 'default' + $ hg shelve --keep + shelved as default + $ hg diff + diff --git a/jungle b/jungle + new file mode 100644 + --- /dev/null + +++ b/jungle + @@ -0,0 +1,1 @@ + +babar $ cd .. Test visibility of in-memory changes inside transaction to external hook