Fossil SCM

Fix annotate_file() so that it correctly errors out if the named file does not exist in the revision.

ashepilko 2018-07-07 20:14 trunk
Commit ae73e4ed327e46939f82a31544b1e579bc93c400e199a3bed4ad420313cad479
1 file changed +12 -1
+12 -1
--- src/diff.c
+++ src/diff.c
@@ -2216,10 +2216,12 @@
22162216
Stmt q; /* Query returning all ancestor versions */
22172217
int cnt = 0; /* Number of versions analyzed */
22182218
int iLimit; /* Maximum number of versions to analyze */
22192219
sqlite3_int64 mxTime; /* Halt at this time if not already complete */
22202220
2221
+ memset(p, 0, sizeof(*p));
2222
+
22212223
if( zLimit ){
22222224
if( strcmp(zLimit,"none")==0 ){
22232225
iLimit = 0;
22242226
mxTime = 0;
22252227
}else if( sqlite3_strglob("*[0-9]s", zLimit)==0 ){
@@ -2235,11 +2237,11 @@
22352237
iLimit = 0;
22362238
mxTime = current_time_in_milliseconds()+1000;
22372239
}
22382240
db_begin_transaction();
22392241
2240
- /* Get the artificate ID for the check-in begin analyzed */
2242
+ /* Get the artifact ID for the check-in begin analyzed */
22412243
if( zRevision ){
22422244
cid = name_to_typed_rid(zRevision, "ci");
22432245
}else{
22442246
db_must_be_within_tree();
22452247
cid = db_lget_int("checkout", 0);
@@ -2308,10 +2310,19 @@
23082310
blob_reset(&step);
23092311
}
23102312
p->nVers++;
23112313
cnt++;
23122314
}
2315
+
2316
+ if( p->nVers==0 ){
2317
+ if( zRevision ){
2318
+ fossil_fatal("file %s does not exist in check-in %s", zFilename, zRevision);
2319
+ }else{
2320
+ fossil_fatal("no history for file: %s", zFilename);
2321
+ }
2322
+ }
2323
+
23132324
db_finalize(&q);
23142325
db_end_transaction(0);
23152326
}
23162327
23172328
/*
23182329
--- src/diff.c
+++ src/diff.c
@@ -2216,10 +2216,12 @@
2216 Stmt q; /* Query returning all ancestor versions */
2217 int cnt = 0; /* Number of versions analyzed */
2218 int iLimit; /* Maximum number of versions to analyze */
2219 sqlite3_int64 mxTime; /* Halt at this time if not already complete */
2220
 
 
2221 if( zLimit ){
2222 if( strcmp(zLimit,"none")==0 ){
2223 iLimit = 0;
2224 mxTime = 0;
2225 }else if( sqlite3_strglob("*[0-9]s", zLimit)==0 ){
@@ -2235,11 +2237,11 @@
2235 iLimit = 0;
2236 mxTime = current_time_in_milliseconds()+1000;
2237 }
2238 db_begin_transaction();
2239
2240 /* Get the artificate ID for the check-in begin analyzed */
2241 if( zRevision ){
2242 cid = name_to_typed_rid(zRevision, "ci");
2243 }else{
2244 db_must_be_within_tree();
2245 cid = db_lget_int("checkout", 0);
@@ -2308,10 +2310,19 @@
2308 blob_reset(&step);
2309 }
2310 p->nVers++;
2311 cnt++;
2312 }
 
 
 
 
 
 
 
 
 
2313 db_finalize(&q);
2314 db_end_transaction(0);
2315 }
2316
2317 /*
2318
--- src/diff.c
+++ src/diff.c
@@ -2216,10 +2216,12 @@
2216 Stmt q; /* Query returning all ancestor versions */
2217 int cnt = 0; /* Number of versions analyzed */
2218 int iLimit; /* Maximum number of versions to analyze */
2219 sqlite3_int64 mxTime; /* Halt at this time if not already complete */
2220
2221 memset(p, 0, sizeof(*p));
2222
2223 if( zLimit ){
2224 if( strcmp(zLimit,"none")==0 ){
2225 iLimit = 0;
2226 mxTime = 0;
2227 }else if( sqlite3_strglob("*[0-9]s", zLimit)==0 ){
@@ -2235,11 +2237,11 @@
2237 iLimit = 0;
2238 mxTime = current_time_in_milliseconds()+1000;
2239 }
2240 db_begin_transaction();
2241
2242 /* Get the artifact ID for the check-in begin analyzed */
2243 if( zRevision ){
2244 cid = name_to_typed_rid(zRevision, "ci");
2245 }else{
2246 db_must_be_within_tree();
2247 cid = db_lget_int("checkout", 0);
@@ -2308,10 +2310,19 @@
2310 blob_reset(&step);
2311 }
2312 p->nVers++;
2313 cnt++;
2314 }
2315
2316 if( p->nVers==0 ){
2317 if( zRevision ){
2318 fossil_fatal("file %s does not exist in check-in %s", zFilename, zRevision);
2319 }else{
2320 fossil_fatal("no history for file: %s", zFilename);
2321 }
2322 }
2323
2324 db_finalize(&q);
2325 db_end_transaction(0);
2326 }
2327
2328 /*
2329

Keyboard Shortcuts

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