]> thyrsus.com Git - src.git/commitdiff
Deal gracefully with directories passed as arguments.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 9 Dec 2014 12:30:41 +0000 (07:30 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 9 Dec 2014 12:30:41 +0000 (07:30 -0500)
src

diff --git a/src b/src
index a350adebed466a93a5626f17d27f3c80e69585d7..9c64a0ccf4a5485c05815719bca4277f349e6b94 100755 (executable)
--- a/src
+++ b/src
@@ -1076,6 +1076,9 @@ def commit_method(*args):
     for arg in ctx.args:
         if not os.path.exists(arg):
             croak("I see no '%s' here." % arg)
+        if os.path.isdir(arg):
+            croak("cannot commit directory '%s'" % arg)
+    for arg in ctx.args:
         if registered(arg):
             metadata = History(arg)
             ctx.resolve(metadata)
@@ -1140,7 +1143,10 @@ def add_method(*args):
            croak("I see no '%s' here." % arg)
        elif os.path.exists(backend.history(arg)):
            croak("%s is already registered." % arg)
-       else:
+       elif os.path.isdir(arg):
+           croak("cannot commit directory '%s'" % arg)
+    for arg in ctx.args:
+       if not os.path.exists(backend.history(arg)):
            backend.add(arg)
            if not quiet and len(ctx.args) > 1:
               announce("%s -> 0" % arg)
@@ -1179,7 +1185,7 @@ def list_method(*args):
                          default_to="branch_reversed",
                          parse_revspec=parse_revspec)
     for arg in ctx.args:
-        if ignore(arg) or not registered(arg):
+        if ignore(arg) or os.path.isdir(arg) or not registered(arg):
             continue
         if custom is None:
             sys.stdout.write("= %s %s\n" % (arg, ((WIDTH - len(arg) - 3) * "=")))
@@ -1224,7 +1230,7 @@ def log_method(*args):
                          default_to="branch_reversed",
                          parse_revspec=parse_revspec)
     for arg in ctx.args:
-        if ignore(arg) or not registered(arg):
+        if ignore(arg) or os.path.isdir(arg) or not registered(arg):
             continue
         sys.stdout.write("= %s %s\n" % (arg, ((WIDTH - len(arg) - 3) * "=")))
         for item in ctx.resolve(History(arg), backwards=True):