From 471b15b1ce3467b5fa6418823ad6ded2e1fc8241 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 21 Nov 2014 06:09:48 -0500 Subject: [PATCH] Fix crash bug on no arguments. --- TODO | 2 -- src | 64 +++++++++++++++++++++++++++++++----------------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/TODO b/TODO index e6e889e..02a760d 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ SRC TODO list -* Limit option for list and log. - * Implement reverse ranges and remove automatic reversal in print and log. * Stop using rcsdiff, it leaks RCS version numbers onto the screen. diff --git a/src b/src index 146b867..f0946c0 100755 --- a/src +++ b/src @@ -1120,28 +1120,29 @@ def list_method(*args): args = list(args) custom = None limit = None - if args[0] == '--': - args.pop(0) - elif args[0] == "-f": - args.pop(0) - try: - custom = args[0] + if args: + if args[0] == '--': args.pop(0) - except IndexError: - croak("list -f requires a following string") - elif args[0].startswith("-f"): - custom = args[0][2:] - args.pop(0) - elif args[0] == "-l": - args.pop(0) - try: - limit = args[0] + elif args[0] == "-f": args.pop(0) - limit = int(limit) - except IndexError: - croak("list -f requires a following string") - except ValueError: - croak("%s is not an integer" % limit) + try: + custom = args[0] + args.pop(0) + except IndexError: + croak("list -f requires a following string") + elif args[0].startswith("-f"): + custom = args[0][2:] + args.pop(0) + elif args[0] == "-l": + args.pop(0) + try: + limit = args[0] + args.pop(0) + limit = int(limit) + except IndexError: + croak("list -f requires a following string") + except ValueError: + croak("%s is not an integer" % limit) ctx = CommandContext("list", args, default_to="branch_reversed") for arg in ctx.args: if ignore(arg) or not registered(arg): @@ -1170,18 +1171,19 @@ def log_method(*args): "Report revision logs" limit = None args = list(args) - if args[0] == '--': - args.pop(0) - elif args[0] == "-l": - args.pop(0) - try: - limit = args[0] + if args: + if args[0] == '--': args.pop(0) - limit = int(limit) - except IndexError: - croak("list -f requires a following string") - except ValueError: - croak("%s is not an integer" % limit) + elif args[0] == "-l": + args.pop(0) + try: + limit = args[0] + args.pop(0) + limit = int(limit) + except IndexError: + croak("list -f requires a following string") + except ValueError: + croak("%s is not an integer" % limit) ctx = CommandContext("log", args, default_to="branch_reversed") for arg in ctx.args: if ignore(arg) or not registered(arg): -- 2.43.0