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