Show More
@@ -0,0 +1,81 b'' | |||
|
1 | #!/bin/sh | |
|
2 | ||
|
3 | hg init a | |
|
4 | echo line 1 > a/a | |
|
5 | hg --cwd a ci -d '0 0' -Ama | |
|
6 | ||
|
7 | echo line 2 >> a/a | |
|
8 | hg --cwd a ci -u someone -d '1 0' -m'second change' | |
|
9 | ||
|
10 | echo % import exported patch | |
|
11 | hg clone -r0 a b | |
|
12 | hg --cwd a export tip > tip.patch | |
|
13 | hg --cwd b import ../tip.patch | |
|
14 | echo % message should be same | |
|
15 | hg --cwd b tip | grep 'second change' | |
|
16 | echo % committer should be same | |
|
17 | hg --cwd b tip | grep someone | |
|
18 | rm -rf b | |
|
19 | ||
|
20 | echo % import of plain diff should fail without message | |
|
21 | hg clone -r0 a b | |
|
22 | hg --cwd a diff -r0:1 > tip.patch | |
|
23 | hg --cwd b import ../tip.patch | |
|
24 | rm -rf b | |
|
25 | ||
|
26 | echo % import of plain diff should be ok with message | |
|
27 | hg clone -r0 a b | |
|
28 | hg --cwd a diff -r0:1 > tip.patch | |
|
29 | hg --cwd b import -mpatch ../tip.patch | |
|
30 | rm -rf b | |
|
31 | ||
|
32 | echo % import from stdin | |
|
33 | hg clone -r0 a b | |
|
34 | hg --cwd a export tip | hg --cwd b import - | |
|
35 | rm -rf b | |
|
36 | ||
|
37 | echo % override commit message | |
|
38 | hg clone -r0 a b | |
|
39 | hg --cwd a export tip | hg --cwd b import -m 'override' - | |
|
40 | hg --cwd b tip | grep override | |
|
41 | rm -rf b | |
|
42 | ||
|
43 | cat > mkmsg.py <<EOF | |
|
44 | import email.Message, sys | |
|
45 | msg = email.Message.Message() | |
|
46 | msg.set_payload('email commit message\n' + open('tip.patch').read()) | |
|
47 | msg['Subject'] = 'email patch' | |
|
48 | msg['From'] = 'email patcher' | |
|
49 | sys.stdout.write(msg.as_string()) | |
|
50 | EOF | |
|
51 | ||
|
52 | echo % plain diff in email, subject, message body | |
|
53 | hg clone -r0 a b | |
|
54 | hg --cwd a diff -r0:1 > tip.patch | |
|
55 | python mkmsg.py > msg.patch | |
|
56 | hg --cwd b import ../msg.patch | |
|
57 | hg --cwd b tip | grep email | |
|
58 | rm -rf b | |
|
59 | ||
|
60 | echo % plain diff in email, no subject, message body | |
|
61 | hg clone -r0 a b | |
|
62 | grep -v '^Subject:' msg.patch | hg --cwd b import - | |
|
63 | rm -rf b | |
|
64 | ||
|
65 | echo % plain diff in email, subject, no message body | |
|
66 | hg clone -r0 a b | |
|
67 | grep -v '^email ' msg.patch | hg --cwd b import - | |
|
68 | rm -rf b | |
|
69 | ||
|
70 | echo % plain diff in email, no subject, no message body, should fail | |
|
71 | hg clone -r0 a b | |
|
72 | grep -v '^\(Subject\|email\)' msg.patch | hg --cwd b import - | |
|
73 | rm -rf b | |
|
74 | ||
|
75 | echo % hg export in email, should use patch header | |
|
76 | hg clone -r0 a b | |
|
77 | hg --cwd a export tip > tip.patch | |
|
78 | python mkmsg.py | hg --cwd b import - | |
|
79 | hg --cwd b tip | grep second | |
|
80 | rm -rf b | |
|
81 |
@@ -0,0 +1,103 b'' | |||
|
1 | adding a | |
|
2 | % import exported patch | |
|
3 | requesting all changes | |
|
4 | adding changesets | |
|
5 | adding manifests | |
|
6 | adding file changes | |
|
7 | added 1 changesets with 1 changes to 1 files | |
|
8 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
9 | applying ../tip.patch | |
|
10 | patching file a | |
|
11 | % message should be same | |
|
12 | summary: second change | |
|
13 | % committer should be same | |
|
14 | user: someone | |
|
15 | % import of plain diff should fail without message | |
|
16 | requesting all changes | |
|
17 | adding changesets | |
|
18 | adding manifests | |
|
19 | adding file changes | |
|
20 | added 1 changesets with 1 changes to 1 files | |
|
21 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
22 | applying ../tip.patch | |
|
23 | patching file a | |
|
24 | transaction abort! | |
|
25 | rollback completed | |
|
26 | % import of plain diff should be ok with message | |
|
27 | requesting all changes | |
|
28 | adding changesets | |
|
29 | adding manifests | |
|
30 | adding file changes | |
|
31 | added 1 changesets with 1 changes to 1 files | |
|
32 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
33 | applying ../tip.patch | |
|
34 | patching file a | |
|
35 | % import from stdin | |
|
36 | requesting all changes | |
|
37 | adding changesets | |
|
38 | adding manifests | |
|
39 | adding file changes | |
|
40 | added 1 changesets with 1 changes to 1 files | |
|
41 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
42 | applying patch from stdin | |
|
43 | patching file a | |
|
44 | % override commit message | |
|
45 | requesting all changes | |
|
46 | adding changesets | |
|
47 | adding manifests | |
|
48 | adding file changes | |
|
49 | added 1 changesets with 1 changes to 1 files | |
|
50 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
51 | applying patch from stdin | |
|
52 | patching file a | |
|
53 | summary: override | |
|
54 | % plain diff in email, subject, message body | |
|
55 | requesting all changes | |
|
56 | adding changesets | |
|
57 | adding manifests | |
|
58 | adding file changes | |
|
59 | added 1 changesets with 1 changes to 1 files | |
|
60 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
61 | applying ../msg.patch | |
|
62 | patching file a | |
|
63 | user: email patcher | |
|
64 | summary: email patch | |
|
65 | % plain diff in email, no subject, message body | |
|
66 | requesting all changes | |
|
67 | adding changesets | |
|
68 | adding manifests | |
|
69 | adding file changes | |
|
70 | added 1 changesets with 1 changes to 1 files | |
|
71 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
72 | applying patch from stdin | |
|
73 | patching file a | |
|
74 | % plain diff in email, subject, no message body | |
|
75 | requesting all changes | |
|
76 | adding changesets | |
|
77 | adding manifests | |
|
78 | adding file changes | |
|
79 | added 1 changesets with 1 changes to 1 files | |
|
80 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
81 | applying patch from stdin | |
|
82 | patching file a | |
|
83 | % plain diff in email, no subject, no message body, should fail | |
|
84 | requesting all changes | |
|
85 | adding changesets | |
|
86 | adding manifests | |
|
87 | adding file changes | |
|
88 | added 1 changesets with 1 changes to 1 files | |
|
89 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
90 | applying patch from stdin | |
|
91 | patching file a | |
|
92 | transaction abort! | |
|
93 | rollback completed | |
|
94 | % hg export in email, should use patch header | |
|
95 | requesting all changes | |
|
96 | adding changesets | |
|
97 | adding manifests | |
|
98 | adding file changes | |
|
99 | added 1 changesets with 1 changes to 1 files | |
|
100 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
101 | applying patch from stdin | |
|
102 | patching file a | |
|
103 | summary: second change |
@@ -1787,10 +1787,16 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1787 | 1787 | diffs_seen += 1 |
|
1788 | 1788 | hgpatch = False |
|
1789 | 1789 | fp = cStringIO.StringIO() |
|
1790 | if message: | |
|
1791 | fp.write(message) | |
|
1792 | fp.write('\n') | |
|
1790 | 1793 | for line in payload[:m.start(0)].splitlines(): |
|
1791 | 1794 | if line.startswith('# HG changeset patch'): |
|
1792 | 1795 | ui.debug(_('patch generated by hg export\n')) |
|
1793 | 1796 | hgpatch = True |
|
1797 | # drop earlier commit message content | |
|
1798 | fp.seek(0) | |
|
1799 | fp.truncate() | |
|
1794 | 1800 | elif hgpatch: |
|
1795 | 1801 | if line.startswith('# User '): |
|
1796 | 1802 | user = line[7:] |
@@ -1800,8 +1806,7 b' def import_(ui, repo, patch1, *patches, ' | |||
|
1800 | 1806 | if not line.startswith('# '): |
|
1801 | 1807 | fp.write(line) |
|
1802 | 1808 | fp.write('\n') |
|
1803 |
|
|
|
1804 | message = fp.getvalue() or message | |
|
1809 | message = fp.getvalue() | |
|
1805 | 1810 | if tmpfp: |
|
1806 | 1811 | tmpfp.write(payload) |
|
1807 | 1812 | if not payload.endswith('\n'): |
General Comments 0
You need to be logged in to leave comments.
Login now