Check-in [70d5cc86b7]
Not logged in
Overview

SHA1 Hash:70d5cc86b72dcaff64a5ce720d61fb8d7b4ab723
Date: 2007-10-05 13:47:00
User: drh
Comment:Add the shun table. Do not process artifacts named in the shun table.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/manifest.c from [c827402f3d] to [6fb6d5c8bf].

@@ -828,15 +828,19 @@
     char *zTag = mprintf("wiki-%s", m.zWikiTitle);
     int tagid = tag_findid(zTag, 1);
     int prior;
     tag_insert(zTag, 1, 0, rid, m.rDate, rid);
     free(zTag);
-    prior = db_int(0, "SELECT rid FROM tagxref WHERE tagid=%d"
-                      " ORDER BY mtime DESC LIMIT 1 OFFSET 1", tagid);
+    prior = db_int(0,
+      "SELECT rid FROM tagxref"
+      " WHERE tagid=%d AND mtime<%.17g"
+      " ORDER BY mtime DESC",
+      tagid, m.rDate
+    );
     if( prior ){
       content_deltify(prior, rid, 0);
     }
   }
   db_end_transaction(0);
   manifest_clear(&m);
   return 1;
 }

Modified src/rebuild.c from [6a267b5a25] to [6f9e0bad18].

@@ -44,28 +44,34 @@
   int errCnt = 0;
   char *zTable;
 
   db_multi_exec(
     "CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);"
+    "CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);"
   );
   for(;;){
     zTable = db_text(0,
        "SELECT name FROM sqlite_master"
        " WHERE type='table'"
-       " AND name NOT IN ('blob','delta','rcvfrom','user','config')");
+       " AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')");
     if( zTable==0 ) break;
     db_multi_exec("DROP TABLE %Q", zTable);
     free(zTable);
   }
   db_multi_exec(zRepositorySchema2);
 
   db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob");
   db_multi_exec(
+     "DELETE FROM unclustered"
+     " WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
+  );
+  db_multi_exec(
     "DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')"
   );
   db_prepare(&s,
-     "SELECT rid, size FROM blob %s",
+     "SELECT rid, size FROM blob %s"
+     " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)",
      randomize ? "ORDER BY random()" : ""
   );
   while( db_step(&s)==SQLITE_ROW ){
     int rid = db_column_int(&s, 0);
     int size = db_column_int(&s, 1);

Modified src/schema.c from [62d0eee5f5] to [551d7af8e5].

@@ -115,10 +115,17 @@
 @ CREATE TABLE config(
 @   name TEXT PRIMARY KEY NOT NULL,  -- Primary name of the entry
 @   value CLOB,                      -- Content of the named parameter
 @   CHECK( typeof(name)='text' AND length(name)>=1 )
 @ );
+@
+@ -- Artifacts that should not be processed are identified in the
+@ -- "shun" table.  Artifacts that are control-file forgeries or
+@ -- spam can be shunned in order to prevent them from contaminating
+@ -- the repository.
+@ --
+@ CREATE TABLE shun(uuid UNIQUE);
 ;
 const char zRepositorySchema2[] =
 @ -- Filenames
 @ --
 @ CREATE TABLE filename(
@@ -199,12 +206,13 @@
 @ );
 @
 @ -- Each baseline or manifest can have one or more tags.  A tag
 @ -- is defined by a row in the next table.
 @ --
-@ -- Tags that begin with "br" automatically propagate to direct
-@ -- children, but not to merge children.
+@ -- Wiki pages are tagged with "wiki-NAME" where NAME is the name of
+@ -- the wiki page.  Tickets changes are tagged with "ticket-UUID" where
+@ -- UUID is the indentifier of the ticket.
 @ --
 @ CREATE TABLE tag(
 @   tagid INTEGER PRIMARY KEY,       -- Numeric tag ID
 @   tagname TEXT UNIQUE              -- Tag name.
 @ );

Modified src/xfer.c from [6ecd805cfb] to [3c34086239].

@@ -106,10 +106,14 @@
     return;
   }
   blob_zero(&content);
   blob_zero(&hash);
   blob_extract(pXfer->pIn, n, &content);
+  if( db_exists("SELECT 1 FROM shun WHERE uuid=%B", &pXfer->aToken[1]) ){
+    /* Ignore files that have been shunned */
+    return;
+  }
   if( pXfer->nToken==4 ){
     Blob src;
     int srcid = rid_from_uuid(&pXfer->aToken[2], 1);
     if( content_get(srcid, &src)==0 ){
       content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
@@ -238,11 +242,14 @@
 /*
 ** Send a gimme message for every phantom.
 */
 static void request_phantoms(Xfer *pXfer){
   Stmt q;
-  db_prepare(&q, "SELECT uuid FROM phantom JOIN blob USING(rid)");
+  db_prepare(&q,
+    "SELECT uuid FROM phantom JOIN blob USING(rid)"
+    " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
+  );
   while( db_step(&q)==SQLITE_ROW ){
     const char *zUuid = db_column_text(&q, 0);
     blob_appendf(pXfer->pOut, "gimme %s\n", zUuid);
     pXfer->nGimmeSent++;
   }
@@ -375,11 +382,14 @@
 ** Return the number of messages sent.
 */
 static int send_unclustered(Xfer *pXfer){
   Stmt q;
   int cnt = 0;
-  db_prepare(&q, "SELECT uuid FROM unclustered JOIN blob USING(rid)");
+  db_prepare(&q,
+    "SELECT uuid FROM unclustered JOIN blob USING(rid)"
+    " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
+  );
   while( db_step(&q)==SQLITE_ROW ){
     blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
     cnt++;
   }
   db_finalize(&q);