Check-in [7c7edde116]
Not logged in
Overview

SHA1 Hash:7c7edde1169340698ada867fcd31df6b11ad4d55
Date: 2009-01-21 02:47:42
User: drh
Comment:Add the sym-trunk and newbranch tags to the root check-in when rebuilding. Also add the newbranch tag to the root check-in when creating a new repository.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/db.c from [5247c90b26] to [7c76208342].

@@ -940,10 +940,11 @@
     blob_appendf(&manifest, "D %s\n", zDate);
     blob_appendf(&manifest, "P\n");
     md5sum_init();
     blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
     blob_appendf(&manifest, "T *sym-trunk *\n");
+    blob_appendf(&manifest, "T +newbranch *\n");
     blob_appendf(&manifest, "U %F\n", g.zLogin);
     md5sum_blob(&manifest, &hash);
     blob_appendf(&manifest, "Z %b\n", &hash);
     blob_reset(&hash);
     content_put(&manifest, 0, 0);

Modified src/rebuild.c from [9a9c00a3c9] to [194f1062f7].

@@ -166,10 +166,42 @@
   bag_clear(&children);
   rebuild_step_done(rid);
 }
 
 /*
+** Check to see if the the "sym-trunk" tag exists.  If not, create it
+** and attach it to the very first check-in.
+*/
+static void rebuild_tag_trunk(void){
+  int tagid = db_int(0, "SELECT 1 FROM tag WHERE tagname='sym-trunk'");
+  int rid;
+  char *zUuid;
+  Stmt q;
+
+  if( tagid>0 ) return;
+  rid = db_int(0, "SELECT pid FROM plink AS x WHERE NOT EXISTS("
+                  "  SELECT 1 FROM plink WHERE cid=x.pid)");
+  if( rid==0 ) return;
+  db_prepare(&q, "SELECT uuid FROM tagxref, blob"
+                 " WHERE tagid=%d AND tagtype>0 AND blob.rid=tagxref.rid",
+                 TAG_NEWBRANCH);
+
+  /* Block the trunk tag at all branches */
+  while( db_step(&q)==SQLITE_ROW ){
+    const char *z = db_column_text(&q, 0);
+    tag_add_artifact("sym-", "trunk", z, 0, 0);
+  }
+  db_finalize(&q);
+
+  /* Add the trunk tag to the root of the whole tree */
+  zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
+  if( zUuid==0 ) return;
+  tag_add_artifact("sym-", "trunk", zUuid, 0, 2);
+  tag_add_artifact("", "newbranch", zUuid, 0, 1);
+}
+
+/*
 ** Core function to rebuild the infomration in the derived tables of a
 ** fossil repository from the blobs. This function is shared between
 ** 'rebuild_database' ('rebuild') and 'reconstruct_cmd'
 ** ('reconstruct'), both of which have to regenerate this information
 ** from scratch.
@@ -248,10 +280,11 @@
       db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
       rebuild_step_done(rid);
     }
   }
   db_finalize(&s);
+  rebuild_tag_trunk();
   if( ttyOutput ){
     printf("\n");
   }
   return errCnt;
 }

Modified src/tag.c from [4892a40848] to [cbad7c19e2].

@@ -246,11 +246,11 @@
 
 /*
 ** Add a control record to the repository that either creates
 ** or cancels a tag.
 */
-static void tag_add_artifact(
+void tag_add_artifact(
   const char *zPrefix,        /* Prefix to prepend to tag name */
   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 */
@@ -293,17 +293,12 @@
     blob_appendf(&ctrl, "\n");
   }
   blob_appendf(&ctrl, "U %F\n", g.zLogin);
   md5sum_blob(&ctrl, &cksum);
   blob_appendf(&ctrl, "Z %b\n", &cksum);
-  db_begin_transaction();
   nrid = content_put(&ctrl, 0, 0);
   manifest_crosslink(nrid, &ctrl);
-  db_end_transaction(0);
-
-  /* Do an autosync push if requested */
-  autosync(AUTOSYNC_PUSH);
 }
 
 /*
 ** COMMAND: tag
 ** Usage: %fossil tag SUBCOMMAND ...
@@ -370,11 +365,13 @@
     char *zValue;
     if( g.argc!=5 && g.argc!=6 ){
       usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?");
     }
     zValue = g.argc==6 ? g.argv[5] : 0;
+    db_begin_transaction();
     tag_add_artifact(zPrefix, g.argv[3], g.argv[4], zValue, 1+fPropagate);
+    db_end_transaction(0);
   }else
 
   if( strncmp(g.argv[2],"branch",n)==0 ){
     fossil_fatal("the \"fossil tag branch\" command is discontinued\n"
                  "Use the \"fossil branch new\" command instead.");
@@ -382,11 +379,13 @@
 
   if( strncmp(g.argv[2],"cancel",n)==0 ){
     if( g.argc!=5 ){
       usage("cancel ?--raw? TAGNAME CHECK-IN");
     }
+    db_begin_transaction();
     tag_add_artifact(zPrefix, g.argv[3], g.argv[4], 0, 0);
+    db_end_transaction(0);
   }else
 
   if( strncmp(g.argv[2],"find",n)==0 ){
     Stmt q;
     if( g.argc!=4 ){