[PATCH V3] shelve: add -n/--name option to unshelve (issue5475)

liscju piotr.listkiewicz at gmail.com
Sun Feb 19 18:50:44 UTC 2017


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1487498168 -3600
#      Sun Feb 19 10:56:08 2017 +0100
# Node ID 07d5e04a0641a33917bd6eccc7284c76103f46c7
# 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', '',
+           _('restore shelved change with given name'), _('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


More information about the Mercurial-devel mailing list