Fossil SCM

Take out the "test-fts" command and replace it with "fts-config" which has a more user-friendly format. Add "fts-config" to the "all" command too.

drh 2015-02-03 16:40 trunk
Commit 7b6adfbf92ca9fefee20221417e1504c8452b61d
2 files changed +3 +92 -66
--- src/allrepo.c
+++ src/allrepo.c
@@ -234,10 +234,13 @@
234234
}else if( strncmp(zCmd, "setting", n)==0 ){
235235
zCmd = "setting -R";
236236
collect_argv(&extra, 3);
237237
}else if( strncmp(zCmd, "unset", n)==0 ){
238238
zCmd = "unset -R";
239
+ collect_argv(&extra, 3);
240
+ }else if( strncmp(zCmd, "fts-config", n)==0 ){
241
+ zCmd = "fts-config -R";
239242
collect_argv(&extra, 3);
240243
}else if( strncmp(zCmd, "sync", n)==0 ){
241244
zCmd = "sync -autourl -R";
242245
collect_argument(&extra, "verbose","v");
243246
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
244247
--- src/allrepo.c
+++ src/allrepo.c
@@ -234,10 +234,13 @@
234 }else if( strncmp(zCmd, "setting", n)==0 ){
235 zCmd = "setting -R";
236 collect_argv(&extra, 3);
237 }else if( strncmp(zCmd, "unset", n)==0 ){
238 zCmd = "unset -R";
 
 
 
239 collect_argv(&extra, 3);
240 }else if( strncmp(zCmd, "sync", n)==0 ){
241 zCmd = "sync -autourl -R";
242 collect_argument(&extra, "verbose","v");
243 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
244
--- src/allrepo.c
+++ src/allrepo.c
@@ -234,10 +234,13 @@
234 }else if( strncmp(zCmd, "setting", n)==0 ){
235 zCmd = "setting -R";
236 collect_argv(&extra, 3);
237 }else if( strncmp(zCmd, "unset", n)==0 ){
238 zCmd = "unset -R";
239 collect_argv(&extra, 3);
240 }else if( strncmp(zCmd, "fts-config", n)==0 ){
241 zCmd = "fts-config -R";
242 collect_argv(&extra, 3);
243 }else if( strncmp(zCmd, "sync", n)==0 ){
244 zCmd = "sync -autourl -R";
245 collect_argument(&extra, "verbose","v");
246 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
247
+92 -66
--- src/search.c
+++ src/search.c
@@ -1363,81 +1363,107 @@
13631363
search_update_wiki_index();
13641364
}
13651365
}
13661366
13671367
/*
1368
-** COMMAND: test-fts
1368
+** COMMAND: fts-config*
1369
+**
1370
+** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT?
1371
+**
1372
+** The "fossil fts-config" command configures the full-text search capabilities
1373
+** of the repository. Subcommands:
1374
+**
1375
+** reindex Rebuild the search index. Create it if it does
1376
+** not already exist
1377
+**
1378
+** index (on|off) Turn the search index on or off
1379
+**
1380
+** enable cdtw Enable various kinds of search. c=Check-ins,
1381
+** d=Documents, t=Tickets, w=Wiki.
1382
+**
1383
+** disable cdtw Disable versious kinds of search
1384
+**
1385
+** The current search settings are displayed after any changes are applied.
1386
+** Run this command with no arguments to simply see the settings.
13691387
*/
13701388
void test_fts_cmd(void){
1371
- char *zSubCmd;
1372
- int i, n;
13731389
static const struct { int iCmd; const char *z; } aCmd[] = {
1374
- { 1, "create" },
1375
- { 2, "drop" },
1376
- { 3, "exists" },
1377
- { 4, "fill" },
1378
- { 8, "refill" },
1379
- { 5, "pending" },
1380
- { 7, "update" },
1390
+ { 1, "reindex" },
1391
+ { 2, "index" },
1392
+ { 3, "disable" },
1393
+ { 4, "enable" },
1394
+ };
1395
+ static const struct { char *zSetting; char *zName; char *zSw; } aSetng[] = {
1396
+ { "search-ckin", "check-in search:", "c" },
1397
+ { "search-doc", "document search:", "d" },
1398
+ { "search-tkt", "ticket search:", "t" },
1399
+ { "search-wiki", "wiki search:", "w" },
13811400
};
1401
+ char *zSubCmd;
1402
+ int i, j, n;
1403
+ int iCmd = 0;
1404
+ int iAction = 0;
13821405
db_find_and_open_repository(0, 0);
1383
- if( g.argc<3 ) usage("SUBCMD ...");
1384
- zSubCmd = g.argv[2];
1385
- n = (int)strlen(zSubCmd);
1386
- for(i=0; i<ArraySize(aCmd); i++){
1387
- if( fossil_strncmp(aCmd[i].z, zSubCmd, n)==0 ) break;
1388
- }
1389
- if( i>=ArraySize(aCmd) ){
1390
- Blob all;
1391
- blob_init(&all,0,0);
1392
- for(i=0; i<ArraySize(aCmd); i++) blob_appendf(&all, " %s", aCmd[i].z);
1393
- fossil_fatal("unknown \"%s\" - should be:%s", zSubCmd, blob_str(&all));
1394
- return;
1406
+ if( g.argc>2 ){
1407
+ zSubCmd = g.argv[2];
1408
+ n = (int)strlen(zSubCmd);
1409
+ for(i=0; i<ArraySize(aCmd); i++){
1410
+ if( fossil_strncmp(aCmd[i].z, zSubCmd, n)==0 ) break;
1411
+ }
1412
+ if( i>=ArraySize(aCmd) ){
1413
+ Blob all;
1414
+ blob_init(&all,0,0);
1415
+ for(i=0; i<ArraySize(aCmd); i++) blob_appendf(&all, " %s", aCmd[i].z);
1416
+ fossil_fatal("unknown \"%s\" - should be on of:%s",
1417
+ zSubCmd, blob_str(&all));
1418
+ return;
1419
+ }
1420
+ iCmd = aCmd[i].iCmd;
1421
+ }
1422
+ if( iCmd==1 ){
1423
+ iAction = 2;
1424
+ }
1425
+ if( iCmd==2 ){
1426
+ if( g.argc<3 ) usage("index (on|off)");
1427
+ iAction = 1 + is_truth(g.argv[3]);
13951428
}
13961429
db_begin_transaction();
1397
- switch( aCmd[i].iCmd ){
1398
- case 1: { assert( fossil_strncmp(zSubCmd, "create", n)==0 );
1399
- search_create_index();
1400
- break;
1401
- }
1402
- case 2: { assert( fossil_strncmp(zSubCmd, "drop", n)==0 );
1403
- search_drop_index();
1404
- break;
1405
- }
1406
- case 3: { assert( fossil_strncmp(zSubCmd, "exists", n)==0 );
1407
- fossil_print("search_index_exists() = %d\n", search_index_exists());
1408
- break;
1409
- }
1410
- case 4: { assert( fossil_strncmp(zSubCmd, "fill", n)==0 );
1411
- search_fill_index();
1412
- break;
1413
- }
1414
- case 8: { assert( fossil_strncmp(zSubCmd, "refill", n)==0 );
1415
- search_drop_index();
1416
- search_create_index();
1417
- search_fill_index();
1418
- break;
1419
- }
1420
- case 5: { assert( fossil_strncmp(zSubCmd, "pending", n)==0 );
1421
- Stmt q;
1422
- if( !search_index_exists() ) break;
1423
- db_prepare(&q, "SELECT rowid,type,rid,quote(name) FROM ftsdocs"
1424
- " WHERE NOT idxed");
1425
- while( db_step(&q)==SQLITE_ROW ){
1426
- fossil_print("%6d: %s %6d %s\n",
1427
- db_column_int(&q, 0),
1428
- db_column_text(&q, 1),
1429
- db_column_int(&q, 2),
1430
- db_column_text(&q, 3)
1431
- );
1432
- }
1433
- db_finalize(&q);
1434
- break;
1435
- }
1436
- case 7: { assert( fossil_strncmp(zSubCmd, "update", n)==0 );
1437
- search_update_index(SRCH_ALL);
1438
- break;
1439
- }
1440
-
1430
+
1431
+ /* Adjust search settings */
1432
+ if( iCmd==3 || iCmd==4 ){
1433
+ const char *zCtrl;
1434
+ if( g.argc<4 ) usage("enable STRING");
1435
+ zCtrl = g.argv[3];
1436
+ for(j=0; j<ArraySize(aSetng); j++){
1437
+ if( strchr(zCtrl, aSetng[j].zSw[0])!=0 ){
1438
+ db_set_int(aSetng[j].zSetting, iCmd-3, 0);
1439
+ }
1440
+ }
1441
+ }
1442
+
1443
+ /* destroy or rebuild the index, if requested */
1444
+ if( iAction>=1 ){
1445
+ search_drop_index();
1446
+ }
1447
+ if( iAction>=2 ){
1448
+ fossil_print("rebuilding the search index...");
1449
+ fflush(stdout);
1450
+ search_create_index();
1451
+ search_fill_index();
1452
+ search_update_index(search_restrict(SRCH_ALL));
1453
+ fossil_print(" done\n");
1454
+ }
1455
+
1456
+ /* Always show the status before ending */
1457
+ for(i=0; i<ArraySize(aSetng); i++){
1458
+ fossil_print("%-16s %s\n", aSetng[i].zName,
1459
+ db_get_boolean(aSetng[i].zSetting,0) ? "on" : "off");
1460
+ }
1461
+ if( search_index_exists() ){
1462
+ fossil_print("%-16s enabled\n", "full-text index:");
1463
+ fossil_print("%-16s %d\n", "documents:",
1464
+ db_int(0, "SELECT count(*) FROM ftsdocs"));
1465
+ }else{
1466
+ fossil_print("%-16s disabled\n", "full-text index:");
14411467
}
14421468
db_end_transaction(0);
14431469
}
14441470
--- src/search.c
+++ src/search.c
@@ -1363,81 +1363,107 @@
1363 search_update_wiki_index();
1364 }
1365 }
1366
1367 /*
1368 ** COMMAND: test-fts
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1369 */
1370 void test_fts_cmd(void){
1371 char *zSubCmd;
1372 int i, n;
1373 static const struct { int iCmd; const char *z; } aCmd[] = {
1374 { 1, "create" },
1375 { 2, "drop" },
1376 { 3, "exists" },
1377 { 4, "fill" },
1378 { 8, "refill" },
1379 { 5, "pending" },
1380 { 7, "update" },
 
 
 
1381 };
 
 
 
 
1382 db_find_and_open_repository(0, 0);
1383 if( g.argc<3 ) usage("SUBCMD ...");
1384 zSubCmd = g.argv[2];
1385 n = (int)strlen(zSubCmd);
1386 for(i=0; i<ArraySize(aCmd); i++){
1387 if( fossil_strncmp(aCmd[i].z, zSubCmd, n)==0 ) break;
1388 }
1389 if( i>=ArraySize(aCmd) ){
1390 Blob all;
1391 blob_init(&all,0,0);
1392 for(i=0; i<ArraySize(aCmd); i++) blob_appendf(&all, " %s", aCmd[i].z);
1393 fossil_fatal("unknown \"%s\" - should be:%s", zSubCmd, blob_str(&all));
1394 return;
 
 
 
 
 
 
 
 
 
 
1395 }
1396 db_begin_transaction();
1397 switch( aCmd[i].iCmd ){
1398 case 1: { assert( fossil_strncmp(zSubCmd, "create", n)==0 );
1399 search_create_index();
1400 break;
1401 }
1402 case 2: { assert( fossil_strncmp(zSubCmd, "drop", n)==0 );
1403 search_drop_index();
1404 break;
1405 }
1406 case 3: { assert( fossil_strncmp(zSubCmd, "exists", n)==0 );
1407 fossil_print("search_index_exists() = %d\n", search_index_exists());
1408 break;
1409 }
1410 case 4: { assert( fossil_strncmp(zSubCmd, "fill", n)==0 );
1411 search_fill_index();
1412 break;
1413 }
1414 case 8: { assert( fossil_strncmp(zSubCmd, "refill", n)==0 );
1415 search_drop_index();
1416 search_create_index();
1417 search_fill_index();
1418 break;
1419 }
1420 case 5: { assert( fossil_strncmp(zSubCmd, "pending", n)==0 );
1421 Stmt q;
1422 if( !search_index_exists() ) break;
1423 db_prepare(&q, "SELECT rowid,type,rid,quote(name) FROM ftsdocs"
1424 " WHERE NOT idxed");
1425 while( db_step(&q)==SQLITE_ROW ){
1426 fossil_print("%6d: %s %6d %s\n",
1427 db_column_int(&q, 0),
1428 db_column_text(&q, 1),
1429 db_column_int(&q, 2),
1430 db_column_text(&q, 3)
1431 );
1432 }
1433 db_finalize(&q);
1434 break;
1435 }
1436 case 7: { assert( fossil_strncmp(zSubCmd, "update", n)==0 );
1437 search_update_index(SRCH_ALL);
1438 break;
1439 }
1440
1441 }
1442 db_end_transaction(0);
1443 }
1444
--- src/search.c
+++ src/search.c
@@ -1363,81 +1363,107 @@
1363 search_update_wiki_index();
1364 }
1365 }
1366
1367 /*
1368 ** COMMAND: fts-config*
1369 **
1370 ** Usage: fossil fts-config ?SUBCOMMAND? ?ARGUMENT?
1371 **
1372 ** The "fossil fts-config" command configures the full-text search capabilities
1373 ** of the repository. Subcommands:
1374 **
1375 ** reindex Rebuild the search index. Create it if it does
1376 ** not already exist
1377 **
1378 ** index (on|off) Turn the search index on or off
1379 **
1380 ** enable cdtw Enable various kinds of search. c=Check-ins,
1381 ** d=Documents, t=Tickets, w=Wiki.
1382 **
1383 ** disable cdtw Disable versious kinds of search
1384 **
1385 ** The current search settings are displayed after any changes are applied.
1386 ** Run this command with no arguments to simply see the settings.
1387 */
1388 void test_fts_cmd(void){
 
 
1389 static const struct { int iCmd; const char *z; } aCmd[] = {
1390 { 1, "reindex" },
1391 { 2, "index" },
1392 { 3, "disable" },
1393 { 4, "enable" },
1394 };
1395 static const struct { char *zSetting; char *zName; char *zSw; } aSetng[] = {
1396 { "search-ckin", "check-in search:", "c" },
1397 { "search-doc", "document search:", "d" },
1398 { "search-tkt", "ticket search:", "t" },
1399 { "search-wiki", "wiki search:", "w" },
1400 };
1401 char *zSubCmd;
1402 int i, j, n;
1403 int iCmd = 0;
1404 int iAction = 0;
1405 db_find_and_open_repository(0, 0);
1406 if( g.argc>2 ){
1407 zSubCmd = g.argv[2];
1408 n = (int)strlen(zSubCmd);
1409 for(i=0; i<ArraySize(aCmd); i++){
1410 if( fossil_strncmp(aCmd[i].z, zSubCmd, n)==0 ) break;
1411 }
1412 if( i>=ArraySize(aCmd) ){
1413 Blob all;
1414 blob_init(&all,0,0);
1415 for(i=0; i<ArraySize(aCmd); i++) blob_appendf(&all, " %s", aCmd[i].z);
1416 fossil_fatal("unknown \"%s\" - should be on of:%s",
1417 zSubCmd, blob_str(&all));
1418 return;
1419 }
1420 iCmd = aCmd[i].iCmd;
1421 }
1422 if( iCmd==1 ){
1423 iAction = 2;
1424 }
1425 if( iCmd==2 ){
1426 if( g.argc<3 ) usage("index (on|off)");
1427 iAction = 1 + is_truth(g.argv[3]);
1428 }
1429 db_begin_transaction();
1430
1431 /* Adjust search settings */
1432 if( iCmd==3 || iCmd==4 ){
1433 const char *zCtrl;
1434 if( g.argc<4 ) usage("enable STRING");
1435 zCtrl = g.argv[3];
1436 for(j=0; j<ArraySize(aSetng); j++){
1437 if( strchr(zCtrl, aSetng[j].zSw[0])!=0 ){
1438 db_set_int(aSetng[j].zSetting, iCmd-3, 0);
1439 }
1440 }
1441 }
1442
1443 /* destroy or rebuild the index, if requested */
1444 if( iAction>=1 ){
1445 search_drop_index();
1446 }
1447 if( iAction>=2 ){
1448 fossil_print("rebuilding the search index...");
1449 fflush(stdout);
1450 search_create_index();
1451 search_fill_index();
1452 search_update_index(search_restrict(SRCH_ALL));
1453 fossil_print(" done\n");
1454 }
1455
1456 /* Always show the status before ending */
1457 for(i=0; i<ArraySize(aSetng); i++){
1458 fossil_print("%-16s %s\n", aSetng[i].zName,
1459 db_get_boolean(aSetng[i].zSetting,0) ? "on" : "off");
1460 }
1461 if( search_index_exists() ){
1462 fossil_print("%-16s enabled\n", "full-text index:");
1463 fossil_print("%-16s %d\n", "documents:",
1464 db_int(0, "SELECT count(*) FROM ftsdocs"));
1465 }else{
1466 fossil_print("%-16s disabled\n", "full-text index:");
 
 
 
 
 
 
 
1467 }
1468 db_end_transaction(0);
1469 }
1470

Keyboard Shortcuts

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