Fossil SCM

The annotate_file() function is now closer to being correct, but is still not quote right.

drh 2017-09-24 10:58 UTC andygoth-annotation-enhancements
Commit 54c0dab0c6e6c91bbd0527bdb80033e448a96f1b5eb592278586afeffe98d074
1 file changed +17 -32
+17 -32
--- src/diff.c
+++ src/diff.c
@@ -2198,11 +2198,10 @@
21982198
int cid; /* Selected check-in ID */
21992199
int mid; /* Manifest where file was most recently changed */
22002200
int rid; /* Artifact ID of the file being annotated */
22012201
int fnid; /* Filename ID */
22022202
Stmt q; /* Query returning all ancestor versions */
2203
- Stmt ins; /* Inserts into the temporary VSEEN table */
22042203
int cnt = 0; /* Number of versions examined */
22052204
22062205
/* Get artifact IDs of selected check-in and file */
22072206
if( zRevision ){
22082207
/* Get artifact ID of selected check-in manifest */
@@ -2257,34 +2256,27 @@
22572256
}
22582257
if( iLimit<=0 ) iLimit = 1000000000;
22592258
blob_to_utf8_no_bom(&toAnnotate, 0);
22602259
annotation_start(p, &toAnnotate, annFlags);
22612260
db_begin_transaction();
2262
- db_multi_exec(
2263
- "CREATE TEMP TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);"
2264
- "DELETE FROM vseen;"
2265
- );
2266
-
2267
- db_prepare(&ins, "INSERT OR IGNORE INTO vseen(rid) VALUES(:rid)");
2268
- db_prepare(&q,
2269
- "SELECT (SELECT uuid FROM blob WHERE rid=mlink.fid),"
2270
- " (SELECT uuid FROM blob WHERE rid=mlink.mid),"
2271
- " date(event.mtime),"
2272
- " coalesce(event.euser,event.user),"
2273
- " mlink.pid"
2274
- " FROM mlink, event, ancestor"
2275
- " WHERE mlink.fid=:rid"
2276
- " AND event.objid=mlink.mid"
2277
- " AND mlink.pid NOT IN vseen"
2278
- " AND ancestor.rid=mlink.mid"
2279
- " ORDER BY ancestor.generation;"
2280
- );
2281
-
2282
- db_bind_int(&q, ":rid", rid);
2283
- if( iLimit==0 ) iLimit = 1000000000;
2284
- while( rid && iLimit>cnt && db_step(&q)==SQLITE_ROW ){
2285
- int prevId = db_column_int(&q, 4);
2261
+
2262
+ db_prepare(&q,
2263
+ "SELECT DISTINCT"
2264
+ " (SELECT uuid FROM blob WHERE rid=mlink.fid),"
2265
+ " (SELECT uuid FROM blob WHERE rid=mlink.mid),"
2266
+ " date(event.mtime),"
2267
+ " coalesce(event.euser,event.user)"
2268
+ " FROM mlink, event, ancestor"
2269
+ " WHERE mlink.fnid=%d"
2270
+ " AND event.objid=mlink.mid"
2271
+ " AND ancestor.rid=mlink.mid"
2272
+ " ORDER BY ancestor.generation;",
2273
+ fnid
2274
+ );
2275
+
2276
+ if( iLimit==0 ) iLimit = 1000000000;
2277
+ while( iLimit>cnt && db_step(&q)==SQLITE_ROW ){
22862278
p->aVers = fossil_realloc(p->aVers, (p->nVers+1)*sizeof(p->aVers[0]));
22872279
p->aVers[p->nVers].zFUuid = fossil_strdup(db_column_text(&q, 0));
22882280
p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1));
22892281
p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2));
22902282
p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3));
@@ -2293,21 +2285,14 @@
22932285
blob_to_utf8_no_bom(&step, 0);
22942286
annotation_step(p, &step, p->nVers-1, annFlags);
22952287
blob_reset(&step);
22962288
}
22972289
p->nVers++;
2298
- db_bind_int(&ins, ":rid", rid);
2299
- db_step(&ins);
2300
- db_reset(&ins);
2301
- db_reset(&q);
2302
- rid = prevId;
2303
- db_bind_int(&q, ":rid", prevId);
23042290
cnt++;
23052291
}
23062292
p->bLimit = iLimit==cnt;
23072293
db_finalize(&q);
2308
- db_finalize(&ins);
23092294
db_end_transaction(0);
23102295
}
23112296
23122297
/*
23132298
** Return a color from a gradient.
23142299
--- src/diff.c
+++ src/diff.c
@@ -2198,11 +2198,10 @@
2198 int cid; /* Selected check-in ID */
2199 int mid; /* Manifest where file was most recently changed */
2200 int rid; /* Artifact ID of the file being annotated */
2201 int fnid; /* Filename ID */
2202 Stmt q; /* Query returning all ancestor versions */
2203 Stmt ins; /* Inserts into the temporary VSEEN table */
2204 int cnt = 0; /* Number of versions examined */
2205
2206 /* Get artifact IDs of selected check-in and file */
2207 if( zRevision ){
2208 /* Get artifact ID of selected check-in manifest */
@@ -2257,34 +2256,27 @@
2257 }
2258 if( iLimit<=0 ) iLimit = 1000000000;
2259 blob_to_utf8_no_bom(&toAnnotate, 0);
2260 annotation_start(p, &toAnnotate, annFlags);
2261 db_begin_transaction();
2262 db_multi_exec(
2263 "CREATE TEMP TABLE IF NOT EXISTS vseen(rid INTEGER PRIMARY KEY);"
2264 "DELETE FROM vseen;"
2265 );
2266
2267 db_prepare(&ins, "INSERT OR IGNORE INTO vseen(rid) VALUES(:rid)");
2268 db_prepare(&q,
2269 "SELECT (SELECT uuid FROM blob WHERE rid=mlink.fid),"
2270 " (SELECT uuid FROM blob WHERE rid=mlink.mid),"
2271 " date(event.mtime),"
2272 " coalesce(event.euser,event.user),"
2273 " mlink.pid"
2274 " FROM mlink, event, ancestor"
2275 " WHERE mlink.fid=:rid"
2276 " AND event.objid=mlink.mid"
2277 " AND mlink.pid NOT IN vseen"
2278 " AND ancestor.rid=mlink.mid"
2279 " ORDER BY ancestor.generation;"
2280 );
2281
2282 db_bind_int(&q, ":rid", rid);
2283 if( iLimit==0 ) iLimit = 1000000000;
2284 while( rid && iLimit>cnt && db_step(&q)==SQLITE_ROW ){
2285 int prevId = db_column_int(&q, 4);
2286 p->aVers = fossil_realloc(p->aVers, (p->nVers+1)*sizeof(p->aVers[0]));
2287 p->aVers[p->nVers].zFUuid = fossil_strdup(db_column_text(&q, 0));
2288 p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1));
2289 p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2));
2290 p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3));
@@ -2293,21 +2285,14 @@
2293 blob_to_utf8_no_bom(&step, 0);
2294 annotation_step(p, &step, p->nVers-1, annFlags);
2295 blob_reset(&step);
2296 }
2297 p->nVers++;
2298 db_bind_int(&ins, ":rid", rid);
2299 db_step(&ins);
2300 db_reset(&ins);
2301 db_reset(&q);
2302 rid = prevId;
2303 db_bind_int(&q, ":rid", prevId);
2304 cnt++;
2305 }
2306 p->bLimit = iLimit==cnt;
2307 db_finalize(&q);
2308 db_finalize(&ins);
2309 db_end_transaction(0);
2310 }
2311
2312 /*
2313 ** Return a color from a gradient.
2314
--- src/diff.c
+++ src/diff.c
@@ -2198,11 +2198,10 @@
2198 int cid; /* Selected check-in ID */
2199 int mid; /* Manifest where file was most recently changed */
2200 int rid; /* Artifact ID of the file being annotated */
2201 int fnid; /* Filename ID */
2202 Stmt q; /* Query returning all ancestor versions */
 
2203 int cnt = 0; /* Number of versions examined */
2204
2205 /* Get artifact IDs of selected check-in and file */
2206 if( zRevision ){
2207 /* Get artifact ID of selected check-in manifest */
@@ -2257,34 +2256,27 @@
2256 }
2257 if( iLimit<=0 ) iLimit = 1000000000;
2258 blob_to_utf8_no_bom(&toAnnotate, 0);
2259 annotation_start(p, &toAnnotate, annFlags);
2260 db_begin_transaction();
2261
2262 db_prepare(&q,
2263 "SELECT DISTINCT"
2264 " (SELECT uuid FROM blob WHERE rid=mlink.fid),"
2265 " (SELECT uuid FROM blob WHERE rid=mlink.mid),"
2266 " date(event.mtime),"
2267 " coalesce(event.euser,event.user)"
2268 " FROM mlink, event, ancestor"
2269 " WHERE mlink.fnid=%d"
2270 " AND event.objid=mlink.mid"
2271 " AND ancestor.rid=mlink.mid"
2272 " ORDER BY ancestor.generation;",
2273 fnid
2274 );
2275
2276 if( iLimit==0 ) iLimit = 1000000000;
2277 while( iLimit>cnt && db_step(&q)==SQLITE_ROW ){
 
 
 
 
 
 
 
2278 p->aVers = fossil_realloc(p->aVers, (p->nVers+1)*sizeof(p->aVers[0]));
2279 p->aVers[p->nVers].zFUuid = fossil_strdup(db_column_text(&q, 0));
2280 p->aVers[p->nVers].zMUuid = fossil_strdup(db_column_text(&q, 1));
2281 p->aVers[p->nVers].zDate = fossil_strdup(db_column_text(&q, 2));
2282 p->aVers[p->nVers].zUser = fossil_strdup(db_column_text(&q, 3));
@@ -2293,21 +2285,14 @@
2285 blob_to_utf8_no_bom(&step, 0);
2286 annotation_step(p, &step, p->nVers-1, annFlags);
2287 blob_reset(&step);
2288 }
2289 p->nVers++;
 
 
 
 
 
 
2290 cnt++;
2291 }
2292 p->bLimit = iLimit==cnt;
2293 db_finalize(&q);
 
2294 db_end_transaction(0);
2295 }
2296
2297 /*
2298 ** Return a color from a gradient.
2299

Keyboard Shortcuts

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