From: Eric S. Raymond Date: Thu, 6 Nov 2014 18:48:28 +0000 (-0500) Subject: Status (no help for this). X-Git-Tag: 0.1~28 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=c7b45ca266e02a55ab458552fd5a7828cc2c2ba3;p=src.git Status (no help for this). --- diff --git a/src b/src index d9ca235..9318a5a 100755 --- a/src +++ b/src @@ -2,10 +2,14 @@ # # src - simple revision control. # -import sys, os, subprocess +import sys, os, subprocess, time version = 0.1 +def rfc3339(t): + "RFC3339 string from Unix time." + return time.strftime(b"%Y-%m-%dT%H:%M:%SZ", time.gmtime(t)) + def announce(msg): sys.stdout.write("src: " + msg + "\n") @@ -46,7 +50,7 @@ class popen_or_die: self.fp = None def __enter__(self): if debug >= DEBUG_COMMANDS: - if self.mode == "r": + if self.mode == "rb": announce(b"%s: reading from '%s'%s" % (rfc3339(time.time()), self.command, self.legend)) else: announce(b"%s: writing to '%s'%s" % (rfc3339(time.time()), self.command, self.legend)) @@ -65,6 +69,15 @@ 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 help_method(*args): "Summarize src commands, or (with argument) show help for a single command." print""" @@ -131,7 +144,7 @@ def add_method(*args): elif os.path.exists(".src/%s,v" % arg): complain("%s is already registered." % arg) else: - do_or_die("rcs -q -i %s