changeset 31041:4189d790e8a4

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.
author liscju <piotr.listkiewicz@gmail.com>
date Sun, 19 Feb 2017 10:56:08 +0100
parents 2d1bf84046f6
children 705ecab649ea
files hgext/shelve.py tests/test-shelve.t
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Sat Feb 18 17:23:43 2017 -0800
+++ b/hgext/shelve.py	Sun Feb 19 10:56:08 2017 +0100
@@ -747,10 +747,12 @@
            _('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 @@
     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:
--- a/tests/test-shelve.t	Sat Feb 18 17:23:43 2017 -0800
+++ b/tests/test-shelve.t	Sun Feb 19 10:56:08 2017 +0100
@@ -493,7 +493,7 @@
   $ 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