Fossil SCM

The --verily option should imply --disable-undo. The --force option should not imply --disable-undo. Extend and enhance tests.

mistachkin 2015-07-03 20:44 enhancedUndo
Commit a58b4a878ebe1b695af52523f176d3d3d3d58dcb
3 files changed +10 -6 +107 -10 +15 -2
+10 -6
--- src/checkin.c
+++ src/checkin.c
@@ -672,14 +672,15 @@
672672
** therefore, directories that contain only files
673673
** that were removed will be removed as well.
674674
** -f|--force Remove files without prompting.
675675
** -x|--verily WARNING: Remove everything that is not a managed
676676
** file or the repository itself. This option
677
-** implies the --force, --emptydirs, and --dotfiles
678
-** options. Furthermore, it completely disregards
679
-** the keep-glob and ignore-glob settings. However,
680
-** it does honor the --ignore and --keep options.
677
+** implies the --force, --emptydirs, --dotfiles, and
678
+** --disable-undo options. Furthermore, it completely
679
+** disregards the keep-glob and ignore-glob settings.
680
+** However, it does honor the --ignore and --keep
681
+** options.
681682
** --clean <CSG> WARNING: Never prompt to delete any files matching
682683
** this comma separated list of glob patterns. Also,
683684
** deletions of any files matching this pattern list
684685
** cannot be undone.
685686
** --ignore <CSG> Ignore files matching patterns from the
@@ -731,10 +732,11 @@
731732
zCleanFlag = find_option("clean",0,1);
732733
db_must_be_within_tree();
733734
if( find_option("verily","x",0)!=0 ){
734735
verilyFlag = allFileFlag = allDirFlag = 1;
735736
emptyDirsFlag = 1;
737
+ disableUndo = 1;
736738
scanFlags |= SCAN_ALL;
737739
zCleanFlag = 0;
738740
}
739741
if( zIgnoreFlag==0 && !verilyFlag ){
740742
zIgnoreFlag = db_get("ignore-glob", 0);
@@ -774,18 +776,20 @@
774776
fossil_print("KEPT file \"%s\" not removed (due to --keep"
775777
" or \"keep-glob\")\n", zName+nRoot);
776778
}
777779
continue;
778780
}
779
- if( !allFileFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
781
+ if( !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
780782
int undoRc = UNDO_NONE;
781783
if( !disableUndo ){
782784
undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT);
783785
}
784786
if( undoRc!=UNDO_SAVED_OK ){
785787
char cReply;
786
- if( !noPrompt ){
788
+ if( allFileFlag ){
789
+ cReply = 'Y';
790
+ }else if( !noPrompt ){
787791
Blob ans;
788792
char *prompt = mprintf("\nWARNING: Deletion of this file will "
789793
"not be undoable via the 'undo'\n"
790794
" command because %s.\n\n"
791795
"Remove unmanaged file \"%s\" (a=all/y/N)? ",
792796
--- src/checkin.c
+++ src/checkin.c
@@ -672,14 +672,15 @@
672 ** therefore, directories that contain only files
673 ** that were removed will be removed as well.
674 ** -f|--force Remove files without prompting.
675 ** -x|--verily WARNING: Remove everything that is not a managed
676 ** file or the repository itself. This option
677 ** implies the --force, --emptydirs, and --dotfiles
678 ** options. Furthermore, it completely disregards
679 ** the keep-glob and ignore-glob settings. However,
680 ** it does honor the --ignore and --keep options.
 
681 ** --clean <CSG> WARNING: Never prompt to delete any files matching
682 ** this comma separated list of glob patterns. Also,
683 ** deletions of any files matching this pattern list
684 ** cannot be undone.
685 ** --ignore <CSG> Ignore files matching patterns from the
@@ -731,10 +732,11 @@
731 zCleanFlag = find_option("clean",0,1);
732 db_must_be_within_tree();
733 if( find_option("verily","x",0)!=0 ){
734 verilyFlag = allFileFlag = allDirFlag = 1;
735 emptyDirsFlag = 1;
 
736 scanFlags |= SCAN_ALL;
737 zCleanFlag = 0;
738 }
739 if( zIgnoreFlag==0 && !verilyFlag ){
740 zIgnoreFlag = db_get("ignore-glob", 0);
@@ -774,18 +776,20 @@
774 fossil_print("KEPT file \"%s\" not removed (due to --keep"
775 " or \"keep-glob\")\n", zName+nRoot);
776 }
777 continue;
778 }
779 if( !allFileFlag && !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
780 int undoRc = UNDO_NONE;
781 if( !disableUndo ){
782 undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT);
783 }
784 if( undoRc!=UNDO_SAVED_OK ){
785 char cReply;
786 if( !noPrompt ){
 
 
787 Blob ans;
788 char *prompt = mprintf("\nWARNING: Deletion of this file will "
789 "not be undoable via the 'undo'\n"
790 " command because %s.\n\n"
791 "Remove unmanaged file \"%s\" (a=all/y/N)? ",
792
--- src/checkin.c
+++ src/checkin.c
@@ -672,14 +672,15 @@
672 ** therefore, directories that contain only files
673 ** that were removed will be removed as well.
674 ** -f|--force Remove files without prompting.
675 ** -x|--verily WARNING: Remove everything that is not a managed
676 ** file or the repository itself. This option
677 ** implies the --force, --emptydirs, --dotfiles, and
678 ** --disable-undo options. Furthermore, it completely
679 ** disregards the keep-glob and ignore-glob settings.
680 ** However, it does honor the --ignore and --keep
681 ** options.
682 ** --clean <CSG> WARNING: Never prompt to delete any files matching
683 ** this comma separated list of glob patterns. Also,
684 ** deletions of any files matching this pattern list
685 ** cannot be undone.
686 ** --ignore <CSG> Ignore files matching patterns from the
@@ -731,10 +732,11 @@
732 zCleanFlag = find_option("clean",0,1);
733 db_must_be_within_tree();
734 if( find_option("verily","x",0)!=0 ){
735 verilyFlag = allFileFlag = allDirFlag = 1;
736 emptyDirsFlag = 1;
737 disableUndo = 1;
738 scanFlags |= SCAN_ALL;
739 zCleanFlag = 0;
740 }
741 if( zIgnoreFlag==0 && !verilyFlag ){
742 zIgnoreFlag = db_get("ignore-glob", 0);
@@ -774,18 +776,20 @@
776 fossil_print("KEPT file \"%s\" not removed (due to --keep"
777 " or \"keep-glob\")\n", zName+nRoot);
778 }
779 continue;
780 }
781 if( !dryRunFlag && !glob_match(pClean, zName+nRoot) ){
782 int undoRc = UNDO_NONE;
783 if( !disableUndo ){
784 undoRc = undo_maybe_save(zName+nRoot, UNDO_SIZE_LIMIT);
785 }
786 if( undoRc!=UNDO_SAVED_OK ){
787 char cReply;
788 if( allFileFlag ){
789 cReply = 'Y';
790 }else if( !noPrompt ){
791 Blob ans;
792 char *prompt = mprintf("\nWARNING: Deletion of this file will "
793 "not be undoable via the 'undo'\n"
794 " command because %s.\n\n"
795 "Remove unmanaged file \"%s\" (a=all/y/N)? ",
796
+107 -10
--- test/clean.test
+++ test/clean.test
@@ -44,11 +44,12 @@
4444
fossil extra
4545
test clean-3 {[normalize_result] eq {f2}}
4646
4747
###############################################################################
4848
49
-fossil clean; # undo enabled, file < 10MiB
49
+# clean w/undo enabled, should not prompt, 1 file < 10MiB
50
+fossil clean
5051
test clean-4 {[normalize_result] eq \
5152
{"fossil undo" is available to undo changes to the working checkout.}}
5253
5354
###############################################################################
5455
@@ -57,36 +58,132 @@
5758
5859
###############################################################################
5960
6061
fossil undo
6162
test clean-6 {[normalize_result] eq {NEW f2}}
62
-test clean-7 {[normalize_result] eq {NEW f2}}
63
+test clean-7 {[read_file f2] eq "f2 line"}
6364
6465
###############################################################################
6566
6667
fossil extra
6768
test clean-8 {[normalize_result] eq {f2}}
6869
6970
###############################################################################
7071
7172
write_file f3 [string repeat ABCDEFGHIJK 1048576]
72
-fossil clean --no-prompt; # undo enabled, one file < 10MiB, one file > 10MiB
73
-test clean-9 {[normalize_result] eq \
73
+fossil extra
74
+test clean-9 {[normalize_result] eq {f2
75
+f3}}
76
+
77
+###############################################################################
78
+
79
+# clean w/undo enabled, no prompt, 1 file < 10MiB, 1 file > 10MiB
80
+fossil clean --no-prompt
81
+test clean-10 {[normalize_result] eq \
82
+{"fossil undo" is available to undo changes to the working checkout.}}
83
+
84
+###############################################################################
85
+
86
+fossil extra
87
+test clean-11 {[normalize_result] eq {f3}}
88
+
89
+###############################################################################
90
+
91
+fossil undo
92
+test clean-12 {[normalize_result] eq {NEW f2}}
93
+test clean-13 {[read_file f2] eq "f2 line"}
94
+test clean-14 {[read_file f3] eq [string repeat ABCDEFGHIJK 1048576]}
95
+
96
+###############################################################################
97
+
98
+fossil extra
99
+test clean-15 {[normalize_result] eq {f2
100
+f3}}
101
+
102
+###############################################################################
103
+
104
+# clean w/undo enabled, force, 1 file < 10MiB, 1 file > 10MiB
105
+fossil clean --force
106
+test clean-16 {[normalize_result] eq \
74107
{"fossil undo" is available to undo changes to the working checkout.}}
75108
76109
###############################################################################
77110
78111
fossil extra
79
-test clean-10 {[normalize_result] eq {f3}}
112
+test clean-17 {[normalize_result] eq {}}
113
+
114
+###############################################################################
115
+
116
+fossil undo
117
+test clean-18 {[normalize_result] eq {NEW f2}}
118
+test clean-19 {[read_file f2] eq "f2 line"}
119
+
120
+###############################################################################
121
+
122
+write_file f4 [string repeat KJIHGFEDCBA 1048576]
123
+fossil extra
124
+test clean-20 {[normalize_result] eq {f2
125
+f4}}
126
+
127
+###############################################################################
128
+
129
+# clean w/undo disabled, no prompt, 1 file < 10MiB, 1 file > 10MiB
130
+fossil clean --disable-undo --no-prompt
131
+test clean-21 {[normalize_result] eq {}}
132
+
133
+###############################################################################
134
+
135
+fossil extra
136
+test clean-22 {[normalize_result] eq {f2
137
+f4}}
138
+
139
+###############################################################################
140
+
141
+fossil undo
142
+test clean-23 {[normalize_result] eq {nothing to undo}}
143
+
144
+###############################################################################
145
+
146
+# clean w/undo disabled, force, 1 file < 10MiB, 1 file > 10MiB
147
+fossil clean --disable-undo --force
148
+test clean-24 {[normalize_result] eq {}}
149
+
150
+###############################################################################
151
+
152
+fossil extra
153
+test clean-25 {[normalize_result] eq {}}
154
+
155
+###############################################################################
156
+
157
+fossil undo
158
+test clean-26 {[normalize_result] eq {nothing to undo}}
159
+
160
+###############################################################################
161
+
162
+write_file f5 "f5 line"
163
+fossil extra
164
+test clean-27 {[normalize_result] eq {f5}}
165
+
166
+###############################################################################
167
+
168
+# clean w/undo disabled, should prompt, 1 file < 10MiB
169
+fossil_maybe_answer Y clean --disable-undo
170
+test clean-28 {[normalize_result] eq \
171
+{WARNING: Deletion of this file will not be undoable via the 'undo'
172
+ command because undo is disabled for this operation.
173
+
174
+Remove unmanaged file "f5" (a=all/y/N)?}}
175
+
176
+###############################################################################
177
+
178
+fossil extra
179
+test clean-29 {[normalize_result] eq {}}
80180
81181
###############################################################################
82182
83183
fossil undo
84
-test clean-11 {[normalize_result] eq {NEW f2}}
85
-test clean-12 {[read_file f2] eq "f2 line"}
86
-test clean-13 {[read_file f3] eq [string repeat ABCDEFGHIJK 1048576]}
184
+test clean-30 {[normalize_result] eq {nothing to undo}}
87185
88186
###############################################################################
89187
90188
fossil extra
91
-test clean-14 {[normalize_result] eq {f2
92
-f3}}
189
+test clean-31 {[normalize_result] eq {}}
93190
--- test/clean.test
+++ test/clean.test
@@ -44,11 +44,12 @@
44 fossil extra
45 test clean-3 {[normalize_result] eq {f2}}
46
47 ###############################################################################
48
49 fossil clean; # undo enabled, file < 10MiB
 
50 test clean-4 {[normalize_result] eq \
51 {"fossil undo" is available to undo changes to the working checkout.}}
52
53 ###############################################################################
54
@@ -57,36 +58,132 @@
57
58 ###############################################################################
59
60 fossil undo
61 test clean-6 {[normalize_result] eq {NEW f2}}
62 test clean-7 {[normalize_result] eq {NEW f2}}
63
64 ###############################################################################
65
66 fossil extra
67 test clean-8 {[normalize_result] eq {f2}}
68
69 ###############################################################################
70
71 write_file f3 [string repeat ABCDEFGHIJK 1048576]
72 fossil clean --no-prompt; # undo enabled, one file < 10MiB, one file > 10MiB
73 test clean-9 {[normalize_result] eq \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74 {"fossil undo" is available to undo changes to the working checkout.}}
75
76 ###############################################################################
77
78 fossil extra
79 test clean-10 {[normalize_result] eq {f3}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
81 ###############################################################################
82
83 fossil undo
84 test clean-11 {[normalize_result] eq {NEW f2}}
85 test clean-12 {[read_file f2] eq "f2 line"}
86 test clean-13 {[read_file f3] eq [string repeat ABCDEFGHIJK 1048576]}
87
88 ###############################################################################
89
90 fossil extra
91 test clean-14 {[normalize_result] eq {f2
92 f3}}
93
--- test/clean.test
+++ test/clean.test
@@ -44,11 +44,12 @@
44 fossil extra
45 test clean-3 {[normalize_result] eq {f2}}
46
47 ###############################################################################
48
49 # clean w/undo enabled, should not prompt, 1 file < 10MiB
50 fossil clean
51 test clean-4 {[normalize_result] eq \
52 {"fossil undo" is available to undo changes to the working checkout.}}
53
54 ###############################################################################
55
@@ -57,36 +58,132 @@
58
59 ###############################################################################
60
61 fossil undo
62 test clean-6 {[normalize_result] eq {NEW f2}}
63 test clean-7 {[read_file f2] eq "f2 line"}
64
65 ###############################################################################
66
67 fossil extra
68 test clean-8 {[normalize_result] eq {f2}}
69
70 ###############################################################################
71
72 write_file f3 [string repeat ABCDEFGHIJK 1048576]
73 fossil extra
74 test clean-9 {[normalize_result] eq {f2
75 f3}}
76
77 ###############################################################################
78
79 # clean w/undo enabled, no prompt, 1 file < 10MiB, 1 file > 10MiB
80 fossil clean --no-prompt
81 test clean-10 {[normalize_result] eq \
82 {"fossil undo" is available to undo changes to the working checkout.}}
83
84 ###############################################################################
85
86 fossil extra
87 test clean-11 {[normalize_result] eq {f3}}
88
89 ###############################################################################
90
91 fossil undo
92 test clean-12 {[normalize_result] eq {NEW f2}}
93 test clean-13 {[read_file f2] eq "f2 line"}
94 test clean-14 {[read_file f3] eq [string repeat ABCDEFGHIJK 1048576]}
95
96 ###############################################################################
97
98 fossil extra
99 test clean-15 {[normalize_result] eq {f2
100 f3}}
101
102 ###############################################################################
103
104 # clean w/undo enabled, force, 1 file < 10MiB, 1 file > 10MiB
105 fossil clean --force
106 test clean-16 {[normalize_result] eq \
107 {"fossil undo" is available to undo changes to the working checkout.}}
108
109 ###############################################################################
110
111 fossil extra
112 test clean-17 {[normalize_result] eq {}}
113
114 ###############################################################################
115
116 fossil undo
117 test clean-18 {[normalize_result] eq {NEW f2}}
118 test clean-19 {[read_file f2] eq "f2 line"}
119
120 ###############################################################################
121
122 write_file f4 [string repeat KJIHGFEDCBA 1048576]
123 fossil extra
124 test clean-20 {[normalize_result] eq {f2
125 f4}}
126
127 ###############################################################################
128
129 # clean w/undo disabled, no prompt, 1 file < 10MiB, 1 file > 10MiB
130 fossil clean --disable-undo --no-prompt
131 test clean-21 {[normalize_result] eq {}}
132
133 ###############################################################################
134
135 fossil extra
136 test clean-22 {[normalize_result] eq {f2
137 f4}}
138
139 ###############################################################################
140
141 fossil undo
142 test clean-23 {[normalize_result] eq {nothing to undo}}
143
144 ###############################################################################
145
146 # clean w/undo disabled, force, 1 file < 10MiB, 1 file > 10MiB
147 fossil clean --disable-undo --force
148 test clean-24 {[normalize_result] eq {}}
149
150 ###############################################################################
151
152 fossil extra
153 test clean-25 {[normalize_result] eq {}}
154
155 ###############################################################################
156
157 fossil undo
158 test clean-26 {[normalize_result] eq {nothing to undo}}
159
160 ###############################################################################
161
162 write_file f5 "f5 line"
163 fossil extra
164 test clean-27 {[normalize_result] eq {f5}}
165
166 ###############################################################################
167
168 # clean w/undo disabled, should prompt, 1 file < 10MiB
169 fossil_maybe_answer Y clean --disable-undo
170 test clean-28 {[normalize_result] eq \
171 {WARNING: Deletion of this file will not be undoable via the 'undo'
172 command because undo is disabled for this operation.
173
174 Remove unmanaged file "f5" (a=all/y/N)?}}
175
176 ###############################################################################
177
178 fossil extra
179 test clean-29 {[normalize_result] eq {}}
180
181 ###############################################################################
182
183 fossil undo
184 test clean-30 {[normalize_result] eq {nothing to undo}}
 
 
185
186 ###############################################################################
187
188 fossil extra
189 test clean-31 {[normalize_result] eq {}}
 
190
+15 -2
--- test/tester.tcl
+++ test/tester.tcl
@@ -87,22 +87,35 @@
8787
puts $out $msg
8888
close $out
8989
}
9090
}
9191
92
-# Run the fossil program
92
+# Run the fossil program.
9393
#
9494
proc fossil {args} {
95
+ return [uplevel 1 fossil_maybe_answer [list ""] $args]
96
+}
97
+
98
+# Run the fossil program and possibly answer the first prompt.
99
+#
100
+proc fossil_maybe_answer {answer args} {
95101
global fossilexe
96102
set cmd $fossilexe
97103
foreach a $args {
98104
lappend cmd $a
99105
}
100106
protOut $cmd
101107
102108
flush stdout
103
- set rc [catch {eval exec $cmd} result]
109
+ if {[string length $answer] > 0} {
110
+ set prompt_file [file join $::tempPath fossil_prompt_answer]
111
+ write_file $prompt_file $answer\n
112
+ set rc [catch {eval exec $cmd <$prompt_file} result]
113
+ file delete $prompt_file
114
+ } else {
115
+ set rc [catch {eval exec $cmd} result]
116
+ }
104117
global RESULT CODE
105118
set CODE $rc
106119
if {$rc} {
107120
protOut "ERROR: $result"
108121
} elseif {$::VERBOSE} {
109122
--- test/tester.tcl
+++ test/tester.tcl
@@ -87,22 +87,35 @@
87 puts $out $msg
88 close $out
89 }
90 }
91
92 # Run the fossil program
93 #
94 proc fossil {args} {
 
 
 
 
 
 
95 global fossilexe
96 set cmd $fossilexe
97 foreach a $args {
98 lappend cmd $a
99 }
100 protOut $cmd
101
102 flush stdout
103 set rc [catch {eval exec $cmd} result]
 
 
 
 
 
 
 
104 global RESULT CODE
105 set CODE $rc
106 if {$rc} {
107 protOut "ERROR: $result"
108 } elseif {$::VERBOSE} {
109
--- test/tester.tcl
+++ test/tester.tcl
@@ -87,22 +87,35 @@
87 puts $out $msg
88 close $out
89 }
90 }
91
92 # Run the fossil program.
93 #
94 proc fossil {args} {
95 return [uplevel 1 fossil_maybe_answer [list ""] $args]
96 }
97
98 # Run the fossil program and possibly answer the first prompt.
99 #
100 proc fossil_maybe_answer {answer args} {
101 global fossilexe
102 set cmd $fossilexe
103 foreach a $args {
104 lappend cmd $a
105 }
106 protOut $cmd
107
108 flush stdout
109 if {[string length $answer] > 0} {
110 set prompt_file [file join $::tempPath fossil_prompt_answer]
111 write_file $prompt_file $answer\n
112 set rc [catch {eval exec $cmd <$prompt_file} result]
113 file delete $prompt_file
114 } else {
115 set rc [catch {eval exec $cmd} result]
116 }
117 global RESULT CODE
118 set CODE $rc
119 if {$rc} {
120 protOut "ERROR: $result"
121 } elseif {$::VERBOSE} {
122

Keyboard Shortcuts

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