Fossil SCM
The /file page for a file that is not part of the latest checkin tries to substitute the most recent checking that added the file.
Commit
5cf5ad8491c97b09aa992135bbf20c0e8f5aa0f1f3d03a02ad76e379928e9bd3
Parent
67a4c1d3134784d…
1 file changed
+26
-4
+26
-4
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2284,10 +2284,11 @@ | ||
| 2284 | 2284 | rid = artifact_from_ci_and_filename(0); |
| 2285 | 2285 | } |
| 2286 | 2286 | |
| 2287 | 2287 | if( rid==0 ){ /* Artifact not found */ |
| 2288 | 2288 | if( isFile ){ |
| 2289 | + Stmt q; | |
| 2289 | 2290 | /* For /file, also check to see if name= refers to a directory, |
| 2290 | 2291 | ** and if so, do a listing for that directory */ |
| 2291 | 2292 | int nName = (int)strlen(zName); |
| 2292 | 2293 | if( nName && zName[nName-1]=='/' ) nName--; |
| 2293 | 2294 | if( db_exists( |
| @@ -2297,18 +2298,39 @@ | ||
| 2297 | 2298 | ) ){ |
| 2298 | 2299 | if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
| 2299 | 2300 | page_tree(); |
| 2300 | 2301 | return; |
| 2301 | 2302 | } |
| 2302 | - style_header("No such file"); | |
| 2303 | - @ File '%h(zName)' does not exist in this repository. | |
| 2303 | + /* No directory found, look for an historic version of the file | |
| 2304 | + ** that was subsequently deleted. */ | |
| 2305 | + db_prepare(&q, | |
| 2306 | + "SELECT fid, uuid FROM mlink, filename, event, blob" | |
| 2307 | + " WHERE filename.name=%Q" | |
| 2308 | + " AND mlink.fnid=filename.fnid AND mlink.fid>0" | |
| 2309 | + " AND event.objid=mlink.mid" | |
| 2310 | + " AND blob.rid=mlink.mid" | |
| 2311 | + " ORDER BY event.mtime DESC", | |
| 2312 | + zName | |
| 2313 | + ); | |
| 2314 | + if( db_step(&q)==SQLITE_ROW ){ | |
| 2315 | + rid = db_column_int(&q, 0); | |
| 2316 | + zCIUuid = zCI = fossil_strdup(db_column_text(&q, 1)); | |
| 2317 | + url_add_parameter(&url, "ci", zCI); | |
| 2318 | + } | |
| 2319 | + db_finalize(&q); | |
| 2320 | + if( rid==0 ){ | |
| 2321 | + style_header("No such file"); | |
| 2322 | + @ File '%h(zName)' does not exist in this repository. | |
| 2323 | + } | |
| 2304 | 2324 | }else{ |
| 2305 | 2325 | style_header("No such artifact"); |
| 2306 | 2326 | @ Artifact '%h(zName)' does not exist in this repository. |
| 2307 | 2327 | } |
| 2308 | - style_footer(); | |
| 2309 | - return; | |
| 2328 | + if( rid==0 ){ | |
| 2329 | + style_footer(); | |
| 2330 | + return; | |
| 2331 | + } | |
| 2310 | 2332 | } |
| 2311 | 2333 | |
| 2312 | 2334 | if( descOnly || P("verbose")!=0 ){ |
| 2313 | 2335 | url_add_parameter(&url, "verbose", "1"); |
| 2314 | 2336 | objdescFlags |= OBJDESC_DETAIL; |
| 2315 | 2337 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2284,10 +2284,11 @@ | |
| 2284 | rid = artifact_from_ci_and_filename(0); |
| 2285 | } |
| 2286 | |
| 2287 | if( rid==0 ){ /* Artifact not found */ |
| 2288 | if( isFile ){ |
| 2289 | /* For /file, also check to see if name= refers to a directory, |
| 2290 | ** and if so, do a listing for that directory */ |
| 2291 | int nName = (int)strlen(zName); |
| 2292 | if( nName && zName[nName-1]=='/' ) nName--; |
| 2293 | if( db_exists( |
| @@ -2297,18 +2298,39 @@ | |
| 2297 | ) ){ |
| 2298 | if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
| 2299 | page_tree(); |
| 2300 | return; |
| 2301 | } |
| 2302 | style_header("No such file"); |
| 2303 | @ File '%h(zName)' does not exist in this repository. |
| 2304 | }else{ |
| 2305 | style_header("No such artifact"); |
| 2306 | @ Artifact '%h(zName)' does not exist in this repository. |
| 2307 | } |
| 2308 | style_footer(); |
| 2309 | return; |
| 2310 | } |
| 2311 | |
| 2312 | if( descOnly || P("verbose")!=0 ){ |
| 2313 | url_add_parameter(&url, "verbose", "1"); |
| 2314 | objdescFlags |= OBJDESC_DETAIL; |
| 2315 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -2284,10 +2284,11 @@ | |
| 2284 | rid = artifact_from_ci_and_filename(0); |
| 2285 | } |
| 2286 | |
| 2287 | if( rid==0 ){ /* Artifact not found */ |
| 2288 | if( isFile ){ |
| 2289 | Stmt q; |
| 2290 | /* For /file, also check to see if name= refers to a directory, |
| 2291 | ** and if so, do a listing for that directory */ |
| 2292 | int nName = (int)strlen(zName); |
| 2293 | if( nName && zName[nName-1]=='/' ) nName--; |
| 2294 | if( db_exists( |
| @@ -2297,18 +2298,39 @@ | |
| 2298 | ) ){ |
| 2299 | if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
| 2300 | page_tree(); |
| 2301 | return; |
| 2302 | } |
| 2303 | /* No directory found, look for an historic version of the file |
| 2304 | ** that was subsequently deleted. */ |
| 2305 | db_prepare(&q, |
| 2306 | "SELECT fid, uuid FROM mlink, filename, event, blob" |
| 2307 | " WHERE filename.name=%Q" |
| 2308 | " AND mlink.fnid=filename.fnid AND mlink.fid>0" |
| 2309 | " AND event.objid=mlink.mid" |
| 2310 | " AND blob.rid=mlink.mid" |
| 2311 | " ORDER BY event.mtime DESC", |
| 2312 | zName |
| 2313 | ); |
| 2314 | if( db_step(&q)==SQLITE_ROW ){ |
| 2315 | rid = db_column_int(&q, 0); |
| 2316 | zCIUuid = zCI = fossil_strdup(db_column_text(&q, 1)); |
| 2317 | url_add_parameter(&url, "ci", zCI); |
| 2318 | } |
| 2319 | db_finalize(&q); |
| 2320 | if( rid==0 ){ |
| 2321 | style_header("No such file"); |
| 2322 | @ File '%h(zName)' does not exist in this repository. |
| 2323 | } |
| 2324 | }else{ |
| 2325 | style_header("No such artifact"); |
| 2326 | @ Artifact '%h(zName)' does not exist in this repository. |
| 2327 | } |
| 2328 | if( rid==0 ){ |
| 2329 | style_footer(); |
| 2330 | return; |
| 2331 | } |
| 2332 | } |
| 2333 | |
| 2334 | if( descOnly || P("verbose")!=0 ){ |
| 2335 | url_add_parameter(&url, "verbose", "1"); |
| 2336 | objdescFlags |= OBJDESC_DETAIL; |
| 2337 |