##// END OF EJS Templates
tests: make removeemptydirs more portable...
marmoute -
r48794:1941064d stable
parent child Browse files
Show More
@@ -1,284 +1,300
1 Tests for experimental.removeemptydirs
1 Tests for experimental.removeemptydirs
2
2
3 $ cat >> pwd.py << EOF
4 > import os
5 > try:
6 > print(os.getcwd())
7 > except OSError:
8 > print("<directory is no longer accessible>")
9 > EOF
10
3 $ NO_RM=--config=experimental.removeemptydirs=0
11 $ NO_RM=--config=experimental.removeemptydirs=0
4 $ DO_RM=--config=experimental.removeemptydirs=1
12 $ DO_RM=--config=experimental.removeemptydirs=1
5 $ isdir() { if [ -d $1 ]; then echo yes; else echo no; fi }
13 $ isdir() { if [ -d $1 ]; then echo yes; else echo no; fi }
6 $ isfile() { if [ -f $1 ]; then echo yes; else echo no; fi }
14 $ isfile() { if [ -f $1 ]; then echo yes; else echo no; fi }
7
15
8 `hg rm` of the last file in a directory:
16 `hg rm` of the last file in a directory:
9 $ hg init hgrm
17 $ hg init hgrm
10 $ cd hgrm
18 $ cd hgrm
11 $ mkdir somedir
19 $ mkdir somedir
12 $ echo hi > somedir/foo
20 $ echo hi > somedir/foo
13 $ hg ci -qAm foo
21 $ hg ci -qAm foo
14 $ isdir somedir
22 $ isdir somedir
15 yes
23 yes
16 $ hg rm somedir/foo
24 $ hg rm somedir/foo
17 $ isdir somedir
25 $ isdir somedir
18 no
26 no
19 $ hg revert -qa
27 $ hg revert -qa
20 $ isdir somedir
28 $ isdir somedir
21 yes
29 yes
22 $ hg $NO_RM rm somedir/foo
30 $ hg $NO_RM rm somedir/foo
23 $ isdir somedir
31 $ isdir somedir
24 yes
32 yes
25 $ ls somedir
33 $ ls somedir
26 $ cd $TESTTMP
34 $ cd $TESTTMP
27
35
28 `hg mv` of the last file in a directory:
36 `hg mv` of the last file in a directory:
29 $ hg init hgmv
37 $ hg init hgmv
30 $ cd hgmv
38 $ cd hgmv
31 $ mkdir somedir
39 $ mkdir somedir
32 $ mkdir destdir
40 $ mkdir destdir
33 $ echo hi > somedir/foo
41 $ echo hi > somedir/foo
34 $ hg ci -qAm foo
42 $ hg ci -qAm foo
35 $ isdir somedir
43 $ isdir somedir
36 yes
44 yes
37 $ hg mv somedir/foo destdir/foo
45 $ hg mv somedir/foo destdir/foo
38 $ isdir somedir
46 $ isdir somedir
39 no
47 no
40 $ hg revert -qa
48 $ hg revert -qa
41 (revert doesn't get rid of destdir/foo?)
49 (revert doesn't get rid of destdir/foo?)
42 $ rm destdir/foo
50 $ rm destdir/foo
43 $ isdir somedir
51 $ isdir somedir
44 yes
52 yes
45 $ hg $NO_RM mv somedir/foo destdir/foo
53 $ hg $NO_RM mv somedir/foo destdir/foo
46 $ isdir somedir
54 $ isdir somedir
47 yes
55 yes
48 $ ls somedir
56 $ ls somedir
49 $ cd $TESTTMP
57 $ cd $TESTTMP
50
58
51 Updating to a commit that doesn't have the directory:
59 Updating to a commit that doesn't have the directory:
52 $ hg init hgupdate
60 $ hg init hgupdate
53 $ cd hgupdate
61 $ cd hgupdate
54 $ echo hi > r0
62 $ echo hi > r0
55 $ hg ci -qAm r0
63 $ hg ci -qAm r0
56 $ mkdir somedir
64 $ mkdir somedir
57 $ echo hi > somedir/foo
65 $ echo hi > somedir/foo
58 $ hg ci -qAm r1
66 $ hg ci -qAm r1
59 $ isdir somedir
67 $ isdir somedir
60 yes
68 yes
61 $ hg co -q -r ".^"
69 $ hg co -q -r ".^"
62 $ isdir somedir
70 $ isdir somedir
63 no
71 no
64 $ hg co -q tip
72 $ hg co -q tip
65 $ isdir somedir
73 $ isdir somedir
66 yes
74 yes
67 $ hg $NO_RM co -q -r ".^"
75 $ hg $NO_RM co -q -r ".^"
68 $ isdir somedir
76 $ isdir somedir
69 yes
77 yes
70 $ ls somedir
78 $ ls somedir
71 $ cd $TESTTMP
79 $ cd $TESTTMP
72
80
73 Rebasing across a commit that doesn't have the directory, from inside the
81 Rebasing across a commit that doesn't have the directory, from inside the
74 directory:
82 directory:
75 $ hg init hgrebase
83 $ hg init hgrebase
76 $ cd hgrebase
84 $ cd hgrebase
77 $ echo hi > r0
85 $ echo hi > r0
78 $ hg ci -qAm r0
86 $ hg ci -qAm r0
79 $ mkdir somedir
87 $ mkdir somedir
80 $ echo hi > somedir/foo
88 $ echo hi > somedir/foo
81 $ hg ci -qAm first_rebase_source
89 $ hg ci -qAm first_rebase_source
82 $ hg $NO_RM co -q -r ".^"
90 $ hg $NO_RM co -q -r ".^"
83 $ echo hi > somedir/bar
91 $ echo hi > somedir/bar
84 $ hg ci -qAm first_rebase_dest
92 $ hg ci -qAm first_rebase_dest
85 $ hg $NO_RM co -q -r ".^"
93 $ hg $NO_RM co -q -r ".^"
86 $ echo hi > somedir/baz
94 $ echo hi > somedir/baz
87 $ hg ci -qAm second_rebase_dest
95 $ hg ci -qAm second_rebase_dest
88 $ hg co -qr 'desc(first_rebase_source)'
96 $ hg co -qr 'desc(first_rebase_source)'
89 $ cd $TESTTMP/hgrebase/somedir
97 $ cd $TESTTMP/hgrebase/somedir
90 $ hg --config extensions.rebase= rebase -qr . -d 'desc(first_rebase_dest)'
98 $ hg --config extensions.rebase= rebase -qr . -d 'desc(first_rebase_dest)'
91 current directory was removed (rmcwd !)
99 current directory was removed (rmcwd !)
92 (consider changing to repo root: $TESTTMP/hgrebase) (rmcwd !)
100 (consider changing to repo root: $TESTTMP/hgrebase) (rmcwd !)
93 $ cd $TESTTMP/hgrebase/somedir
101 $ cd $TESTTMP/hgrebase/somedir
94 (The current node is the rebased first_rebase_source on top of
102 (The current node is the rebased first_rebase_source on top of
95 first_rebase_dest)
103 first_rebase_dest)
96 This should not output anything about current directory being removed:
104 This should not output anything about current directory being removed:
97 $ hg $NO_RM --config extensions.rebase= rebase -qr . -d 'desc(second_rebase_dest)'
105 $ hg $NO_RM --config extensions.rebase= rebase -qr . -d 'desc(second_rebase_dest)'
98 $ cd $TESTTMP
106 $ cd $TESTTMP
99
107
100 Histediting across a commit that doesn't have the directory, from inside the
108 Histediting across a commit that doesn't have the directory, from inside the
101 directory (reordering nodes):
109 directory (reordering nodes):
102
110
103 A directory with the right pass exists at the end of the run, but it is a
111 A directory with the right pass exists at the end of the run, but it is a
104 different directory than the current one.
112 different directory than the current one.
105
113
106 Windows is not affected
114 Windows is not affected
107
115
108 $ hg init hghistedit
116 $ hg init hghistedit
109 $ cd hghistedit
117 $ cd hghistedit
110 $ echo hi > r0
118 $ echo hi > r0
111 $ hg ci -qAm r0
119 $ hg ci -qAm r0
112 $ echo hi > r1
120 $ echo hi > r1
113 $ hg ci -qAm r1
121 $ hg ci -qAm r1
114 $ echo hi > r2
122 $ echo hi > r2
115 $ hg ci -qAm r2
123 $ hg ci -qAm r2
116 $ mkdir somedir
124 $ mkdir somedir
117 $ echo hi > somedir/foo
125 $ echo hi > somedir/foo
118 $ hg ci -qAm migrating_revision
126 $ hg ci -qAm migrating_revision
119 $ cat > histedit_commands <<EOF
127 $ cat > histedit_commands <<EOF
120 > pick 89079fab8aee 0 r0
128 > pick 89079fab8aee 0 r0
121 > pick e6d271df3142 1 r1
129 > pick e6d271df3142 1 r1
122 > pick 89e25aa83f0f 3 migrating_revision
130 > pick 89e25aa83f0f 3 migrating_revision
123 > pick b550aa12d873 2 r2
131 > pick b550aa12d873 2 r2
124 > EOF
132 > EOF
125 $ cd $TESTTMP/hghistedit/somedir
133 $ cd $TESTTMP/hghistedit/somedir
126 $ hg $DO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
134 $ hg $DO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
127 current directory was removed (no-windows !)
135 current directory was removed (no-windows !)
128 (consider changing to repo root: $TESTTMP/hghistedit) (no-windows !)
136 (consider changing to repo root: $TESTTMP/hghistedit) (no-windows !)
129 $ ls -1 $TESTTMP/hghistedit/
137 $ ls -1 $TESTTMP/hghistedit/
130 histedit_commands
138 histedit_commands
131 r0
139 r0
132 r1
140 r1
133 r2
141 r2
134 somedir
142 somedir
135 $ pwd
143 #if windows
144 $ "$PYTHON" "$TESTTMP/pwd.py"
136 $TESTTMP/hghistedit/somedir
145 $TESTTMP/hghistedit/somedir
146 #else
147 $ echo ${PWD} # no-pwd-check
148 $TESTTMP/hghistedit/somedir
149 $ "$PYTHON" "$TESTTMP/pwd.py"
150 <directory is no longer accessible>
151 #endif
137 $ ls -1 $TESTTMP/hghistedit/somedir
152 $ ls -1 $TESTTMP/hghistedit/somedir
138 foo
153 foo
139 $ ls -1
154 $ ls -1
140 foo (windows !)
155 foo (windows !)
141
156
142 Get out of the doomed directory
157 Get out of the doomed directory
143
158
144 $ cd $TESTTMP/hghistedit
159 $ cd $TESTTMP/hghistedit
160 chdir: error retrieving current directory: getcwd: cannot access parent directories: $ENOENT$ (?)
145 $ hg files --rev . | grep somedir/
161 $ hg files --rev . | grep somedir/
146 somedir/foo
162 somedir/foo
147
163
148
164
149 $ cat > histedit_commands <<EOF
165 $ cat > histedit_commands <<EOF
150 > pick 89079fab8aee 0 r0
166 > pick 89079fab8aee 0 r0
151 > pick 7c7a22c6009f 3 migrating_revision
167 > pick 7c7a22c6009f 3 migrating_revision
152 > pick e6d271df3142 1 r1
168 > pick e6d271df3142 1 r1
153 > pick 40a53c2d4276 2 r2
169 > pick 40a53c2d4276 2 r2
154 > EOF
170 > EOF
155 $ cd $TESTTMP/hghistedit/somedir
171 $ cd $TESTTMP/hghistedit/somedir
156 $ hg $NO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
172 $ hg $NO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
157 Regardless of system, we should always get a 'yes' here.
173 Regardless of system, we should always get a 'yes' here.
158 $ isfile foo
174 $ isfile foo
159 yes
175 yes
160 $ cd $TESTTMP
176 $ cd $TESTTMP
161
177
162 This is essentially the exact test from issue5826, just cleaned up a little:
178 This is essentially the exact test from issue5826, just cleaned up a little:
163
179
164 $ hg init issue5826_withrm
180 $ hg init issue5826_withrm
165 $ cd issue5826_withrm
181 $ cd issue5826_withrm
166
182
167 Let's only turn this on for this repo so that we don't contaminate later tests.
183 Let's only turn this on for this repo so that we don't contaminate later tests.
168 $ cat >> .hg/hgrc <<EOF
184 $ cat >> .hg/hgrc <<EOF
169 > [extensions]
185 > [extensions]
170 > histedit =
186 > histedit =
171 > EOF
187 > EOF
172 Commit three revisions that each create a directory:
188 Commit three revisions that each create a directory:
173
189
174 $ mkdir foo
190 $ mkdir foo
175 $ touch foo/bar
191 $ touch foo/bar
176 $ hg commit -qAm "add foo"
192 $ hg commit -qAm "add foo"
177
193
178 $ mkdir bar
194 $ mkdir bar
179 $ touch bar/bar
195 $ touch bar/bar
180 $ hg commit -qAm "add bar"
196 $ hg commit -qAm "add bar"
181
197
182 $ mkdir baz
198 $ mkdir baz
183 $ touch baz/bar
199 $ touch baz/bar
184 $ hg commit -qAm "add baz"
200 $ hg commit -qAm "add baz"
185
201
186 Enter the first directory:
202 Enter the first directory:
187
203
188 $ cd foo
204 $ cd foo
189
205
190 Histedit doing 'pick, pick, fold':
206 Histedit doing 'pick, pick, fold':
191
207
192 #if rmcwd
208 #if rmcwd
193
209
194 $ hg histedit --commands - <<EOF
210 $ hg histedit --commands - <<EOF
195 > pick 6274c77c93c3 1 add bar
211 > pick 6274c77c93c3 1 add bar
196 > pick ff70a87b588f 0 add foo
212 > pick ff70a87b588f 0 add foo
197 > fold 9992bb0ac0db 2 add baz
213 > fold 9992bb0ac0db 2 add baz
198 > EOF
214 > EOF
199 current directory was removed
215 current directory was removed
200 (consider changing to repo root: $TESTTMP/issue5826_withrm)
216 (consider changing to repo root: $TESTTMP/issue5826_withrm)
201 abort: $ENOENT$
217 abort: $ENOENT$
202 [255]
218 [255]
203
219
204 Go back to the repo root after losing it as part of that operation:
220 Go back to the repo root after losing it as part of that operation:
205 $ cd $TESTTMP/issue5826_withrm
221 $ cd $TESTTMP/issue5826_withrm
206
222
207 Note the lack of a non-zero exit code from this function - it exits
223 Note the lack of a non-zero exit code from this function - it exits
208 successfully, but doesn't really do anything.
224 successfully, but doesn't really do anything.
209 $ hg histedit --continue
225 $ hg histedit --continue
210 9992bb0ac0db: cannot fold - working copy is not a descendant of previous commit 5c806432464a
226 9992bb0ac0db: cannot fold - working copy is not a descendant of previous commit 5c806432464a
211 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/ff70a87b588f-e94f9789-histedit.hg
227 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/ff70a87b588f-e94f9789-histedit.hg
212
228
213 $ hg log -T '{rev}:{node|short} {desc}\n'
229 $ hg log -T '{rev}:{node|short} {desc}\n'
214 2:94e3f9fae1d6 fold-temp-revision 9992bb0ac0db
230 2:94e3f9fae1d6 fold-temp-revision 9992bb0ac0db
215 1:5c806432464a add foo
231 1:5c806432464a add foo
216 0:d17db4b0303a add bar
232 0:d17db4b0303a add bar
217
233
218 #else
234 #else
219
235
220 $ cd $TESTTMP/issue5826_withrm
236 $ cd $TESTTMP/issue5826_withrm
221
237
222 $ hg histedit --commands - <<EOF
238 $ hg histedit --commands - <<EOF
223 > pick 6274c77c93c3 1 add bar
239 > pick 6274c77c93c3 1 add bar
224 > pick ff70a87b588f 0 add foo
240 > pick ff70a87b588f 0 add foo
225 > fold 9992bb0ac0db 2 add baz
241 > fold 9992bb0ac0db 2 add baz
226 > EOF
242 > EOF
227 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
243 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
228
244
229 $ hg log -T '{rev}:{node|short} {desc}\n'
245 $ hg log -T '{rev}:{node|short} {desc}\n'
230 1:b9eddaa97cbc add foo
246 1:b9eddaa97cbc add foo
231 ***
247 ***
232 add baz
248 add baz
233 0:d17db4b0303a add bar
249 0:d17db4b0303a add bar
234
250
235 #endif
251 #endif
236
252
237 Now test that again with experimental.removeemptydirs=false:
253 Now test that again with experimental.removeemptydirs=false:
238 $ hg init issue5826_norm
254 $ hg init issue5826_norm
239 $ cd issue5826_norm
255 $ cd issue5826_norm
240
256
241 Let's only turn this on for this repo so that we don't contaminate later tests.
257 Let's only turn this on for this repo so that we don't contaminate later tests.
242 $ cat >> .hg/hgrc <<EOF
258 $ cat >> .hg/hgrc <<EOF
243 > [extensions]
259 > [extensions]
244 > histedit =
260 > histedit =
245 > [experimental]
261 > [experimental]
246 > removeemptydirs = false
262 > removeemptydirs = false
247 > EOF
263 > EOF
248 Commit three revisions that each create a directory:
264 Commit three revisions that each create a directory:
249
265
250 $ mkdir foo
266 $ mkdir foo
251 $ touch foo/bar
267 $ touch foo/bar
252 $ hg commit -qAm "add foo"
268 $ hg commit -qAm "add foo"
253
269
254 $ mkdir bar
270 $ mkdir bar
255 $ touch bar/bar
271 $ touch bar/bar
256 $ hg commit -qAm "add bar"
272 $ hg commit -qAm "add bar"
257
273
258 $ mkdir baz
274 $ mkdir baz
259 $ touch baz/bar
275 $ touch baz/bar
260 $ hg commit -qAm "add baz"
276 $ hg commit -qAm "add baz"
261
277
262 Enter the first directory:
278 Enter the first directory:
263
279
264 $ cd foo
280 $ cd foo
265
281
266 Histedit doing 'pick, pick, fold':
282 Histedit doing 'pick, pick, fold':
267
283
268 $ hg histedit --commands - <<EOF
284 $ hg histedit --commands - <<EOF
269 > pick 6274c77c93c3 1 add bar
285 > pick 6274c77c93c3 1 add bar
270 > pick ff70a87b588f 0 add foo
286 > pick ff70a87b588f 0 add foo
271 > fold 9992bb0ac0db 2 add baz
287 > fold 9992bb0ac0db 2 add baz
272 > EOF
288 > EOF
273 saved backup bundle to $TESTTMP/issue5826_withrm/issue5826_norm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
289 saved backup bundle to $TESTTMP/issue5826_withrm/issue5826_norm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
274
290
275 Note the lack of a 'cd' being necessary here, and we don't need to 'histedit
291 Note the lack of a 'cd' being necessary here, and we don't need to 'histedit
276 --continue'
292 --continue'
277
293
278 $ hg log -T '{rev}:{node|short} {desc}\n'
294 $ hg log -T '{rev}:{node|short} {desc}\n'
279 1:b9eddaa97cbc add foo
295 1:b9eddaa97cbc add foo
280 ***
296 ***
281 add baz
297 add baz
282 0:d17db4b0303a add bar
298 0:d17db4b0303a add bar
283
299
284 $ cd $TESTTMP
300 $ cd $TESTTMP
General Comments 0
You need to be logged in to leave comments. Login now