Show More
@@ -1,131 +1,131 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
3 | hg init a |
|
3 | hg init a | |
4 | mkdir a/d1 |
|
4 | mkdir a/d1 | |
5 | mkdir a/d1/d2 |
|
5 | mkdir a/d1/d2 | |
6 | echo line 1 > a/a |
|
6 | echo line 1 > a/a | |
7 | echo line 1 > a/d1/d2/a |
|
7 | echo line 1 > a/d1/d2/a | |
8 | hg --cwd a ci -d '0 0' -Ama |
|
8 | hg --cwd a ci -d '0 0' -Ama | |
9 |
|
9 | |||
10 | echo line 2 >> a/a |
|
10 | echo line 2 >> a/a | |
11 | hg --cwd a ci -u someone -d '1 0' -m'second change' |
|
11 | hg --cwd a ci -u someone -d '1 0' -m'second change' | |
12 |
|
12 | |||
13 | echo % import exported patch |
|
13 | echo % import exported patch | |
14 | hg clone -r0 a b |
|
14 | hg clone -r0 a b | |
15 | hg --cwd a export tip > tip.patch |
|
15 | hg --cwd a export tip > tip.patch | |
16 | hg --cwd b import ../tip.patch |
|
16 | hg --cwd b import ../tip.patch | |
17 | echo % message should be same |
|
17 | echo % message should be same | |
18 | hg --cwd b tip | grep 'second change' |
|
18 | hg --cwd b tip | grep 'second change' | |
19 | echo % committer should be same |
|
19 | echo % committer should be same | |
20 | hg --cwd b tip | grep someone |
|
20 | hg --cwd b tip | grep someone | |
21 | rm -r b |
|
21 | rm -r b | |
22 |
|
22 | |||
23 | echo % import of plain diff should fail without message |
|
23 | echo % import of plain diff should fail without message | |
24 | hg clone -r0 a b |
|
24 | hg clone -r0 a b | |
25 | hg --cwd a diff -r0:1 > tip.patch |
|
25 | hg --cwd a diff -r0:1 > tip.patch | |
26 | hg --cwd b import ../tip.patch |
|
26 | hg --cwd b import ../tip.patch | |
27 | rm -r b |
|
27 | rm -r b | |
28 |
|
28 | |||
29 | echo % import of plain diff should be ok with message |
|
29 | echo % import of plain diff should be ok with message | |
30 | hg clone -r0 a b |
|
30 | hg clone -r0 a b | |
31 | hg --cwd a diff -r0:1 > tip.patch |
|
31 | hg --cwd a diff -r0:1 > tip.patch | |
32 | hg --cwd b import -mpatch ../tip.patch |
|
32 | hg --cwd b import -mpatch ../tip.patch | |
33 | rm -r b |
|
33 | rm -r b | |
34 |
|
34 | |||
35 | echo % hg -R repo import |
|
35 | echo % hg -R repo import | |
36 | # put the clone in a subdir - having a directory named "a" |
|
36 | # put the clone in a subdir - having a directory named "a" | |
37 | # used to hide a bug. |
|
37 | # used to hide a bug. | |
38 | mkdir dir |
|
38 | mkdir dir | |
39 | hg clone -r0 a dir/b |
|
39 | hg clone -r0 a dir/b | |
40 | hg --cwd a export tip > dir/tip.patch |
|
40 | hg --cwd a export tip > dir/tip.patch | |
41 | cd dir |
|
41 | cd dir | |
42 | hg -R b import tip.patch |
|
42 | hg -R b import tip.patch | |
43 | cd .. |
|
43 | cd .. | |
44 | rm -r dir |
|
44 | rm -r dir | |
45 |
|
45 | |||
46 | echo % import from stdin |
|
46 | echo % import from stdin | |
47 | hg clone -r0 a b |
|
47 | hg clone -r0 a b | |
48 | hg --cwd a export tip | hg --cwd b import - |
|
48 | hg --cwd a export tip | hg --cwd b import - | |
49 | rm -r b |
|
49 | rm -r b | |
50 |
|
50 | |||
51 | echo % override commit message |
|
51 | echo % override commit message | |
52 | hg clone -r0 a b |
|
52 | hg clone -r0 a b | |
53 | hg --cwd a export tip | hg --cwd b import -m 'override' - |
|
53 | hg --cwd a export tip | hg --cwd b import -m 'override' - | |
54 | hg --cwd b tip | grep override |
|
54 | hg --cwd b tip | grep override | |
55 | rm -r b |
|
55 | rm -r b | |
56 |
|
56 | |||
57 | cat > mkmsg.py <<EOF |
|
57 | cat > mkmsg.py <<EOF | |
58 | import email.Message, sys |
|
58 | import email.Message, sys | |
59 | msg = email.Message.Message() |
|
59 | msg = email.Message.Message() | |
60 | msg.set_payload('email commit message\n' + open('tip.patch').read()) |
|
60 | msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read()) | |
61 | msg['Subject'] = 'email patch' |
|
61 | msg['Subject'] = 'email patch' | |
62 | msg['From'] = 'email patcher' |
|
62 | msg['From'] = 'email patcher' | |
63 | sys.stdout.write(msg.as_string()) |
|
63 | sys.stdout.write(msg.as_string()) | |
64 | EOF |
|
64 | EOF | |
65 |
|
65 | |||
66 | echo % plain diff in email, subject, message body |
|
66 | echo % plain diff in email, subject, message body | |
67 | hg clone -r0 a b |
|
67 | hg clone -r0 a b | |
68 | hg --cwd a diff -r0:1 > tip.patch |
|
68 | hg --cwd a diff -r0:1 > tip.patch | |
69 | python mkmsg.py > msg.patch |
|
69 | python mkmsg.py > msg.patch | |
70 | hg --cwd b import ../msg.patch |
|
70 | hg --cwd b import ../msg.patch | |
71 | hg --cwd b tip | grep email |
|
71 | hg --cwd b tip | grep email | |
72 | rm -r b |
|
72 | rm -r b | |
73 |
|
73 | |||
74 | echo % plain diff in email, no subject, message body |
|
74 | echo % plain diff in email, no subject, message body | |
75 | hg clone -r0 a b |
|
75 | hg clone -r0 a b | |
76 | grep -v '^Subject:' msg.patch | hg --cwd b import - |
|
76 | grep -v '^Subject:' msg.patch | hg --cwd b import - | |
77 | rm -r b |
|
77 | rm -r b | |
78 |
|
78 | |||
79 | echo % plain diff in email, subject, no message body |
|
79 | echo % plain diff in email, subject, no message body | |
80 | hg clone -r0 a b |
|
80 | hg clone -r0 a b | |
81 | grep -v '^email ' msg.patch | hg --cwd b import - |
|
81 | grep -v '^email ' msg.patch | hg --cwd b import - | |
82 | rm -r b |
|
82 | rm -r b | |
83 |
|
83 | |||
84 | echo % plain diff in email, no subject, no message body, should fail |
|
84 | echo % plain diff in email, no subject, no message body, should fail | |
85 | hg clone -r0 a b |
|
85 | hg clone -r0 a b | |
86 | egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - |
|
86 | egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - | |
87 | rm -r b |
|
87 | rm -r b | |
88 |
|
88 | |||
89 | echo % hg export in email, should use patch header |
|
89 | echo % hg export in email, should use patch header | |
90 | hg clone -r0 a b |
|
90 | hg clone -r0 a b | |
91 | hg --cwd a export tip > tip.patch |
|
91 | hg --cwd a export tip > tip.patch | |
92 | python mkmsg.py | hg --cwd b import - |
|
92 | python mkmsg.py | hg --cwd b import - | |
93 | hg --cwd b tip | grep second |
|
93 | hg --cwd b tip | grep second | |
94 | rm -r b |
|
94 | rm -r b | |
95 |
|
95 | |||
96 | # subject: duplicate detection, removal of [PATCH] |
|
96 | # subject: duplicate detection, removal of [PATCH] | |
97 | # The '---' tests the gitsendmail handling without proper mail headers |
|
97 | # The '---' tests the gitsendmail handling without proper mail headers | |
98 | cat > mkmsg2.py <<EOF |
|
98 | cat > mkmsg2.py <<EOF | |
99 | import email.Message, sys |
|
99 | import email.Message, sys | |
100 | msg = email.Message.Message() |
|
100 | msg = email.Message.Message() | |
101 | msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read()) |
|
101 | msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read()) | |
102 | msg['Subject'] = '[PATCH] email patch' |
|
102 | msg['Subject'] = '[PATCH] email patch' | |
103 | msg['From'] = 'email patcher' |
|
103 | msg['From'] = 'email patcher' | |
104 | sys.stdout.write(msg.as_string()) |
|
104 | sys.stdout.write(msg.as_string()) | |
105 | EOF |
|
105 | EOF | |
106 |
|
106 | |||
107 | echo '% plain diff in email, [PATCH] subject, message body with subject' |
|
107 | echo '% plain diff in email, [PATCH] subject, message body with subject' | |
108 | hg clone -r0 a b |
|
108 | hg clone -r0 a b | |
109 | hg --cwd a diff -r0:1 > tip.patch |
|
109 | hg --cwd a diff -r0:1 > tip.patch | |
110 | python mkmsg2.py | hg --cwd b import - |
|
110 | python mkmsg2.py | hg --cwd b import - | |
111 | hg --cwd b tip --template '{desc}\n' |
|
111 | hg --cwd b tip --template '{desc}\n' | |
112 | rm -r b |
|
112 | rm -r b | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | # bug non regression test |
|
115 | # bug non regression test | |
116 | # importing a patch in a subdirectory failed at the commit stage |
|
116 | # importing a patch in a subdirectory failed at the commit stage | |
117 | echo line 2 >> a/d1/d2/a |
|
117 | echo line 2 >> a/d1/d2/a | |
118 | hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' |
|
118 | hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' | |
119 | echo % hg import in a subdirectory |
|
119 | echo % hg import in a subdirectory | |
120 | hg clone -r0 a b |
|
120 | hg clone -r0 a b | |
121 | hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch |
|
121 | hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch | |
122 | dir=`pwd` |
|
122 | dir=`pwd` | |
123 | cd b/d1/d2 2>&1 > /dev/null |
|
123 | cd b/d1/d2 2>&1 > /dev/null | |
124 | hg import ../../../tip.patch |
|
124 | hg import ../../../tip.patch | |
125 | cd $dir |
|
125 | cd $dir | |
126 | echo "% message should be 'subdir change'" |
|
126 | echo "% message should be 'subdir change'" | |
127 | hg --cwd b tip | grep 'subdir change' |
|
127 | hg --cwd b tip | grep 'subdir change' | |
128 | echo "% committer should be 'someoneelse'" |
|
128 | echo "% committer should be 'someoneelse'" | |
129 | hg --cwd b tip | grep someoneelse |
|
129 | hg --cwd b tip | grep someoneelse | |
130 | echo "% should be empty" |
|
130 | echo "% should be empty" | |
131 | hg --cwd b status |
|
131 | hg --cwd b status |
General Comments 0
You need to be logged in to leave comments.
Login now