Check-in [c887b2b66e]
Not logged in
Overview

SHA1 Hash:c887b2b66e643ef09989ecfda62733f9b274066a
Date: 2008-10-22 19:35:08
User: eric
Comment:Add a --nofork option to "tag branch" so that --raw is not being used for two different purposes. Modify and tidy up the corresponding help text.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/tag.c from [842caf6a79] to [7a59c3269f].

@@ -257,19 +257,20 @@
 ** is not complete at that stage.
 */
 static void tag_prepare_fork(
   Blob *pCtrl,
   const char *zTagname,
-  int rid
+  int rid,
+  int preflen                 /* Tag prefix length to adjust name if reqd */
 ){
   Stmt q;
   Manifest origin;
   Blob originContent;
   char *zDate;
   int i;
 
-  blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+4);
+  blob_appendf(pCtrl, "C Create\\snamed\\sfork\\s%s\n", zTagname+preflen);
   content_get(rid, &originContent);
   manifest_parse(&origin, &originContent);
   zDate = db_text(0, "SELECT datetime('now')");
   zDate[10] = 'T';
   blob_appendf(pCtrl, "D %s\n", zDate);
@@ -309,11 +310,12 @@
 static void tag_add_artifact(
   const char *zTagname,       /* The tag to add or cancel */
   const char *zObjName,       /* Name of object attached to */
   const char *zValue,         /* Value for the tag.  Might be NULL */
   int tagtype,                /* 0:cancel 1:singleton 2:propagated */
-  int fork                    /* Should a fork created from zObjName? */
+  int fork,                   /* Should a fork created from zObjName? */
+  int preflen                 /* Tag prefix length to adjust name if reqd */
 ){
   int rid;
   int nrid;
   char *zDate;
   Blob uuid;
@@ -334,11 +336,11 @@
   if( validate16(zTagname, strlen(zTagname)) ){
     fossil_fatal("invalid tag name \"%s\" - might be confused with a UUID",
                  zTagname);
   }
   if( fork ){
-    tag_prepare_fork(&ctrl, zTagname, rid);
+    tag_prepare_fork(&ctrl, zTagname, rid, preflen);
   }else{
     zDate = db_text(0, "SELECT datetime('now')");
     zDate[10] = 'T';
     blob_appendf(&ctrl, "D %s\n", zDate);
     blob_appendf(&ctrl, "T %c%F %b", zTagtype[tagtype], zTagname, &uuid);
@@ -367,32 +369,31 @@
 ** Run various subcommands to control tags and properties
 **
 **     %fossil tag add ?--raw? TAGNAME UUID ?VALUE?
 **
 **         Add a new tag or property to UUID. The tag will
-**         be usable instead of a UUID in commands like
-**         update and such.
-**
-**     %fossil tag branch ?--raw? TAGNAME UUID ?VALUE?
-**
-**         A fork of UUID will be created. Then the new tag
-**         or property will be added to the fork that
-**         propagate to all direct children.
-**
-**         Additionally all symbolic tags of that fork
-**         inherited from UUID will be cancelled.
-**
-**         However, if the option '--raw' was given, no
-**         fork will be created but the tag/property will be
-**         added to UUID directly and no tag will be
-**         canceled.
-**
-**         Please see the description of '--raw' below too.
+**         be usable instead of a UUID in commands such as
+**         update and merge.
+**
+**     %fossil tag branch ?--raw? ?--nofork? TAGNAME UUID ?VALUE?
+**
+**         A fork will be created so that the new checkin
+**         is a sibling of UUID and identical to it except
+**         for a generated comment. Then the new tag will
+**         be added to the new checkin and propagated to
+**         all direct children.  Additionally all symbolic
+**         tags of that checkin inherited from UUID will
+**         be cancelled.
+**
+**         However, if the option --nofork is given, no
+**         fork will be created and the tag/property will be
+**         added to UUID directly. No tags will be canceled.
 **
 **     %fossil tag cancel ?--raw? TAGNAME UUID
 **
-**         Cancel the tag TAGNAME from UUID
+**         Remove the tag TAGNAME from UUID, and also remove
+**         the propagation of the tag to any descendants.
 **
 **     %fossil tag find ?--raw? TAGNAME
 **
 **         List all baselines that use TAGNAME
 **
@@ -399,32 +400,33 @@
 **     %fossil tag list ?--raw? ?UUID?
 **
 **         List all tags, or if UUID is supplied, list
 **         all tags and their values for UUID.
 **
-** The option ?--raw? is to expose the internal interface
-** for tag handling. This option is not necessary for the
-** normal use.
+** The option --raw allows the manipulation of all types of
+** tags used for various internal purposes in fossil. You
+** should not use this option to make changes unless you are
+** sure what you are doing.
+**
+** If you need to use a tagname that might be confused with
+** a UUID, you can explicitly disambiguate it by prefixing
+** it with "tag:". For instance:
 **
-** If you use a tagname that might be confused with a UUID,
-** you have to explicitly disambiguate it by prefixing it
-** with "tag:". For instance:
+**   fossil update decaf
 **
-**   fossil update cfcfcfee
-**
-** is not the same as:
+** will be taken as a UUID and fossil will probably complain
+** that no such revision was found. However
 **
 **   fossil update tag:cfcfcfee
 **
-** The first will be taken as UUID and fossil will complain
-** if no such revision was found, and the second one expect
-** "cfcfcfee" to be a tag/branch name!
+** will assume that "decaf" is a tag/branch name.
 **
 */
 void tag_cmd(void){
   int n;
   int raw = find_option("raw","",0)!=0;
+  int fork = find_option("nofork","",0)==0;
   const char *prefix = raw ? "" : "sym-";
   int preflen = strlen(prefix);
   Blob tagname;
 
   db_find_and_open_repository(1);
@@ -443,22 +445,23 @@
     if( g.argc!=5 && g.argc!=6 ){
       usage("add ?--raw? TAGNAME UUID ?VALUE?");
     }
     blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
     zValue = g.argc==6 ? g.argv[5] : 0;
-    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0);
+    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 1, 0, 0);
   }else
 
   if( strncmp(g.argv[2],"branch",n)==0 ){
     char *zValue;
     if( g.argc!=5 && g.argc!=6 ){
-      usage("branch ?--raw? TAGNAME UUID ?VALUE?");
+      usage("branch ?--raw? ?--nofork? TAGNAME UUID ?VALUE?");
     }
     blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
     zValue = g.argc==6 ? g.argv[5] : 0;
-    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, raw==0);
-    if( !raw ){
+    tag_add_artifact(blob_str(&tagname), g.argv[4], zValue, 2, fork!=0,
+                                                      preflen);
+    if( fork ){
       const char *zUuid = db_text(0, "SELECT uuid, MAX(rowid) FROM blob");
       printf("New_Fork \"%s\": %s\n", g.argv[3], zUuid);
     }
   }else
 
@@ -465,11 +468,11 @@
   if( strncmp(g.argv[2],"cancel",n)==0 ){
     if( g.argc!=5 ){
       usage("cancel ?--raw? TAGNAME UUID");
     }
     blob_append(&tagname, g.argv[3], strlen(g.argv[3]));
-    tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0);
+    tag_add_artifact(blob_str(&tagname), g.argv[4], 0, 0, 0, 0);
   }else
 
   if( strncmp(g.argv[2],"find",n)==0 ){
     Stmt q;
     if( g.argc!=4 ){