Fossil SCM

If "fossil clean" is undoable, there is no need to prompt for each file first.

jan.nijtmans 2015-06-26 21:05 undo-clean
Commit 466ccf96c6a528a76c69379a833a20597c403c69
1 file changed +7 -19
+7 -19
--- src/checkin.c
+++ src/checkin.c
@@ -668,11 +668,11 @@
668668
** or another applicable setting or command line
669669
** argument. Matching files, if any, are removed
670670
** prior to checking for any empty directories;
671671
** therefore, directories that contain only files
672672
** that were removed will be removed as well.
673
-** -f|--force Remove files without prompting.
673
+** -f|--force Remove directories without prompting.
674674
** -x|--verily Remove everything that is not a managed file or
675675
** the repository itself. Implies -f --emptydirs
676676
** --dotfiles. Disregard keep-glob and ignore-glob,
677677
** except that files matching ignore-glob are not
678678
** never undo-able.
@@ -688,11 +688,11 @@
688688
** -v|--verbose Show all files as they are removed.
689689
**
690690
** See also: addremove, extras, status
691691
*/
692692
void clean_cmd(void){
693
- int allFileFlag, allDirFlag, dryRunFlag, verboseFlag, forceFlag;
693
+ int allDirFlag, dryRunFlag, verboseFlag;
694694
int emptyDirsFlag, dirsOnlyFlag;
695695
unsigned scanFlags = 0;
696696
int verilyFlag = 0;
697697
const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
698698
Glob *pIgnore, *pKeep, *pClean;
@@ -703,11 +703,11 @@
703703
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
704704
}
705705
if( !dryRunFlag ){
706706
dryRunFlag = find_option("whatif",0,0)!=0;
707707
}
708
- allFileFlag = allDirFlag = forceFlag = find_option("force","f",0)!=0;
708
+ allDirFlag = find_option("force","f",0)!=0;
709709
if( !dryRunFlag ){
710710
undo_capture_command_line();
711711
}
712712
dirsOnlyFlag = find_option("dirsonly",0,0)!=0;
713713
emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag;
@@ -718,11 +718,11 @@
718718
verboseFlag = find_option("verbose","v",0)!=0;
719719
zKeepFlag = find_option("keep",0,1);
720720
zCleanFlag = find_option("clean",0,1);
721721
db_must_be_within_tree();
722722
if( find_option("verily","x",0)!=0 ){
723
- verilyFlag = allFileFlag = allDirFlag = 1;
723
+ verilyFlag = allDirFlag = 1;
724724
emptyDirsFlag = 1;
725725
scanFlags |= SCAN_ALL;
726726
zCleanFlag = 0;
727727
}
728728
if( zIgnoreFlag==0 ){
@@ -739,11 +739,11 @@
739739
pIgnore = glob_create(zIgnoreFlag);
740740
pKeep = glob_create(zKeepFlag);
741741
pClean = glob_create(zCleanFlag);
742742
nRoot = (int)strlen(g.zLocalRoot);
743743
g.allowSymlinks = 1; /* Find symlinks too */
744
- if( !forceFlag && !dryRunFlag ) undo_begin();
744
+ if( !dryRunFlag ) undo_begin();
745745
if( !dirsOnlyFlag ){
746746
Stmt q;
747747
Blob repo;
748748
char cReply;
749749
Blob ans;
@@ -767,24 +767,12 @@
767767
fossil_print("KEPT file \"%s\" not removed (due to --keep"
768768
" or \"keep-glob\")\n", zName+nRoot);
769769
}
770770
continue;
771771
}
772
- if( !allFileFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
773
- prompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ",
774
- zName+nRoot);
775
- prompt_user(prompt, &ans);
776
- cReply = blob_str(&ans)[0];
777
- if( cReply=='a' || cReply=='A' ){
778
- allFileFlag = 1;
779
- }else if( cReply!='y' && cReply!='Y' ){
780
- blob_reset(&ans);
781
- continue;
782
- }
783
- blob_reset(&ans);
784
- }
785
- if( !dryRunFlag && !(verilyFlag && glob_match(pIgnore, zName+nRoot))
772
+ if( !dryRunFlag && !glob_match(pClean, zName+nRoot)
773
+ && !(verilyFlag && glob_match(pIgnore, zName+nRoot))
786774
&& undo_save(zName+nRoot, 10*1024*1024) ){
787775
prompt = mprintf("file \"%s\" too big. Deletion will not be "
788776
"undo-able. Continue (y/N)? ", zName+nRoot);
789777
blob_zero(&ans);
790778
prompt_user(prompt, &ans);
791779
--- src/checkin.c
+++ src/checkin.c
@@ -668,11 +668,11 @@
668 ** or another applicable setting or command line
669 ** argument. Matching files, if any, are removed
670 ** prior to checking for any empty directories;
671 ** therefore, directories that contain only files
672 ** that were removed will be removed as well.
673 ** -f|--force Remove files without prompting.
674 ** -x|--verily Remove everything that is not a managed file or
675 ** the repository itself. Implies -f --emptydirs
676 ** --dotfiles. Disregard keep-glob and ignore-glob,
677 ** except that files matching ignore-glob are not
678 ** never undo-able.
@@ -688,11 +688,11 @@
688 ** -v|--verbose Show all files as they are removed.
689 **
690 ** See also: addremove, extras, status
691 */
692 void clean_cmd(void){
693 int allFileFlag, allDirFlag, dryRunFlag, verboseFlag, forceFlag;
694 int emptyDirsFlag, dirsOnlyFlag;
695 unsigned scanFlags = 0;
696 int verilyFlag = 0;
697 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
698 Glob *pIgnore, *pKeep, *pClean;
@@ -703,11 +703,11 @@
703 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
704 }
705 if( !dryRunFlag ){
706 dryRunFlag = find_option("whatif",0,0)!=0;
707 }
708 allFileFlag = allDirFlag = forceFlag = find_option("force","f",0)!=0;
709 if( !dryRunFlag ){
710 undo_capture_command_line();
711 }
712 dirsOnlyFlag = find_option("dirsonly",0,0)!=0;
713 emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag;
@@ -718,11 +718,11 @@
718 verboseFlag = find_option("verbose","v",0)!=0;
719 zKeepFlag = find_option("keep",0,1);
720 zCleanFlag = find_option("clean",0,1);
721 db_must_be_within_tree();
722 if( find_option("verily","x",0)!=0 ){
723 verilyFlag = allFileFlag = allDirFlag = 1;
724 emptyDirsFlag = 1;
725 scanFlags |= SCAN_ALL;
726 zCleanFlag = 0;
727 }
728 if( zIgnoreFlag==0 ){
@@ -739,11 +739,11 @@
739 pIgnore = glob_create(zIgnoreFlag);
740 pKeep = glob_create(zKeepFlag);
741 pClean = glob_create(zCleanFlag);
742 nRoot = (int)strlen(g.zLocalRoot);
743 g.allowSymlinks = 1; /* Find symlinks too */
744 if( !forceFlag && !dryRunFlag ) undo_begin();
745 if( !dirsOnlyFlag ){
746 Stmt q;
747 Blob repo;
748 char cReply;
749 Blob ans;
@@ -767,24 +767,12 @@
767 fossil_print("KEPT file \"%s\" not removed (due to --keep"
768 " or \"keep-glob\")\n", zName+nRoot);
769 }
770 continue;
771 }
772 if( !allFileFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
773 prompt = mprintf("Remove unmanaged file \"%s\" (a=all/y/N)? ",
774 zName+nRoot);
775 prompt_user(prompt, &ans);
776 cReply = blob_str(&ans)[0];
777 if( cReply=='a' || cReply=='A' ){
778 allFileFlag = 1;
779 }else if( cReply!='y' && cReply!='Y' ){
780 blob_reset(&ans);
781 continue;
782 }
783 blob_reset(&ans);
784 }
785 if( !dryRunFlag && !(verilyFlag && glob_match(pIgnore, zName+nRoot))
786 && undo_save(zName+nRoot, 10*1024*1024) ){
787 prompt = mprintf("file \"%s\" too big. Deletion will not be "
788 "undo-able. Continue (y/N)? ", zName+nRoot);
789 blob_zero(&ans);
790 prompt_user(prompt, &ans);
791
--- src/checkin.c
+++ src/checkin.c
@@ -668,11 +668,11 @@
668 ** or another applicable setting or command line
669 ** argument. Matching files, if any, are removed
670 ** prior to checking for any empty directories;
671 ** therefore, directories that contain only files
672 ** that were removed will be removed as well.
673 ** -f|--force Remove directories without prompting.
674 ** -x|--verily Remove everything that is not a managed file or
675 ** the repository itself. Implies -f --emptydirs
676 ** --dotfiles. Disregard keep-glob and ignore-glob,
677 ** except that files matching ignore-glob are not
678 ** never undo-able.
@@ -688,11 +688,11 @@
688 ** -v|--verbose Show all files as they are removed.
689 **
690 ** See also: addremove, extras, status
691 */
692 void clean_cmd(void){
693 int allDirFlag, dryRunFlag, verboseFlag;
694 int emptyDirsFlag, dirsOnlyFlag;
695 unsigned scanFlags = 0;
696 int verilyFlag = 0;
697 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
698 Glob *pIgnore, *pKeep, *pClean;
@@ -703,11 +703,11 @@
703 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
704 }
705 if( !dryRunFlag ){
706 dryRunFlag = find_option("whatif",0,0)!=0;
707 }
708 allDirFlag = find_option("force","f",0)!=0;
709 if( !dryRunFlag ){
710 undo_capture_command_line();
711 }
712 dirsOnlyFlag = find_option("dirsonly",0,0)!=0;
713 emptyDirsFlag = find_option("emptydirs","d",0)!=0 || dirsOnlyFlag;
@@ -718,11 +718,11 @@
718 verboseFlag = find_option("verbose","v",0)!=0;
719 zKeepFlag = find_option("keep",0,1);
720 zCleanFlag = find_option("clean",0,1);
721 db_must_be_within_tree();
722 if( find_option("verily","x",0)!=0 ){
723 verilyFlag = allDirFlag = 1;
724 emptyDirsFlag = 1;
725 scanFlags |= SCAN_ALL;
726 zCleanFlag = 0;
727 }
728 if( zIgnoreFlag==0 ){
@@ -739,11 +739,11 @@
739 pIgnore = glob_create(zIgnoreFlag);
740 pKeep = glob_create(zKeepFlag);
741 pClean = glob_create(zCleanFlag);
742 nRoot = (int)strlen(g.zLocalRoot);
743 g.allowSymlinks = 1; /* Find symlinks too */
744 if( !dryRunFlag ) undo_begin();
745 if( !dirsOnlyFlag ){
746 Stmt q;
747 Blob repo;
748 char cReply;
749 Blob ans;
@@ -767,24 +767,12 @@
767 fossil_print("KEPT file \"%s\" not removed (due to --keep"
768 " or \"keep-glob\")\n", zName+nRoot);
769 }
770 continue;
771 }
772 if( !dryRunFlag && !glob_match(pClean, zName+nRoot)
773 && !(verilyFlag && glob_match(pIgnore, zName+nRoot))
 
 
 
 
 
 
 
 
 
 
 
 
774 && undo_save(zName+nRoot, 10*1024*1024) ){
775 prompt = mprintf("file \"%s\" too big. Deletion will not be "
776 "undo-able. Continue (y/N)? ", zName+nRoot);
777 blob_zero(&ans);
778 prompt_user(prompt, &ans);
779

Keyboard Shortcuts

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