From cf6ed8db1c3425a4ea3cc2bfe4e3fab96fab6cf7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 8 Nov 2014 08:30:37 -0500 Subject: [PATCH] Implement and document the -q option. --- src | 26 ++++++++++++++++++++------ src.asc | 13 +++++++++++++ srctest | 21 +++++++++++++++++---- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src b/src index 65b7912..1738ac3 100755 --- a/src +++ b/src @@ -30,8 +30,10 @@ debug = 0 DEBUG_COMMANDS = 1 # Show commands as they are executed DEBUG_PARSE = 2 # Debug logfile parse -# If true (option -T) use an artificial clock for regression testing -pseudotime = False +quiet = False # option -q: run more quietly +pseudotime = False # option -T: artificial clock for regression testing + + # Repo directory repodir = ".src" @@ -373,8 +375,9 @@ def add_method(*args): elif os.path.exists(master(arg)): croak("%s is already registered." % arg) else: - do_or_die("rcs -q -kb -i {0} 1: + announce("%s -> 0" % arg) class lifted: "Temporatily lift a master to the working directory." @@ -433,7 +436,8 @@ def commit_method(*args): comment = comment.replace("'", r"\'") with lifted(arg): do_or_die("ci -l -m'{1}' {0}".format(arg, comment)) - announce("%s -> %d" % (arg, len(RCSLog(arg)))) + if not quiet and len(args) > 1: + announce("%s -> %d" % (arg, len(RCSLog(arg)))) def list_method(*args): "Generate a summary listing of commits, one line per commit." @@ -486,7 +490,8 @@ def checkout_method(*args): revision = master[len(master) - revspec[0]].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])) + if not quiet and len(args) > 1: + announce("%s <- %d" % (arg, revspec[0])) def cat_method(*args): "Dump revision content to standard output." @@ -544,6 +549,8 @@ def delete_tags(args): else: with lifted(arg): do_or_die("rcs -n{0} {1}".format(tagname, arg)) + if not quiet and len(args) > 1: + announce("tag %s removed from %s" % (tagname, arg)) def set_tags(args): if not args: @@ -555,12 +562,17 @@ def set_tags(args): revspec = master.resolve(revspec) if revspec is None: revision = master.tip().revision + revno = master.tip().revno elif len(revspec) == 1: revision = master.revno_to_rcs(revspec[0]) + revno = revspec[0] else: croak("can't accept a range when setting tags.") with lifted(arg): do_or_die("rcs -N{0}:{1} {2}".format(tagname, revision, arg)) + if not quiet and len(args) > 1: + announce("tag %s = %s in " % (tagname, revno, arg)) + def tag_method(*args): "Inspect, create, and delete tags." @@ -661,6 +673,8 @@ if __name__ == "__main__": while command and command[0].startswith("-"): if command[0] == '-d': debug += 1 + elif command[0] == '-q': + quiet = True elif command[0] == '-T': pseudotime = True elif command[0] == '-S': diff --git a/src.asc b/src.asc index 5373fea..27debb8 100644 --- a/src.asc +++ b/src.asc @@ -88,6 +88,19 @@ src fast-export ['file'...] If no files are specified, all eligible files are operated on in sequence. +== NOISE CONTROL == + +Silence is golden. When you have selected only one file to operate +on, and the command is not a report generator (cat, log, list, +fast-export, the listing modes of tag and branch) you will see a reply +only if the operation failed. + +Other commands (add, commit, checkout, tag creation and deletion) give +you a success message per file when operating on multiple files, so +you will not be in doubt about which operation succeeded. This +behavior can be suppressed with the -q option, placed 'before' the +subcommand word. + == DEBUGGING OPTIONS == These will be of interet mainly to developers" diff --git a/srctest b/srctest index d98d624..ecba8a4 100755 --- a/srctest +++ b/srctest @@ -2,7 +2,11 @@ # # Regression tester for SRC. # -trap "rm -f testfile* .sandbox/testfile*" 0 1 2 15 + +# Needs to not be a subdirectory of here, or git gets confused +SANDBOX=/tmp/src-sandbox + +trap "rm -f testfile* $SANDBOX/testfile*" 0 1 2 15 check() { case $? in @@ -11,9 +15,9 @@ check() { esac } -TESTOPTS="-T -S .sandbox $*" +TESTOPTS="-T -S $SANDBOX $*" -rm -fr .sandbox +rm -fr $SANDBOX # Catches dumb and obvious case of code having a Python syntax error src $TESTOPTS init @@ -151,6 +155,15 @@ src $TESTOPTS tag >testfile13 diff testfile12 testfile13 check "tag list check after deletion" -# to do: fast-export +exit 0 +mkdir $SANDBOX/foo +src $TESTOPTS fast-export testfile1 >testfile14 +cat testfile14 +cat testfile14 | (cd $SANDBOX/foo >/dev/null; git init; git fast-import --quiet) +(cd $SANDBOX/foo; git log) + +#(cd $SANDBOX/foo; git fast-export --all) >testfile15 +#diff testfile14 testfile15 + # end -- 2.43.0