From 86edcd87db812ce0a78d77ce7cbcf6a2fdfafcee Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 9 Dec 2014 07:30:41 -0500 Subject: [PATCH] Deal gracefully with directories passed as arguments. --- src | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src b/src index a350ade..9c64a0c 100755 --- 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): -- 2.43.0