]> thyrsus.com Git - src.git/commitdiff
Fix crash bug on no arguments.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 21 Nov 2014 11:09:48 +0000 (06:09 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 21 Nov 2014 11:09:48 +0000 (06:09 -0500)
TODO
src

diff --git a/TODO b/TODO
index e6e889e82aff9a81c1fe272c749bf0d1fb0e2a72..02a760d7110c547cafe8eba5662fa77a356d84bc 100644 (file)
--- 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 146b867896fa712a6bf68cc7952f640bcd8df8a1..f0946c069aa74f430bb4f2f84319196815c72d01 100755 (executable)
--- 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):