--- src/diff.c.orig 2013-02-16 01:13:55.000000000 +0100 +++ src/diff.c 2013-03-18 11:16:10.684776601 +0100 @@ -2202,6 +2202,7 @@ int rid; /* Artifact ID of the file being annotated */ char *zLabel; /* Label to apply to a line */ Stmt q; /* Query returning all ancestor versions */ + Stmt ins; /* Inserts into the temporary VSEEN table */ int cnt = 0; /* Number of versions examined */ /* Initialize the annotation */ @@ -2214,7 +2215,13 @@ } if( iLimit<=0 ) iLimit = 1000000000; annotation_start(p, &toAnnotate); - + db_begin_transaction(); + db_multi_exec( + "CREATE TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);" + "DELETE FROM vseen;" + ); + + db_prepare(&ins, "INSERT OR IGNORE INTO vseen(rid) VALUES(:rid)"); db_prepare(&q, "SELECT (SELECT uuid FROM blob WHERE rid=mlink.%s)," " date(event.mtime)," @@ -2223,10 +2230,11 @@ " FROM mlink, event" " WHERE mlink.fid=:rid" " AND event.objid=mlink.mid" + " AND mlink.pid NOT IN vseen" " ORDER BY event.mtime", (annFlags & ANN_FILE_VERS)!=0 ? "fid" : "mid" ); - + db_bind_int(&q, ":rid", rid); if( iLimit==0 ) iLimit = 1000000000; while( rid && iLimit>cnt && db_step(&q)==SQLITE_ROW ){ @@ -2247,6 +2255,9 @@ p->azVers[p->nVers-1] = zLabel; content_get(rid, &step); annotation_step(p, &step, zLabel); + db_bind_int(&ins, ":rid", rid); + db_step(&ins); + db_reset(&ins); blob_reset(&step); db_reset(&q); rid = prevId; @@ -2254,6 +2265,8 @@ cnt++; } db_finalize(&q); + db_finalize(&ins); + db_end_transaction(0); } /*