##// END OF EJS Templates
tests: conditionalize an error message about unlinking a non empty directory...
Matt Harbison -
r39514:c4a7ba10 default
parent child Browse files
Show More
@@ -1,431 +1,432 b''
1 1 $ cat <<EOF > merge
2 2 > from __future__ import print_function
3 3 > import sys, os
4 4 >
5 5 > try:
6 6 > import msvcrt
7 7 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
8 8 > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
9 9 > except ImportError:
10 10 > pass
11 11 >
12 12 > print("merging for", os.path.basename(sys.argv[1]))
13 13 > EOF
14 14 $ HGMERGE="$PYTHON ../merge"; export HGMERGE
15 15
16 16 $ hg init t
17 17 $ cd t
18 18 $ echo This is file a1 > a
19 19 $ hg add a
20 20 $ hg commit -m "commit #0"
21 21 $ echo This is file b1 > b
22 22 $ hg add b
23 23 $ hg commit -m "commit #1"
24 24
25 25 $ hg update 0
26 26 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
27 27
28 28 Test interrupted updates by having a non-empty dir with the same name as one
29 29 of the files in a commit we're updating to
30 30
31 31 $ mkdir b && touch b/nonempty
32 32 $ hg up
33 abort: Directory not empty: '$TESTTMP/t/b'
33 abort: Unlinking directory not permitted: '$TESTTMP/t/b' (windows !)
34 abort: Directory not empty: '$TESTTMP/t/b' (no-windows !)
34 35 [255]
35 36 $ hg ci
36 37 abort: last update was interrupted
37 38 (use 'hg update' to get a consistent checkout)
38 39 [255]
39 40 $ hg sum
40 41 parent: 0:538afb845929
41 42 commit #0
42 43 branch: default
43 44 commit: 1 unknown (interrupted update)
44 45 update: 1 new changesets (update)
45 46 phases: 2 draft
46 47
47 48 $ rm b/nonempty
48 49
49 50 $ hg up
50 51 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 52 $ hg sum
52 53 parent: 1:b8bb4a988f25 tip
53 54 commit #1
54 55 branch: default
55 56 commit: (clean)
56 57 update: (current)
57 58 phases: 2 draft
58 59
59 60 Prepare a basic merge
60 61
61 62 $ hg up 0
62 63 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
63 64 $ echo This is file c1 > c
64 65 $ hg add c
65 66 $ hg commit -m "commit #2"
66 67 created new head
67 68 $ echo This is file b1 > b
68 69 no merges expected
69 70 $ hg merge -P 1
70 71 changeset: 1:b8bb4a988f25
71 72 user: test
72 73 date: Thu Jan 01 00:00:00 1970 +0000
73 74 summary: commit #1
74 75
75 76 $ hg merge 1
76 77 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 78 (branch merge, don't forget to commit)
78 79 $ hg diff --nodates
79 80 diff -r 49035e18a8e6 b
80 81 --- /dev/null
81 82 +++ b/b
82 83 @@ -0,0 +1,1 @@
83 84 +This is file b1
84 85 $ hg status
85 86 M b
86 87 $ cd ..; rm -r t
87 88
88 89 $ hg init t
89 90 $ cd t
90 91 $ echo This is file a1 > a
91 92 $ hg add a
92 93 $ hg commit -m "commit #0"
93 94 $ echo This is file b1 > b
94 95 $ hg add b
95 96 $ hg commit -m "commit #1"
96 97
97 98 $ hg update 0
98 99 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
99 100 $ echo This is file c1 > c
100 101 $ hg add c
101 102 $ hg commit -m "commit #2"
102 103 created new head
103 104 $ echo This is file b2 > b
104 105 merge should fail
105 106 $ hg merge 1
106 107 b: untracked file differs
107 108 abort: untracked files in working directory differ from files in requested revision
108 109 [255]
109 110
110 111 #if symlink
111 112 symlinks to directories should be treated as regular files (issue5027)
112 113 $ rm b
113 114 $ ln -s 'This is file b2' b
114 115 $ hg merge 1
115 116 b: untracked file differs
116 117 abort: untracked files in working directory differ from files in requested revision
117 118 [255]
118 119 symlinks shouldn't be followed
119 120 $ rm b
120 121 $ echo This is file b1 > .hg/b
121 122 $ ln -s .hg/b b
122 123 $ hg merge 1
123 124 b: untracked file differs
124 125 abort: untracked files in working directory differ from files in requested revision
125 126 [255]
126 127
127 128 $ rm b
128 129 $ echo This is file b2 > b
129 130 #endif
130 131
131 132 bad config
132 133 $ hg merge 1 --config merge.checkunknown=x
133 134 abort: merge.checkunknown not valid ('x' is none of 'abort', 'ignore', 'warn')
134 135 [255]
135 136 this merge should fail
136 137 $ hg merge 1 --config merge.checkunknown=abort
137 138 b: untracked file differs
138 139 abort: untracked files in working directory differ from files in requested revision
139 140 [255]
140 141
141 142 this merge should warn
142 143 $ hg merge 1 --config merge.checkunknown=warn
143 144 b: replacing untracked file
144 145 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
145 146 (branch merge, don't forget to commit)
146 147 $ cat b.orig
147 148 This is file b2
148 149 $ hg up --clean 2
149 150 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
150 151 $ mv b.orig b
151 152
152 153 this merge should silently ignore
153 154 $ cat b
154 155 This is file b2
155 156 $ hg merge 1 --config merge.checkunknown=ignore
156 157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
157 158 (branch merge, don't forget to commit)
158 159
159 160 merge.checkignored
160 161 $ hg up --clean 1
161 162 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
162 163 $ cat >> .hgignore << EOF
163 164 > remoteignored
164 165 > EOF
165 166 $ echo This is file localignored3 > localignored
166 167 $ echo This is file remoteignored3 > remoteignored
167 168 $ hg add .hgignore localignored remoteignored
168 169 $ hg commit -m "commit #3"
169 170
170 171 $ hg up 2
171 172 1 files updated, 0 files merged, 4 files removed, 0 files unresolved
172 173 $ cat >> .hgignore << EOF
173 174 > localignored
174 175 > EOF
175 176 $ hg add .hgignore
176 177 $ hg commit -m "commit #4"
177 178
178 179 remote .hgignore shouldn't be used for determining whether a file is ignored
179 180 $ echo This is file remoteignored4 > remoteignored
180 181 $ hg merge 3 --config merge.checkignored=ignore --config merge.checkunknown=abort
181 182 remoteignored: untracked file differs
182 183 abort: untracked files in working directory differ from files in requested revision
183 184 [255]
184 185 $ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=ignore
185 186 merging .hgignore
186 187 merging for .hgignore
187 188 3 files updated, 1 files merged, 0 files removed, 0 files unresolved
188 189 (branch merge, don't forget to commit)
189 190 $ cat remoteignored
190 191 This is file remoteignored3
191 192 $ cat remoteignored.orig
192 193 This is file remoteignored4
193 194 $ rm remoteignored.orig
194 195
195 196 local .hgignore should be used for that
196 197 $ hg up --clean 4
197 198 1 files updated, 0 files merged, 3 files removed, 0 files unresolved
198 199 $ echo This is file localignored4 > localignored
199 200 also test other conflicting files to see we output the full set of warnings
200 201 $ echo This is file b2 > b
201 202 $ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=abort
202 203 b: untracked file differs
203 204 localignored: untracked file differs
204 205 abort: untracked files in working directory differ from files in requested revision
205 206 [255]
206 207 $ hg merge 3 --config merge.checkignored=abort --config merge.checkunknown=ignore
207 208 localignored: untracked file differs
208 209 abort: untracked files in working directory differ from files in requested revision
209 210 [255]
210 211 $ hg merge 3 --config merge.checkignored=warn --config merge.checkunknown=abort
211 212 b: untracked file differs
212 213 abort: untracked files in working directory differ from files in requested revision
213 214 [255]
214 215 $ hg merge 3 --config merge.checkignored=warn --config merge.checkunknown=warn
215 216 b: replacing untracked file
216 217 localignored: replacing untracked file
217 218 merging .hgignore
218 219 merging for .hgignore
219 220 3 files updated, 1 files merged, 0 files removed, 0 files unresolved
220 221 (branch merge, don't forget to commit)
221 222 $ cat localignored
222 223 This is file localignored3
223 224 $ cat localignored.orig
224 225 This is file localignored4
225 226 $ rm localignored.orig
226 227
227 228 $ cat b.orig
228 229 This is file b2
229 230 $ hg up --clean 2
230 231 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
231 232 $ mv b.orig b
232 233
233 234 this merge of b should work
234 235 $ cat b
235 236 This is file b2
236 237 $ hg merge -f 1
237 238 merging b
238 239 merging for b
239 240 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
240 241 (branch merge, don't forget to commit)
241 242 $ hg diff --nodates
242 243 diff -r 49035e18a8e6 b
243 244 --- /dev/null
244 245 +++ b/b
245 246 @@ -0,0 +1,1 @@
246 247 +This is file b2
247 248 $ hg status
248 249 M b
249 250 $ cd ..; rm -r t
250 251
251 252 $ hg init t
252 253 $ cd t
253 254 $ echo This is file a1 > a
254 255 $ hg add a
255 256 $ hg commit -m "commit #0"
256 257 $ echo This is file b1 > b
257 258 $ hg add b
258 259 $ hg commit -m "commit #1"
259 260 $ echo This is file b22 > b
260 261 $ hg commit -m "commit #2"
261 262 $ hg update 1
262 263 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
263 264 $ echo This is file c1 > c
264 265 $ hg add c
265 266 $ hg commit -m "commit #3"
266 267 created new head
267 268
268 269 Contents of b should be "this is file b1"
269 270 $ cat b
270 271 This is file b1
271 272
272 273 $ echo This is file b22 > b
273 274 merge fails
274 275 $ hg merge 2
275 276 abort: uncommitted changes
276 277 (use 'hg status' to list changes)
277 278 [255]
278 279 merge expected!
279 280 $ hg merge -f 2
280 281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
281 282 (branch merge, don't forget to commit)
282 283 $ hg diff --nodates
283 284 diff -r 85de557015a8 b
284 285 --- a/b
285 286 +++ b/b
286 287 @@ -1,1 +1,1 @@
287 288 -This is file b1
288 289 +This is file b22
289 290 $ hg status
290 291 M b
291 292 $ cd ..; rm -r t
292 293
293 294 $ hg init t
294 295 $ cd t
295 296 $ echo This is file a1 > a
296 297 $ hg add a
297 298 $ hg commit -m "commit #0"
298 299 $ echo This is file b1 > b
299 300 $ hg add b
300 301 $ hg commit -m "commit #1"
301 302 $ echo This is file b22 > b
302 303 $ hg commit -m "commit #2"
303 304 $ hg update 1
304 305 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
305 306 $ echo This is file c1 > c
306 307 $ hg add c
307 308 $ hg commit -m "commit #3"
308 309 created new head
309 310 $ echo This is file b33 > b
310 311 merge of b should fail
311 312 $ hg merge 2
312 313 abort: uncommitted changes
313 314 (use 'hg status' to list changes)
314 315 [255]
315 316 merge of b expected
316 317 $ hg merge -f 2
317 318 merging b
318 319 merging for b
319 320 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
320 321 (branch merge, don't forget to commit)
321 322 $ hg diff --nodates
322 323 diff -r 85de557015a8 b
323 324 --- a/b
324 325 +++ b/b
325 326 @@ -1,1 +1,1 @@
326 327 -This is file b1
327 328 +This is file b33
328 329 $ hg status
329 330 M b
330 331
331 332 Test for issue2364
332 333
333 334 $ hg up -qC .
334 335 $ hg rm b
335 336 $ hg ci -md
336 337 $ hg revert -r -2 b
337 338 $ hg up -q -- -2
338 339
339 340 Test that updated files are treated as "modified", when
340 341 'merge.update()' is aborted before 'merge.recordupdates()' (= parents
341 342 aren't changed), even if none of mode, size and timestamp of them
342 343 isn't changed on the filesystem (see also issue4583).
343 344
344 345 $ cat > $TESTTMP/abort.py <<EOF
345 346 > from __future__ import absolute_import
346 347 > # emulate aborting before "recordupdates()". in this case, files
347 348 > # are changed without updating dirstate
348 349 > from mercurial import (
349 350 > error,
350 351 > extensions,
351 352 > merge,
352 353 > )
353 354 > def applyupdates(orig, *args, **kwargs):
354 355 > orig(*args, **kwargs)
355 356 > raise error.Abort('intentional aborting')
356 357 > def extsetup(ui):
357 358 > extensions.wrapfunction(merge, "applyupdates", applyupdates)
358 359 > EOF
359 360
360 361 $ cat >> .hg/hgrc <<EOF
361 362 > [fakedirstatewritetime]
362 363 > # emulate invoking dirstate.write() via repo.status()
363 364 > # at 2000-01-01 00:00
364 365 > fakenow = 200001010000
365 366 > EOF
366 367
367 368 (file gotten from other revision)
368 369
369 370 $ hg update -q -C 2
370 371 $ echo 'THIS IS FILE B5' > b
371 372 $ hg commit -m 'commit #5'
372 373
373 374 $ hg update -q -C 3
374 375 $ cat b
375 376 This is file b1
376 377 $ touch -t 200001010000 b
377 378 $ hg debugrebuildstate
378 379
379 380 $ cat >> .hg/hgrc <<EOF
380 381 > [extensions]
381 382 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
382 383 > abort = $TESTTMP/abort.py
383 384 > EOF
384 385 $ hg merge 5
385 386 abort: intentional aborting
386 387 [255]
387 388 $ cat >> .hg/hgrc <<EOF
388 389 > [extensions]
389 390 > fakedirstatewritetime = !
390 391 > abort = !
391 392 > EOF
392 393
393 394 $ cat b
394 395 THIS IS FILE B5
395 396 $ touch -t 200001010000 b
396 397 $ hg status -A b
397 398 M b
398 399
399 400 (file merged from other revision)
400 401
401 402 $ hg update -q -C 3
402 403 $ echo 'this is file b6' > b
403 404 $ hg commit -m 'commit #6'
404 405 created new head
405 406
406 407 $ cat b
407 408 this is file b6
408 409 $ touch -t 200001010000 b
409 410 $ hg debugrebuildstate
410 411
411 412 $ cat >> .hg/hgrc <<EOF
412 413 > [extensions]
413 414 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
414 415 > abort = $TESTTMP/abort.py
415 416 > EOF
416 417 $ hg merge --tool internal:other 5
417 418 abort: intentional aborting
418 419 [255]
419 420 $ cat >> .hg/hgrc <<EOF
420 421 > [extensions]
421 422 > fakedirstatewritetime = !
422 423 > abort = !
423 424 > EOF
424 425
425 426 $ cat b
426 427 THIS IS FILE B5
427 428 $ touch -t 200001010000 b
428 429 $ hg status -A b
429 430 M b
430 431
431 432 $ cd ..
@@ -1,92 +1,93 b''
1 1 Test update logic when there are renames or weird same-name cases between dirs
2 2 and files
3 3
4 4 Update with local changes across a file rename
5 5
6 6 $ hg init r1 && cd r1
7 7
8 8 $ echo a > a
9 9 $ hg add a
10 10 $ hg ci -m a
11 11
12 12 $ hg mv a b
13 13 $ hg ci -m rename
14 14
15 15 $ echo b > b
16 16 $ hg ci -m change
17 17
18 18 $ hg up -q 0
19 19
20 20 $ echo c > a
21 21
22 22 $ hg up
23 23 merging a and b to b
24 24 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
25 25 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
26 26 use 'hg resolve' to retry unresolved file merges
27 27 [1]
28 28
29 29 Test update when local untracked directory exists with the same name as a
30 30 tracked file in a commit we are updating to
31 31 $ hg init r2 && cd r2
32 32 $ echo root > root && hg ci -Am root # rev 0
33 33 adding root
34 34 $ echo text > name && hg ci -Am "name is a file" # rev 1
35 35 adding name
36 36 $ hg up 0
37 37 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
38 38 $ mkdir name
39 39 $ hg up 1
40 40 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
41 41
42 42 Test update when local untracked directory exists with some files in it and has
43 43 the same name a tracked file in a commit we are updating to. In future this
44 44 should be updated to give an friendlier error message, but now we should just
45 45 make sure that this does not erase untracked data
46 46 $ hg up 0
47 47 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
48 48 $ mkdir name
49 49 $ echo text > name/file
50 50 $ hg st
51 51 ? name/file
52 52 $ hg up 1
53 abort: Directory not empty: '$TESTTMP/r1/r2/name'
53 abort: Unlinking directory not permitted: '$TESTTMP/r1/r2/name' (windows !)
54 abort: Directory not empty: '$TESTTMP/r1/r2/name' (no-windows !)
54 55 [255]
55 56 $ cat name/file
56 57 text
57 58 $ cd ..
58 59
59 60 #if symlink
60 61
61 62 Test update when two commits have symlinks that point to different folders
62 63 $ hg init r3 && cd r3
63 64 $ echo root > root && hg ci -Am root
64 65 adding root
65 66 $ mkdir folder1 && mkdir folder2
66 67 $ ln -s folder1 folder
67 68 $ hg ci -Am "symlink to folder1"
68 69 adding folder
69 70 $ rm folder
70 71 $ ln -s folder2 folder
71 72 $ hg ci -Am "symlink to folder2"
72 73 $ hg up 1
73 74 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
74 75 $ cd ..
75 76
76 77 #endif
77 78
78 79 #if rmcwd
79 80
80 81 Test that warning is printed if cwd is deleted during update
81 82 $ hg init r4 && cd r4
82 83 $ mkdir dir
83 84 $ cd dir
84 85 $ echo a > a
85 86 $ echo b > b
86 87 $ hg add a b
87 88 $ hg ci -m "file and dir"
88 89 $ hg up -q null
89 90 current directory was removed
90 91 (consider changing to repo root: $TESTTMP/r1/r4)
91 92
92 93 #endif
General Comments 0
You need to be logged in to leave comments. Login now