##// END OF EJS Templates
tests: unify test-mq-qimport
Matt Mackall -
r12464:3177e3a7 default
parent child Browse files
Show More
@@ -1,127 +1,203 b''
1 #!/bin/sh
2
3 cat > writelines.py <<EOF
4 import sys
5 path = sys.argv[1]
6 args = sys.argv[2:]
7 assert (len(args) % 2) == 0
8
1
9 f = file(path, 'wb')
2 $ cat > writelines.py <<EOF
10 for i in xrange(len(args)/2):
3 > import sys
11 count, s = args[2*i:2*i+2]
4 > path = sys.argv[1]
12 count = int(count)
5 > args = sys.argv[2:]
13 s = s.decode('string_escape')
6 > assert (len(args) % 2) == 0
14 f.write(s*count)
7 >
15 f.close()
8 > f = file(path, 'wb')
16
9 > for i in xrange(len(args)/2):
17 EOF
10 > count, s = args[2*i:2*i+2]
11 > count = int(count)
12 > s = s.decode('string_escape')
13 > f.write(s*count)
14 > f.close()
15 >
16 > EOF
17 $ echo "[extensions]" >> $HGRCPATH
18 $ echo "mq=" >> $HGRCPATH
19 $ echo "[diff]" >> $HGRCPATH
20 $ echo "git=1" >> $HGRCPATH
21 $ hg init repo
22 $ cd repo
18
23
19 echo "[extensions]" >> $HGRCPATH
24 qimport non-existing-file
20 echo "mq=" >> $HGRCPATH
21 echo "[diff]" >> $HGRCPATH
22 echo "git=1" >> $HGRCPATH
23
25
24 hg init repo
26 $ hg qimport non-existing-file
25 cd repo
27 abort: unable to read file non-existing-file
28 [255]
26
29
27 echo % qimport non-existing-file
30 import email
28 hg qimport non-existing-file
29
31
30 echo % import email
32 $ hg qimport --push -n email - <<EOF
31 hg qimport --push -n email - <<EOF
33 > From: Username in email <test@example.net>
32 From: Username in email <test@example.net>
34 > Subject: [PATCH] Message in email
33 Subject: [PATCH] Message in email
35 > Date: Fri, 02 Jan 1970 00:00:00 +0000
34 Date: Fri, 02 Jan 1970 00:00:00 +0000
36 >
37 > Text before patch.
38 >
39 > # HG changeset patch
40 > # User Username in patch <test@example.net>
41 > # Date 0 0
42 > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
43 > # Parent 0000000000000000000000000000000000000000
44 > First line of commit message.
45 >
46 > More text in commit message.
47 > --- confuse the diff detection
48 >
49 > diff --git a/x b/x
50 > new file mode 100644
51 > --- /dev/null
52 > +++ b/x
53 > @@ -0,0 +1,1 @@
54 > +new file
55 > Text after patch.
56 >
57 > EOF
58 adding email to series file
59 applying email
60 now at: email
35
61
36 Text before patch.
62 hg tip -v
37
38 # HG changeset patch
39 # User Username in patch <test@example.net>
40 # Date 0 0
41 # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
42 # Parent 0000000000000000000000000000000000000000
43 First line of commit message.
44
63
45 More text in commit message.
64 $ hg tip -v
46 --- confuse the diff detection
65 changeset: 0:1a706973a7d8
66 tag: email
67 tag: qbase
68 tag: qtip
69 tag: tip
70 user: Username in patch <test@example.net>
71 date: Thu Jan 01 00:00:00 1970 +0000
72 files: x
73 description:
74 First line of commit message.
75
76 More text in commit message.
77
78
79 $ hg qpop
80 popping email
81 patch queue now empty
82 $ hg qdelete email
47
83
48 diff --git a/x b/x
84 import URL
49 new file mode 100644
85
50 --- /dev/null
86 $ echo foo >> foo
51 +++ b/x
87 $ hg add foo
52 @@ -0,0 +1,1 @@
88 $ hg diff > $HGTMP/url.diff
53 +new file
89 $ hg revert --no-backup foo
54 Text after patch.
90 $ rm foo
55
91
56 EOF
92 Under unix: file:///foobar/blah
93 Under windows: file:///c:/foobar/blah
57
94
58 echo % hg tip -v
95 $ patchurl=`echo "$HGTMP"/url.diff | tr '\\\\' /`
59 hg tip -v
96 $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
60 hg qpop
97 $ hg qimport file://"$patchurl"
61 hg qdelete email
98 adding url.diff to series file
99 $ hg qun
100 url.diff
62
101
63 echo % import URL
102 import patch that already exists
64 echo foo >> foo
103
65 hg add foo
104 $ echo foo2 >> foo
66 hg diff > $HGTMP/url.diff
105 $ hg add foo
67 hg revert --no-backup foo
106 $ hg diff > ../url.diff
68 rm foo
107 $ hg revert --no-backup foo
69 # Under unix: file:///foobar/blah
108 $ rm foo
70 # Under windows: file:///c:/foobar/blah
109 $ hg qimport ../url.diff
71 patchurl=`echo "$HGTMP"/url.diff | tr '\\\\' /`
110 abort: patch "url.diff" already exists
72 expr "$patchurl" : "\/" > /dev/null
111 [255]
73 if [ $? -ne 0 ]; then
112 $ hg qpush
74 patchurl="/$patchurl"
113 applying url.diff
75 fi
114 now at: url.diff
76 hg qimport file://"$patchurl"
115 $ cat foo
77 hg qun
116 foo
117 $ hg qpop
118 popping url.diff
119 patch queue now empty
120
121 qimport -f
78
122
79 echo % import patch that already exists
123 $ hg qimport -f ../url.diff
80 echo foo2 >> foo
124 adding url.diff to series file
81 hg add foo
125 $ hg qpush
82 hg diff > ../url.diff
126 applying url.diff
83 hg revert --no-backup foo
127 now at: url.diff
84 rm foo
128 $ cat foo
85 hg qimport ../url.diff
129 foo2
86 hg qpush
130 $ hg qpop
87 cat foo
131 popping url.diff
88 hg qpop
132 patch queue now empty
89 echo % qimport -f
133
90 hg qimport -f ../url.diff
134 build diff with CRLF
91 hg qpush
135
92 cat foo
136 $ python ../writelines.py b 5 'a\n' 5 'a\r\n'
93 hg qpop
137 $ hg ci -Am addb
138 adding b
139 $ python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
140 $ hg diff > b.diff
141 $ hg up -C
142 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
143
144 qimport CRLF diff
145
146 $ hg qimport b.diff
147 adding b.diff to series file
148 $ hg qpush
149 applying b.diff
150 now at: b.diff
94
151
95 echo % build diff with CRLF
152 try to import --push
96 python ../writelines.py b 5 'a\n' 5 'a\r\n'
153
97 hg ci -Am addb
154 $ echo another >> b
98 python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
155 $ hg diff > another.diff
99 hg diff > b.diff
156 $ hg up -C
100 hg up -C
157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 echo % qimport CRLF diff
158 $ hg qimport --push another.diff
102 hg qimport b.diff
159 adding another.diff to series file
103 hg qpush
160 applying another.diff
161 now at: another.diff
162 $ hg qfin -a
163 patch b.diff finalized without changeset message
164 patch another.diff finalized without changeset message
165 $ hg qimport -rtip -P
166 $ hg qpop -a
167 popping 2.diff
168 patch queue now empty
169 $ hg qdel -k 2.diff
170
171 qimport -e
172
173 $ hg qimport -e 2.diff
174 adding 2.diff to series file
175 $ hg qdel -k 2.diff
104
176
105 echo % try to import --push
177 qimport -e --name newname oldexisitingpatch
106 echo another >> b
178
107 hg diff > another.diff
179 $ hg qimport -e --name this-name-is-better 2.diff
108 hg up -C
180 renaming 2.diff to this-name-is-better
109 hg qimport --push another.diff
181 adding this-name-is-better to series file
110 hg qfin -a
182 $ hg qser
111 hg qimport -rtip -P
183 this-name-is-better
184 url.diff
185
186 qimport -e --name without --force
112
187
113 hg qpop -a
188 $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
114 hg qdel -k 2.diff
189 $ hg qimport -e --name this-name-is-better 3.diff
115 echo % qimport -e
190 abort: patch "this-name-is-better" already exists
116 hg qimport -e 2.diff
191 [255]
117 hg qdel -k 2.diff
192 $ hg qser
118 echo % qimport -e --name newname oldexisitingpatch
193 this-name-is-better
119 hg qimport -e --name this-name-is-better 2.diff
194 url.diff
120 hg qser
195
121 echo % qimport -e --name without --force
196 qimport -e --name with --force
122 cp .hg/patches/this-name-is-better .hg/patches/3.diff
197
123 hg qimport -e --name this-name-is-better 3.diff
198 $ hg qimport --force -e --name this-name-is-better 3.diff
124 hg qser
199 renaming 3.diff to this-name-is-better
125 echo % qimport -e --name with --force
200 adding this-name-is-better to series file
126 hg qimport --force -e --name this-name-is-better 3.diff
201 $ hg qser
127 hg qser
202 this-name-is-better
203 url.diff
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