changeset 38118:d8bd6a9c64a5

githelp: fail gracefully in a couple cases where arguments are missing I didn't bother adding tests because the other commands that already handled missing arguments don't test these edge cases. I didn't read over all of the code, rather I scanned for `args` not being checked before indexing.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 May 2018 22:32:15 -0400
parents 69ec6f98cfa6
children ee96458afdb6
files hgext/githelp.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/githelp.py	Wed Mar 07 12:00:58 2018 +0100
+++ b/hgext/githelp.py	Mon May 21 22:32:15 2018 -0400
@@ -236,6 +236,8 @@
                 # shell command to output the active bookmark for the active
                 # revision
                 old = '`hg log -T"{activebookmark}" -r .`'
+        else:
+            raise error.Abort(_('missing newbranch argument'))
         new = args[0]
         cmd['-m'] = old
         cmd.append(new)
@@ -957,6 +959,8 @@
     ui.status((bytes(cmd)), "\n")
 
 def svn(ui, repo, *args, **kwargs):
+    if not args:
+        raise error.Abort(_('missing svn command'))
     svncmd = args[0]
     if not svncmd in gitsvncommands:
         ui.warn(_("error: unknown git svn command %s\n") % (svncmd))
@@ -988,6 +992,9 @@
     ]
     args, opts = parseoptions(ui, cmdoptions, args)
 
+    if not args:
+        raise error.Abort(_('missing find-rev argument'))
+
     cmd = Command('log')
     cmd['-r'] = args[0]
 
@@ -1020,6 +1027,10 @@
         cmd = Command('tags')
     else:
         cmd = Command('tag')
+
+        if not args:
+            raise error.Abort(_('missing tag argument'))
+
         cmd.append(args[0])
         if len(args) > 1:
             cmd['-r'] = args[1]