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

login
register
mail settings
Submitter liscju
Date Feb. 19, 2017, 6:50 p.m.
Message ID <07d5e04a0641a33917bd.1487530244@liscju-VirtualBox>
Download mbox | patch
Permalink /patch/18654/
State Accepted
Headers show

Comments

liscju - Feb. 19, 2017, 6:50 p.m.
# HG changeset patch
# User liscju <piotr.listkiewicz@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.
Augie Fackler - Feb. 20, 2017, 1:49 a.m.
On Sun, Feb 19, 2017 at 07:50:44PM +0100, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz@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)

Sure, queued. Thanks!

Patch

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