From 993b276696a2417dea6a9126ae77d42ede110d9b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 6 Nov 2014 13:54:39 -0500 Subject: [PATCH] Beginning of log function. --- src | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src b/src index 9318a5a..db86201 100755 --- a/src +++ b/src @@ -69,14 +69,8 @@ class popen_or_die: complain(b"%s%s returned error." % (self.command, self.legend)) return False -def revcount(fn): - "Count revisions in the log output from an RCS file." - with popen_or_die("cd .src >/dev/null; rlog %s; cd ..>/dev/null" % fn) as fp: - revno = 0 - for line in fp: - if line.startswith("----------------------------"): - revno += 1 - return revno +def log_capture(fn): + return popen_or_die("cd .src >/dev/null; rlog %s; cd ..>/dev/null" % fn) def help_method(*args): "Summarize src commands, or (with argument) show help for a single command." @@ -160,17 +154,23 @@ def commit_method(*args): do_or_die("mv .src/{0},v . && ci -l {0} && mv {0},v .src".format(arg)) announce("%s %d" % (arg, revcount(arg))) -def status_method(*args): - args = preamble("status", args) +def log_method(*args): + args = preamble("log", args) for arg in args: - announce("%s %d" % (arg, revcount(arg))) + sys.stdout.write("%s:\n" % arg) + with log_capture(arg) as fp: + revno = 0 + for line in fp: + if line.startswith("----------------------------"): + revno += 1 + print "%d\n" % revno dispatch = { "help": help_method, "init": init_method, "add": add_method, "commit": commit_method, - "status": status_method, + "log": log_method, } if __name__ == "__main__": -- 2.43.0