Fossil SCM

Prevent time warps from causing infinite loops in the annotator.

drh 2013-03-14 20:27 trunk
Commit 1605649f3e16812127d36210c650a47b012c3529
1 file changed +13
+13
--- src/diff.c
+++ src/diff.c
@@ -2286,10 +2286,11 @@
22862286
Blob toAnnotate; /* Text of the final (mid) version of the file */
22872287
Blob step; /* Text of previous revision */
22882288
int rid; /* Artifact ID of the file being annotated */
22892289
char *zLabel; /* Label to apply to a line */
22902290
Stmt q; /* Query returning all ancestor versions */
2291
+ Stmt ins; /* Inserts into the temporary VSEEN table */
22912292
int cnt = 0; /* Number of versions examined */
22922293
22932294
/* Initialize the annotation */
22942295
rid = db_int(0, "SELECT fid FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid);
22952296
if( rid==0 ){
@@ -2298,19 +2299,26 @@
22982299
if( !content_get(rid, &toAnnotate) ){
22992300
fossil_panic("unable to retrieve content of artifact #%d", rid);
23002301
}
23012302
if( iLimit<=0 ) iLimit = 1000000000;
23022303
annotation_start(p, &toAnnotate);
2304
+ db_begin_transaction();
2305
+ db_multi_exec(
2306
+ "CREATE TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);"
2307
+ "DELETE FROM vseen;"
2308
+ );
23032309
2310
+ db_prepare(&ins, "INSERT OR IGNORE INTO vseen(rid) VALUES(:rid)");
23042311
db_prepare(&q,
23052312
"SELECT (SELECT uuid FROM blob WHERE rid=mlink.%s),"
23062313
" date(event.mtime),"
23072314
" coalesce(event.euser,event.user),"
23082315
" mlink.pid"
23092316
" FROM mlink, event"
23102317
" WHERE mlink.fid=:rid"
23112318
" AND event.objid=mlink.mid"
2319
+ " AND mlink.pid NOT IN vseen"
23122320
" ORDER BY %s event.mtime",
23132321
(annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid",
23142322
(annFlags & ANN_FILE_ANCEST)!=0 ?
23152323
"(mlink.mid IN (SELECT rid FROM ancestor)) DESC,":""
23162324
);
@@ -2333,17 +2341,22 @@
23332341
p->nVers++;
23342342
p->azVers = fossil_realloc(p->azVers, p->nVers*sizeof(p->azVers[0]) );
23352343
p->azVers[p->nVers-1] = zLabel;
23362344
content_get(rid, &step);
23372345
annotation_step(p, &step, zLabel);
2346
+ db_bind_int(&ins, ":rid", rid);
2347
+ db_step(&ins);
2348
+ db_reset(&ins);
23382349
blob_reset(&step);
23392350
db_reset(&q);
23402351
rid = prevId;
23412352
db_bind_int(&q, ":rid", prevId);
23422353
cnt++;
23432354
}
23442355
db_finalize(&q);
2356
+ db_finalize(&ins);
2357
+ db_end_transaction(0);
23452358
}
23462359
23472360
/*
23482361
** WEBPAGE: annotate
23492362
**
23502363
--- src/diff.c
+++ src/diff.c
@@ -2286,10 +2286,11 @@
2286 Blob toAnnotate; /* Text of the final (mid) version of the file */
2287 Blob step; /* Text of previous revision */
2288 int rid; /* Artifact ID of the file being annotated */
2289 char *zLabel; /* Label to apply to a line */
2290 Stmt q; /* Query returning all ancestor versions */
 
2291 int cnt = 0; /* Number of versions examined */
2292
2293 /* Initialize the annotation */
2294 rid = db_int(0, "SELECT fid FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid);
2295 if( rid==0 ){
@@ -2298,19 +2299,26 @@
2298 if( !content_get(rid, &toAnnotate) ){
2299 fossil_panic("unable to retrieve content of artifact #%d", rid);
2300 }
2301 if( iLimit<=0 ) iLimit = 1000000000;
2302 annotation_start(p, &toAnnotate);
 
 
 
 
 
2303
 
2304 db_prepare(&q,
2305 "SELECT (SELECT uuid FROM blob WHERE rid=mlink.%s),"
2306 " date(event.mtime),"
2307 " coalesce(event.euser,event.user),"
2308 " mlink.pid"
2309 " FROM mlink, event"
2310 " WHERE mlink.fid=:rid"
2311 " AND event.objid=mlink.mid"
 
2312 " ORDER BY %s event.mtime",
2313 (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid",
2314 (annFlags & ANN_FILE_ANCEST)!=0 ?
2315 "(mlink.mid IN (SELECT rid FROM ancestor)) DESC,":""
2316 );
@@ -2333,17 +2341,22 @@
2333 p->nVers++;
2334 p->azVers = fossil_realloc(p->azVers, p->nVers*sizeof(p->azVers[0]) );
2335 p->azVers[p->nVers-1] = zLabel;
2336 content_get(rid, &step);
2337 annotation_step(p, &step, zLabel);
 
 
 
2338 blob_reset(&step);
2339 db_reset(&q);
2340 rid = prevId;
2341 db_bind_int(&q, ":rid", prevId);
2342 cnt++;
2343 }
2344 db_finalize(&q);
 
 
2345 }
2346
2347 /*
2348 ** WEBPAGE: annotate
2349 **
2350
--- src/diff.c
+++ src/diff.c
@@ -2286,10 +2286,11 @@
2286 Blob toAnnotate; /* Text of the final (mid) version of the file */
2287 Blob step; /* Text of previous revision */
2288 int rid; /* Artifact ID of the file being annotated */
2289 char *zLabel; /* Label to apply to a line */
2290 Stmt q; /* Query returning all ancestor versions */
2291 Stmt ins; /* Inserts into the temporary VSEEN table */
2292 int cnt = 0; /* Number of versions examined */
2293
2294 /* Initialize the annotation */
2295 rid = db_int(0, "SELECT fid FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid);
2296 if( rid==0 ){
@@ -2298,19 +2299,26 @@
2299 if( !content_get(rid, &toAnnotate) ){
2300 fossil_panic("unable to retrieve content of artifact #%d", rid);
2301 }
2302 if( iLimit<=0 ) iLimit = 1000000000;
2303 annotation_start(p, &toAnnotate);
2304 db_begin_transaction();
2305 db_multi_exec(
2306 "CREATE TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);"
2307 "DELETE FROM vseen;"
2308 );
2309
2310 db_prepare(&ins, "INSERT OR IGNORE INTO vseen(rid) VALUES(:rid)");
2311 db_prepare(&q,
2312 "SELECT (SELECT uuid FROM blob WHERE rid=mlink.%s),"
2313 " date(event.mtime),"
2314 " coalesce(event.euser,event.user),"
2315 " mlink.pid"
2316 " FROM mlink, event"
2317 " WHERE mlink.fid=:rid"
2318 " AND event.objid=mlink.mid"
2319 " AND mlink.pid NOT IN vseen"
2320 " ORDER BY %s event.mtime",
2321 (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid",
2322 (annFlags & ANN_FILE_ANCEST)!=0 ?
2323 "(mlink.mid IN (SELECT rid FROM ancestor)) DESC,":""
2324 );
@@ -2333,17 +2341,22 @@
2341 p->nVers++;
2342 p->azVers = fossil_realloc(p->azVers, p->nVers*sizeof(p->azVers[0]) );
2343 p->azVers[p->nVers-1] = zLabel;
2344 content_get(rid, &step);
2345 annotation_step(p, &step, zLabel);
2346 db_bind_int(&ins, ":rid", rid);
2347 db_step(&ins);
2348 db_reset(&ins);
2349 blob_reset(&step);
2350 db_reset(&q);
2351 rid = prevId;
2352 db_bind_int(&q, ":rid", prevId);
2353 cnt++;
2354 }
2355 db_finalize(&q);
2356 db_finalize(&ins);
2357 db_end_transaction(0);
2358 }
2359
2360 /*
2361 ** WEBPAGE: annotate
2362 **
2363

Keyboard Shortcuts

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