Show More
@@ -1,83 +1,83 b'' | |||
|
1 | 1 | $ echo '[extensions]' >> $HGRCPATH |
|
2 | 2 | $ echo 'strip =' >> $HGRCPATH |
|
3 | 3 | |
|
4 | 4 | $ cat >findbranch.py <<EOF |
|
5 | 5 | > from __future__ import absolute_import |
|
6 | 6 | > import re |
|
7 | 7 | > import sys |
|
8 | 8 | > |
|
9 | 9 | > head_re = re.compile('^#(?:(?:\\s+([A-Za-z][A-Za-z0-9_]*)(?:\\s.*)?)|(?:\\s*))$') |
|
10 | 10 | > |
|
11 | 11 | > for line in sys.stdin: |
|
12 | 12 | > hmatch = head_re.match(line) |
|
13 | 13 | > if not hmatch: |
|
14 | 14 | > sys.exit(1) |
|
15 | 15 | > if hmatch.group(1) == 'Branch': |
|
16 | 16 | > sys.exit(0) |
|
17 | 17 | > sys.exit(1) |
|
18 | 18 | > EOF |
|
19 | 19 | |
|
20 | 20 | $ hg init a |
|
21 | 21 | $ cd a |
|
22 | 22 | $ echo "Rev 1" >rev |
|
23 | 23 | $ hg add rev |
|
24 | 24 | $ hg commit -m "No branch." |
|
25 | 25 | $ hg branch abranch |
|
26 | 26 | marked working directory as branch abranch |
|
27 | 27 | (branches are permanent and global, did you want a bookmark?) |
|
28 | 28 | $ echo "Rev 2" >rev |
|
29 | 29 | $ hg commit -m "With branch." |
|
30 | 30 | |
|
31 | 31 | $ hg export 0 > ../r0.patch |
|
32 | 32 | $ hg export 1 > ../r1.patch |
|
33 | 33 | $ cd .. |
|
34 | 34 | |
|
35 | 35 | $ if $PYTHON findbranch.py < r0.patch; then |
|
36 | 36 | > echo "Export of default branch revision has Branch header" 1>&2 |
|
37 | 37 | > exit 1 |
|
38 | 38 | > fi |
|
39 | 39 | |
|
40 | 40 | $ if $PYTHON findbranch.py < r1.patch; then |
|
41 | 41 | > : # Do nothing |
|
42 | 42 | > else |
|
43 | 43 | > echo "Export of branch revision is missing Branch header" 1>&2 |
|
44 | 44 | > exit 1 |
|
45 | 45 | > fi |
|
46 | 46 | |
|
47 | 47 | Make sure import still works with branch information in patches. |
|
48 | 48 | |
|
49 | 49 | $ hg init b |
|
50 | 50 | $ cd b |
|
51 | 51 | $ hg import ../r0.patch |
|
52 | 52 | applying ../r0.patch |
|
53 | 53 | $ hg import ../r1.patch |
|
54 | 54 | applying ../r1.patch |
|
55 | 55 | $ cd .. |
|
56 | 56 | |
|
57 | 57 | $ hg init c |
|
58 | 58 | $ cd c |
|
59 | 59 | $ hg import --exact --no-commit ../r0.patch |
|
60 | 60 | applying ../r0.patch |
|
61 | 61 | warning: can't check exact import with --no-commit |
|
62 | 62 | $ hg st |
|
63 | 63 | A rev |
|
64 | 64 | $ hg revert -a |
|
65 | 65 | forgetting rev |
|
66 | 66 | $ rm rev |
|
67 | 67 | $ hg import --exact ../r0.patch |
|
68 | 68 | applying ../r0.patch |
|
69 | 69 | $ hg import --exact ../r1.patch |
|
70 | 70 | applying ../r1.patch |
|
71 | 71 | |
|
72 | 72 | Test --exact and patch header separators (issue3356) |
|
73 | 73 | |
|
74 | 74 | $ hg strip --no-backup . |
|
75 | 75 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
76 | 76 | >>> import re |
|
77 | 77 | >>> p = open('../r1.patch', 'rb').read() |
|
78 | >>> p = re.sub(r'Parent\s+', 'Parent ', p) | |
|
79 | >>> open('../r1-ws.patch', 'wb').write(p) | |
|
78 | >>> p = re.sub(br'Parent\s+', b'Parent ', p) | |
|
79 | >>> open('../r1-ws.patch', 'wb').write(p) and None | |
|
80 | 80 | $ hg import --exact ../r1-ws.patch |
|
81 | 81 | applying ../r1-ws.patch |
|
82 | 82 | |
|
83 | 83 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now