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