From patchwork Sun Feb 19 15:21:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2] shelve: add -n/--name option to unshelve (issue5475) From: liscju X-Patchwork-Id: 18653 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 19 Feb 2017 16:21:22 +0100 # HG changeset patch # User liscju # Date 1487498168 -3600 # Sun Feb 19 10:56:08 2017 +0100 # Node ID f89322e6f48bfe709f759abe71e39fba06f06632 # Parent 01eebb65a61d9edcad1665ed747c7092f1ddb8b9 shelve: add -n/--name option to unshelve (issue5475) This makes using shelve/unshelve more consistent because shelving can be done using name option and unshelving as well. Author of the idea of this improvement and solution is joshgold. diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -747,10 +747,12 @@ def _checkunshelveuntrackedproblems(ui, _('continue an incomplete unshelve operation')), ('k', 'keep', None, _('keep shelve after unshelving')), + ('n', 'name', '', + _('use the given name for the shelved commit'), _('NAME')), ('t', 'tool', '', _('specify merge tool')), ('', 'date', '', _('set date for temporary commits (DEPRECATED)'), _('DATE'))], - _('hg unshelve [SHELVED]')) + _('hg unshelve [[-n] SHELVED]')) def unshelve(ui, repo, *shelved, **opts): """restore a shelved change to the working directory @@ -795,6 +797,9 @@ def _dounshelve(ui, repo, *shelved, **op continuef = opts.get('continue') if not abortf and not continuef: cmdutil.checkunfinished(repo) + shelved = list(shelved) + if opts.get("name"): + shelved.append(opts["name"]) if abortf or continuef: if abortf and continuef: diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -493,7 +493,7 @@ ensure that metadata-only changes are sh $ ln -s foo a/a $ hg shelve -q -n symlink a/a $ hg status a/a - $ hg unshelve -q symlink + $ hg unshelve -q -n symlink $ hg status a/a M a/a $ hg revert a/a