371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
** Reset the bisect subsystem.
*/
void bisect_reset(void){
db_multi_exec(
"DELETE FROM vvar WHERE name IN "
" ('bisect-good', 'bisect-bad', 'bisect-log')"
" ('bisect-good', 'bisect-bad', 'bisect-log', 'bisect-complete')"
);
}
/*
** fossil bisect run [OPTIONS] COMMAND
**
** Invoke COMMAND (with arguments) repeatedly to perform the bisect.
** Options:
**
** -i|--interactive Prompt user for decisions rather than
** using the return code from COMMAND
*/
static void bisect_run(void){
const char *zCmd;
int isInteractive = 0;
int i;
if( g.argc<4 ){
fossil_fatal("Usage: fossil bisect run [OPTIONS] COMMAND\n");
}
for(i=3; i<g.argc-1; i++){
const char *zArg = g.argv[i];
if( zArg[0]=='-' && zArg[1]=='-' && zArg[2]!=0 ) zArg++;
if( strcmp(zArg, "-i")==0 || strcmp(zArg, "-interactive")==0 ){
isInteractive = 1;
continue;
}
fossil_fatal("unknown command-line option: \"%s\"\n", g.argv[i]);
}
zCmd = g.argv[i];
if( db_int(0, "SELECT count(*) FROM vvar"
" WHERE name IN ('bisect-good','bisect-bad')")!=2 ){
fossil_fatal("need good/bad boundaries to use \"fossil bisect run\"");
}
while( db_lget_int("bisect-complete",0)==0 ){
int rc;
Blob cmd;
blob_init(&cmd, 0, 0);
blob_append_escaped_arg(&cmd, g.nameOfExe);
rc = fossil_unsafe_system(zCmd);
if( isInteractive ){
Blob in;
fossil_print("test-command result: %d\n", rc);
while(1){
int n;
char *z;
prompt_user("Enter (g)ood, (b)ad, (s)kip, (a)uto, (h)alt: ", &in);
n = blob_size(&in);
z = blob_str(&in);
if( n<1 ) continue;
if( sqlite3_strnicmp("good", z, n)==0 ){
rc = 0;
break;
}
if( sqlite3_strnicmp("bad", z, n)==0 ){
rc = 1;
break;
}
if( sqlite3_strnicmp("skip", z, n)==0 ){
rc = 125;
break;
}
if( sqlite3_strnicmp("auto", z, n)==0 ){
isInteractive = 0;
break;
}
if( sqlite3_strnicmp("halt", z, n)==0 ){
return;
}
blob_reset(&in);
}
}
if( rc==0 ){
blob_append(&cmd, " bisect good", -1);
}else if( rc==125 ){
blob_append(&cmd, " bisect skip", -1);
}else{
blob_append(&cmd, " bisect bad", -1);
}
fossil_print("%s\n", blob_str(&cmd));
fossil_system(blob_str(&cmd));
blob_reset(&cmd);
}
}
/*
** COMMAND: bisect
**
** Usage: %fossil bisect SUBCOMMAND ...
**
** Run various subcommands useful for searching back through the change
|
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
+
+
+
+
+
+
+
+
+
+
|
** value of a bisect option.
**
** > fossil bisect reset
**
** Reinitialize a bisect session. This cancels prior bisect history
** and allows a bisect session to start over from the beginning.
**
** > fossil bisect run [OPTIONS] COMMAND
**
** Invoke COMMAND repeatedly to run the bisect. The exit code for
** COMMAND should be 0 for "good", 125 for "skip", and any other value
** for "bad". Options:
**
** -i|--interactive Prompt the user for the good/bad/skip decision
** after each step, rather than using the exit
** code from COMMAND
**
** > fossil bisect skip ?VERSION?
**
** Cause VERSION (or the current checkout if VERSION is omitted) to
** be ignored for the purpose of the current bisect. This might
** be done, for example, because VERSION does not compile correctly
** or is otherwise unsuitable to participate in this bisect.
**
|
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
|
+
|
PathNode *pMid;
char *zDisplay = db_lget("bisect-display","chart");
int m = (int)strlen(zDisplay);
bisect_path();
pMid = path_midpoint();
if( pMid==0 ){
fossil_print("bisect complete\n");
db_lset_int("bisect-complete",1);
}else{
int nSpan = path_length_not_hidden();
int nStep = path_search_depth();
g.argv[1] = "update";
g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid);
g.argc = 3;
g.fNoSync = 1;
|
560
561
562
563
564
565
566
567
568
569
570
571
572
573
|
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
|
+
+
|
}else if( strncmp(zDisplay, "status", m)==0 ){
bisect_list(1);
}
}else if( strncmp(zCmd, "log", n)==0 ){
bisect_chart(0);
}else if( strncmp(zCmd, "chart", n)==0 ){
bisect_chart(1);
}else if( strncmp(zCmd, "run", n)==0 ){
bisect_run();
}else if( strncmp(zCmd, "options", n)==0 ){
if( g.argc==3 ){
unsigned int i;
for(i=0; i<count(aBisectOption); i++){
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
db_lget(z, (char*)aBisectOption[i].zDefault));
|
610
611
612
613
614
615
616
617
618
619
|
704
705
706
707
708
709
710
711
712
713
|
-
+
|
|| strncmp(zCmd, "ls", n)==0
|| strncmp(zCmd, "status", n)==0
){
int fAll = find_option("all", "a", 0)!=0;
bisect_list(!fAll);
}else if( !foundCmd ){
usage:
usage("bad|good|log|chart|next|options|reset|skip|status|ui|undo");
usage("bad|good|log|chart|next|options|reset|run|skip|status|ui|undo");
}
}
|