##// END OF EJS Templates
py3: replace file() with open() in test-mq-qimport.t...
Pulkit Goyal -
r36038:85c94c9d default
parent child Browse files
Show More
@@ -1,359 +1,359
1 1 #require killdaemons
2 2
3 3 $ cat > writelines.py <<EOF
4 4 > import sys
5 5 > path = sys.argv[1]
6 6 > args = sys.argv[2:]
7 7 > assert (len(args) % 2) == 0
8 8 >
9 > f = file(path, 'wb')
9 > f = open(path, 'wb')
10 10 > for i in xrange(len(args)/2):
11 11 > count, s = args[2*i:2*i+2]
12 12 > count = int(count)
13 13 > s = s.decode('string_escape')
14 14 > f.write(s*count)
15 15 > f.close()
16 16 >
17 17 > EOF
18 18 > cat <<EOF >> $HGRCPATH
19 19 > [extensions]
20 20 > mq =
21 21 > [diff]
22 22 > git = 1
23 23 > EOF
24 24 $ hg init repo
25 25 $ cd repo
26 26
27 27 qimport without file or revision
28 28
29 29 $ hg qimport
30 30 abort: no files or revisions specified
31 31 [255]
32 32
33 33 qimport non-existing-file
34 34
35 35 $ hg qimport non-existing-file
36 36 abort: unable to read file non-existing-file
37 37 [255]
38 38
39 39 qimport null revision
40 40
41 41 $ hg qimport -r null
42 42 abort: revision -1 is not mutable
43 43 (see 'hg help phases' for details)
44 44 [255]
45 45 $ hg qseries
46 46
47 47 import email
48 48
49 49 $ hg qimport --push -n email - <<EOF
50 50 > From: Username in email <test@example.net>
51 51 > Subject: [PATCH] Message in email
52 52 > Date: Fri, 02 Jan 1970 00:00:00 +0000
53 53 >
54 54 > Text before patch.
55 55 >
56 56 > # HG changeset patch
57 57 > # User Username in patch <test@example.net>
58 58 > # Date 0 0
59 59 > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
60 60 > # Parent 0000000000000000000000000000000000000000
61 61 > First line of commit message.
62 62 >
63 63 > More text in commit message.
64 64 > --- confuse the diff detection
65 65 >
66 66 > diff --git a/x b/x
67 67 > new file mode 100644
68 68 > --- /dev/null
69 69 > +++ b/x
70 70 > @@ -0,0 +1,1 @@
71 71 > +new file
72 72 > Text after patch.
73 73 >
74 74 > EOF
75 75 adding email to series file
76 76 applying email
77 77 now at: email
78 78
79 79 hg tip -v
80 80
81 81 $ hg tip -v
82 82 changeset: 0:1a706973a7d8
83 83 tag: email
84 84 tag: qbase
85 85 tag: qtip
86 86 tag: tip
87 87 user: Username in patch <test@example.net>
88 88 date: Thu Jan 01 00:00:00 1970 +0000
89 89 files: x
90 90 description:
91 91 First line of commit message.
92 92
93 93 More text in commit message.
94 94
95 95
96 96 $ hg qpop
97 97 popping email
98 98 patch queue now empty
99 99 $ hg qdelete email
100 100
101 101 import URL
102 102
103 103 $ echo foo >> foo
104 104 $ hg add foo
105 105 $ hg diff > url.diff
106 106 $ hg revert --no-backup foo
107 107 $ rm foo
108 108
109 109 Under unix: file:///foobar/blah
110 110 Under windows: file:///c:/foobar/blah
111 111
112 112 $ patchurl=`pwd | tr '\\\\' /`/url.diff
113 113 $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
114 114 $ hg qimport file://"$patchurl"
115 115 adding url.diff to series file
116 116 $ rm url.diff
117 117 $ hg qun
118 118 url.diff
119 119
120 120 import patch that already exists
121 121
122 122 $ echo foo2 >> foo
123 123 $ hg add foo
124 124 $ hg diff > ../url.diff
125 125 $ hg revert --no-backup foo
126 126 $ rm foo
127 127 $ hg qimport ../url.diff
128 128 abort: patch "url.diff" already exists
129 129 [255]
130 130 $ hg qpush
131 131 applying url.diff
132 132 now at: url.diff
133 133 $ cat foo
134 134 foo
135 135 $ hg qpop
136 136 popping url.diff
137 137 patch queue now empty
138 138
139 139 qimport -f
140 140
141 141 $ hg qimport -f ../url.diff
142 142 adding url.diff to series file
143 143 $ hg qpush
144 144 applying url.diff
145 145 now at: url.diff
146 146 $ cat foo
147 147 foo2
148 148 $ hg qpop
149 149 popping url.diff
150 150 patch queue now empty
151 151
152 152 build diff with CRLF
153 153
154 154 $ $PYTHON ../writelines.py b 5 'a\n' 5 'a\r\n'
155 155 $ hg ci -Am addb
156 156 adding b
157 157 $ $PYTHON ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
158 158 $ hg diff > b.diff
159 159 $ hg up -C
160 160 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
161 161
162 162 qimport CRLF diff
163 163
164 164 $ hg qimport b.diff
165 165 adding b.diff to series file
166 166 $ hg qpush
167 167 applying b.diff
168 168 now at: b.diff
169 169
170 170 try to import --push
171 171
172 172 $ cat > appendfoo.diff <<EOF
173 173 > append foo
174 174 >
175 175 > diff -r 07f494440405 -r 261500830e46 baz
176 176 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
177 177 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
178 178 > @@ -0,0 +1,1 @@
179 179 > +foo
180 180 > EOF
181 181
182 182 $ cat > appendbar.diff <<EOF
183 183 > append bar
184 184 >
185 185 > diff -r 07f494440405 -r 261500830e46 baz
186 186 > --- a/baz Thu Jan 01 00:00:00 1970 +0000
187 187 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
188 188 > @@ -1,1 +1,2 @@
189 189 > foo
190 190 > +bar
191 191 > EOF
192 192
193 193 $ hg qimport --push appendfoo.diff appendbar.diff
194 194 adding appendfoo.diff to series file
195 195 adding appendbar.diff to series file
196 196 applying appendfoo.diff
197 197 applying appendbar.diff
198 198 now at: appendbar.diff
199 199 $ hg qfin -a
200 200 patch b.diff finalized without changeset message
201 201 $ touch .hg/patches/append_foo
202 202 $ hg qimport -r 'p1(.)::'
203 203 $ hg qapplied
204 204 append_foo__1
205 205 append_bar
206 206 $ hg qfin -a
207 207 $ rm .hg/patches/append_foo
208 208 $ hg qimport -r 'p1(.)::' -P
209 209 $ hg qpop -a
210 210 popping append_bar
211 211 popping append_foo
212 212 patch queue now empty
213 213 $ hg qdel append_foo
214 214 $ hg qdel -k append_bar
215 215
216 216 qimport -e
217 217
218 218 $ hg qimport -e append_bar
219 219 adding append_bar to series file
220 220 $ hg qdel -k append_bar
221 221
222 222 qimport -e --name newname oldexisitingpatch
223 223
224 224 $ hg qimport -e --name this-name-is-better append_bar
225 225 renaming append_bar to this-name-is-better
226 226 adding this-name-is-better to series file
227 227 $ hg qser
228 228 this-name-is-better
229 229 url.diff
230 230
231 231 qimport -e --name without --force
232 232
233 233 $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
234 234 $ hg qimport -e --name this-name-is-better 3.diff
235 235 abort: patch "this-name-is-better" already exists
236 236 [255]
237 237 $ hg qser
238 238 this-name-is-better
239 239 url.diff
240 240
241 241 qimport -e --name with --force
242 242
243 243 $ hg qimport --force -e --name this-name-is-better 3.diff
244 244 renaming 3.diff to this-name-is-better
245 245 adding this-name-is-better to series file
246 246 $ hg qser
247 247 this-name-is-better
248 248 url.diff
249 249
250 250 import patch of bad filename
251 251
252 252 $ touch '../ bad.diff'
253 253 $ hg qimport '../ bad.diff'
254 254 abort: patch name cannot begin or end with whitespace
255 255 [255]
256 256 $ touch '.hg/patches/ bad.diff'
257 257 $ hg qimport -e ' bad.diff'
258 258 abort: patch name cannot begin or end with whitespace
259 259 [255]
260 260
261 261 qimport with bad name, should abort before reading file
262 262
263 263 $ hg qimport non-existent-file --name .hg
264 264 abort: patch name cannot begin with ".hg"
265 265 [255]
266 266 $ hg qimport non-existent-file --name ' foo'
267 267 abort: patch name cannot begin or end with whitespace
268 268 [255]
269 269 $ hg qimport non-existent-file --name 'foo '
270 270 abort: patch name cannot begin or end with whitespace
271 271 [255]
272 272
273 273 qimport http:// patch with leading slashes in url
274 274
275 275 set up hgweb
276 276
277 277 $ cd ..
278 278 $ hg init served
279 279 $ cd served
280 280 $ echo a > a
281 281 $ hg ci -Am patch
282 282 adding a
283 283 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
284 284 $ cat hg.pid >> $DAEMON_PIDS
285 285
286 286 $ cd ../repo
287 287 $ hg qimport http://localhost:$HGPORT/raw-rev/0///
288 288 adding 0 to series file
289 289
290 290 check qimport phase:
291 291
292 292 $ hg -q qpush
293 293 now at: 0
294 294 $ hg phase qparent
295 295 1: draft
296 296 $ hg qimport -r qparent
297 297 $ hg phase qbase
298 298 1: draft
299 299 $ hg qfinish qbase
300 300 $ echo '[mq]' >> $HGRCPATH
301 301 $ echo 'secret=true' >> $HGRCPATH
302 302 $ hg qimport -r qparent
303 303 $ hg phase qbase
304 304 1: secret
305 305
306 306 $ cd ..
307 307
308 308 $ killdaemons.py
309 309
310 310 check patch name generation for non-alpha-numeric summary line
311 311
312 312 $ cd repo
313 313
314 314 $ hg qpop -a -q
315 315 patch queue now empty
316 316 $ hg qseries -v
317 317 0 U imported_patch_b_diff
318 318 1 U 0
319 319 2 U this-name-is-better
320 320 3 U url.diff
321 321
322 322 $ echo bb >> b
323 323 $ hg commit -m '==++--=='
324 324
325 325 $ hg qimport -r tip
326 326 $ hg qseries -v
327 327 0 A 1.diff
328 328 1 U imported_patch_b_diff
329 329 2 U 0
330 330 3 U this-name-is-better
331 331 4 U url.diff
332 332
333 333 check reserved patch names
334 334
335 335 $ hg qpop -qa
336 336 patch queue now empty
337 337 $ echo >> b
338 338 $ hg commit -m 'status'
339 339 $ echo >> b
340 340 $ hg commit -m '.'
341 341 $ echo >> b
342 342 $ hg commit -m 'taken'
343 343 $ mkdir .hg/patches/taken
344 344 $ touch .hg/patches/taken__1
345 345 $ hg qimport -r -3::
346 346 $ hg qap
347 347 1.diff__1
348 348 2.diff
349 349 taken__2
350 350
351 351 check very long patch name
352 352
353 353 $ hg qpop -qa
354 354 patch queue now empty
355 355 $ echo >> b
356 356 $ hg commit -m 'abcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
357 357 $ hg qimport -r .
358 358 $ hg qap
359 359 abcdefghi_pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi_pqrstuvwxyzabcdefg
General Comments 0
You need to be logged in to leave comments. Login now