From: Eric S. Raymond Date: Fri, 7 Nov 2014 02:30:44 +0000 (-0500) Subject: A bit more robust against errors. X-Git-Tag: 0.1~9 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=a391e5895d7b3e3b2558957d737233d40300e082;p=src.git A bit more robust against errors. --- diff --git a/src b/src index 4227db3..8d25094 100755 --- a/src +++ b/src @@ -260,6 +260,18 @@ def add_method(*args): do_or_die("rcs -q -kb -i {0} %d" % (arg, len(RCSLog(arg)))) def list_method(*args): @@ -323,7 +336,8 @@ def checkout_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): @@ -333,11 +347,10 @@ 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." @@ -346,16 +359,15 @@ def diff_method(*args): 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,