]> thyrsus.com Git - src.git/commitdiff
Beginning of log function.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 6 Nov 2014 18:54:39 +0000 (13:54 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 6 Nov 2014 18:54:39 +0000 (13:54 -0500)
src

diff --git a/src b/src
index 9318a5a54f33ac4c85e91a8beacf91cc96f7a156..db86201dab1c367f455bb306d5514d28249518ef 100755 (executable)
--- 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__":