# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1526956335 14400
#      Mon May 21 22:32:15 2018 -0400
# Node ID a34bed7475cc8237665aa8a3febc1237a090bc20
# Parent  90e02bd8c4473fec03639f26f3d1b2d30d9861d3
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.

diff --git a/hgext/githelp.py b/hgext/githelp.py
--- a/hgext/githelp.py
+++ b/hgext/githelp.py
@@ -236,6 +236,8 @@ def branch(ui, repo, *args, **kwargs):
                 # 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 @@ def status(ui, repo, *args, **kwargs):
     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 @@ def svnfindrev(ui, repo, *args, **kwargs
     ]
     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 @@ def tag(ui, repo, *args, **kwargs):
         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]
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to