Fossil SCM
Add the shun table. Do not process artifacts named in the shun table.
Commit
70d5cc86b72dcaff64a5ce720d61fb8d7b4ab723
Parent
2ab2db0bd3be4d7…
4 files changed
+6
-2
+8
-2
+10
-2
+12
-2
+6
-2
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -828,12 +828,16 @@ | ||
| 828 | 828 | char *zTag = mprintf("wiki-%s", m.zWikiTitle); |
| 829 | 829 | int tagid = tag_findid(zTag, 1); |
| 830 | 830 | int prior; |
| 831 | 831 | tag_insert(zTag, 1, 0, rid, m.rDate, rid); |
| 832 | 832 | free(zTag); |
| 833 | - prior = db_int(0, "SELECT rid FROM tagxref WHERE tagid=%d" | |
| 834 | - " ORDER BY mtime DESC LIMIT 1 OFFSET 1", tagid); | |
| 833 | + prior = db_int(0, | |
| 834 | + "SELECT rid FROM tagxref" | |
| 835 | + " WHERE tagid=%d AND mtime<%.17g" | |
| 836 | + " ORDER BY mtime DESC", | |
| 837 | + tagid, m.rDate | |
| 838 | + ); | |
| 835 | 839 | if( prior ){ |
| 836 | 840 | content_deltify(prior, rid, 0); |
| 837 | 841 | } |
| 838 | 842 | } |
| 839 | 843 | db_end_transaction(0); |
| 840 | 844 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -828,12 +828,16 @@ | |
| 828 | char *zTag = mprintf("wiki-%s", m.zWikiTitle); |
| 829 | int tagid = tag_findid(zTag, 1); |
| 830 | int prior; |
| 831 | tag_insert(zTag, 1, 0, rid, m.rDate, rid); |
| 832 | free(zTag); |
| 833 | prior = db_int(0, "SELECT rid FROM tagxref WHERE tagid=%d" |
| 834 | " ORDER BY mtime DESC LIMIT 1 OFFSET 1", tagid); |
| 835 | if( prior ){ |
| 836 | content_deltify(prior, rid, 0); |
| 837 | } |
| 838 | } |
| 839 | db_end_transaction(0); |
| 840 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -828,12 +828,16 @@ | |
| 828 | char *zTag = mprintf("wiki-%s", m.zWikiTitle); |
| 829 | int tagid = tag_findid(zTag, 1); |
| 830 | int prior; |
| 831 | tag_insert(zTag, 1, 0, rid, m.rDate, rid); |
| 832 | free(zTag); |
| 833 | prior = db_int(0, |
| 834 | "SELECT rid FROM tagxref" |
| 835 | " WHERE tagid=%d AND mtime<%.17g" |
| 836 | " ORDER BY mtime DESC", |
| 837 | tagid, m.rDate |
| 838 | ); |
| 839 | if( prior ){ |
| 840 | content_deltify(prior, rid, 0); |
| 841 | } |
| 842 | } |
| 843 | db_end_transaction(0); |
| 844 |
+8
-2
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -44,28 +44,34 @@ | ||
| 44 | 44 | int errCnt = 0; |
| 45 | 45 | char *zTable; |
| 46 | 46 | |
| 47 | 47 | db_multi_exec( |
| 48 | 48 | "CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);" |
| 49 | + "CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);" | |
| 49 | 50 | ); |
| 50 | 51 | for(;;){ |
| 51 | 52 | zTable = db_text(0, |
| 52 | 53 | "SELECT name FROM sqlite_master" |
| 53 | 54 | " WHERE type='table'" |
| 54 | - " AND name NOT IN ('blob','delta','rcvfrom','user','config')"); | |
| 55 | + " AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')"); | |
| 55 | 56 | if( zTable==0 ) break; |
| 56 | 57 | db_multi_exec("DROP TABLE %Q", zTable); |
| 57 | 58 | free(zTable); |
| 58 | 59 | } |
| 59 | 60 | db_multi_exec(zRepositorySchema2); |
| 60 | 61 | |
| 61 | 62 | db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob"); |
| 63 | + db_multi_exec( | |
| 64 | + "DELETE FROM unclustered" | |
| 65 | + " WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))" | |
| 66 | + ); | |
| 62 | 67 | db_multi_exec( |
| 63 | 68 | "DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')" |
| 64 | 69 | ); |
| 65 | 70 | db_prepare(&s, |
| 66 | - "SELECT rid, size FROM blob %s", | |
| 71 | + "SELECT rid, size FROM blob %s" | |
| 72 | + " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)", | |
| 67 | 73 | randomize ? "ORDER BY random()" : "" |
| 68 | 74 | ); |
| 69 | 75 | while( db_step(&s)==SQLITE_ROW ){ |
| 70 | 76 | int rid = db_column_int(&s, 0); |
| 71 | 77 | int size = db_column_int(&s, 1); |
| 72 | 78 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -44,28 +44,34 @@ | |
| 44 | int errCnt = 0; |
| 45 | char *zTable; |
| 46 | |
| 47 | db_multi_exec( |
| 48 | "CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);" |
| 49 | ); |
| 50 | for(;;){ |
| 51 | zTable = db_text(0, |
| 52 | "SELECT name FROM sqlite_master" |
| 53 | " WHERE type='table'" |
| 54 | " AND name NOT IN ('blob','delta','rcvfrom','user','config')"); |
| 55 | if( zTable==0 ) break; |
| 56 | db_multi_exec("DROP TABLE %Q", zTable); |
| 57 | free(zTable); |
| 58 | } |
| 59 | db_multi_exec(zRepositorySchema2); |
| 60 | |
| 61 | db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob"); |
| 62 | db_multi_exec( |
| 63 | "DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')" |
| 64 | ); |
| 65 | db_prepare(&s, |
| 66 | "SELECT rid, size FROM blob %s", |
| 67 | randomize ? "ORDER BY random()" : "" |
| 68 | ); |
| 69 | while( db_step(&s)==SQLITE_ROW ){ |
| 70 | int rid = db_column_int(&s, 0); |
| 71 | int size = db_column_int(&s, 1); |
| 72 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -44,28 +44,34 @@ | |
| 44 | int errCnt = 0; |
| 45 | char *zTable; |
| 46 | |
| 47 | db_multi_exec( |
| 48 | "CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);" |
| 49 | "CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);" |
| 50 | ); |
| 51 | for(;;){ |
| 52 | zTable = db_text(0, |
| 53 | "SELECT name FROM sqlite_master" |
| 54 | " WHERE type='table'" |
| 55 | " AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')"); |
| 56 | if( zTable==0 ) break; |
| 57 | db_multi_exec("DROP TABLE %Q", zTable); |
| 58 | free(zTable); |
| 59 | } |
| 60 | db_multi_exec(zRepositorySchema2); |
| 61 | |
| 62 | db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob"); |
| 63 | db_multi_exec( |
| 64 | "DELETE FROM unclustered" |
| 65 | " WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))" |
| 66 | ); |
| 67 | db_multi_exec( |
| 68 | "DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')" |
| 69 | ); |
| 70 | db_prepare(&s, |
| 71 | "SELECT rid, size FROM blob %s" |
| 72 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)", |
| 73 | randomize ? "ORDER BY random()" : "" |
| 74 | ); |
| 75 | while( db_step(&s)==SQLITE_ROW ){ |
| 76 | int rid = db_column_int(&s, 0); |
| 77 | int size = db_column_int(&s, 1); |
| 78 |
+10
-2
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -115,10 +115,17 @@ | ||
| 115 | 115 | @ CREATE TABLE config( |
| 116 | 116 | @ name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry |
| 117 | 117 | @ value CLOB, -- Content of the named parameter |
| 118 | 118 | @ CHECK( typeof(name)='text' AND length(name)>=1 ) |
| 119 | 119 | @ ); |
| 120 | +@ | |
| 121 | +@ -- Artifacts that should not be processed are identified in the | |
| 122 | +@ -- "shun" table. Artifacts that are control-file forgeries or | |
| 123 | +@ -- spam can be shunned in order to prevent them from contaminating | |
| 124 | +@ -- the repository. | |
| 125 | +@ -- | |
| 126 | +@ CREATE TABLE shun(uuid UNIQUE); | |
| 120 | 127 | ; |
| 121 | 128 | const char zRepositorySchema2[] = |
| 122 | 129 | @ -- Filenames |
| 123 | 130 | @ -- |
| 124 | 131 | @ CREATE TABLE filename( |
| @@ -199,12 +206,13 @@ | ||
| 199 | 206 | @ ); |
| 200 | 207 | @ |
| 201 | 208 | @ -- Each baseline or manifest can have one or more tags. A tag |
| 202 | 209 | @ -- is defined by a row in the next table. |
| 203 | 210 | @ -- |
| 204 | -@ -- Tags that begin with "br" automatically propagate to direct | |
| 205 | -@ -- children, but not to merge children. | |
| 211 | +@ -- Wiki pages are tagged with "wiki-NAME" where NAME is the name of | |
| 212 | +@ -- the wiki page. Tickets changes are tagged with "ticket-UUID" where | |
| 213 | +@ -- UUID is the indentifier of the ticket. | |
| 206 | 214 | @ -- |
| 207 | 215 | @ CREATE TABLE tag( |
| 208 | 216 | @ tagid INTEGER PRIMARY KEY, -- Numeric tag ID |
| 209 | 217 | @ tagname TEXT UNIQUE -- Tag name. |
| 210 | 218 | @ ); |
| 211 | 219 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -115,10 +115,17 @@ | |
| 115 | @ CREATE TABLE config( |
| 116 | @ name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry |
| 117 | @ value CLOB, -- Content of the named parameter |
| 118 | @ CHECK( typeof(name)='text' AND length(name)>=1 ) |
| 119 | @ ); |
| 120 | ; |
| 121 | const char zRepositorySchema2[] = |
| 122 | @ -- Filenames |
| 123 | @ -- |
| 124 | @ CREATE TABLE filename( |
| @@ -199,12 +206,13 @@ | |
| 199 | @ ); |
| 200 | @ |
| 201 | @ -- Each baseline or manifest can have one or more tags. A tag |
| 202 | @ -- is defined by a row in the next table. |
| 203 | @ -- |
| 204 | @ -- Tags that begin with "br" automatically propagate to direct |
| 205 | @ -- children, but not to merge children. |
| 206 | @ -- |
| 207 | @ CREATE TABLE tag( |
| 208 | @ tagid INTEGER PRIMARY KEY, -- Numeric tag ID |
| 209 | @ tagname TEXT UNIQUE -- Tag name. |
| 210 | @ ); |
| 211 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -115,10 +115,17 @@ | |
| 115 | @ CREATE TABLE config( |
| 116 | @ name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry |
| 117 | @ value CLOB, -- Content of the named parameter |
| 118 | @ CHECK( typeof(name)='text' AND length(name)>=1 ) |
| 119 | @ ); |
| 120 | @ |
| 121 | @ -- Artifacts that should not be processed are identified in the |
| 122 | @ -- "shun" table. Artifacts that are control-file forgeries or |
| 123 | @ -- spam can be shunned in order to prevent them from contaminating |
| 124 | @ -- the repository. |
| 125 | @ -- |
| 126 | @ CREATE TABLE shun(uuid UNIQUE); |
| 127 | ; |
| 128 | const char zRepositorySchema2[] = |
| 129 | @ -- Filenames |
| 130 | @ -- |
| 131 | @ CREATE TABLE filename( |
| @@ -199,12 +206,13 @@ | |
| 206 | @ ); |
| 207 | @ |
| 208 | @ -- Each baseline or manifest can have one or more tags. A tag |
| 209 | @ -- is defined by a row in the next table. |
| 210 | @ -- |
| 211 | @ -- Wiki pages are tagged with "wiki-NAME" where NAME is the name of |
| 212 | @ -- the wiki page. Tickets changes are tagged with "ticket-UUID" where |
| 213 | @ -- UUID is the indentifier of the ticket. |
| 214 | @ -- |
| 215 | @ CREATE TABLE tag( |
| 216 | @ tagid INTEGER PRIMARY KEY, -- Numeric tag ID |
| 217 | @ tagname TEXT UNIQUE -- Tag name. |
| 218 | @ ); |
| 219 |
+12
-2
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -106,10 +106,14 @@ | ||
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | blob_zero(&content); |
| 109 | 109 | blob_zero(&hash); |
| 110 | 110 | blob_extract(pXfer->pIn, n, &content); |
| 111 | + if( db_exists("SELECT 1 FROM shun WHERE uuid=%B", &pXfer->aToken[1]) ){ | |
| 112 | + /* Ignore files that have been shunned */ | |
| 113 | + return; | |
| 114 | + } | |
| 111 | 115 | if( pXfer->nToken==4 ){ |
| 112 | 116 | Blob src; |
| 113 | 117 | int srcid = rid_from_uuid(&pXfer->aToken[2], 1); |
| 114 | 118 | if( content_get(srcid, &src)==0 ){ |
| 115 | 119 | content_put(&content, blob_str(&pXfer->aToken[1]), srcid); |
| @@ -238,11 +242,14 @@ | ||
| 238 | 242 | /* |
| 239 | 243 | ** Send a gimme message for every phantom. |
| 240 | 244 | */ |
| 241 | 245 | static void request_phantoms(Xfer *pXfer){ |
| 242 | 246 | Stmt q; |
| 243 | - db_prepare(&q, "SELECT uuid FROM phantom JOIN blob USING(rid)"); | |
| 247 | + db_prepare(&q, | |
| 248 | + "SELECT uuid FROM phantom JOIN blob USING(rid)" | |
| 249 | + " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" | |
| 250 | + ); | |
| 244 | 251 | while( db_step(&q)==SQLITE_ROW ){ |
| 245 | 252 | const char *zUuid = db_column_text(&q, 0); |
| 246 | 253 | blob_appendf(pXfer->pOut, "gimme %s\n", zUuid); |
| 247 | 254 | pXfer->nGimmeSent++; |
| 248 | 255 | } |
| @@ -375,11 +382,14 @@ | ||
| 375 | 382 | ** Return the number of messages sent. |
| 376 | 383 | */ |
| 377 | 384 | static int send_unclustered(Xfer *pXfer){ |
| 378 | 385 | Stmt q; |
| 379 | 386 | int cnt = 0; |
| 380 | - db_prepare(&q, "SELECT uuid FROM unclustered JOIN blob USING(rid)"); | |
| 387 | + db_prepare(&q, | |
| 388 | + "SELECT uuid FROM unclustered JOIN blob USING(rid)" | |
| 389 | + " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" | |
| 390 | + ); | |
| 381 | 391 | while( db_step(&q)==SQLITE_ROW ){ |
| 382 | 392 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 383 | 393 | cnt++; |
| 384 | 394 | } |
| 385 | 395 | db_finalize(&q); |
| 386 | 396 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -106,10 +106,14 @@ | |
| 106 | return; |
| 107 | } |
| 108 | blob_zero(&content); |
| 109 | blob_zero(&hash); |
| 110 | blob_extract(pXfer->pIn, n, &content); |
| 111 | if( pXfer->nToken==4 ){ |
| 112 | Blob src; |
| 113 | int srcid = rid_from_uuid(&pXfer->aToken[2], 1); |
| 114 | if( content_get(srcid, &src)==0 ){ |
| 115 | content_put(&content, blob_str(&pXfer->aToken[1]), srcid); |
| @@ -238,11 +242,14 @@ | |
| 238 | /* |
| 239 | ** Send a gimme message for every phantom. |
| 240 | */ |
| 241 | static void request_phantoms(Xfer *pXfer){ |
| 242 | Stmt q; |
| 243 | db_prepare(&q, "SELECT uuid FROM phantom JOIN blob USING(rid)"); |
| 244 | while( db_step(&q)==SQLITE_ROW ){ |
| 245 | const char *zUuid = db_column_text(&q, 0); |
| 246 | blob_appendf(pXfer->pOut, "gimme %s\n", zUuid); |
| 247 | pXfer->nGimmeSent++; |
| 248 | } |
| @@ -375,11 +382,14 @@ | |
| 375 | ** Return the number of messages sent. |
| 376 | */ |
| 377 | static int send_unclustered(Xfer *pXfer){ |
| 378 | Stmt q; |
| 379 | int cnt = 0; |
| 380 | db_prepare(&q, "SELECT uuid FROM unclustered JOIN blob USING(rid)"); |
| 381 | while( db_step(&q)==SQLITE_ROW ){ |
| 382 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 383 | cnt++; |
| 384 | } |
| 385 | db_finalize(&q); |
| 386 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -106,10 +106,14 @@ | |
| 106 | return; |
| 107 | } |
| 108 | blob_zero(&content); |
| 109 | blob_zero(&hash); |
| 110 | blob_extract(pXfer->pIn, n, &content); |
| 111 | if( db_exists("SELECT 1 FROM shun WHERE uuid=%B", &pXfer->aToken[1]) ){ |
| 112 | /* Ignore files that have been shunned */ |
| 113 | return; |
| 114 | } |
| 115 | if( pXfer->nToken==4 ){ |
| 116 | Blob src; |
| 117 | int srcid = rid_from_uuid(&pXfer->aToken[2], 1); |
| 118 | if( content_get(srcid, &src)==0 ){ |
| 119 | content_put(&content, blob_str(&pXfer->aToken[1]), srcid); |
| @@ -238,11 +242,14 @@ | |
| 242 | /* |
| 243 | ** Send a gimme message for every phantom. |
| 244 | */ |
| 245 | static void request_phantoms(Xfer *pXfer){ |
| 246 | Stmt q; |
| 247 | db_prepare(&q, |
| 248 | "SELECT uuid FROM phantom JOIN blob USING(rid)" |
| 249 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 250 | ); |
| 251 | while( db_step(&q)==SQLITE_ROW ){ |
| 252 | const char *zUuid = db_column_text(&q, 0); |
| 253 | blob_appendf(pXfer->pOut, "gimme %s\n", zUuid); |
| 254 | pXfer->nGimmeSent++; |
| 255 | } |
| @@ -375,11 +382,14 @@ | |
| 382 | ** Return the number of messages sent. |
| 383 | */ |
| 384 | static int send_unclustered(Xfer *pXfer){ |
| 385 | Stmt q; |
| 386 | int cnt = 0; |
| 387 | db_prepare(&q, |
| 388 | "SELECT uuid FROM unclustered JOIN blob USING(rid)" |
| 389 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 390 | ); |
| 391 | while( db_step(&q)==SQLITE_ROW ){ |
| 392 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 393 | cnt++; |
| 394 | } |
| 395 | db_finalize(&q); |
| 396 |