Fossil SCM
Enhance the test-phantoms command to provide additional information about delta-phantoms.
Commit
aac885a61981dfd5b5a7cd0d698bd553da4155729c5f9925c1ad599144090056
Parent
41cd8d51ba7ce1a…
1 file changed
+61
-2
+61
-2
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -2203,15 +2203,74 @@ | ||
| 2203 | 2203 | /* |
| 2204 | 2204 | ** COMMAND: test-phantoms |
| 2205 | 2205 | ** |
| 2206 | 2206 | ** Usage: %fossil test-phantoms |
| 2207 | 2207 | ** |
| 2208 | -** Show all phantom artifacts | |
| 2208 | +** Show all phantom artifacts. A phantom artifact is one for which there | |
| 2209 | +** is no content. Options: | |
| 2210 | +** | |
| 2211 | +** --count Show only a count of the number of phantoms. | |
| 2212 | +** --delta Show all delta-phantoms. A delta-phantom is a | |
| 2213 | +** artifact for which there is a delta but the delta | |
| 2214 | +** source is a phantom. | |
| 2215 | +** --list Just list the phantoms. Do not try to describe them. | |
| 2209 | 2216 | */ |
| 2210 | 2217 | void test_phatoms_cmd(void){ |
| 2218 | + int bDelta; | |
| 2219 | + int bList; | |
| 2220 | + int bCount; | |
| 2221 | + unsigned nPhantom = 0; | |
| 2222 | + unsigned nDeltaPhantom = 0; | |
| 2211 | 2223 | db_find_and_open_repository(0,0); |
| 2212 | - describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); | |
| 2224 | + bDelta = find_option("delta", 0, 0)!=0; | |
| 2225 | + bList = find_option("list", 0, 0)!=0; | |
| 2226 | + bCount = find_option("count", 0, 0)!=0; | |
| 2227 | + verify_all_options(); | |
| 2228 | + if( bList || bCount ){ | |
| 2229 | + Stmt q1, q2; | |
| 2230 | + db_prepare(&q1, "SELECT rid, uuid FROM blob WHERE size<0"); | |
| 2231 | + while( db_step(&q1)==SQLITE_ROW ){ | |
| 2232 | + int rid = db_column_int(&q1, 0); | |
| 2233 | + nPhantom++; | |
| 2234 | + if( !bCount ){ | |
| 2235 | + fossil_print("%S (%d)\n", db_column_text(&q1,1), rid); | |
| 2236 | + } | |
| 2237 | + db_prepare(&q2, | |
| 2238 | + "WITH RECURSIVE deltasof(rid) AS (" | |
| 2239 | + " SELECT rid FROM delta WHERE srcid=%d" | |
| 2240 | + " UNION" | |
| 2241 | + " SELECT delta.rid FROM deltasof, delta" | |
| 2242 | + " WHERE delta.srcid=deltasof.rid)" | |
| 2243 | + "SELECT deltasof.rid, blob.uuid FROM deltasof LEFT JOIN blob" | |
| 2244 | + " ON blob.rid=deltasof.rid", rid | |
| 2245 | + ); | |
| 2246 | + while( db_step(&q2)==SQLITE_ROW ){ | |
| 2247 | + nDeltaPhantom++; | |
| 2248 | + if( !bCount ){ | |
| 2249 | + fossil_print(" %S (%d)\n", db_column_text(&q2,1), | |
| 2250 | + db_column_int(&q2,0)); | |
| 2251 | + } | |
| 2252 | + } | |
| 2253 | + db_finalize(&q2); | |
| 2254 | + } | |
| 2255 | + db_finalize(&q1); | |
| 2256 | + if( nPhantom ){ | |
| 2257 | + fossil_print("Phantoms: %u Delta-phantoms: %u\n", | |
| 2258 | + nPhantom, nDeltaPhantom); | |
| 2259 | + } | |
| 2260 | + }else if( bDelta ){ | |
| 2261 | + describe_artifacts_to_stdout( | |
| 2262 | + "IN (WITH RECURSIVE delta_phantom(rid) AS (\n" | |
| 2263 | + " SELECT delta.rid FROM blob, delta\n" | |
| 2264 | + " WHERE blob.size<0 AND delta.srcid=blob.rid\n" | |
| 2265 | + " UNION\n" | |
| 2266 | + " SELECT delta.rid FROM delta_phantom, delta\n" | |
| 2267 | + " WHERE delta.srcid=delta_phantom.rid)\n" | |
| 2268 | + " SELECT rid FROM delta_phantom)", 0); | |
| 2269 | + }else{ | |
| 2270 | + describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); | |
| 2271 | + } | |
| 2213 | 2272 | } |
| 2214 | 2273 | |
| 2215 | 2274 | /* Maximum number of collision examples to remember */ |
| 2216 | 2275 | #define MAX_COLLIDE 25 |
| 2217 | 2276 | |
| 2218 | 2277 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -2203,15 +2203,74 @@ | |
| 2203 | /* |
| 2204 | ** COMMAND: test-phantoms |
| 2205 | ** |
| 2206 | ** Usage: %fossil test-phantoms |
| 2207 | ** |
| 2208 | ** Show all phantom artifacts |
| 2209 | */ |
| 2210 | void test_phatoms_cmd(void){ |
| 2211 | db_find_and_open_repository(0,0); |
| 2212 | describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); |
| 2213 | } |
| 2214 | |
| 2215 | /* Maximum number of collision examples to remember */ |
| 2216 | #define MAX_COLLIDE 25 |
| 2217 | |
| 2218 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -2203,15 +2203,74 @@ | |
| 2203 | /* |
| 2204 | ** COMMAND: test-phantoms |
| 2205 | ** |
| 2206 | ** Usage: %fossil test-phantoms |
| 2207 | ** |
| 2208 | ** Show all phantom artifacts. A phantom artifact is one for which there |
| 2209 | ** is no content. Options: |
| 2210 | ** |
| 2211 | ** --count Show only a count of the number of phantoms. |
| 2212 | ** --delta Show all delta-phantoms. A delta-phantom is a |
| 2213 | ** artifact for which there is a delta but the delta |
| 2214 | ** source is a phantom. |
| 2215 | ** --list Just list the phantoms. Do not try to describe them. |
| 2216 | */ |
| 2217 | void test_phatoms_cmd(void){ |
| 2218 | int bDelta; |
| 2219 | int bList; |
| 2220 | int bCount; |
| 2221 | unsigned nPhantom = 0; |
| 2222 | unsigned nDeltaPhantom = 0; |
| 2223 | db_find_and_open_repository(0,0); |
| 2224 | bDelta = find_option("delta", 0, 0)!=0; |
| 2225 | bList = find_option("list", 0, 0)!=0; |
| 2226 | bCount = find_option("count", 0, 0)!=0; |
| 2227 | verify_all_options(); |
| 2228 | if( bList || bCount ){ |
| 2229 | Stmt q1, q2; |
| 2230 | db_prepare(&q1, "SELECT rid, uuid FROM blob WHERE size<0"); |
| 2231 | while( db_step(&q1)==SQLITE_ROW ){ |
| 2232 | int rid = db_column_int(&q1, 0); |
| 2233 | nPhantom++; |
| 2234 | if( !bCount ){ |
| 2235 | fossil_print("%S (%d)\n", db_column_text(&q1,1), rid); |
| 2236 | } |
| 2237 | db_prepare(&q2, |
| 2238 | "WITH RECURSIVE deltasof(rid) AS (" |
| 2239 | " SELECT rid FROM delta WHERE srcid=%d" |
| 2240 | " UNION" |
| 2241 | " SELECT delta.rid FROM deltasof, delta" |
| 2242 | " WHERE delta.srcid=deltasof.rid)" |
| 2243 | "SELECT deltasof.rid, blob.uuid FROM deltasof LEFT JOIN blob" |
| 2244 | " ON blob.rid=deltasof.rid", rid |
| 2245 | ); |
| 2246 | while( db_step(&q2)==SQLITE_ROW ){ |
| 2247 | nDeltaPhantom++; |
| 2248 | if( !bCount ){ |
| 2249 | fossil_print(" %S (%d)\n", db_column_text(&q2,1), |
| 2250 | db_column_int(&q2,0)); |
| 2251 | } |
| 2252 | } |
| 2253 | db_finalize(&q2); |
| 2254 | } |
| 2255 | db_finalize(&q1); |
| 2256 | if( nPhantom ){ |
| 2257 | fossil_print("Phantoms: %u Delta-phantoms: %u\n", |
| 2258 | nPhantom, nDeltaPhantom); |
| 2259 | } |
| 2260 | }else if( bDelta ){ |
| 2261 | describe_artifacts_to_stdout( |
| 2262 | "IN (WITH RECURSIVE delta_phantom(rid) AS (\n" |
| 2263 | " SELECT delta.rid FROM blob, delta\n" |
| 2264 | " WHERE blob.size<0 AND delta.srcid=blob.rid\n" |
| 2265 | " UNION\n" |
| 2266 | " SELECT delta.rid FROM delta_phantom, delta\n" |
| 2267 | " WHERE delta.srcid=delta_phantom.rid)\n" |
| 2268 | " SELECT rid FROM delta_phantom)", 0); |
| 2269 | }else{ |
| 2270 | describe_artifacts_to_stdout("IN (SELECT rid FROM blob WHERE size<0)", 0); |
| 2271 | } |
| 2272 | } |
| 2273 | |
| 2274 | /* Maximum number of collision examples to remember */ |
| 2275 | #define MAX_COLLIDE 25 |
| 2276 | |
| 2277 |