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