]> thyrsus.com Git - src.git/commitdiff
Reluctantly, we give up on {tag,branch} without a modifier.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 16 Nov 2014 19:00:00 +0000 (14:00 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 16 Nov 2014 19:00:00 +0000 (14:00 -0500)
The problem is that it's just to easy to forget -l when you want to list tags
and wind up creating unwanted tags named for the first file on your list.

Regression test passes.

src
src.asc
srctest

diff --git a/src b/src
index 4f95e962f9a657cfc0d01218a5ccbadf62565cd1..afe5c27c159faef742c971b6a7af15bbb1087b7a 100755 (executable)
--- a/src
+++ b/src
@@ -372,13 +372,13 @@ src status [-a] ['file'...]
    tracked, I = ignored, L = locked (recover with src checkout).
    Find more details under 'help status'. 'st' is a synonym fot status.
 
-src tag [list|-l|delete|del|-d] ['name'] ['revision'] ['file'...] 
+src tag [list|-l|create|-c|delete|del|-d] ['name'] ['revision'] ['file'...] 
    List tags, create tags, or delete tags. Takes a singleton
    revision, defaulting to the current branch tip.
 
-src branch [list|-l|delete|del|-d] ['name'] ['file'...]
-   List, create, or delete branches.  the active branch is first in
-   the list. The default branch is 'trunk'.
+src branch [list|create|-c-l|delete|del|-d] ['name'] ['file'...]
+   List, create, or delete branches. When listing, the active branch
+   is first in the list. The default branch is 'trunk'.
 
 src rename ['tag'|'branch'] ['oldname'] ['newname']  ['file'...]
    Rename a tag or branch. Refuses to step on an existing symbol or
@@ -551,9 +551,9 @@ you give none is the tip revision of the current branch.
 This command is mainly intended for use in scripts.
 """,   
    "tag" : """
-src tag [list|-l|delete|del|-d] ['name'] ['revision'] ['file'...] 
+src tag [list|-l|create|-c|delete|del|-d] ['name'] ['revision'] ['file'...] 
 
-List tags (with -l), create tags, or delete tags (with -d).
+List tags (with -l), create tags (with -c), or delete tags (with -d).
 
 Takes at most a singleton revision; the default is the current branch tip.
 
@@ -562,9 +562,10 @@ creation will not step on an existing tag name, and a noneitent branch
 cannot be deleted.
 """,   
    "branch" : """
-src branch [list|-l|delete|del|-d] ['name'] ['file'...]
+src branch [list|-l|create|-c|delete|del|-d] ['name'] ['file'...]
 
-List branches (with -l), create branches, or delete branches (with -d).
+List branches (with -l), create branches (with -c), or delete branches
+(with -d).
 
 In the list produced by '-', the active branch is first in the list.
 
@@ -1158,7 +1159,7 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method):
                     if not quiet and len(args) > 1:
                         announce("in %s, %s %s removed" % (arg, legend, name))
                 return
-        elif args[0] in ("-l", "list"):
+        if args[0] in ("-l", "list"):
             args.pop(0)
             ctx = CommandContext(legend + " listing", args, require_empty=True)
             width = screenwidth()
@@ -1187,19 +1188,24 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method):
                     if backend.isbranch(value) == (legend == "branch"):
                         sys.stdout.write("%4s\t%s\n" % (display,key))
             return
-    if not args:
-        croak("%s setting requires a name argument" % legend)
-    name = args.pop(0)
-    ctx = CommandContext(legend, args)
-    if ctx.is_range():
-        croak("can't accept a range when setting a %s" % legend)
-    for arg in ctx.args:
-        metadata = History(arg)
-        revision = validation_hook(ctx, metadata, name)
-        with backend.lifter(arg):
-            set_method(name, revision, metadata)
-            if not quiet and len(args) > 1:
-                announce("in %s, %s %s = %s" % (arg, legend, name, ctx.start))
+        if args[0] in ("-c", "create"):
+            args.pop(0)
+            if not args:
+                croak("%s setting requires a name argument" % legend)
+            name = args.pop(0)
+            ctx = CommandContext(legend, args)
+            if ctx.is_range():
+                croak("can't accept a range when setting a %s" % legend)
+            for arg in ctx.args:
+                metadata = History(arg)
+                revision = validation_hook(ctx, metadata, name)
+                with backend.lifter(arg):
+                    set_method(name, revision, metadata)
+                    if not quiet and len(args) > 1:
+                        announce("in %s, %s %s = %s" % (arg, legend, name, ctx.start))
+            return
+        else:
+            croak("%s requires a list, create, or delete modifier" % legend)  
 
 def tag_method(*args):
     "Inspect, create, and delete tags."
diff --git a/src.asc b/src.asc
index 20cb1ec212e783eedbc56e37ce88110d827df903..e8d254a6c411cd3a9953a436ed03dddc80c0ad9d 100644 (file)
--- a/src.asc
+++ b/src.asc
@@ -79,13 +79,13 @@ src status [-a] ['file'...]::
    give the -a switch or specify which files to look at. "st" is a
    synonym for status.
 
-src tag [list|-l|delete|del|-d] ['name'] ['revision'] ['file'...]::
+src tag [list|-l|create|-c|delete|del|-d] ['name'] ['revision'] ['file'...]::
    List tags, create tags, or delete tags. Takes a singleton
    revision, defaulting to the current branch tip.
 
-src branch [list|-l|delete|del|-d] ['name'] ['file'...]::
-   List, create, or delete branches.  the active branch is first in
-   the list. The default branch is 'trunk'.
+src branch [list|-l|create|-c|delete|del|-d] ['name'] ['file'...]::
+   List, create, or delete branches. When listing, the active branch
+   is first in the list. The default branch is 'trunk'.
 
 src rename ['tag'|'branch'] ['oldname'] ['newname']  ['file'...]::
    Rename a tag or branch. Refuses to step on an existing symbol or
diff --git a/srctest b/srctest
index 15bf44b44572498e364a26ddc3556832814b02ec..e1413d6db4e9435e65a151297217d28f3b40aa97 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -135,18 +135,18 @@ do
     check "revision $rev content test"
 done
 
-src $TESTOPTS tag sampletag
+src $TESTOPTS tag create sampletag
 check "tag set to default tip revision"
 
 cat >testfile8 <<EOF
 = testfile1 =================================================================
    3   sampletag
 EOF
-src $TESTOPTS tag >testfile9
+src $TESTOPTS tag list >testfile9
 diff -u testfile8 testfile9
 check "tag list check"
 
-src $TESTOPTS tag basetag 1
+src $TESTOPTS tag create basetag 1
 check "tag set to revision 1"
 
 cat >testfile10 <<EOF
@@ -154,7 +154,7 @@ cat >testfile10 <<EOF
    1   basetag
    3   sampletag
 EOF
-src $TESTOPTS tag >testfile11
+src $TESTOPTS tag -l >testfile11
 diff -u testfile10 testfile11
 check "second tag list check"