]> thyrsus.com Git - src.git/commitdiff
Implement and document the -q option.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 13:30:37 +0000 (08:30 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 13:30:37 +0000 (08:30 -0500)
src
src.asc
srctest

diff --git a/src b/src
index 65b7912209c06397ae2b6a7434dd87d0eab3c8dd..1738ac34953989232de59bd29c8ecb4538a8514b 100755 (executable)
--- 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} </dev/null && mv {0},v {1}".format(arg, repodir))
-           announce("%s: 0" % arg) 
+           do_or_die("rcs -q -kb -i {0} </dev/null && mv {0},v {1}".format(arg, repodir)) 
+           if not quiet and len(args) > 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 5373fea4402fadcf6b74e8b978508159f9fcd3a0..27debb883ab1245d6dbea23b397a9d723b82fe55 100644 (file)
--- 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 d98d624f32bd142923114b512319aeae607f25c0..ecba8a415e1118e83cb600af542b4744086c6c58 100755 (executable)
--- 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