do_or_die("rcs -q -kb -i {0} </dev/null && mv {0},v .src".format(arg))
announce("%s: 0" % arg)
+class lifted:
+ "Temporatily lift a master to the working directory."
+ def __init__(self, name):
+ self.name = name
+ def __enter__(self):
+ do_or_die("mv .src/{0},v .".format(self.name))
+ def __exit__(self, extype, value, traceback_unused):
+ do_or_die("mv {0},v .src".format(self.name))
+ if extype:
+ raise extype(value)
+ return True
+
def commit_method(*args):
"Commit changes to files."
(revspec, args) = preamble("commit", args)
do_or_die(editor + " " + scratchfile)
logcomment = open(scratchfile).read()
logcomment = "." + logcomment.replace("\n", "\n.")[:-1]
- do_or_die("mv .src/{0},v . && ci -l -m'{1}' {0} && mv {0},v .src".format(arg, logcomment))
+ with lifted(arg):
+ do_or_die("ci -l -m'{1}' {0}".format(arg, logcomment))
announce("%s -> %d" % (arg, len(RCSLog(arg))))
def list_method(*args):
croak("%s has only %d revisions" % (arg, len(revlist)))
else:
revision = revlist[len(revlist) - revspec[0]].revision
- do_or_die("mv .src/{0},v . && rm -f {0} && rcs -q -u {0},v && co -q -l{1} {0} ; mv {0},v .src".format(arg, revision))
+ with lifted(arg):
+ do_or_die("rm -f {0} && rcs -q -u {0},v && co -q -l{1} {0}".format(arg, revision))
announce("%s <- %d" % (arg, revspec[0]))
def cat_method(*args):
revlist = RCSLog(arg)
if revspec is None:
revspec = range(1, len(revlist)+1)
- do_or_die("mv .src/{0},v .".format(arg))
- for item in revlist:
- if item.revno in revspec:
- do_or_die("co -q -p -r{1} {0}".format(arg, item.revision), loud=True)
- do_or_die("mv {0},v .src".format(arg))
+ with lifted(arg):
+ for item in revlist:
+ if item.revno in revspec:
+ do_or_die("co -q -p -r{1} {0}".format(arg, item.revision), loud=True)
def diff_method(*args):
"Dump diffs between revisions to standard output."
while args and args[0].startswith("-"):
diffopts += " " + args.pop(0)
for arg in args:
- do_or_die("mv .src/{0},v .".format(arg))
diffspec = ""
if revspec is not None:
state = RCSLog(arg)
diffspec += "-r" + state.revno_to_rcs(revspec[0])
if len(revspec) > 1:
diffspec += " -r" + state.revno_to_rcs(revspec[1])
- # The || : suppresses the error return from diff(1)
- do_or_die("rcsdiff -q {0} {1} {2} || :".format(diffspec, diffopts, arg),loud=True)
- do_or_die("mv {0},v .src".format(arg))
+ with lifted(arg):
+ # The || : suppresses the error return from diff(1)
+ do_or_die("rcsdiff -q {0} {1} {2} || :".format(diffspec, diffopts, arg),loud=True)
dispatch = {
"help": help_method,