Check-in [ce7900a0b6]
Not logged in
Overview

SHA1 Hash:ce7900a0b6bd56ac8a01a8bf94da255705f2b353
Date: 2007-09-25 08:38:24
User: drh
Comment:Correct tag propagationl. Now works even when rebuilding in a randomized order.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/manifest.c from [743c23b52e] to [134870951b].

@@ -539,13 +539,22 @@
         int cid = db_column_int(&q, 0);
         add_mlink(rid, &m, cid, 0);
       }
       db_finalize(&q);
       db_multi_exec(
-        "INSERT INTO event(type,mtime,objid,user,comment)"
-        "VALUES('ci',%.17g,%d,%Q,%Q)",
-        m.rDate, rid, m.zUser, m.zComment
+        "INSERT INTO event(type,mtime,objid,user,comment,"
+        "                  bgcolor,brbgcolor,euser,ecomment)"
+        "VALUES('ci',%.17g,%d,%Q,%Q,"
+        " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype=1),"
+        "(SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype!=1),"
+        "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
+        "  (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
+        m.rDate, rid, m.zUser, m.zComment,
+        TAG_BGCOLOR, rid,
+        TAG_BGCOLOR, rid,
+        TAG_USER, rid,
+        TAG_COMMENT, rid
       );
     }
   }
   if( m.type==CFTYPE_CLUSTER ){
     for(i=0; i<m.nCChild; i++){
@@ -566,18 +575,14 @@
         case '*':  type = 2; break;
         case '-':  type = 0; break;
       }
       tag_insert(&m.aTag[i].zName[1], type, m.aTag[i].zValue,
                  rid, m.rDate, tid);
-      if( tid!=rid ){
-        tag_propagate_all(tid);
-      }
     }
     if( parentid ){
       tag_propagate_all(parentid);
     }
-    tag_propagate_all(rid);
   }
   db_end_transaction(0);
   manifest_clear(&m);
   return 1;
 }

Modified src/tag.c from [9d05af9d92] to [53f340db14].

@@ -151,12 +151,28 @@
   int rid                  /* Artifact to which the tag is to attached */
 ){
   Stmt s;
   const char *zCol;
   int tagid = tag_findid(zTag, 1);
+  int rc;
+
   if( mtime<=0.0 ){
     mtime = db_double(0.0, "SELECT julianday('now')");
+  }
+  db_prepare(&s,
+    "SELECT 1 FROM tagxref"
+    " WHERE tagid=%d"
+    "   AND rid=%d"
+    "   AND mtime>=:mtime",
+    tagid, rid
+  );
+  db_bind_double(&s, ":mtime", mtime);
+  rc = db_step(&s);
+  db_finalize(&s);
+  if( rc==SQLITE_ROW ){
+    /* Another entry this is more recent already exists.  Do nothing */
+    return;
   }
   db_prepare(&s,
     "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
     " VALUES(%d,%d,%d,%Q,:mtime,%d)",
     tagid, tagtype, srcId, zValue, rid