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