##// END OF EJS Templates
tests: unify test-import
Nicolas Dumazet -
r11807:887e9f48 default
parent child Browse files
Show More
This diff has been collapsed as it changes many lines, (1323 lines changed) Show them Hide them
@@ -1,497 +1,916 b''
1 #!/bin/sh
1 $ hg init a
2 $ mkdir a/d1
3 $ mkdir a/d1/d2
4 $ echo line 1 > a/a
5 $ echo line 1 > a/d1/d2/a
6 $ hg --cwd a ci -Ama
7 adding a
8 adding d1/d2/a
9
10 $ echo line 2 >> a/a
11 $ hg --cwd a ci -u someone -d '1 0' -m'second change'
12
13
14 import exported patch
2
15
3 hg init a
16 $ hg clone -r0 a b
4 mkdir a/d1
17 requesting all changes
5 mkdir a/d1/d2
18 adding changesets
6 echo line 1 > a/a
19 adding manifests
7 echo line 1 > a/d1/d2/a
20 adding file changes
8 hg --cwd a ci -Ama
21 added 1 changesets with 2 changes to 2 files
22 updating to branch default
23 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
24 $ hg --cwd a export tip > tip.patch
25 $ hg --cwd b import ../tip.patch
26 applying ../tip.patch
9
27
10 echo line 2 >> a/a
28 message should be same
11 hg --cwd a ci -u someone -d '1 0' -m'second change'
29
30 $ hg --cwd b tip | grep 'second change'
31 summary: second change
32
33 committer should be same
34
35 $ hg --cwd b tip | grep someone
36 user: someone
37 $ rm -r b
38
39
40 import exported patch with external patcher
12
41
13 echo % import exported patch
42 $ cat > dummypatch.py <<EOF
14 hg clone -r0 a b
43 > print 'patching file a'
15 hg --cwd a export tip > tip.patch
44 > file('a', 'wb').write('line2\n')
16 hg --cwd b import ../tip.patch
45 > EOF
17 echo % message should be same
46 $ chmod +x dummypatch.py
18 hg --cwd b tip | grep 'second change'
47 $ hg clone -r0 a b
19 echo % committer should be same
48 requesting all changes
20 hg --cwd b tip | grep someone
49 adding changesets
21 rm -r b
50 adding manifests
51 adding file changes
52 added 1 changesets with 2 changes to 2 files
53 updating to branch default
54 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 $ hg --cwd a export tip > tip.patch
56 $ hg --config ui.patch='python ../dummypatch.py' --cwd b import ../tip.patch
57 applying ../tip.patch
58 $ cat b/a
59 line2
60 $ rm -r b
61
62
63 import of plain diff should fail without message
22
64
23 echo % import exported patch with external patcher
65 $ hg clone -r0 a b
24 cat > dummypatch.py <<EOF
66 requesting all changes
25 print 'patching file a'
67 adding changesets
26 file('a', 'wb').write('line2\n')
68 adding manifests
27 EOF
69 adding file changes
28 chmod +x dummypatch.py
70 added 1 changesets with 2 changes to 2 files
29 hg clone -r0 a b
71 updating to branch default
30 hg --cwd a export tip > tip.patch
72 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
31 hg --config ui.patch='python ../dummypatch.py' --cwd b import ../tip.patch
73 $ hg --cwd a diff -r0:1 > tip.patch
32 cat b/a
74 $ hg --cwd b import ../tip.patch
33 rm -r b
75 applying ../tip.patch
76 abort: empty commit message
77 $ rm -r b
78
34
79
35 echo % import of plain diff should fail without message
80 import of plain diff should be ok with message
36 hg clone -r0 a b
81
37 hg --cwd a diff -r0:1 > tip.patch
82 $ hg clone -r0 a b
38 hg --cwd b import ../tip.patch
83 requesting all changes
39 rm -r b
84 adding changesets
85 adding manifests
86 adding file changes
87 added 1 changesets with 2 changes to 2 files
88 updating to branch default
89 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 $ hg --cwd a diff -r0:1 > tip.patch
91 $ hg --cwd b import -mpatch ../tip.patch
92 applying ../tip.patch
93 $ rm -r b
94
95
96 import of plain diff with specific date and user
40
97
41 echo % import of plain diff should be ok with message
98 $ hg clone -r0 a b
42 hg clone -r0 a b
99 requesting all changes
43 hg --cwd a diff -r0:1 > tip.patch
100 adding changesets
44 hg --cwd b import -mpatch ../tip.patch
101 adding manifests
45 rm -r b
102 adding file changes
103 added 1 changesets with 2 changes to 2 files
104 updating to branch default
105 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
106 $ hg --cwd a diff -r0:1 > tip.patch
107 $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../tip.patch
108 applying ../tip.patch
109 $ hg -R b tip -pv
110 changeset: 1:ca68f19f3a40
111 tag: tip
112 user: user@nowhere.net
113 date: Thu Jan 01 00:00:01 1970 +0000
114 files: a
115 description:
116 patch
117
118
119 diff -r 80971e65b431 -r ca68f19f3a40 a
120 --- a/a Thu Jan 01 00:00:00 1970 +0000
121 +++ b/a Thu Jan 01 00:00:01 1970 +0000
122 @@ -1,1 +1,2 @@
123 line 1
124 +line 2
125
126 $ rm -r b
46
127
47 echo % import of plain diff with specific date and user
128
48 hg clone -r0 a b
129 import of plain diff should be ok with --no-commit
49 hg --cwd a diff -r0:1 > tip.patch
50 hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../tip.patch
51 hg -R b tip -pv
52 rm -r b
53
130
54 echo % import of plain diff should be ok with --no-commit
131 $ hg clone -r0 a b
55 hg clone -r0 a b
132 requesting all changes
56 hg --cwd a diff -r0:1 > tip.patch
133 adding changesets
57 hg --cwd b import --no-commit ../tip.patch
134 adding manifests
58 hg --cwd b diff --nodates
135 adding file changes
59 rm -r b
136 added 1 changesets with 2 changes to 2 files
137 updating to branch default
138 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
139 $ hg --cwd a diff -r0:1 > tip.patch
140 $ hg --cwd b import --no-commit ../tip.patch
141 applying ../tip.patch
142 $ hg --cwd b diff --nodates
143 diff -r 80971e65b431 a
144 --- a/a
145 +++ b/a
146 @@ -1,1 +1,2 @@
147 line 1
148 +line 2
149 $ rm -r b
150
151
152 hg -R repo import
153 put the clone in a subdir - having a directory named "a"
154 used to hide a bug.
60
155
61 echo % hg -R repo import
156 $ mkdir dir
62 # put the clone in a subdir - having a directory named "a"
157 $ hg clone -r0 a dir/b
63 # used to hide a bug.
158 requesting all changes
64 mkdir dir
159 adding changesets
65 hg clone -r0 a dir/b
160 adding manifests
66 hg --cwd a export tip > dir/tip.patch
161 adding file changes
67 cd dir
162 added 1 changesets with 2 changes to 2 files
68 hg -R b import tip.patch
163 updating to branch default
69 cd ..
164 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 rm -r dir
165 $ hg --cwd a export tip > dir/tip.patch
166 $ cd dir
167 $ hg -R b import tip.patch
168 applying tip.patch
169 $ cd ..
170 $ rm -r dir
171
172
173 import from stdin
71
174
72 echo % import from stdin
175 $ hg clone -r0 a b
73 hg clone -r0 a b
176 requesting all changes
74 hg --cwd a export tip | hg --cwd b import -
177 adding changesets
75 rm -r b
178 adding manifests
179 adding file changes
180 added 1 changesets with 2 changes to 2 files
181 updating to branch default
182 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
183 $ hg --cwd a export tip | hg --cwd b import -
184 applying patch from stdin
185 $ rm -r b
186
187
188 import two patches in one stream
76
189
77 echo % import two patches in one stream
190 $ hg init b
78 hg init b
191 $ hg --cwd a export 0:tip | hg --cwd b import -
79 hg --cwd a export 0:tip | hg --cwd b import -
192 applying patch from stdin
80 hg --cwd a id
193 applied 80971e65b431
81 hg --cwd b id
194 $ hg --cwd a id
82 rm -r b
195 1d4bd90af0e4 tip
196 $ hg --cwd b id
197 1d4bd90af0e4 tip
198 $ rm -r b
199
200
201 override commit message
202
203 $ hg clone -r0 a b
204 requesting all changes
205 adding changesets
206 adding manifests
207 adding file changes
208 added 1 changesets with 2 changes to 2 files
209 updating to branch default
210 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
211 $ hg --cwd a export tip | hg --cwd b import -m 'override' -
212 applying patch from stdin
213 $ hg --cwd b tip | grep override
214 summary: override
215 $ rm -r b
83
216
84 echo % override commit message
217 $ cat > mkmsg.py <<EOF
85 hg clone -r0 a b
218 > import email.Message, sys
86 hg --cwd a export tip | hg --cwd b import -m 'override' -
219 > msg = email.Message.Message()
87 hg --cwd b tip | grep override
220 > msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read())
88 rm -r b
221 > msg['Subject'] = 'email patch'
222 > msg['From'] = 'email patcher'
223 > sys.stdout.write(msg.as_string())
224 > EOF
225
226
227 plain diff in email, subject, message body
89
228
90 cat > mkmsg.py <<EOF
229 $ hg clone -r0 a b
91 import email.Message, sys
230 requesting all changes
92 msg = email.Message.Message()
231 adding changesets
93 msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read())
232 adding manifests
94 msg['Subject'] = 'email patch'
233 adding file changes
95 msg['From'] = 'email patcher'
234 added 1 changesets with 2 changes to 2 files
96 sys.stdout.write(msg.as_string())
235 updating to branch default
97 EOF
236 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 $ hg --cwd a diff -r0:1 > tip.patch
238 $ python mkmsg.py > msg.patch
239 $ hg --cwd b import ../msg.patch
240 applying ../msg.patch
241 $ hg --cwd b tip | grep email
242 user: email patcher
243 summary: email patch
244 $ rm -r b
245
246
247 plain diff in email, no subject, message body
248
249 $ hg clone -r0 a b
250 requesting all changes
251 adding changesets
252 adding manifests
253 adding file changes
254 added 1 changesets with 2 changes to 2 files
255 updating to branch default
256 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
257 $ grep -v '^Subject:' msg.patch | hg --cwd b import -
258 applying patch from stdin
259 $ rm -r b
260
261
262 plain diff in email, subject, no message body
98
263
99 echo % plain diff in email, subject, message body
264 $ hg clone -r0 a b
100 hg clone -r0 a b
265 requesting all changes
101 hg --cwd a diff -r0:1 > tip.patch
266 adding changesets
102 python mkmsg.py > msg.patch
267 adding manifests
103 hg --cwd b import ../msg.patch
268 adding file changes
104 hg --cwd b tip | grep email
269 added 1 changesets with 2 changes to 2 files
105 rm -r b
270 updating to branch default
271 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
272 $ grep -v '^email ' msg.patch | hg --cwd b import -
273 applying patch from stdin
274 $ rm -r b
275
276
277 plain diff in email, no subject, no message body, should fail
106
278
107 echo % plain diff in email, no subject, message body
279 $ hg clone -r0 a b
108 hg clone -r0 a b
280 requesting all changes
109 grep -v '^Subject:' msg.patch | hg --cwd b import -
281 adding changesets
110 rm -r b
282 adding manifests
283 adding file changes
284 added 1 changesets with 2 changes to 2 files
285 updating to branch default
286 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
287 $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
288 applying patch from stdin
289 abort: empty commit message
290 $ rm -r b
291
292
293 hg export in email, should use patch header
111
294
112 echo % plain diff in email, subject, no message body
295 $ hg clone -r0 a b
113 hg clone -r0 a b
296 requesting all changes
114 grep -v '^email ' msg.patch | hg --cwd b import -
297 adding changesets
115 rm -r b
298 adding manifests
299 adding file changes
300 added 1 changesets with 2 changes to 2 files
301 updating to branch default
302 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
303 $ hg --cwd a export tip > tip.patch
304 $ python mkmsg.py | hg --cwd b import -
305 applying patch from stdin
306 $ hg --cwd b tip | grep second
307 summary: second change
308 $ rm -r b
116
309
117 echo % plain diff in email, no subject, no message body, should fail
310
118 hg clone -r0 a b
311 subject: duplicate detection, removal of [PATCH]
119 egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
312 The '---' tests the gitsendmail handling without proper mail headers
120 rm -r b
121
313
122 echo % hg export in email, should use patch header
314 $ cat > mkmsg2.py <<EOF
123 hg clone -r0 a b
315 > import email.Message, sys
124 hg --cwd a export tip > tip.patch
316 > msg = email.Message.Message()
125 python mkmsg.py | hg --cwd b import -
317 > msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read())
126 hg --cwd b tip | grep second
318 > msg['Subject'] = '[PATCH] email patch'
127 rm -r b
319 > msg['From'] = 'email patcher'
320 > sys.stdout.write(msg.as_string())
321 > EOF
322
323
324 plain diff in email, [PATCH] subject, message body with subject
128
325
129 # subject: duplicate detection, removal of [PATCH]
326 $ hg clone -r0 a b
130 # The '---' tests the gitsendmail handling without proper mail headers
327 requesting all changes
131 cat > mkmsg2.py <<EOF
328 adding changesets
132 import email.Message, sys
329 adding manifests
133 msg = email.Message.Message()
330 adding file changes
134 msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read())
331 added 1 changesets with 2 changes to 2 files
135 msg['Subject'] = '[PATCH] email patch'
332 updating to branch default
136 msg['From'] = 'email patcher'
333 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
137 sys.stdout.write(msg.as_string())
334 $ hg --cwd a diff -r0:1 > tip.patch
138 EOF
335 $ python mkmsg2.py | hg --cwd b import -
336 applying patch from stdin
337 $ hg --cwd b tip --template '{desc}\n'
338 email patch
339
340 next line
341 ---
342 $ rm -r b
343
344
345 We weren't backing up the correct dirstate file when importing many patches
346 (issue963)
347 import patch1 patch2; rollback
139
348
140 echo '% plain diff in email, [PATCH] subject, message body with subject'
349 $ echo line 3 >> a/a
141 hg clone -r0 a b
350 $ hg --cwd a ci -m'third change'
142 hg --cwd a diff -r0:1 > tip.patch
351 $ hg --cwd a export -o '../patch%R' 1 2
143 python mkmsg2.py | hg --cwd b import -
352 $ hg clone -qr0 a b
144 hg --cwd b tip --template '{desc}\n'
353 $ hg --cwd b parents --template 'parent: {rev}\n'
145 rm -r b
354 parent: 0
355 $ hg --cwd b import ../patch1 ../patch2
356 applying ../patch1
357 applying ../patch2
358 applied 1d4bd90af0e4
359 $ hg --cwd b rollback
360 rolling back to revision 1 (undo commit)
361 $ hg --cwd b parents --template 'parent: {rev}\n'
362 parent: 1
363 $ rm -r b
364
365
366 importing a patch in a subdirectory failed at the commit stage
367
368 $ echo line 2 >> a/d1/d2/a
369 $ hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change'
370
371 hg import in a subdirectory
146
372
147 # We weren't backing up the correct dirstate file when importing many patches
373 $ hg clone -r0 a b
148 # (issue963)
374 requesting all changes
149 echo '% import patch1 patch2; rollback'
375 adding changesets
150 echo line 3 >> a/a
376 adding manifests
151 hg --cwd a ci -m'third change'
377 adding file changes
152 hg --cwd a export -o '../patch%R' 1 2
378 added 1 changesets with 2 changes to 2 files
153 hg clone -qr0 a b
379 updating to branch default
154 hg --cwd b parents --template 'parent: {rev}\n'
380 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
155 hg --cwd b import ../patch1 ../patch2
381 $ hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch
156 hg --cwd b rollback
382 $ dir=`pwd`
157 hg --cwd b parents --template 'parent: {rev}\n'
383 $ cd b/d1/d2 2>&1 > /dev/null
158 rm -r b
384 $ hg import ../../../tip.patch
385 applying ../../../tip.patch
386 $ cd "$dir"
387
388 message should be 'subdir change'
389
390 $ hg --cwd b tip | grep 'subdir change'
391 summary: subdir change
392
393 committer should be 'someoneelse'
394
395 $ hg --cwd b tip | grep someoneelse
396 user: someoneelse
397
398 should be empty
399
400 $ hg --cwd b status
401
402
403 Test fuzziness (ambiguous patch location, fuzz=2)
159
404
160 # bug non regression test
405 $ hg init fuzzy
161 # importing a patch in a subdirectory failed at the commit stage
406 $ cd fuzzy
162 echo line 2 >> a/d1/d2/a
407 $ echo line1 > a
163 hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change'
408 $ echo line0 >> a
164 echo % hg import in a subdirectory
409 $ echo line3 >> a
165 hg clone -r0 a b
410 $ hg ci -Am adda
166 hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch
411 adding a
167 dir=`pwd`
412 $ echo line1 > a
168 cd b/d1/d2 2>&1 > /dev/null
413 $ echo line2 >> a
169 hg import ../../../tip.patch
414 $ echo line0 >> a
170 cd "$dir"
415 $ echo line3 >> a
171 echo "% message should be 'subdir change'"
416 $ hg ci -m change a
172 hg --cwd b tip | grep 'subdir change'
417 $ hg export tip > tip.patch
173 echo "% committer should be 'someoneelse'"
418 $ hg up -C 0
174 hg --cwd b tip | grep someoneelse
419 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 echo "% should be empty"
420 $ echo line1 > a
176 hg --cwd b status
421 $ echo line0 >> a
422 $ echo line1 >> a
423 $ echo line0 >> a
424 $ hg ci -m brancha
425 created new head
426 $ hg import --no-commit -v tip.patch
427 applying tip.patch
428 patching file a
429 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
430 $ hg revert -a
431 reverting a
432
433 test fuzziness with eol=auto
434
435 $ hg --config patch.eol=auto import --no-commit -v tip.patch
436 applying tip.patch
437 patching file a
438 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
439 $ cd ..
177
440
178
441
179 # Test fuzziness (ambiguous patch location, fuzz=2)
442 Test hunk touching empty files (issue906)
180 echo % test fuzziness
181 hg init fuzzy
182 cd fuzzy
183 echo line1 > a
184 echo line0 >> a
185 echo line3 >> a
186 hg ci -Am adda
187 echo line1 > a
188 echo line2 >> a
189 echo line0 >> a
190 echo line3 >> a
191 hg ci -m change a
192 hg export tip > tip.patch
193 hg up -C 0
194 echo line1 > a
195 echo line0 >> a
196 echo line1 >> a
197 echo line0 >> a
198 hg ci -m brancha
199 hg import --no-commit -v tip.patch
200 hg revert -a
201 echo '% test fuzziness with eol=auto'
202 hg --config patch.eol=auto import --no-commit -v tip.patch
203 cd ..
204
443
205 # Test hunk touching empty files (issue906)
444 $ hg init empty
206 hg init empty
445 $ cd empty
207 cd empty
446 $ touch a
208 touch a
447 $ touch b1
209 touch b1
448 $ touch c1
210 touch c1
449 $ echo d > d
211 echo d > d
450 $ hg ci -Am init
212 hg ci -Am init
451 adding a
213 echo a > a
452 adding b1
214 echo b > b1
453 adding c1
215 hg mv b1 b2
454 adding d
216 echo c > c1
455 $ echo a > a
217 hg copy c1 c2
456 $ echo b > b1
218 rm d
457 $ hg mv b1 b2
219 touch d
458 $ echo c > c1
220 hg diff --git
459 $ hg copy c1 c2
221 hg ci -m empty
460 $ rm d
222 hg export --git tip > empty.diff
461 $ touch d
223 hg up -C 0
462 $ hg diff --git
224 hg import empty.diff
463 diff --git a/a b/a
225 for name in a b1 b2 c1 c2 d;
464 --- a/a
226 do
465 +++ b/a
227 echo % $name file
466 @@ -0,0 +1,1 @@
228 test -f $name && cat $name
467 +a
229 done
468 diff --git a/b1 b/b2
230 cd ..
469 rename from b1
470 rename to b2
471 --- a/b1
472 +++ b/b2
473 @@ -0,0 +1,1 @@
474 +b
475 diff --git a/c1 b/c1
476 --- a/c1
477 +++ b/c1
478 @@ -0,0 +1,1 @@
479 +c
480 diff --git a/c1 b/c2
481 copy from c1
482 copy to c2
483 --- a/c1
484 +++ b/c2
485 @@ -0,0 +1,1 @@
486 +c
487 diff --git a/d b/d
488 --- a/d
489 +++ b/d
490 @@ -1,1 +0,0 @@
491 -d
492 $ hg ci -m empty
493 $ hg export --git tip > empty.diff
494 $ hg up -C 0
495 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
496 $ hg import empty.diff
497 applying empty.diff
498 $ for name in a b1 b2 c1 c2 d; do
499 > echo % $name file
500 > test -f $name && cat $name
501 > done
502 % a file
503 a
504 % b1 file
505 % b2 file
506 b
507 % c1 file
508 c
509 % c2 file
510 c
511 % d file
512 $ cd ..
231
513
232 # Test importing a patch ending with a binary file removal
514
233 echo % test trailing binary removal
515 Test importing a patch ending with a binary file removal
234 hg init binaryremoval
516
235 cd binaryremoval
517 $ hg init binaryremoval
236 echo a > a
518 $ cd binaryremoval
237 python -c "file('b', 'wb').write('a\x00b')"
519 $ echo a > a
238 hg ci -Am addall
520 $ python -c "file('b', 'wb').write('a\x00b')"
239 hg rm a
521 $ hg ci -Am addall
240 hg rm b
522 adding a
241 hg st
523 adding b
242 hg ci -m remove
524 $ hg rm a
243 hg export --git . > remove.diff
525 $ hg rm b
244 cat remove.diff | grep git
526 $ hg st
245 hg up -C 0
527 R a
246 hg import remove.diff
528 R b
247 hg manifest
529 $ hg ci -m remove
248 cd ..
530 $ hg export --git . > remove.diff
531 $ cat remove.diff | grep git
532 diff --git a/a b/a
533 diff --git a/b b/b
534 $ hg up -C 0
535 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
536 $ hg import remove.diff
537 applying remove.diff
538 $ hg manifest
539 $ cd ..
540
541
542 test update+rename with common name (issue 927)
249
543
250 echo % 'test update+rename with common name (issue 927)'
544 $ hg init t
251 hg init t
545 $ cd t
252 cd t
546 $ touch a
253 touch a
547 $ hg ci -Am t
254 hg ci -Am t
548 adding a
255 echo a > a
549 $ echo a > a
256 # Here, bfile.startswith(afile)
550
257 hg copy a a2
551 Here, bfile.startswith(afile)
258 hg ci -m copya
552
259 hg export --git tip > copy.diff
553 $ hg copy a a2
260 hg up -C 0
554 $ hg ci -m copya
261 hg import copy.diff
555 $ hg export --git tip > copy.diff
262 echo % view a
556 $ hg up -C 0
263 # a should contain an 'a'
557 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
264 cat a
558 $ hg import copy.diff
265 echo % view a2
559 applying copy.diff
266 # and a2 should have duplicated it
560
267 cat a2
561 a should contain an 'a'
268 cd ..
562
563 $ cat a
564 a
565
566 and a2 should have duplicated it
269
567
270 echo % 'test -p0'
568 $ cat a2
271 hg init p0
569 a
272 cd p0
570 $ cd ..
273 echo a > a
571
274 hg ci -Am t
572
275 hg import -p0 - << EOF
573 test -p0
276 foobar
574
277 --- a Sat Apr 12 22:43:58 2008 -0400
575 $ hg init p0
278 +++ a Sat Apr 12 22:44:05 2008 -0400
576 $ cd p0
279 @@ -1,1 +1,1 @@
577 $ echo a > a
280 -a
578 $ hg ci -Am t
281 +bb
579 adding a
282 EOF
580 $ hg import -p0 - << EOF
283 hg status
581 > foobar
284 cat a
582 > --- a Sat Apr 12 22:43:58 2008 -0400
285 cd ..
583 > +++ a Sat Apr 12 22:44:05 2008 -0400
584 > @@ -1,1 +1,1 @@
585 > -a
586 > +bb
587 > EOF
588 applying patch from stdin
589 $ hg status
590 $ cat a
591 bb
592 $ cd ..
593
594
595 test paths outside repo root
286
596
287 echo % 'test paths outside repo root'
597 $ mkdir outside
288 mkdir outside
598 $ touch outside/foo
289 touch outside/foo
599 $ hg init inside
290 hg init inside
600 $ cd inside
291 cd inside
601 $ hg import - <<EOF
292 hg import - <<EOF
602 > diff --git a/a b/b
293 diff --git a/a b/b
603 > rename from ../outside/foo
294 rename from ../outside/foo
604 > rename to bar
295 rename to bar
605 > EOF
296 EOF
606 applying patch from stdin
297 cd ..
607 abort: ../outside/foo not under root
608 $ cd ..
609
610
611 test import with similarity and git and strip (issue295 et al.)
298
612
299 echo '% test import with similarity and git and strip (issue295 et al.)'
613 $ hg init sim
300 hg init sim
614 $ cd sim
301 cd sim
615 $ echo 'this is a test' > a
302 echo 'this is a test' > a
616 $ hg ci -Ama
303 hg ci -Ama
617 adding a
304 cat > ../rename.diff <<EOF
618 $ cat > ../rename.diff <<EOF
305 diff --git a/foo/a b/foo/a
619 > diff --git a/foo/a b/foo/a
306 deleted file mode 100644
620 > deleted file mode 100644
307 --- a/foo/a
621 > --- a/foo/a
308 +++ /dev/null
622 > +++ /dev/null
309 @@ -1,1 +0,0 @@
623 > @@ -1,1 +0,0 @@
310 -this is a test
624 > -this is a test
311 diff --git a/foo/b b/foo/b
625 > diff --git a/foo/b b/foo/b
312 new file mode 100644
626 > new file mode 100644
313 --- /dev/null
627 > --- /dev/null
314 +++ b/foo/b
628 > +++ b/foo/b
315 @@ -0,0 +1,2 @@
629 > @@ -0,0 +1,2 @@
316 +this is a test
630 > +this is a test
317 +foo
631 > +foo
318 EOF
632 > EOF
319 hg import --no-commit -v -s 1 ../rename.diff -p2
633 $ hg import --no-commit -v -s 1 ../rename.diff -p2
320 hg st -C
634 applying ../rename.diff
321 hg revert -a
635 patching file a
322 rm b
636 patching file b
323 hg import --no-commit -v -s 100 ../rename.diff -p2
637 removing a
324 hg st -C
638 adding b
325 cd ..
639 recording removal of a as rename to b (88% similar)
640 $ hg st -C
641 A b
642 a
643 R a
644 $ hg revert -a
645 undeleting a
646 forgetting b
647 $ rm b
648 $ hg import --no-commit -v -s 100 ../rename.diff -p2
649 applying ../rename.diff
650 patching file a
651 patching file b
652 removing a
653 adding b
654 $ hg st -C
655 A b
656 R a
657 $ cd ..
326
658
327
659
328 echo '% add empty file from the end of patch (issue 1495)'
660 add empty file from the end of patch (issue 1495)
329 hg init addemptyend
661
330 cd addemptyend
662 $ hg init addemptyend
331 touch a
663 $ cd addemptyend
332 hg addremove
664 $ touch a
333 hg ci -m "commit"
665 $ hg addremove
334 cat > a.patch <<EOF
666 adding a
335 diff --git a/a b/a
667 $ hg ci -m "commit"
336 --- a/a
668 $ cat > a.patch <<EOF
337 +++ b/a
669 > diff --git a/a b/a
338 @@ -0,0 +1,1 @@
670 > --- a/a
339 +a
671 > +++ b/a
340 diff --git a/b b/b
672 > @@ -0,0 +1,1 @@
341 new file mode 100644
673 > +a
342 EOF
674 > diff --git a/b b/b
343 hg import --no-commit a.patch
675 > new file mode 100644
344 cd ..
676 > EOF
677 $ hg import --no-commit a.patch
678 applying a.patch
679 $ cd ..
680
681
682 create file when source is not /dev/null
683
684 $ cat > create.patch <<EOF
685 > diff -Naur proj-orig/foo proj-new/foo
686 > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800
687 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
688 > @@ -0,0 +1,1 @@
689 > +a
690 > EOF
691
692 some people have patches like the following too
345
693
346 echo '% create file when source is not /dev/null'
694 $ cat > create2.patch <<EOF
347 cat > create.patch <<EOF
695 > diff -Naur proj-orig/foo proj-new/foo
348 diff -Naur proj-orig/foo proj-new/foo
696 > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800
349 --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800
697 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
350 +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
698 > @@ -0,0 +1,1 @@
351 @@ -0,0 +1,1 @@
699 > +a
352 +a
700 > EOF
353 EOF
701 $ hg init oddcreate
354 # some people have patches like the following too
702 $ cd oddcreate
355 cat > create2.patch <<EOF
703 $ hg import --no-commit ../create.patch
356 diff -Naur proj-orig/foo proj-new/foo
704 applying ../create.patch
357 --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800
705 $ cat foo
358 +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
706 a
359 @@ -0,0 +1,1 @@
707 $ rm foo
360 +a
708 $ hg revert foo
361 EOF
709 $ hg import --no-commit ../create2.patch
362 hg init oddcreate
710 applying ../create2.patch
363 cd oddcreate
711 $ cat foo
364 hg import --no-commit ../create.patch
712 a
365 cat foo
713
366 rm foo
714
367 hg revert foo
715 first line mistaken for email headers (issue 1859)
368 hg import --no-commit ../create2.patch
369 cat foo
370
716
371 echo % 'first line mistaken for email headers (issue 1859)'
717 $ hg init emailconfusion
372 hg init emailconfusion
718 $ cd emailconfusion
373 cd emailconfusion
719 $ cat > a.patch <<EOF
374 cat > a.patch <<EOF
720 > module: summary
375 module: summary
721 >
376
722 > description
377 description
723 >
724 >
725 > diff -r 000000000000 -r 9b4c1e343b55 test.txt
726 > --- /dev/null
727 > +++ b/a
728 > @@ -0,0 +1,1 @@
729 > +a
730 > EOF
731 $ hg import -d '0 0' a.patch
732 applying a.patch
733 $ hg parents -v
734 changeset: 0:5a681217c0ad
735 tag: tip
736 user: test
737 date: Thu Jan 01 00:00:00 1970 +0000
738 files: a
739 description:
740 module: summary
741
742 description
743
744
745 $ cd ..
378
746
379
747
380 diff -r 000000000000 -r 9b4c1e343b55 test.txt
748 --- in commit message
381 --- /dev/null
382 +++ b/a
383 @@ -0,0 +1,1 @@
384 +a
385 EOF
386 hg import -d '0 0' a.patch
387 hg parents -v
388 cd ..
389
390 echo % '--- in commit message'
391 hg init commitconfusion
392 cd commitconfusion
393 cat > a.patch <<EOF
394 module: summary
395
396 --- description
397
749
398 diff --git a/a b/a
750 $ hg init commitconfusion
399 new file mode 100644
751 $ cd commitconfusion
400 --- /dev/null
752 $ cat > a.patch <<EOF
401 +++ b/a
753 > module: summary
402 @@ -0,0 +1,1 @@
754 >
403 +a
755 > --- description
404 EOF
756 >
405 hg import -d '0 0' a.patch
757 > diff --git a/a b/a
406 hg parents -v
758 > new file mode 100644
407 cd ..
759 > --- /dev/null
408
760 > +++ b/a
409 echo '% tricky header splitting'
761 > @@ -0,0 +1,1 @@
410 cat > trickyheaders.patch <<EOF
762 > +a
411 From: User A <user@a>
763 > EOF
412 Subject: [PATCH] from: tricky!
764 > hg import -d '0 0' a.patch
765 > hg parents -v
766 > cd ..
767 >
768 > echo '% tricky header splitting'
769 > cat > trickyheaders.patch <<EOF
770 > From: User A <user@a>
771 > Subject: [PATCH] from: tricky!
772 >
773 > # HG changeset patch
774 > # User User B
775 > # Date 1266264441 18000
776 > # Branch stable
777 > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0
778 > # Parent 0000000000000000000000000000000000000000
779 > from: tricky!
780 >
781 > That is not a header.
782 >
783 > diff -r 000000000000 -r f2be6a1170ac foo
784 > --- /dev/null
785 > +++ b/foo
786 > @@ -0,0 +1,1 @@
787 > +foo
788 > EOF
789 applying a.patch
790 changeset: 0:f34d9187897d
791 tag: tip
792 user: test
793 date: Thu Jan 01 00:00:00 1970 +0000
794 files: a
795 description:
796 module: summary
797
798
799 % tricky header splitting
413
800
414 # HG changeset patch
801 $ hg init trickyheaders
415 # User User B
802 $ cd trickyheaders
416 # Date 1266264441 18000
803 $ hg import -d '0 0' ../trickyheaders.patch
417 # Branch stable
804 applying ../trickyheaders.patch
418 # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0
805 $ hg export --git tip
419 # Parent 0000000000000000000000000000000000000000
806 # HG changeset patch
420 from: tricky!
807 # User User B
421
808 # Date 0 0
422 That is not a header.
809 # Node ID eb56ab91903632294ac504838508cb370c0901d2
810 # Parent 0000000000000000000000000000000000000000
811 from: tricky!
812
813 That is not a header.
814
815 diff --git a/foo b/foo
816 new file mode 100644
817 --- /dev/null
818 +++ b/foo
819 @@ -0,0 +1,1 @@
820 +foo
821 $ cd ..
423
822
424 diff -r 000000000000 -r f2be6a1170ac foo
425 --- /dev/null
426 +++ b/foo
427 @@ -0,0 +1,1 @@
428 +foo
429 EOF
430
823
431 hg init trickyheaders
824 issue2102
432 cd trickyheaders
433 hg import -d '0 0' ../trickyheaders.patch
434 hg export --git tip
435 cd ..
436
825
437 echo '% issue2102'
826 $ hg init issue2102
438 hg init issue2102
827 $ cd issue2102
439 cd issue2102
828 $ mkdir -p src/cmd/gc
440 mkdir -p src/cmd/gc
829 $ touch src/cmd/gc/mksys.bash
441 touch src/cmd/gc/mksys.bash
830 $ hg ci -Am init
442 hg ci -Am init
831 adding src/cmd/gc/mksys.bash
443 hg import - <<EOF
832 $ hg import - <<EOF
444 # HG changeset patch
833 > # HG changeset patch
445 # User Rob Pike
834 > # User Rob Pike
446 # Date 1216685449 25200
835 > # Date 1216685449 25200
447 # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98
836 > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98
448 # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84
837 > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84
449 help management of empty pkg and lib directories in perforce
838 > help management of empty pkg and lib directories in perforce
450
839 >
451 R=gri
840 > R=gri
452 DELTA=4 (4 added, 0 deleted, 0 changed)
841 > DELTA=4 (4 added, 0 deleted, 0 changed)
453 OCL=13328
842 > OCL=13328
454 CL=13328
843 > CL=13328
844 >
845 > diff --git a/lib/place-holder b/lib/place-holder
846 > new file mode 100644
847 > --- /dev/null
848 > +++ b/lib/place-holder
849 > @@ -0,0 +1,2 @@
850 > +perforce does not maintain empty directories.
851 > +this file helps.
852 > diff --git a/pkg/place-holder b/pkg/place-holder
853 > new file mode 100644
854 > --- /dev/null
855 > +++ b/pkg/place-holder
856 > @@ -0,0 +1,2 @@
857 > +perforce does not maintain empty directories.
858 > +this file helps.
859 > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
860 > old mode 100644
861 > new mode 100755
862 > EOF
863 applying patch from stdin
864 $ hg sum
865 parent: 1:d59915696727 tip
866 help management of empty pkg and lib directories in perforce
867 branch: default
868 commit: (clean)
869 update: (current)
870 $ hg diff --git -c tip
871 diff --git a/lib/place-holder b/lib/place-holder
872 new file mode 100644
873 --- /dev/null
874 +++ b/lib/place-holder
875 @@ -0,0 +1,2 @@
876 +perforce does not maintain empty directories.
877 +this file helps.
878 diff --git a/pkg/place-holder b/pkg/place-holder
879 new file mode 100644
880 --- /dev/null
881 +++ b/pkg/place-holder
882 @@ -0,0 +1,2 @@
883 +perforce does not maintain empty directories.
884 +this file helps.
885 diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
886 old mode 100644
887 new mode 100755
888 $ cd ..
455
889
456 diff --git a/lib/place-holder b/lib/place-holder
890
457 new file mode 100644
891 diff lines looking like headers
458 --- /dev/null
892
459 +++ b/lib/place-holder
893 $ hg init difflineslikeheaders
460 @@ -0,0 +1,2 @@
894 $ cd difflineslikeheaders
461 +perforce does not maintain empty directories.
895 $ echo a >a
462 +this file helps.
896 $ echo b >b
463 diff --git a/pkg/place-holder b/pkg/place-holder
897 $ echo c >c
464 new file mode 100644
898 $ hg ci -Am1
465 --- /dev/null
899 adding a
466 +++ b/pkg/place-holder
900 adding b
467 @@ -0,0 +1,2 @@
901 adding c
468 +perforce does not maintain empty directories.
469 +this file helps.
470 diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
471 old mode 100644
472 new mode 100755
473 EOF
474 hg sum
475 hg diff --git -c tip
476 cd ..
477
902
478 echo '% diff lines looking like headers'
903 $ echo "key: value" >>a
479 hg init difflineslikeheaders
904 $ echo "key: value" >>b
480 cd difflineslikeheaders
905 $ echo "foo" >>c
481 echo a >a
906 $ hg ci -m2
482 echo b >b
483 echo c >c
484 hg ci -Am1
485
907
486 echo "key: value" >>a
908 $ hg up -C 0
487 echo "key: value" >>b
909 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
488 echo "foo" >>c
910 $ hg diff --git -c1 >want
489 hg ci -m2
911 $ hg diff -c1 | hg import --no-commit -
912 applying patch from stdin
913 $ hg diff --git >have
914 $ diff want have
915 $ cd ..
490
916
491 hg up -C 0
492 hg diff --git -c1 >want
493 hg diff -c1 | hg import --no-commit -
494 hg diff --git >have
495 diff want have
496 cd ..
497
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now