Fossil SCM
Prevent time warps from causing infinite loops in the annotator.
Commit
1605649f3e16812127d36210c650a47b012c3529
Parent
9e9e4d080fb6385…
1 file changed
+13
+13
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -2286,10 +2286,11 @@ | ||
| 2286 | 2286 | Blob toAnnotate; /* Text of the final (mid) version of the file */ |
| 2287 | 2287 | Blob step; /* Text of previous revision */ |
| 2288 | 2288 | int rid; /* Artifact ID of the file being annotated */ |
| 2289 | 2289 | char *zLabel; /* Label to apply to a line */ |
| 2290 | 2290 | Stmt q; /* Query returning all ancestor versions */ |
| 2291 | + Stmt ins; /* Inserts into the temporary VSEEN table */ | |
| 2291 | 2292 | int cnt = 0; /* Number of versions examined */ |
| 2292 | 2293 | |
| 2293 | 2294 | /* Initialize the annotation */ |
| 2294 | 2295 | rid = db_int(0, "SELECT fid FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid); |
| 2295 | 2296 | if( rid==0 ){ |
| @@ -2298,19 +2299,26 @@ | ||
| 2298 | 2299 | if( !content_get(rid, &toAnnotate) ){ |
| 2299 | 2300 | fossil_panic("unable to retrieve content of artifact #%d", rid); |
| 2300 | 2301 | } |
| 2301 | 2302 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2302 | 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 | + ); | |
| 2303 | 2309 | |
| 2310 | + db_prepare(&ins, "INSERT OR IGNORE INTO vseen(rid) VALUES(:rid)"); | |
| 2304 | 2311 | db_prepare(&q, |
| 2305 | 2312 | "SELECT (SELECT uuid FROM blob WHERE rid=mlink.%s)," |
| 2306 | 2313 | " date(event.mtime)," |
| 2307 | 2314 | " coalesce(event.euser,event.user)," |
| 2308 | 2315 | " mlink.pid" |
| 2309 | 2316 | " FROM mlink, event" |
| 2310 | 2317 | " WHERE mlink.fid=:rid" |
| 2311 | 2318 | " AND event.objid=mlink.mid" |
| 2319 | + " AND mlink.pid NOT IN vseen" | |
| 2312 | 2320 | " ORDER BY %s event.mtime", |
| 2313 | 2321 | (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid", |
| 2314 | 2322 | (annFlags & ANN_FILE_ANCEST)!=0 ? |
| 2315 | 2323 | "(mlink.mid IN (SELECT rid FROM ancestor)) DESC,":"" |
| 2316 | 2324 | ); |
| @@ -2333,17 +2341,22 @@ | ||
| 2333 | 2341 | p->nVers++; |
| 2334 | 2342 | p->azVers = fossil_realloc(p->azVers, p->nVers*sizeof(p->azVers[0]) ); |
| 2335 | 2343 | p->azVers[p->nVers-1] = zLabel; |
| 2336 | 2344 | content_get(rid, &step); |
| 2337 | 2345 | annotation_step(p, &step, zLabel); |
| 2346 | + db_bind_int(&ins, ":rid", rid); | |
| 2347 | + db_step(&ins); | |
| 2348 | + db_reset(&ins); | |
| 2338 | 2349 | blob_reset(&step); |
| 2339 | 2350 | db_reset(&q); |
| 2340 | 2351 | rid = prevId; |
| 2341 | 2352 | db_bind_int(&q, ":rid", prevId); |
| 2342 | 2353 | cnt++; |
| 2343 | 2354 | } |
| 2344 | 2355 | db_finalize(&q); |
| 2356 | + db_finalize(&ins); | |
| 2357 | + db_end_transaction(0); | |
| 2345 | 2358 | } |
| 2346 | 2359 | |
| 2347 | 2360 | /* |
| 2348 | 2361 | ** WEBPAGE: annotate |
| 2349 | 2362 | ** |
| 2350 | 2363 |
| --- 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 |