Fossil SCM

Remove excess verbage from the output of "fossil clean" unless the --verbose or -v command-line option is used. Issue an error if an unrecognized command-line argument is seen, to prevent mistakes like using --dryrun instead of --dry-run.

drh 2013-05-17 12:04 trunk
Commit 273ec22f25699c150fbdde995780b504cb77d4a8
+8 -2
--- src/checkin.c
+++ src/checkin.c
@@ -406,10 +406,11 @@
406406
** comma separated list of glob patterns.
407407
** --keep <CSG> keep files matching this comma separated
408408
** list of glob patterns.
409409
** -n|--dry-run If given, display instead of run actions
410410
** --temp Remove only Fossil-generated temporary files
411
+** -v|--verbose Show all files as they are removed
411412
**
412413
** See also: addremove, extra, status
413414
*/
414415
void clean_cmd(void){
415416
int allFlag;
@@ -418,15 +419,17 @@
418419
Blob path, repo;
419420
Stmt q;
420421
int n;
421422
Glob *pIgnore, *pKeep, *pClean;
422423
int dryRunFlag = 0;
424
+ int verboseFlag;
423425
424426
allFlag = find_option("force","f",0)!=0;
425427
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
426428
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
427429
zIgnoreFlag = find_option("ignore",0,1);
430
+ verboseFlag = find_option("verbose","v",0)!=0;
428431
dryRunFlag = find_option("dry-run","n",0)!=0;
429432
if( !dryRunFlag ){
430433
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
431434
}
432435
zKeepFlag = find_option("keep",0,1);
@@ -440,10 +443,11 @@
440443
zKeepFlag = db_get("keep-glob", 0);
441444
}
442445
if( zCleanFlag==0 ){
443446
zCleanFlag = db_get("clean-glob", 0);
444447
}
448
+ verify_all_options();
445449
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
446450
filename_collation());
447451
n = strlen(g.zLocalRoot);
448452
blob_init(&path, g.zLocalRoot, n-1);
449453
pIgnore = glob_create(zIgnoreFlag);
@@ -462,11 +466,11 @@
462466
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
463467
}
464468
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
465469
while( db_step(&q)==SQLITE_ROW ){
466470
const char *zName = db_column_text(&q, 0);
467
- if( !allFlag && !glob_match(pClean, zName+n) ){
471
+ if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+n) ){
468472
Blob ans;
469473
char cReply;
470474
char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
471475
zName+n);
472476
blob_zero(&ans);
@@ -476,11 +480,13 @@
476480
allFlag = 1;
477481
}else if( cReply!='y' && cReply!='Y' ){
478482
continue;
479483
}
480484
}
481
- fossil_print("removed unmanaged file \"%s\"\n", zName+n);
485
+ if( dryRunFlag || verboseFlag ){
486
+ fossil_print("removed unmanaged file: %s\n", zName+n);
487
+ }
482488
if( !dryRunFlag ){
483489
file_delete(zName);
484490
}
485491
}
486492
glob_free(pClean);
487493
--- src/checkin.c
+++ src/checkin.c
@@ -406,10 +406,11 @@
406 ** comma separated list of glob patterns.
407 ** --keep <CSG> keep files matching this comma separated
408 ** list of glob patterns.
409 ** -n|--dry-run If given, display instead of run actions
410 ** --temp Remove only Fossil-generated temporary files
 
411 **
412 ** See also: addremove, extra, status
413 */
414 void clean_cmd(void){
415 int allFlag;
@@ -418,15 +419,17 @@
418 Blob path, repo;
419 Stmt q;
420 int n;
421 Glob *pIgnore, *pKeep, *pClean;
422 int dryRunFlag = 0;
 
423
424 allFlag = find_option("force","f",0)!=0;
425 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
426 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
427 zIgnoreFlag = find_option("ignore",0,1);
 
428 dryRunFlag = find_option("dry-run","n",0)!=0;
429 if( !dryRunFlag ){
430 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
431 }
432 zKeepFlag = find_option("keep",0,1);
@@ -440,10 +443,11 @@
440 zKeepFlag = db_get("keep-glob", 0);
441 }
442 if( zCleanFlag==0 ){
443 zCleanFlag = db_get("clean-glob", 0);
444 }
 
445 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
446 filename_collation());
447 n = strlen(g.zLocalRoot);
448 blob_init(&path, g.zLocalRoot, n-1);
449 pIgnore = glob_create(zIgnoreFlag);
@@ -462,11 +466,11 @@
462 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
463 }
464 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
465 while( db_step(&q)==SQLITE_ROW ){
466 const char *zName = db_column_text(&q, 0);
467 if( !allFlag && !glob_match(pClean, zName+n) ){
468 Blob ans;
469 char cReply;
470 char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
471 zName+n);
472 blob_zero(&ans);
@@ -476,11 +480,13 @@
476 allFlag = 1;
477 }else if( cReply!='y' && cReply!='Y' ){
478 continue;
479 }
480 }
481 fossil_print("removed unmanaged file \"%s\"\n", zName+n);
 
 
482 if( !dryRunFlag ){
483 file_delete(zName);
484 }
485 }
486 glob_free(pClean);
487
--- src/checkin.c
+++ src/checkin.c
@@ -406,10 +406,11 @@
406 ** comma separated list of glob patterns.
407 ** --keep <CSG> keep files matching this comma separated
408 ** list of glob patterns.
409 ** -n|--dry-run If given, display instead of run actions
410 ** --temp Remove only Fossil-generated temporary files
411 ** -v|--verbose Show all files as they are removed
412 **
413 ** See also: addremove, extra, status
414 */
415 void clean_cmd(void){
416 int allFlag;
@@ -418,15 +419,17 @@
419 Blob path, repo;
420 Stmt q;
421 int n;
422 Glob *pIgnore, *pKeep, *pClean;
423 int dryRunFlag = 0;
424 int verboseFlag;
425
426 allFlag = find_option("force","f",0)!=0;
427 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
428 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
429 zIgnoreFlag = find_option("ignore",0,1);
430 verboseFlag = find_option("verbose","v",0)!=0;
431 dryRunFlag = find_option("dry-run","n",0)!=0;
432 if( !dryRunFlag ){
433 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
434 }
435 zKeepFlag = find_option("keep",0,1);
@@ -440,10 +443,11 @@
443 zKeepFlag = db_get("keep-glob", 0);
444 }
445 if( zCleanFlag==0 ){
446 zCleanFlag = db_get("clean-glob", 0);
447 }
448 verify_all_options();
449 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
450 filename_collation());
451 n = strlen(g.zLocalRoot);
452 blob_init(&path, g.zLocalRoot, n-1);
453 pIgnore = glob_create(zIgnoreFlag);
@@ -462,11 +466,11 @@
466 db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
467 }
468 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
469 while( db_step(&q)==SQLITE_ROW ){
470 const char *zName = db_column_text(&q, 0);
471 if( !allFlag && !dryRunFlag && !glob_match(pClean, zName+n) ){
472 Blob ans;
473 char cReply;
474 char *prompt = mprintf("remove unmanaged file \"%s\" (a=all/y/N)? ",
475 zName+n);
476 blob_zero(&ans);
@@ -476,11 +480,13 @@
480 allFlag = 1;
481 }else if( cReply!='y' && cReply!='Y' ){
482 continue;
483 }
484 }
485 if( dryRunFlag || verboseFlag ){
486 fossil_print("removed unmanaged file: %s\n", zName+n);
487 }
488 if( !dryRunFlag ){
489 file_delete(zName);
490 }
491 }
492 glob_free(pClean);
493
--- src/printf.c
+++ src/printf.c
@@ -864,10 +864,18 @@
864864
** of a line, if it is not there already.
865865
*/
866866
void fossil_force_newline(void){
867867
if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0);
868868
}
869
+
870
+/*
871
+** Indicate that the cursor has moved to the start of a line by means
872
+** other than writing to standard output.
873
+*/
874
+void fossil_new_line_started(void){
875
+ stdoutAtBOL = 1;
876
+}
869877
870878
/*
871879
** Write output for user consumption. If g.cgiOutput is enabled, then
872880
** send the output as part of the CGI reply. If g.cgiOutput is false,
873881
** then write on standard output.
874882
--- src/printf.c
+++ src/printf.c
@@ -864,10 +864,18 @@
864 ** of a line, if it is not there already.
865 */
866 void fossil_force_newline(void){
867 if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0);
868 }
 
 
 
 
 
 
 
 
869
870 /*
871 ** Write output for user consumption. If g.cgiOutput is enabled, then
872 ** send the output as part of the CGI reply. If g.cgiOutput is false,
873 ** then write on standard output.
874
--- src/printf.c
+++ src/printf.c
@@ -864,10 +864,18 @@
864 ** of a line, if it is not there already.
865 */
866 void fossil_force_newline(void){
867 if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0);
868 }
869
870 /*
871 ** Indicate that the cursor has moved to the start of a line by means
872 ** other than writing to standard output.
873 */
874 void fossil_new_line_started(void){
875 stdoutAtBOL = 1;
876 }
877
878 /*
879 ** Write output for user consumption. If g.cgiOutput is enabled, then
880 ** send the output as part of the CGI reply. If g.cgiOutput is false,
881 ** then write on standard output.
882
+2
--- src/user.c
+++ src/user.c
@@ -141,10 +141,12 @@
141141
fossil_force_newline();
142142
fossil_print("%s", zPrompt);
143143
fflush(stdout);
144144
z = fgets(zLine, sizeof(zLine), stdin);
145145
if( z ){
146
+ int n = (int)strlen(z);
147
+ if( n>0 && z[n-1]=='\n' ) fossil_new_line_started();
146148
strip_string(pIn, z);
147149
}
148150
}
149151
150152
151153
--- src/user.c
+++ src/user.c
@@ -141,10 +141,12 @@
141 fossil_force_newline();
142 fossil_print("%s", zPrompt);
143 fflush(stdout);
144 z = fgets(zLine, sizeof(zLine), stdin);
145 if( z ){
 
 
146 strip_string(pIn, z);
147 }
148 }
149
150
151
--- src/user.c
+++ src/user.c
@@ -141,10 +141,12 @@
141 fossil_force_newline();
142 fossil_print("%s", zPrompt);
143 fflush(stdout);
144 z = fgets(zLine, sizeof(zLine), stdin);
145 if( z ){
146 int n = (int)strlen(z);
147 if( n>0 && z[n-1]=='\n' ) fossil_new_line_started();
148 strip_string(pIn, z);
149 }
150 }
151
152
153

Keyboard Shortcuts

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