Fossil SCM
Enhance the "fossil whatis" command so that it response to ticket IDs.
Commit
86d07e8a74480097c2e165692104dd2927362e531e9f62c0bd6c9989b6c647cd
Parent
1a93c064ccc562c…
1 file changed
+53
-5
+53
-5
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -1223,16 +1223,23 @@ | ||
| 1223 | 1223 | if( cnt ) fossil_print("\n"); |
| 1224 | 1224 | db_finalize(&q); |
| 1225 | 1225 | |
| 1226 | 1226 | /* Check for entries on the timeline that reference this object */ |
| 1227 | 1227 | db_prepare(&q, |
| 1228 | - "SELECT type, datetime(mtime,toLocal())," | |
| 1229 | - " coalesce(euser,user), coalesce(ecomment,comment)" | |
| 1230 | - " FROM event WHERE objid=%d", rid); | |
| 1228 | + "SELECT" | |
| 1229 | + " type," | |
| 1230 | + " datetime(mtime,toLocal())," | |
| 1231 | + " coalesce(euser,user)," | |
| 1232 | + " coalesce(ecomment,comment)," | |
| 1233 | + " if(type='t',(SELECT substr(tagname,5) FROM tag" | |
| 1234 | + " WHERE tag.tagid=event.tagid))" | |
| 1235 | + "FROM event WHERE objid=%d", | |
| 1236 | + rid); | |
| 1231 | 1237 | if( db_step(&q)==SQLITE_ROW ){ |
| 1232 | 1238 | const char *zType; |
| 1233 | - switch( db_column_text(&q,0)[0] ){ | |
| 1239 | + char eType = db_column_text(&q,0)[0]; | |
| 1240 | + switch( eType ){ | |
| 1234 | 1241 | case 'c': zType = "Check-in"; break; |
| 1235 | 1242 | case 'w': zType = "Wiki-edit"; break; |
| 1236 | 1243 | case 'e': zType = "Technote"; break; |
| 1237 | 1244 | case 'f': zType = "Forum-post"; break; |
| 1238 | 1245 | case 't': zType = "Ticket-change"; break; |
| @@ -1239,10 +1246,13 @@ | ||
| 1239 | 1246 | case 'g': zType = "Tag-change"; break; |
| 1240 | 1247 | default: zType = "Unknown"; break; |
| 1241 | 1248 | } |
| 1242 | 1249 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 1243 | 1250 | db_column_text(&q, 1)); |
| 1251 | + if( eType=='t' && db_column_type(&q,4)==SQLITE_TEXT ){ | |
| 1252 | + fossil_print("ticket-id: %s\n", db_column_text(&q,4)); | |
| 1253 | + } | |
| 1244 | 1254 | fossil_print("comment: "); |
| 1245 | 1255 | comment_print(db_column_text(&q,3), 0, 12, -1, get_comment_format()); |
| 1246 | 1256 | cnt++; |
| 1247 | 1257 | } |
| 1248 | 1258 | db_finalize(&q); |
| @@ -1335,10 +1345,32 @@ | ||
| 1335 | 1345 | const char *zFileName,/* Optional: original filename (in file mode) */ |
| 1336 | 1346 | const char *zType, /* Artifact type filter */ |
| 1337 | 1347 | int mFlags /* WHATIS_* flags */ |
| 1338 | 1348 | ){ |
| 1339 | 1349 | int rid = symbolic_name_to_rid(zName, zType); |
| 1350 | + size_t nName; | |
| 1351 | + char *zC = 0; | |
| 1352 | + int nTkt = 0; | |
| 1353 | + if( (nName = strlen(zName))>=4 && validate16(zName,nName) ){ | |
| 1354 | + zC = fossil_strdup(zName); | |
| 1355 | + canonical16(zC, nName); | |
| 1356 | + nTkt = db_int(0,"SELECT count(*) FROM tag WHERE tagname GLOB 'tkt-%q*'",zC); | |
| 1357 | + if( nTkt>0 ){ | |
| 1358 | + if( rid==0 ){ | |
| 1359 | + rid = db_int(0, | |
| 1360 | + "SELECT srcid FROM tag, tagxref" | |
| 1361 | + " WHERE tag.tagname GLOB 'tkt-%q*'" | |
| 1362 | + " AND tagxref.tagid=tag.tagid" | |
| 1363 | + " AND tagxref.tagtype=1" | |
| 1364 | + " ORDER BY tagxref.mtime", | |
| 1365 | + zC | |
| 1366 | + ); | |
| 1367 | + }else{ | |
| 1368 | + rid = -1; | |
| 1369 | + } | |
| 1370 | + } | |
| 1371 | + } | |
| 1340 | 1372 | if( rid<0 ){ |
| 1341 | 1373 | Stmt q; |
| 1342 | 1374 | int cnt = 0; |
| 1343 | 1375 | if( mFlags & WHATIS_REPO ){ |
| 1344 | 1376 | fossil_print("\nrepository: %s\n", g.zRepositoryName); |
| @@ -1348,16 +1380,31 @@ | ||
| 1348 | 1380 | } |
| 1349 | 1381 | fossil_print("%-12s%s (ambiguous)\n", "hash:", zName); |
| 1350 | 1382 | db_prepare(&q, |
| 1351 | 1383 | "SELECT rid FROM blob WHERE uuid>=lower(%Q) AND uuid<(lower(%Q)||'z')", |
| 1352 | 1384 | zName, zName |
| 1353 | - ); | |
| 1385 | + ); | |
| 1354 | 1386 | while( db_step(&q)==SQLITE_ROW ){ |
| 1355 | 1387 | if( cnt++ ) fossil_print("%12s---- meaning #%d ----\n", " ", cnt); |
| 1356 | 1388 | whatis_rid(db_column_int(&q, 0), mFlags); |
| 1357 | 1389 | } |
| 1358 | 1390 | db_finalize(&q); |
| 1391 | + if( nTkt>0 ){ | |
| 1392 | + db_prepare(&q, | |
| 1393 | + "SELECT (SELECT srcid FROM tagxref" | |
| 1394 | + " WHERE tagxref.tagid=tag.tagid" | |
| 1395 | + " AND tagxref.tagtype=1" | |
| 1396 | + " ORDER BY mtime LIMIT 1)" | |
| 1397 | + " FROM tag WHERE tagname GLOB 'tkt-%q*'", | |
| 1398 | + zC | |
| 1399 | + ); | |
| 1400 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 1401 | + if( cnt++ ) fossil_print("%12s---- meaning #%d ----\n", " ", cnt); | |
| 1402 | + whatis_rid(db_column_int(&q, 0), mFlags); | |
| 1403 | + } | |
| 1404 | + db_finalize(&q); | |
| 1405 | + } | |
| 1359 | 1406 | }else if( rid==0 ){ |
| 1360 | 1407 | if( (mFlags & (WHATIS_OMIT_UNK|WHATIS_HASHONLY))==0 ){ |
| 1361 | 1408 | /* 0123456789 12 */ |
| 1362 | 1409 | if( zFileName ){ |
| 1363 | 1410 | fossil_print("%-12s%s\n", "name:", zFileName); |
| @@ -1374,10 +1421,11 @@ | ||
| 1374 | 1421 | if( (mFlags & WHATIS_HASHONLY)==0 ){ |
| 1375 | 1422 | fossil_print("%-12s%s\n", "name:", zName); |
| 1376 | 1423 | } |
| 1377 | 1424 | whatis_rid(rid, mFlags); |
| 1378 | 1425 | } |
| 1426 | + fossil_free(zC); | |
| 1379 | 1427 | } |
| 1380 | 1428 | |
| 1381 | 1429 | /* |
| 1382 | 1430 | ** COMMAND: whatis* |
| 1383 | 1431 | ** |
| 1384 | 1432 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -1223,16 +1223,23 @@ | |
| 1223 | if( cnt ) fossil_print("\n"); |
| 1224 | db_finalize(&q); |
| 1225 | |
| 1226 | /* Check for entries on the timeline that reference this object */ |
| 1227 | db_prepare(&q, |
| 1228 | "SELECT type, datetime(mtime,toLocal())," |
| 1229 | " coalesce(euser,user), coalesce(ecomment,comment)" |
| 1230 | " FROM event WHERE objid=%d", rid); |
| 1231 | if( db_step(&q)==SQLITE_ROW ){ |
| 1232 | const char *zType; |
| 1233 | switch( db_column_text(&q,0)[0] ){ |
| 1234 | case 'c': zType = "Check-in"; break; |
| 1235 | case 'w': zType = "Wiki-edit"; break; |
| 1236 | case 'e': zType = "Technote"; break; |
| 1237 | case 'f': zType = "Forum-post"; break; |
| 1238 | case 't': zType = "Ticket-change"; break; |
| @@ -1239,10 +1246,13 @@ | |
| 1239 | case 'g': zType = "Tag-change"; break; |
| 1240 | default: zType = "Unknown"; break; |
| 1241 | } |
| 1242 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 1243 | db_column_text(&q, 1)); |
| 1244 | fossil_print("comment: "); |
| 1245 | comment_print(db_column_text(&q,3), 0, 12, -1, get_comment_format()); |
| 1246 | cnt++; |
| 1247 | } |
| 1248 | db_finalize(&q); |
| @@ -1335,10 +1345,32 @@ | |
| 1335 | const char *zFileName,/* Optional: original filename (in file mode) */ |
| 1336 | const char *zType, /* Artifact type filter */ |
| 1337 | int mFlags /* WHATIS_* flags */ |
| 1338 | ){ |
| 1339 | int rid = symbolic_name_to_rid(zName, zType); |
| 1340 | if( rid<0 ){ |
| 1341 | Stmt q; |
| 1342 | int cnt = 0; |
| 1343 | if( mFlags & WHATIS_REPO ){ |
| 1344 | fossil_print("\nrepository: %s\n", g.zRepositoryName); |
| @@ -1348,16 +1380,31 @@ | |
| 1348 | } |
| 1349 | fossil_print("%-12s%s (ambiguous)\n", "hash:", zName); |
| 1350 | db_prepare(&q, |
| 1351 | "SELECT rid FROM blob WHERE uuid>=lower(%Q) AND uuid<(lower(%Q)||'z')", |
| 1352 | zName, zName |
| 1353 | ); |
| 1354 | while( db_step(&q)==SQLITE_ROW ){ |
| 1355 | if( cnt++ ) fossil_print("%12s---- meaning #%d ----\n", " ", cnt); |
| 1356 | whatis_rid(db_column_int(&q, 0), mFlags); |
| 1357 | } |
| 1358 | db_finalize(&q); |
| 1359 | }else if( rid==0 ){ |
| 1360 | if( (mFlags & (WHATIS_OMIT_UNK|WHATIS_HASHONLY))==0 ){ |
| 1361 | /* 0123456789 12 */ |
| 1362 | if( zFileName ){ |
| 1363 | fossil_print("%-12s%s\n", "name:", zFileName); |
| @@ -1374,10 +1421,11 @@ | |
| 1374 | if( (mFlags & WHATIS_HASHONLY)==0 ){ |
| 1375 | fossil_print("%-12s%s\n", "name:", zName); |
| 1376 | } |
| 1377 | whatis_rid(rid, mFlags); |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | /* |
| 1382 | ** COMMAND: whatis* |
| 1383 | ** |
| 1384 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -1223,16 +1223,23 @@ | |
| 1223 | if( cnt ) fossil_print("\n"); |
| 1224 | db_finalize(&q); |
| 1225 | |
| 1226 | /* Check for entries on the timeline that reference this object */ |
| 1227 | db_prepare(&q, |
| 1228 | "SELECT" |
| 1229 | " type," |
| 1230 | " datetime(mtime,toLocal())," |
| 1231 | " coalesce(euser,user)," |
| 1232 | " coalesce(ecomment,comment)," |
| 1233 | " if(type='t',(SELECT substr(tagname,5) FROM tag" |
| 1234 | " WHERE tag.tagid=event.tagid))" |
| 1235 | "FROM event WHERE objid=%d", |
| 1236 | rid); |
| 1237 | if( db_step(&q)==SQLITE_ROW ){ |
| 1238 | const char *zType; |
| 1239 | char eType = db_column_text(&q,0)[0]; |
| 1240 | switch( eType ){ |
| 1241 | case 'c': zType = "Check-in"; break; |
| 1242 | case 'w': zType = "Wiki-edit"; break; |
| 1243 | case 'e': zType = "Technote"; break; |
| 1244 | case 'f': zType = "Forum-post"; break; |
| 1245 | case 't': zType = "Ticket-change"; break; |
| @@ -1239,10 +1246,13 @@ | |
| 1246 | case 'g': zType = "Tag-change"; break; |
| 1247 | default: zType = "Unknown"; break; |
| 1248 | } |
| 1249 | fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), |
| 1250 | db_column_text(&q, 1)); |
| 1251 | if( eType=='t' && db_column_type(&q,4)==SQLITE_TEXT ){ |
| 1252 | fossil_print("ticket-id: %s\n", db_column_text(&q,4)); |
| 1253 | } |
| 1254 | fossil_print("comment: "); |
| 1255 | comment_print(db_column_text(&q,3), 0, 12, -1, get_comment_format()); |
| 1256 | cnt++; |
| 1257 | } |
| 1258 | db_finalize(&q); |
| @@ -1335,10 +1345,32 @@ | |
| 1345 | const char *zFileName,/* Optional: original filename (in file mode) */ |
| 1346 | const char *zType, /* Artifact type filter */ |
| 1347 | int mFlags /* WHATIS_* flags */ |
| 1348 | ){ |
| 1349 | int rid = symbolic_name_to_rid(zName, zType); |
| 1350 | size_t nName; |
| 1351 | char *zC = 0; |
| 1352 | int nTkt = 0; |
| 1353 | if( (nName = strlen(zName))>=4 && validate16(zName,nName) ){ |
| 1354 | zC = fossil_strdup(zName); |
| 1355 | canonical16(zC, nName); |
| 1356 | nTkt = db_int(0,"SELECT count(*) FROM tag WHERE tagname GLOB 'tkt-%q*'",zC); |
| 1357 | if( nTkt>0 ){ |
| 1358 | if( rid==0 ){ |
| 1359 | rid = db_int(0, |
| 1360 | "SELECT srcid FROM tag, tagxref" |
| 1361 | " WHERE tag.tagname GLOB 'tkt-%q*'" |
| 1362 | " AND tagxref.tagid=tag.tagid" |
| 1363 | " AND tagxref.tagtype=1" |
| 1364 | " ORDER BY tagxref.mtime", |
| 1365 | zC |
| 1366 | ); |
| 1367 | }else{ |
| 1368 | rid = -1; |
| 1369 | } |
| 1370 | } |
| 1371 | } |
| 1372 | if( rid<0 ){ |
| 1373 | Stmt q; |
| 1374 | int cnt = 0; |
| 1375 | if( mFlags & WHATIS_REPO ){ |
| 1376 | fossil_print("\nrepository: %s\n", g.zRepositoryName); |
| @@ -1348,16 +1380,31 @@ | |
| 1380 | } |
| 1381 | fossil_print("%-12s%s (ambiguous)\n", "hash:", zName); |
| 1382 | db_prepare(&q, |
| 1383 | "SELECT rid FROM blob WHERE uuid>=lower(%Q) AND uuid<(lower(%Q)||'z')", |
| 1384 | zName, zName |
| 1385 | ); |
| 1386 | while( db_step(&q)==SQLITE_ROW ){ |
| 1387 | if( cnt++ ) fossil_print("%12s---- meaning #%d ----\n", " ", cnt); |
| 1388 | whatis_rid(db_column_int(&q, 0), mFlags); |
| 1389 | } |
| 1390 | db_finalize(&q); |
| 1391 | if( nTkt>0 ){ |
| 1392 | db_prepare(&q, |
| 1393 | "SELECT (SELECT srcid FROM tagxref" |
| 1394 | " WHERE tagxref.tagid=tag.tagid" |
| 1395 | " AND tagxref.tagtype=1" |
| 1396 | " ORDER BY mtime LIMIT 1)" |
| 1397 | " FROM tag WHERE tagname GLOB 'tkt-%q*'", |
| 1398 | zC |
| 1399 | ); |
| 1400 | while( db_step(&q)==SQLITE_ROW ){ |
| 1401 | if( cnt++ ) fossil_print("%12s---- meaning #%d ----\n", " ", cnt); |
| 1402 | whatis_rid(db_column_int(&q, 0), mFlags); |
| 1403 | } |
| 1404 | db_finalize(&q); |
| 1405 | } |
| 1406 | }else if( rid==0 ){ |
| 1407 | if( (mFlags & (WHATIS_OMIT_UNK|WHATIS_HASHONLY))==0 ){ |
| 1408 | /* 0123456789 12 */ |
| 1409 | if( zFileName ){ |
| 1410 | fossil_print("%-12s%s\n", "name:", zFileName); |
| @@ -1374,10 +1421,11 @@ | |
| 1421 | if( (mFlags & WHATIS_HASHONLY)==0 ){ |
| 1422 | fossil_print("%-12s%s\n", "name:", zName); |
| 1423 | } |
| 1424 | whatis_rid(rid, mFlags); |
| 1425 | } |
| 1426 | fossil_free(zC); |
| 1427 | } |
| 1428 | |
| 1429 | /* |
| 1430 | ** COMMAND: whatis* |
| 1431 | ** |
| 1432 |