Fossil SCM

Add the shun table. Do not process artifacts named in the shun table.

drh 2007-10-05 13:47 trunk
Commit 70d5cc86b72dcaff64a5ce720d61fb8d7b4ab723
+6 -2
--- src/manifest.c
+++ src/manifest.c
@@ -828,12 +828,16 @@
828828
char *zTag = mprintf("wiki-%s", m.zWikiTitle);
829829
int tagid = tag_findid(zTag, 1);
830830
int prior;
831831
tag_insert(zTag, 1, 0, rid, m.rDate, rid);
832832
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
+ );
835839
if( prior ){
836840
content_deltify(prior, rid, 0);
837841
}
838842
}
839843
db_end_transaction(0);
840844
--- 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 @@
4444
int errCnt = 0;
4545
char *zTable;
4646
4747
db_multi_exec(
4848
"CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);"
49
+ "CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);"
4950
);
5051
for(;;){
5152
zTable = db_text(0,
5253
"SELECT name FROM sqlite_master"
5354
" WHERE type='table'"
54
- " AND name NOT IN ('blob','delta','rcvfrom','user','config')");
55
+ " AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')");
5556
if( zTable==0 ) break;
5657
db_multi_exec("DROP TABLE %Q", zTable);
5758
free(zTable);
5859
}
5960
db_multi_exec(zRepositorySchema2);
6061
6162
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
+ );
6267
db_multi_exec(
6368
"DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')"
6469
);
6570
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)",
6773
randomize ? "ORDER BY random()" : ""
6874
);
6975
while( db_step(&s)==SQLITE_ROW ){
7076
int rid = db_column_int(&s, 0);
7177
int size = db_column_int(&s, 1);
7278
--- 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 @@
115115
@ CREATE TABLE config(
116116
@ name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry
117117
@ value CLOB, -- Content of the named parameter
118118
@ CHECK( typeof(name)='text' AND length(name)>=1 )
119119
@ );
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);
120127
;
121128
const char zRepositorySchema2[] =
122129
@ -- Filenames
123130
@ --
124131
@ CREATE TABLE filename(
@@ -199,12 +206,13 @@
199206
@ );
200207
@
201208
@ -- Each baseline or manifest can have one or more tags. A tag
202209
@ -- is defined by a row in the next table.
203210
@ --
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.
206214
@ --
207215
@ CREATE TABLE tag(
208216
@ tagid INTEGER PRIMARY KEY, -- Numeric tag ID
209217
@ tagname TEXT UNIQUE -- Tag name.
210218
@ );
211219
--- 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 @@
106106
return;
107107
}
108108
blob_zero(&content);
109109
blob_zero(&hash);
110110
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
+ }
111115
if( pXfer->nToken==4 ){
112116
Blob src;
113117
int srcid = rid_from_uuid(&pXfer->aToken[2], 1);
114118
if( content_get(srcid, &src)==0 ){
115119
content_put(&content, blob_str(&pXfer->aToken[1]), srcid);
@@ -238,11 +242,14 @@
238242
/*
239243
** Send a gimme message for every phantom.
240244
*/
241245
static void request_phantoms(Xfer *pXfer){
242246
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
+ );
244251
while( db_step(&q)==SQLITE_ROW ){
245252
const char *zUuid = db_column_text(&q, 0);
246253
blob_appendf(pXfer->pOut, "gimme %s\n", zUuid);
247254
pXfer->nGimmeSent++;
248255
}
@@ -375,11 +382,14 @@
375382
** Return the number of messages sent.
376383
*/
377384
static int send_unclustered(Xfer *pXfer){
378385
Stmt q;
379386
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
+ );
381391
while( db_step(&q)==SQLITE_ROW ){
382392
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
383393
cnt++;
384394
}
385395
db_finalize(&q);
386396
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button