changeset 42416:7752cd3a2f83

githelp: translate git stash show and clear actions and --patch flag Differential Revision: https://phab.mercurial-scm.org/D6461
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 30 May 2019 16:42:38 +0800
parents 37ff80505dfd
children 060ff3396589
files hgext/githelp.py tests/test-githelp.t
diffstat 2 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/githelp.py	Thu May 30 16:40:34 2019 +0800
+++ b/hgext/githelp.py	Thu May 30 16:42:38 2019 +0800
@@ -923,6 +923,7 @@
 
 def stash(ui, repo, *args, **kwargs):
     cmdoptions = [
+        ('p', 'patch', None, ''),
     ]
     args, opts = parseoptions(ui, cmdoptions, args)
 
@@ -931,6 +932,17 @@
 
     if action == 'list':
         cmd['-l'] = None
+        if opts.get('patch'):
+            cmd['-p'] = None
+    elif action == 'show':
+        if opts.get('patch'):
+            cmd['-p'] = None
+        else:
+            cmd['--stat'] = None
+        if len(args) > 1:
+            cmd.append(args[1])
+    elif action == 'clear':
+        cmd['--cleanup'] = None
     elif action == 'drop':
         cmd['-d'] = None
         if len(args) > 1:
@@ -943,10 +955,9 @@
             cmd.append(args[1])
         if action == 'apply':
             cmd['--keep'] = None
-    elif (action == 'branch' or action == 'show' or action == 'clear'
-        or action == 'create'):
+    elif action == 'branch' or action == 'create':
         ui.status(_("note: Mercurial doesn't have equivalents to the "
-                    "git stash branch, show, clear, or create actions\n\n"))
+                    "git stash branch or create actions\n\n"))
         return
     else:
         if len(args) > 0:
--- a/tests/test-githelp.t	Thu May 30 16:40:34 2019 +0800
+++ b/tests/test-githelp.t	Thu May 30 16:42:38 2019 +0800
@@ -219,6 +219,22 @@
   $ hg githelp -- git stash drop xyz
   hg shelve -d xyz
 
+githelp for stash list with patch
+  $ hg githelp -- git stash list -p
+  hg shelve -l -p
+
+githelp for stash show
+  $ hg githelp -- git stash show
+  hg shelve --stat
+
+githelp for stash show with patch and name
+  $ hg githelp -- git stash show -p mystash
+  hg shelve -p mystash
+
+githelp for stash clear
+  $ hg githelp -- git stash clear
+  hg shelve --cleanup
+
 githelp for whatchanged should show deprecated message
   $ hg githelp -- whatchanged -p
   this command has been deprecated in the git project, thus isn't supported by this tool