comparison hgext/githelp.py @ 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 764ada920db5
children ee96458afdb6
comparison
equal deleted inserted replaced
38117:69ec6f98cfa6 38118:d8bd6a9c64a5
234 old = args.pop(0) 234 old = args.pop(0)
235 else: 235 else:
236 # shell command to output the active bookmark for the active 236 # shell command to output the active bookmark for the active
237 # revision 237 # revision
238 old = '`hg log -T"{activebookmark}" -r .`' 238 old = '`hg log -T"{activebookmark}" -r .`'
239 else:
240 raise error.Abort(_('missing newbranch argument'))
239 new = args[0] 241 new = args[0]
240 cmd['-m'] = old 242 cmd['-m'] = old
241 cmd.append(new) 243 cmd.append(new)
242 else: 244 else:
243 if len(args) > 1: 245 if len(args) > 1:
955 cmd['-i'] = None 957 cmd['-i'] = None
956 958
957 ui.status((bytes(cmd)), "\n") 959 ui.status((bytes(cmd)), "\n")
958 960
959 def svn(ui, repo, *args, **kwargs): 961 def svn(ui, repo, *args, **kwargs):
962 if not args:
963 raise error.Abort(_('missing svn command'))
960 svncmd = args[0] 964 svncmd = args[0]
961 if not svncmd in gitsvncommands: 965 if not svncmd in gitsvncommands:
962 ui.warn(_("error: unknown git svn command %s\n") % (svncmd)) 966 ui.warn(_("error: unknown git svn command %s\n") % (svncmd))
963 967
964 args = args[1:] 968 args = args[1:]
985 989
986 def svnfindrev(ui, repo, *args, **kwargs): 990 def svnfindrev(ui, repo, *args, **kwargs):
987 cmdoptions = [ 991 cmdoptions = [
988 ] 992 ]
989 args, opts = parseoptions(ui, cmdoptions, args) 993 args, opts = parseoptions(ui, cmdoptions, args)
994
995 if not args:
996 raise error.Abort(_('missing find-rev argument'))
990 997
991 cmd = Command('log') 998 cmd = Command('log')
992 cmd['-r'] = args[0] 999 cmd['-r'] = args[0]
993 1000
994 ui.status((bytes(cmd)), "\n") 1001 ui.status((bytes(cmd)), "\n")
1018 1025
1019 if opts.get('list'): 1026 if opts.get('list'):
1020 cmd = Command('tags') 1027 cmd = Command('tags')
1021 else: 1028 else:
1022 cmd = Command('tag') 1029 cmd = Command('tag')
1030
1031 if not args:
1032 raise error.Abort(_('missing tag argument'))
1033
1023 cmd.append(args[0]) 1034 cmd.append(args[0])
1024 if len(args) > 1: 1035 if len(args) > 1:
1025 cmd['-r'] = args[1] 1036 cmd['-r'] = args[1]
1026 1037
1027 if opts.get('delete'): 1038 if opts.get('delete'):