##// END OF EJS Templates
py3: use lower-cased module 'email.message' in test-import.t
Yuya Nishihara -
r37484:abd9f5ec default
parent child Browse files
Show More
@@ -1,1919 +1,1919 b''
1 $ hg init a
1 $ hg init a
2 $ mkdir a/d1
2 $ mkdir a/d1
3 $ mkdir a/d1/d2
3 $ mkdir a/d1/d2
4 $ echo line 1 > a/a
4 $ echo line 1 > a/a
5 $ echo line 1 > a/d1/d2/a
5 $ echo line 1 > a/d1/d2/a
6 $ hg --cwd a ci -Ama
6 $ hg --cwd a ci -Ama
7 adding a
7 adding a
8 adding d1/d2/a
8 adding d1/d2/a
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 import with no args:
13 import with no args:
14
14
15 $ hg --cwd a import
15 $ hg --cwd a import
16 abort: need at least one patch to import
16 abort: need at least one patch to import
17 [255]
17 [255]
18
18
19 generate patches for the test
19 generate patches for the test
20
20
21 $ hg --cwd a export tip > exported-tip.patch
21 $ hg --cwd a export tip > exported-tip.patch
22 $ hg --cwd a diff -r0:1 > diffed-tip.patch
22 $ hg --cwd a diff -r0:1 > diffed-tip.patch
23
23
24
24
25 import exported patch
25 import exported patch
26 (this also tests that editor is not invoked, if the patch contains the
26 (this also tests that editor is not invoked, if the patch contains the
27 commit message and '--edit' is not specified)
27 commit message and '--edit' is not specified)
28
28
29 $ hg clone -r0 a b
29 $ hg clone -r0 a b
30 adding changesets
30 adding changesets
31 adding manifests
31 adding manifests
32 adding file changes
32 adding file changes
33 added 1 changesets with 2 changes to 2 files
33 added 1 changesets with 2 changes to 2 files
34 new changesets 80971e65b431
34 new changesets 80971e65b431
35 updating to branch default
35 updating to branch default
36 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 $ HGEDITOR=cat hg --cwd b import ../exported-tip.patch
37 $ HGEDITOR=cat hg --cwd b import ../exported-tip.patch
38 applying ../exported-tip.patch
38 applying ../exported-tip.patch
39
39
40 message and committer and date should be same
40 message and committer and date should be same
41
41
42 $ hg --cwd b tip
42 $ hg --cwd b tip
43 changeset: 1:1d4bd90af0e4
43 changeset: 1:1d4bd90af0e4
44 tag: tip
44 tag: tip
45 user: someone
45 user: someone
46 date: Thu Jan 01 00:00:01 1970 +0000
46 date: Thu Jan 01 00:00:01 1970 +0000
47 summary: second change
47 summary: second change
48
48
49 $ rm -r b
49 $ rm -r b
50
50
51
51
52 import exported patch with external patcher
52 import exported patch with external patcher
53 (this also tests that editor is invoked, if the '--edit' is specified,
53 (this also tests that editor is invoked, if the '--edit' is specified,
54 regardless of the commit message in the patch)
54 regardless of the commit message in the patch)
55
55
56 $ cat > dummypatch.py <<EOF
56 $ cat > dummypatch.py <<EOF
57 > from __future__ import print_function
57 > from __future__ import print_function
58 > print('patching file a')
58 > print('patching file a')
59 > open('a', 'wb').write(b'line2\n')
59 > open('a', 'wb').write(b'line2\n')
60 > EOF
60 > EOF
61 $ hg clone -r0 a b
61 $ hg clone -r0 a b
62 adding changesets
62 adding changesets
63 adding manifests
63 adding manifests
64 adding file changes
64 adding file changes
65 added 1 changesets with 2 changes to 2 files
65 added 1 changesets with 2 changes to 2 files
66 new changesets 80971e65b431
66 new changesets 80971e65b431
67 updating to branch default
67 updating to branch default
68 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
68 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
69 $ HGEDITOR=cat hg --config ui.patch="$PYTHON ../dummypatch.py" --cwd b import --edit ../exported-tip.patch
69 $ HGEDITOR=cat hg --config ui.patch="$PYTHON ../dummypatch.py" --cwd b import --edit ../exported-tip.patch
70 applying ../exported-tip.patch
70 applying ../exported-tip.patch
71 second change
71 second change
72
72
73
73
74 HG: Enter commit message. Lines beginning with 'HG:' are removed.
74 HG: Enter commit message. Lines beginning with 'HG:' are removed.
75 HG: Leave message empty to abort commit.
75 HG: Leave message empty to abort commit.
76 HG: --
76 HG: --
77 HG: user: someone
77 HG: user: someone
78 HG: branch 'default'
78 HG: branch 'default'
79 HG: changed a
79 HG: changed a
80 $ cat b/a
80 $ cat b/a
81 line2
81 line2
82 $ rm -r b
82 $ rm -r b
83
83
84
84
85 import of plain diff should fail without message
85 import of plain diff should fail without message
86 (this also tests that editor is invoked, if the patch doesn't contain
86 (this also tests that editor is invoked, if the patch doesn't contain
87 the commit message, regardless of '--edit')
87 the commit message, regardless of '--edit')
88
88
89 $ hg clone -r0 a b
89 $ hg clone -r0 a b
90 adding changesets
90 adding changesets
91 adding manifests
91 adding manifests
92 adding file changes
92 adding file changes
93 added 1 changesets with 2 changes to 2 files
93 added 1 changesets with 2 changes to 2 files
94 new changesets 80971e65b431
94 new changesets 80971e65b431
95 updating to branch default
95 updating to branch default
96 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
96 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 $ cat > $TESTTMP/editor.sh <<EOF
97 $ cat > $TESTTMP/editor.sh <<EOF
98 > env | grep HGEDITFORM
98 > env | grep HGEDITFORM
99 > cat \$1
99 > cat \$1
100 > EOF
100 > EOF
101 $ HGEDITOR="sh $TESTTMP/editor.sh" hg --cwd b import ../diffed-tip.patch
101 $ HGEDITOR="sh $TESTTMP/editor.sh" hg --cwd b import ../diffed-tip.patch
102 applying ../diffed-tip.patch
102 applying ../diffed-tip.patch
103 HGEDITFORM=import.normal.normal
103 HGEDITFORM=import.normal.normal
104
104
105
105
106 HG: Enter commit message. Lines beginning with 'HG:' are removed.
106 HG: Enter commit message. Lines beginning with 'HG:' are removed.
107 HG: Leave message empty to abort commit.
107 HG: Leave message empty to abort commit.
108 HG: --
108 HG: --
109 HG: user: test
109 HG: user: test
110 HG: branch 'default'
110 HG: branch 'default'
111 HG: changed a
111 HG: changed a
112 abort: empty commit message
112 abort: empty commit message
113 [255]
113 [255]
114
114
115 Test avoiding editor invocation at applying the patch with --exact,
115 Test avoiding editor invocation at applying the patch with --exact,
116 even if commit message is empty
116 even if commit message is empty
117
117
118 $ echo a >> b/a
118 $ echo a >> b/a
119 $ hg --cwd b commit -m ' '
119 $ hg --cwd b commit -m ' '
120 $ hg --cwd b tip -T "{node}\n"
120 $ hg --cwd b tip -T "{node}\n"
121 d8804f3f5396d800812f579c8452796a5993bdb2
121 d8804f3f5396d800812f579c8452796a5993bdb2
122 $ hg --cwd b export -o ../empty-log.diff .
122 $ hg --cwd b export -o ../empty-log.diff .
123 $ hg --cwd b update -q -C ".^1"
123 $ hg --cwd b update -q -C ".^1"
124 $ hg --cwd b --config extensions.strip= strip -q tip
124 $ hg --cwd b --config extensions.strip= strip -q tip
125 $ HGEDITOR=cat hg --cwd b import --exact ../empty-log.diff
125 $ HGEDITOR=cat hg --cwd b import --exact ../empty-log.diff
126 applying ../empty-log.diff
126 applying ../empty-log.diff
127 $ hg --cwd b tip -T "{node}\n"
127 $ hg --cwd b tip -T "{node}\n"
128 d8804f3f5396d800812f579c8452796a5993bdb2
128 d8804f3f5396d800812f579c8452796a5993bdb2
129
129
130 $ rm -r b
130 $ rm -r b
131
131
132
132
133 import of plain diff should be ok with message
133 import of plain diff should be ok with message
134
134
135 $ hg clone -r0 a b
135 $ hg clone -r0 a b
136 adding changesets
136 adding changesets
137 adding manifests
137 adding manifests
138 adding file changes
138 adding file changes
139 added 1 changesets with 2 changes to 2 files
139 added 1 changesets with 2 changes to 2 files
140 new changesets 80971e65b431
140 new changesets 80971e65b431
141 updating to branch default
141 updating to branch default
142 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
143 $ hg --cwd b import -mpatch ../diffed-tip.patch
143 $ hg --cwd b import -mpatch ../diffed-tip.patch
144 applying ../diffed-tip.patch
144 applying ../diffed-tip.patch
145 $ rm -r b
145 $ rm -r b
146
146
147
147
148 import of plain diff with specific date and user
148 import of plain diff with specific date and user
149 (this also tests that editor is not invoked, if
149 (this also tests that editor is not invoked, if
150 '--message'/'--logfile' is specified and '--edit' is not)
150 '--message'/'--logfile' is specified and '--edit' is not)
151
151
152 $ hg clone -r0 a b
152 $ hg clone -r0 a b
153 adding changesets
153 adding changesets
154 adding manifests
154 adding manifests
155 adding file changes
155 adding file changes
156 added 1 changesets with 2 changes to 2 files
156 added 1 changesets with 2 changes to 2 files
157 new changesets 80971e65b431
157 new changesets 80971e65b431
158 updating to branch default
158 updating to branch default
159 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
159 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../diffed-tip.patch
160 $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../diffed-tip.patch
161 applying ../diffed-tip.patch
161 applying ../diffed-tip.patch
162 $ hg -R b tip -pv
162 $ hg -R b tip -pv
163 changeset: 1:ca68f19f3a40
163 changeset: 1:ca68f19f3a40
164 tag: tip
164 tag: tip
165 user: user@nowhere.net
165 user: user@nowhere.net
166 date: Thu Jan 01 00:00:01 1970 +0000
166 date: Thu Jan 01 00:00:01 1970 +0000
167 files: a
167 files: a
168 description:
168 description:
169 patch
169 patch
170
170
171
171
172 diff -r 80971e65b431 -r ca68f19f3a40 a
172 diff -r 80971e65b431 -r ca68f19f3a40 a
173 --- a/a Thu Jan 01 00:00:00 1970 +0000
173 --- a/a Thu Jan 01 00:00:00 1970 +0000
174 +++ b/a Thu Jan 01 00:00:01 1970 +0000
174 +++ b/a Thu Jan 01 00:00:01 1970 +0000
175 @@ -1,1 +1,2 @@
175 @@ -1,1 +1,2 @@
176 line 1
176 line 1
177 +line 2
177 +line 2
178
178
179 $ rm -r b
179 $ rm -r b
180
180
181
181
182 import of plain diff should be ok with --no-commit
182 import of plain diff should be ok with --no-commit
183 (this also tests that editor is not invoked, if '--no-commit' is
183 (this also tests that editor is not invoked, if '--no-commit' is
184 specified, regardless of '--edit')
184 specified, regardless of '--edit')
185
185
186 $ hg clone -r0 a b
186 $ hg clone -r0 a b
187 adding changesets
187 adding changesets
188 adding manifests
188 adding manifests
189 adding file changes
189 adding file changes
190 added 1 changesets with 2 changes to 2 files
190 added 1 changesets with 2 changes to 2 files
191 new changesets 80971e65b431
191 new changesets 80971e65b431
192 updating to branch default
192 updating to branch default
193 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
194 $ HGEDITOR=cat hg --cwd b import --no-commit --edit ../diffed-tip.patch
194 $ HGEDITOR=cat hg --cwd b import --no-commit --edit ../diffed-tip.patch
195 applying ../diffed-tip.patch
195 applying ../diffed-tip.patch
196 $ hg --cwd b diff --nodates
196 $ hg --cwd b diff --nodates
197 diff -r 80971e65b431 a
197 diff -r 80971e65b431 a
198 --- a/a
198 --- a/a
199 +++ b/a
199 +++ b/a
200 @@ -1,1 +1,2 @@
200 @@ -1,1 +1,2 @@
201 line 1
201 line 1
202 +line 2
202 +line 2
203 $ rm -r b
203 $ rm -r b
204
204
205
205
206 import of malformed plain diff should fail
206 import of malformed plain diff should fail
207
207
208 $ hg clone -r0 a b
208 $ hg clone -r0 a b
209 adding changesets
209 adding changesets
210 adding manifests
210 adding manifests
211 adding file changes
211 adding file changes
212 added 1 changesets with 2 changes to 2 files
212 added 1 changesets with 2 changes to 2 files
213 new changesets 80971e65b431
213 new changesets 80971e65b431
214 updating to branch default
214 updating to branch default
215 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
215 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
216 $ sed 's/1,1/foo/' < diffed-tip.patch > broken.patch
216 $ sed 's/1,1/foo/' < diffed-tip.patch > broken.patch
217 $ hg --cwd b import -mpatch ../broken.patch
217 $ hg --cwd b import -mpatch ../broken.patch
218 applying ../broken.patch
218 applying ../broken.patch
219 abort: bad hunk #1
219 abort: bad hunk #1
220 [255]
220 [255]
221 $ rm -r b
221 $ rm -r b
222
222
223
223
224 hg -R repo import
224 hg -R repo import
225 put the clone in a subdir - having a directory named "a"
225 put the clone in a subdir - having a directory named "a"
226 used to hide a bug.
226 used to hide a bug.
227
227
228 $ mkdir dir
228 $ mkdir dir
229 $ hg clone -r0 a dir/b
229 $ hg clone -r0 a dir/b
230 adding changesets
230 adding changesets
231 adding manifests
231 adding manifests
232 adding file changes
232 adding file changes
233 added 1 changesets with 2 changes to 2 files
233 added 1 changesets with 2 changes to 2 files
234 new changesets 80971e65b431
234 new changesets 80971e65b431
235 updating to branch default
235 updating to branch default
236 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
236 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 $ cd dir
237 $ cd dir
238 $ hg -R b import ../exported-tip.patch
238 $ hg -R b import ../exported-tip.patch
239 applying ../exported-tip.patch
239 applying ../exported-tip.patch
240 $ cd ..
240 $ cd ..
241 $ rm -r dir
241 $ rm -r dir
242
242
243
243
244 import from stdin
244 import from stdin
245
245
246 $ hg clone -r0 a b
246 $ hg clone -r0 a b
247 adding changesets
247 adding changesets
248 adding manifests
248 adding manifests
249 adding file changes
249 adding file changes
250 added 1 changesets with 2 changes to 2 files
250 added 1 changesets with 2 changes to 2 files
251 new changesets 80971e65b431
251 new changesets 80971e65b431
252 updating to branch default
252 updating to branch default
253 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
253 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
254 $ hg --cwd b import - < exported-tip.patch
254 $ hg --cwd b import - < exported-tip.patch
255 applying patch from stdin
255 applying patch from stdin
256 $ rm -r b
256 $ rm -r b
257
257
258
258
259 import two patches in one stream
259 import two patches in one stream
260
260
261 $ hg init b
261 $ hg init b
262 $ hg --cwd a export 0:tip | hg --cwd b import -
262 $ hg --cwd a export 0:tip | hg --cwd b import -
263 applying patch from stdin
263 applying patch from stdin
264 $ hg --cwd a id
264 $ hg --cwd a id
265 1d4bd90af0e4 tip
265 1d4bd90af0e4 tip
266 $ hg --cwd b id
266 $ hg --cwd b id
267 1d4bd90af0e4 tip
267 1d4bd90af0e4 tip
268 $ rm -r b
268 $ rm -r b
269
269
270
270
271 override commit message
271 override commit message
272
272
273 $ hg clone -r0 a b
273 $ hg clone -r0 a b
274 adding changesets
274 adding changesets
275 adding manifests
275 adding manifests
276 adding file changes
276 adding file changes
277 added 1 changesets with 2 changes to 2 files
277 added 1 changesets with 2 changes to 2 files
278 new changesets 80971e65b431
278 new changesets 80971e65b431
279 updating to branch default
279 updating to branch default
280 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
280 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
281 $ hg --cwd b import -m 'override' - < exported-tip.patch
281 $ hg --cwd b import -m 'override' - < exported-tip.patch
282 applying patch from stdin
282 applying patch from stdin
283 $ hg --cwd b tip | grep override
283 $ hg --cwd b tip | grep override
284 summary: override
284 summary: override
285 $ rm -r b
285 $ rm -r b
286
286
287 $ cat > mkmsg.py <<EOF
287 $ cat > mkmsg.py <<EOF
288 > import email.Message, sys
288 > import email.message, sys
289 > msg = email.Message.Message()
289 > msg = email.message.Message()
290 > patch = open(sys.argv[1], 'rb').read()
290 > patch = open(sys.argv[1], 'rb').read()
291 > msg.set_payload('email commit message\n' + patch)
291 > msg.set_payload('email commit message\n' + patch)
292 > msg['Subject'] = 'email patch'
292 > msg['Subject'] = 'email patch'
293 > msg['From'] = 'email patcher'
293 > msg['From'] = 'email patcher'
294 > open(sys.argv[2], 'wb').write(msg.as_string())
294 > open(sys.argv[2], 'wb').write(msg.as_string())
295 > EOF
295 > EOF
296
296
297
297
298 plain diff in email, subject, message body
298 plain diff in email, subject, message body
299
299
300 $ hg clone -r0 a b
300 $ hg clone -r0 a b
301 adding changesets
301 adding changesets
302 adding manifests
302 adding manifests
303 adding file changes
303 adding file changes
304 added 1 changesets with 2 changes to 2 files
304 added 1 changesets with 2 changes to 2 files
305 new changesets 80971e65b431
305 new changesets 80971e65b431
306 updating to branch default
306 updating to branch default
307 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
307 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
308 $ $PYTHON mkmsg.py diffed-tip.patch msg.patch
308 $ $PYTHON mkmsg.py diffed-tip.patch msg.patch
309 $ hg --cwd b import ../msg.patch
309 $ hg --cwd b import ../msg.patch
310 applying ../msg.patch
310 applying ../msg.patch
311 $ hg --cwd b tip | grep email
311 $ hg --cwd b tip | grep email
312 user: email patcher
312 user: email patcher
313 summary: email patch
313 summary: email patch
314 $ rm -r b
314 $ rm -r b
315
315
316
316
317 plain diff in email, no subject, message body
317 plain diff in email, no subject, message body
318
318
319 $ hg clone -r0 a b
319 $ hg clone -r0 a b
320 adding changesets
320 adding changesets
321 adding manifests
321 adding manifests
322 adding file changes
322 adding file changes
323 added 1 changesets with 2 changes to 2 files
323 added 1 changesets with 2 changes to 2 files
324 new changesets 80971e65b431
324 new changesets 80971e65b431
325 updating to branch default
325 updating to branch default
326 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
326 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
327 $ grep -v '^Subject:' msg.patch | hg --cwd b import -
327 $ grep -v '^Subject:' msg.patch | hg --cwd b import -
328 applying patch from stdin
328 applying patch from stdin
329 $ rm -r b
329 $ rm -r b
330
330
331
331
332 plain diff in email, subject, no message body
332 plain diff in email, subject, no message body
333
333
334 $ hg clone -r0 a b
334 $ hg clone -r0 a b
335 adding changesets
335 adding changesets
336 adding manifests
336 adding manifests
337 adding file changes
337 adding file changes
338 added 1 changesets with 2 changes to 2 files
338 added 1 changesets with 2 changes to 2 files
339 new changesets 80971e65b431
339 new changesets 80971e65b431
340 updating to branch default
340 updating to branch default
341 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
341 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
342 $ grep -v '^email ' msg.patch | hg --cwd b import -
342 $ grep -v '^email ' msg.patch | hg --cwd b import -
343 applying patch from stdin
343 applying patch from stdin
344 $ rm -r b
344 $ rm -r b
345
345
346
346
347 plain diff in email, no subject, no message body, should fail
347 plain diff in email, no subject, no message body, should fail
348
348
349 $ hg clone -r0 a b
349 $ hg clone -r0 a b
350 adding changesets
350 adding changesets
351 adding manifests
351 adding manifests
352 adding file changes
352 adding file changes
353 added 1 changesets with 2 changes to 2 files
353 added 1 changesets with 2 changes to 2 files
354 new changesets 80971e65b431
354 new changesets 80971e65b431
355 updating to branch default
355 updating to branch default
356 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
356 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
357 $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
357 $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
358 applying patch from stdin
358 applying patch from stdin
359 abort: empty commit message
359 abort: empty commit message
360 [255]
360 [255]
361 $ rm -r b
361 $ rm -r b
362
362
363
363
364 hg export in email, should use patch header
364 hg export in email, should use patch header
365
365
366 $ hg clone -r0 a b
366 $ hg clone -r0 a b
367 adding changesets
367 adding changesets
368 adding manifests
368 adding manifests
369 adding file changes
369 adding file changes
370 added 1 changesets with 2 changes to 2 files
370 added 1 changesets with 2 changes to 2 files
371 new changesets 80971e65b431
371 new changesets 80971e65b431
372 updating to branch default
372 updating to branch default
373 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
374 $ $PYTHON mkmsg.py exported-tip.patch msg.patch
374 $ $PYTHON mkmsg.py exported-tip.patch msg.patch
375 $ cat msg.patch | hg --cwd b import -
375 $ cat msg.patch | hg --cwd b import -
376 applying patch from stdin
376 applying patch from stdin
377 $ hg --cwd b tip | grep second
377 $ hg --cwd b tip | grep second
378 summary: second change
378 summary: second change
379 $ rm -r b
379 $ rm -r b
380
380
381
381
382 subject: duplicate detection, removal of [PATCH]
382 subject: duplicate detection, removal of [PATCH]
383 The '---' tests the gitsendmail handling without proper mail headers
383 The '---' tests the gitsendmail handling without proper mail headers
384
384
385 $ cat > mkmsg2.py <<EOF
385 $ cat > mkmsg2.py <<EOF
386 > import email.Message, sys
386 > import email.message, sys
387 > msg = email.Message.Message()
387 > msg = email.message.Message()
388 > patch = open(sys.argv[1], 'rb').read()
388 > patch = open(sys.argv[1], 'rb').read()
389 > msg.set_payload('email patch\n\nnext line\n---\n' + patch)
389 > msg.set_payload('email patch\n\nnext line\n---\n' + patch)
390 > msg['Subject'] = '[PATCH] email patch'
390 > msg['Subject'] = '[PATCH] email patch'
391 > msg['From'] = 'email patcher'
391 > msg['From'] = 'email patcher'
392 > open(sys.argv[2], 'wb').write(msg.as_string())
392 > open(sys.argv[2], 'wb').write(msg.as_string())
393 > EOF
393 > EOF
394
394
395
395
396 plain diff in email, [PATCH] subject, message body with subject
396 plain diff in email, [PATCH] subject, message body with subject
397
397
398 $ hg clone -r0 a b
398 $ hg clone -r0 a b
399 adding changesets
399 adding changesets
400 adding manifests
400 adding manifests
401 adding file changes
401 adding file changes
402 added 1 changesets with 2 changes to 2 files
402 added 1 changesets with 2 changes to 2 files
403 new changesets 80971e65b431
403 new changesets 80971e65b431
404 updating to branch default
404 updating to branch default
405 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
405 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
406 $ $PYTHON mkmsg2.py diffed-tip.patch msg.patch
406 $ $PYTHON mkmsg2.py diffed-tip.patch msg.patch
407 $ cat msg.patch | hg --cwd b import -
407 $ cat msg.patch | hg --cwd b import -
408 applying patch from stdin
408 applying patch from stdin
409 $ hg --cwd b tip --template '{desc}\n'
409 $ hg --cwd b tip --template '{desc}\n'
410 email patch
410 email patch
411
411
412 next line
412 next line
413 $ rm -r b
413 $ rm -r b
414
414
415
415
416 Issue963: Parent of working dir incorrect after import of multiple
416 Issue963: Parent of working dir incorrect after import of multiple
417 patches and rollback
417 patches and rollback
418
418
419 We weren't backing up the correct dirstate file when importing many
419 We weren't backing up the correct dirstate file when importing many
420 patches: import patch1 patch2; rollback
420 patches: import patch1 patch2; rollback
421
421
422 $ echo line 3 >> a/a
422 $ echo line 3 >> a/a
423 $ hg --cwd a ci -m'third change'
423 $ hg --cwd a ci -m'third change'
424 $ hg --cwd a export -o '../patch%R' 1 2
424 $ hg --cwd a export -o '../patch%R' 1 2
425 $ hg clone -qr0 a b
425 $ hg clone -qr0 a b
426 $ hg --cwd b parents --template 'parent: {rev}\n'
426 $ hg --cwd b parents --template 'parent: {rev}\n'
427 parent: 0
427 parent: 0
428 $ hg --cwd b import -v ../patch1 ../patch2
428 $ hg --cwd b import -v ../patch1 ../patch2
429 applying ../patch1
429 applying ../patch1
430 patching file a
430 patching file a
431 committing files:
431 committing files:
432 a
432 a
433 committing manifest
433 committing manifest
434 committing changelog
434 committing changelog
435 created 1d4bd90af0e4
435 created 1d4bd90af0e4
436 applying ../patch2
436 applying ../patch2
437 patching file a
437 patching file a
438 committing files:
438 committing files:
439 a
439 a
440 committing manifest
440 committing manifest
441 committing changelog
441 committing changelog
442 created 6d019af21222
442 created 6d019af21222
443 $ hg --cwd b rollback
443 $ hg --cwd b rollback
444 repository tip rolled back to revision 0 (undo import)
444 repository tip rolled back to revision 0 (undo import)
445 working directory now based on revision 0
445 working directory now based on revision 0
446 $ hg --cwd b parents --template 'parent: {rev}\n'
446 $ hg --cwd b parents --template 'parent: {rev}\n'
447 parent: 0
447 parent: 0
448
448
449 Test that "hg rollback" doesn't restore dirstate to one at the
449 Test that "hg rollback" doesn't restore dirstate to one at the
450 beginning of the rolled back transaction in not-"parent-gone" case.
450 beginning of the rolled back transaction in not-"parent-gone" case.
451
451
452 invoking pretxncommit hook will cause marking '.hg/dirstate' as a file
452 invoking pretxncommit hook will cause marking '.hg/dirstate' as a file
453 to be restored when rolling back, after DirstateTransactionPlan (see wiki
453 to be restored when rolling back, after DirstateTransactionPlan (see wiki
454 page for detail).
454 page for detail).
455
455
456 $ hg --cwd b branch -q foobar
456 $ hg --cwd b branch -q foobar
457 $ hg --cwd b commit -m foobar
457 $ hg --cwd b commit -m foobar
458 $ hg --cwd b update 0 -q
458 $ hg --cwd b update 0 -q
459 $ hg --cwd b import ../patch1 ../patch2 --config hooks.pretxncommit=true
459 $ hg --cwd b import ../patch1 ../patch2 --config hooks.pretxncommit=true
460 applying ../patch1
460 applying ../patch1
461 applying ../patch2
461 applying ../patch2
462 $ hg --cwd b update -q 1
462 $ hg --cwd b update -q 1
463 $ hg --cwd b rollback -q
463 $ hg --cwd b rollback -q
464 $ hg --cwd b parents --template 'parent: {rev}\n'
464 $ hg --cwd b parents --template 'parent: {rev}\n'
465 parent: 1
465 parent: 1
466
466
467 $ hg --cwd b update -q -C 0
467 $ hg --cwd b update -q -C 0
468 $ hg --cwd b --config extensions.strip= strip -q 1
468 $ hg --cwd b --config extensions.strip= strip -q 1
469
469
470 Test visibility of in-memory dirstate changes inside transaction to
470 Test visibility of in-memory dirstate changes inside transaction to
471 external process
471 external process
472
472
473 $ echo foo > a/foo
473 $ echo foo > a/foo
474 $ hg --cwd a commit -A -m 'adding foo' foo
474 $ hg --cwd a commit -A -m 'adding foo' foo
475 $ hg --cwd a export -o '../patch%R' 3
475 $ hg --cwd a export -o '../patch%R' 3
476
476
477 $ cat > $TESTTMP/checkvisibility.sh <<EOF
477 $ cat > $TESTTMP/checkvisibility.sh <<EOF
478 > echo "===="
478 > echo "===="
479 > hg parents --template "VISIBLE {rev}:{node|short}\n"
479 > hg parents --template "VISIBLE {rev}:{node|short}\n"
480 > hg status -amr
480 > hg status -amr
481 > # test that pending changes are hidden
481 > # test that pending changes are hidden
482 > unset HG_PENDING
482 > unset HG_PENDING
483 > hg parents --template "ACTUAL {rev}:{node|short}\n"
483 > hg parents --template "ACTUAL {rev}:{node|short}\n"
484 > hg status -amr
484 > hg status -amr
485 > echo "===="
485 > echo "===="
486 > EOF
486 > EOF
487
487
488 == test visibility to external editor
488 == test visibility to external editor
489
489
490 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
490 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
491 ====
491 ====
492 VISIBLE 0:80971e65b431
492 VISIBLE 0:80971e65b431
493 ACTUAL 0:80971e65b431
493 ACTUAL 0:80971e65b431
494 ====
494 ====
495
495
496 $ HGEDITOR="sh $TESTTMP/checkvisibility.sh" hg --cwd b import -v --edit ../patch1 ../patch2 ../patch3
496 $ HGEDITOR="sh $TESTTMP/checkvisibility.sh" hg --cwd b import -v --edit ../patch1 ../patch2 ../patch3
497 applying ../patch1
497 applying ../patch1
498 patching file a
498 patching file a
499 ====
499 ====
500 VISIBLE 0:80971e65b431
500 VISIBLE 0:80971e65b431
501 M a
501 M a
502 ACTUAL 0:80971e65b431
502 ACTUAL 0:80971e65b431
503 M a
503 M a
504 ====
504 ====
505 committing files:
505 committing files:
506 a
506 a
507 committing manifest
507 committing manifest
508 committing changelog
508 committing changelog
509 created 1d4bd90af0e4
509 created 1d4bd90af0e4
510 applying ../patch2
510 applying ../patch2
511 patching file a
511 patching file a
512 ====
512 ====
513 VISIBLE 1:1d4bd90af0e4
513 VISIBLE 1:1d4bd90af0e4
514 M a
514 M a
515 ACTUAL 0:80971e65b431
515 ACTUAL 0:80971e65b431
516 M a
516 M a
517 ====
517 ====
518 committing files:
518 committing files:
519 a
519 a
520 committing manifest
520 committing manifest
521 committing changelog
521 committing changelog
522 created 6d019af21222
522 created 6d019af21222
523 applying ../patch3
523 applying ../patch3
524 patching file foo
524 patching file foo
525 adding foo
525 adding foo
526 ====
526 ====
527 VISIBLE 2:6d019af21222
527 VISIBLE 2:6d019af21222
528 A foo
528 A foo
529 ACTUAL 0:80971e65b431
529 ACTUAL 0:80971e65b431
530 M a
530 M a
531 ====
531 ====
532 committing files:
532 committing files:
533 foo
533 foo
534 committing manifest
534 committing manifest
535 committing changelog
535 committing changelog
536 created 55e3f75b2378
536 created 55e3f75b2378
537
537
538 $ hg --cwd b rollback -q
538 $ hg --cwd b rollback -q
539
539
540 (content of file "a" is already changed and it should be recognized as
540 (content of file "a" is already changed and it should be recognized as
541 "M", even though dirstate is restored to one before "hg import")
541 "M", even though dirstate is restored to one before "hg import")
542
542
543 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
543 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
544 ====
544 ====
545 VISIBLE 0:80971e65b431
545 VISIBLE 0:80971e65b431
546 M a
546 M a
547 ACTUAL 0:80971e65b431
547 ACTUAL 0:80971e65b431
548 M a
548 M a
549 ====
549 ====
550 $ hg --cwd b revert --no-backup a
550 $ hg --cwd b revert --no-backup a
551 $ rm -f b/foo
551 $ rm -f b/foo
552
552
553 == test visibility to precommit external hook
553 == test visibility to precommit external hook
554
554
555 $ cat >> b/.hg/hgrc <<EOF
555 $ cat >> b/.hg/hgrc <<EOF
556 > [hooks]
556 > [hooks]
557 > precommit.visibility = sh $TESTTMP/checkvisibility.sh
557 > precommit.visibility = sh $TESTTMP/checkvisibility.sh
558 > EOF
558 > EOF
559
559
560 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
560 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
561 ====
561 ====
562 VISIBLE 0:80971e65b431
562 VISIBLE 0:80971e65b431
563 ACTUAL 0:80971e65b431
563 ACTUAL 0:80971e65b431
564 ====
564 ====
565
565
566 $ hg --cwd b import ../patch1 ../patch2 ../patch3
566 $ hg --cwd b import ../patch1 ../patch2 ../patch3
567 applying ../patch1
567 applying ../patch1
568 ====
568 ====
569 VISIBLE 0:80971e65b431
569 VISIBLE 0:80971e65b431
570 M a
570 M a
571 ACTUAL 0:80971e65b431
571 ACTUAL 0:80971e65b431
572 M a
572 M a
573 ====
573 ====
574 applying ../patch2
574 applying ../patch2
575 ====
575 ====
576 VISIBLE 1:1d4bd90af0e4
576 VISIBLE 1:1d4bd90af0e4
577 M a
577 M a
578 ACTUAL 0:80971e65b431
578 ACTUAL 0:80971e65b431
579 M a
579 M a
580 ====
580 ====
581 applying ../patch3
581 applying ../patch3
582 ====
582 ====
583 VISIBLE 2:6d019af21222
583 VISIBLE 2:6d019af21222
584 A foo
584 A foo
585 ACTUAL 0:80971e65b431
585 ACTUAL 0:80971e65b431
586 M a
586 M a
587 ====
587 ====
588
588
589 $ hg --cwd b rollback -q
589 $ hg --cwd b rollback -q
590 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
590 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
591 ====
591 ====
592 VISIBLE 0:80971e65b431
592 VISIBLE 0:80971e65b431
593 M a
593 M a
594 ACTUAL 0:80971e65b431
594 ACTUAL 0:80971e65b431
595 M a
595 M a
596 ====
596 ====
597 $ hg --cwd b revert --no-backup a
597 $ hg --cwd b revert --no-backup a
598 $ rm -f b/foo
598 $ rm -f b/foo
599
599
600 $ cat >> b/.hg/hgrc <<EOF
600 $ cat >> b/.hg/hgrc <<EOF
601 > [hooks]
601 > [hooks]
602 > precommit.visibility =
602 > precommit.visibility =
603 > EOF
603 > EOF
604
604
605 == test visibility to pretxncommit external hook
605 == test visibility to pretxncommit external hook
606
606
607 $ cat >> b/.hg/hgrc <<EOF
607 $ cat >> b/.hg/hgrc <<EOF
608 > [hooks]
608 > [hooks]
609 > pretxncommit.visibility = sh $TESTTMP/checkvisibility.sh
609 > pretxncommit.visibility = sh $TESTTMP/checkvisibility.sh
610 > EOF
610 > EOF
611
611
612 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
612 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
613 ====
613 ====
614 VISIBLE 0:80971e65b431
614 VISIBLE 0:80971e65b431
615 ACTUAL 0:80971e65b431
615 ACTUAL 0:80971e65b431
616 ====
616 ====
617
617
618 $ hg --cwd b import ../patch1 ../patch2 ../patch3
618 $ hg --cwd b import ../patch1 ../patch2 ../patch3
619 applying ../patch1
619 applying ../patch1
620 ====
620 ====
621 VISIBLE 0:80971e65b431
621 VISIBLE 0:80971e65b431
622 M a
622 M a
623 ACTUAL 0:80971e65b431
623 ACTUAL 0:80971e65b431
624 M a
624 M a
625 ====
625 ====
626 applying ../patch2
626 applying ../patch2
627 ====
627 ====
628 VISIBLE 1:1d4bd90af0e4
628 VISIBLE 1:1d4bd90af0e4
629 M a
629 M a
630 ACTUAL 0:80971e65b431
630 ACTUAL 0:80971e65b431
631 M a
631 M a
632 ====
632 ====
633 applying ../patch3
633 applying ../patch3
634 ====
634 ====
635 VISIBLE 2:6d019af21222
635 VISIBLE 2:6d019af21222
636 A foo
636 A foo
637 ACTUAL 0:80971e65b431
637 ACTUAL 0:80971e65b431
638 M a
638 M a
639 ====
639 ====
640
640
641 $ hg --cwd b rollback -q
641 $ hg --cwd b rollback -q
642 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
642 $ (cd b && sh "$TESTTMP/checkvisibility.sh")
643 ====
643 ====
644 VISIBLE 0:80971e65b431
644 VISIBLE 0:80971e65b431
645 M a
645 M a
646 ACTUAL 0:80971e65b431
646 ACTUAL 0:80971e65b431
647 M a
647 M a
648 ====
648 ====
649 $ hg --cwd b revert --no-backup a
649 $ hg --cwd b revert --no-backup a
650 $ rm -f b/foo
650 $ rm -f b/foo
651
651
652 $ cat >> b/.hg/hgrc <<EOF
652 $ cat >> b/.hg/hgrc <<EOF
653 > [hooks]
653 > [hooks]
654 > pretxncommit.visibility =
654 > pretxncommit.visibility =
655 > EOF
655 > EOF
656
656
657 $ rm -r b
657 $ rm -r b
658
658
659
659
660 importing a patch in a subdirectory failed at the commit stage
660 importing a patch in a subdirectory failed at the commit stage
661
661
662 $ echo line 2 >> a/d1/d2/a
662 $ echo line 2 >> a/d1/d2/a
663 $ hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change'
663 $ hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change'
664
664
665 hg import in a subdirectory
665 hg import in a subdirectory
666
666
667 $ hg clone -r0 a b
667 $ hg clone -r0 a b
668 adding changesets
668 adding changesets
669 adding manifests
669 adding manifests
670 adding file changes
670 adding file changes
671 added 1 changesets with 2 changes to 2 files
671 added 1 changesets with 2 changes to 2 files
672 new changesets 80971e65b431
672 new changesets 80971e65b431
673 updating to branch default
673 updating to branch default
674 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
674 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
675 $ hg --cwd a export tip > tmp
675 $ hg --cwd a export tip > tmp
676 $ sed -e 's/d1\/d2\///' < tmp > subdir-tip.patch
676 $ sed -e 's/d1\/d2\///' < tmp > subdir-tip.patch
677 $ dir=`pwd`
677 $ dir=`pwd`
678 $ cd b/d1/d2 2>&1 > /dev/null
678 $ cd b/d1/d2 2>&1 > /dev/null
679 $ hg import ../../../subdir-tip.patch
679 $ hg import ../../../subdir-tip.patch
680 applying ../../../subdir-tip.patch
680 applying ../../../subdir-tip.patch
681 $ cd "$dir"
681 $ cd "$dir"
682
682
683 message should be 'subdir change'
683 message should be 'subdir change'
684 committer should be 'someoneelse'
684 committer should be 'someoneelse'
685
685
686 $ hg --cwd b tip
686 $ hg --cwd b tip
687 changeset: 1:3577f5aea227
687 changeset: 1:3577f5aea227
688 tag: tip
688 tag: tip
689 user: someoneelse
689 user: someoneelse
690 date: Thu Jan 01 00:00:01 1970 +0000
690 date: Thu Jan 01 00:00:01 1970 +0000
691 summary: subdir change
691 summary: subdir change
692
692
693
693
694 should be empty
694 should be empty
695
695
696 $ hg --cwd b status
696 $ hg --cwd b status
697
697
698
698
699 Test fuzziness (ambiguous patch location, fuzz=2)
699 Test fuzziness (ambiguous patch location, fuzz=2)
700
700
701 $ hg init fuzzy
701 $ hg init fuzzy
702 $ cd fuzzy
702 $ cd fuzzy
703 $ echo line1 > a
703 $ echo line1 > a
704 $ echo line0 >> a
704 $ echo line0 >> a
705 $ echo line3 >> a
705 $ echo line3 >> a
706 $ hg ci -Am adda
706 $ hg ci -Am adda
707 adding a
707 adding a
708 $ echo line1 > a
708 $ echo line1 > a
709 $ echo line2 >> a
709 $ echo line2 >> a
710 $ echo line0 >> a
710 $ echo line0 >> a
711 $ echo line3 >> a
711 $ echo line3 >> a
712 $ hg ci -m change a
712 $ hg ci -m change a
713 $ hg export tip > fuzzy-tip.patch
713 $ hg export tip > fuzzy-tip.patch
714 $ hg up -C 0
714 $ hg up -C 0
715 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
715 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
716 $ echo line1 > a
716 $ echo line1 > a
717 $ echo line0 >> a
717 $ echo line0 >> a
718 $ echo line1 >> a
718 $ echo line1 >> a
719 $ echo line0 >> a
719 $ echo line0 >> a
720 $ hg ci -m brancha
720 $ hg ci -m brancha
721 created new head
721 created new head
722 $ hg import --config patch.fuzz=0 -v fuzzy-tip.patch
722 $ hg import --config patch.fuzz=0 -v fuzzy-tip.patch
723 applying fuzzy-tip.patch
723 applying fuzzy-tip.patch
724 patching file a
724 patching file a
725 Hunk #1 FAILED at 0
725 Hunk #1 FAILED at 0
726 1 out of 1 hunks FAILED -- saving rejects to file a.rej
726 1 out of 1 hunks FAILED -- saving rejects to file a.rej
727 abort: patch failed to apply
727 abort: patch failed to apply
728 [255]
728 [255]
729 $ hg import --no-commit -v fuzzy-tip.patch
729 $ hg import --no-commit -v fuzzy-tip.patch
730 applying fuzzy-tip.patch
730 applying fuzzy-tip.patch
731 patching file a
731 patching file a
732 Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines).
732 Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines).
733 applied to working directory
733 applied to working directory
734 $ hg revert -a
734 $ hg revert -a
735 reverting a
735 reverting a
736
736
737
737
738 import with --no-commit should have written .hg/last-message.txt
738 import with --no-commit should have written .hg/last-message.txt
739
739
740 $ cat .hg/last-message.txt
740 $ cat .hg/last-message.txt
741 change (no-eol)
741 change (no-eol)
742
742
743
743
744 test fuzziness with eol=auto
744 test fuzziness with eol=auto
745
745
746 $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch
746 $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch
747 applying fuzzy-tip.patch
747 applying fuzzy-tip.patch
748 patching file a
748 patching file a
749 Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines).
749 Hunk #1 succeeded at 2 with fuzz 1 (offset 0 lines).
750 applied to working directory
750 applied to working directory
751 $ cd ..
751 $ cd ..
752
752
753
753
754 Test hunk touching empty files (issue906)
754 Test hunk touching empty files (issue906)
755
755
756 $ hg init empty
756 $ hg init empty
757 $ cd empty
757 $ cd empty
758 $ touch a
758 $ touch a
759 $ touch b1
759 $ touch b1
760 $ touch c1
760 $ touch c1
761 $ echo d > d
761 $ echo d > d
762 $ hg ci -Am init
762 $ hg ci -Am init
763 adding a
763 adding a
764 adding b1
764 adding b1
765 adding c1
765 adding c1
766 adding d
766 adding d
767 $ echo a > a
767 $ echo a > a
768 $ echo b > b1
768 $ echo b > b1
769 $ hg mv b1 b2
769 $ hg mv b1 b2
770 $ echo c > c1
770 $ echo c > c1
771 $ hg copy c1 c2
771 $ hg copy c1 c2
772 $ rm d
772 $ rm d
773 $ touch d
773 $ touch d
774 $ hg diff --git
774 $ hg diff --git
775 diff --git a/a b/a
775 diff --git a/a b/a
776 --- a/a
776 --- a/a
777 +++ b/a
777 +++ b/a
778 @@ -0,0 +1,1 @@
778 @@ -0,0 +1,1 @@
779 +a
779 +a
780 diff --git a/b1 b/b2
780 diff --git a/b1 b/b2
781 rename from b1
781 rename from b1
782 rename to b2
782 rename to b2
783 --- a/b1
783 --- a/b1
784 +++ b/b2
784 +++ b/b2
785 @@ -0,0 +1,1 @@
785 @@ -0,0 +1,1 @@
786 +b
786 +b
787 diff --git a/c1 b/c1
787 diff --git a/c1 b/c1
788 --- a/c1
788 --- a/c1
789 +++ b/c1
789 +++ b/c1
790 @@ -0,0 +1,1 @@
790 @@ -0,0 +1,1 @@
791 +c
791 +c
792 diff --git a/c1 b/c2
792 diff --git a/c1 b/c2
793 copy from c1
793 copy from c1
794 copy to c2
794 copy to c2
795 --- a/c1
795 --- a/c1
796 +++ b/c2
796 +++ b/c2
797 @@ -0,0 +1,1 @@
797 @@ -0,0 +1,1 @@
798 +c
798 +c
799 diff --git a/d b/d
799 diff --git a/d b/d
800 --- a/d
800 --- a/d
801 +++ b/d
801 +++ b/d
802 @@ -1,1 +0,0 @@
802 @@ -1,1 +0,0 @@
803 -d
803 -d
804 $ hg ci -m empty
804 $ hg ci -m empty
805 $ hg export --git tip > empty.diff
805 $ hg export --git tip > empty.diff
806 $ hg up -C 0
806 $ hg up -C 0
807 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
807 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
808 $ hg import empty.diff
808 $ hg import empty.diff
809 applying empty.diff
809 applying empty.diff
810 $ for name in a b1 b2 c1 c2 d; do
810 $ for name in a b1 b2 c1 c2 d; do
811 > echo % $name file
811 > echo % $name file
812 > test -f $name && cat $name
812 > test -f $name && cat $name
813 > done
813 > done
814 % a file
814 % a file
815 a
815 a
816 % b1 file
816 % b1 file
817 % b2 file
817 % b2 file
818 b
818 b
819 % c1 file
819 % c1 file
820 c
820 c
821 % c2 file
821 % c2 file
822 c
822 c
823 % d file
823 % d file
824 $ cd ..
824 $ cd ..
825
825
826
826
827 Test importing a patch ending with a binary file removal
827 Test importing a patch ending with a binary file removal
828
828
829 $ hg init binaryremoval
829 $ hg init binaryremoval
830 $ cd binaryremoval
830 $ cd binaryremoval
831 $ echo a > a
831 $ echo a > a
832 $ $PYTHON -c "open('b', 'wb').write(b'a\x00b')"
832 $ $PYTHON -c "open('b', 'wb').write(b'a\x00b')"
833 $ hg ci -Am addall
833 $ hg ci -Am addall
834 adding a
834 adding a
835 adding b
835 adding b
836 $ hg rm a
836 $ hg rm a
837 $ hg rm b
837 $ hg rm b
838 $ hg st
838 $ hg st
839 R a
839 R a
840 R b
840 R b
841 $ hg ci -m remove
841 $ hg ci -m remove
842 $ hg export --git . > remove.diff
842 $ hg export --git . > remove.diff
843 $ cat remove.diff | grep git
843 $ cat remove.diff | grep git
844 diff --git a/a b/a
844 diff --git a/a b/a
845 diff --git a/b b/b
845 diff --git a/b b/b
846 $ hg up -C 0
846 $ hg up -C 0
847 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
847 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
848 $ hg import remove.diff
848 $ hg import remove.diff
849 applying remove.diff
849 applying remove.diff
850 $ hg manifest
850 $ hg manifest
851 $ cd ..
851 $ cd ..
852
852
853
853
854 Issue927: test update+rename with common name
854 Issue927: test update+rename with common name
855
855
856 $ hg init t
856 $ hg init t
857 $ cd t
857 $ cd t
858 $ touch a
858 $ touch a
859 $ hg ci -Am t
859 $ hg ci -Am t
860 adding a
860 adding a
861 $ echo a > a
861 $ echo a > a
862
862
863 Here, bfile.startswith(afile)
863 Here, bfile.startswith(afile)
864
864
865 $ hg copy a a2
865 $ hg copy a a2
866 $ hg ci -m copya
866 $ hg ci -m copya
867 $ hg export --git tip > copy.diff
867 $ hg export --git tip > copy.diff
868 $ hg up -C 0
868 $ hg up -C 0
869 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
869 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
870 $ hg import copy.diff
870 $ hg import copy.diff
871 applying copy.diff
871 applying copy.diff
872
872
873 a should contain an 'a'
873 a should contain an 'a'
874
874
875 $ cat a
875 $ cat a
876 a
876 a
877
877
878 and a2 should have duplicated it
878 and a2 should have duplicated it
879
879
880 $ cat a2
880 $ cat a2
881 a
881 a
882 $ cd ..
882 $ cd ..
883
883
884
884
885 test -p0
885 test -p0
886
886
887 $ hg init p0
887 $ hg init p0
888 $ cd p0
888 $ cd p0
889 $ echo a > a
889 $ echo a > a
890 $ hg ci -Am t
890 $ hg ci -Am t
891 adding a
891 adding a
892 $ hg import -p foo
892 $ hg import -p foo
893 abort: invalid value 'foo' for option -p, expected int
893 abort: invalid value 'foo' for option -p, expected int
894 [255]
894 [255]
895 $ hg import -p0 - << EOF
895 $ hg import -p0 - << EOF
896 > foobar
896 > foobar
897 > --- a Sat Apr 12 22:43:58 2008 -0400
897 > --- a Sat Apr 12 22:43:58 2008 -0400
898 > +++ a Sat Apr 12 22:44:05 2008 -0400
898 > +++ a Sat Apr 12 22:44:05 2008 -0400
899 > @@ -1,1 +1,1 @@
899 > @@ -1,1 +1,1 @@
900 > -a
900 > -a
901 > +bb
901 > +bb
902 > EOF
902 > EOF
903 applying patch from stdin
903 applying patch from stdin
904 $ hg status
904 $ hg status
905 $ cat a
905 $ cat a
906 bb
906 bb
907
907
908 test --prefix
908 test --prefix
909
909
910 $ mkdir -p dir/dir2
910 $ mkdir -p dir/dir2
911 $ echo b > dir/dir2/b
911 $ echo b > dir/dir2/b
912 $ hg ci -Am b
912 $ hg ci -Am b
913 adding dir/dir2/b
913 adding dir/dir2/b
914 $ hg import -p2 --prefix dir - << EOF
914 $ hg import -p2 --prefix dir - << EOF
915 > foobar
915 > foobar
916 > --- drop1/drop2/dir2/b
916 > --- drop1/drop2/dir2/b
917 > +++ drop1/drop2/dir2/b
917 > +++ drop1/drop2/dir2/b
918 > @@ -1,1 +1,1 @@
918 > @@ -1,1 +1,1 @@
919 > -b
919 > -b
920 > +cc
920 > +cc
921 > EOF
921 > EOF
922 applying patch from stdin
922 applying patch from stdin
923 $ hg status
923 $ hg status
924 $ cat dir/dir2/b
924 $ cat dir/dir2/b
925 cc
925 cc
926 $ cd ..
926 $ cd ..
927
927
928
928
929 test paths outside repo root
929 test paths outside repo root
930
930
931 $ mkdir outside
931 $ mkdir outside
932 $ touch outside/foo
932 $ touch outside/foo
933 $ hg init inside
933 $ hg init inside
934 $ cd inside
934 $ cd inside
935 $ hg import - <<EOF
935 $ hg import - <<EOF
936 > diff --git a/a b/b
936 > diff --git a/a b/b
937 > rename from ../outside/foo
937 > rename from ../outside/foo
938 > rename to bar
938 > rename to bar
939 > EOF
939 > EOF
940 applying patch from stdin
940 applying patch from stdin
941 abort: path contains illegal component: ../outside/foo
941 abort: path contains illegal component: ../outside/foo
942 [255]
942 [255]
943 $ cd ..
943 $ cd ..
944
944
945
945
946 test import with similarity and git and strip (issue295 et al.)
946 test import with similarity and git and strip (issue295 et al.)
947
947
948 $ hg init sim
948 $ hg init sim
949 $ cd sim
949 $ cd sim
950 $ echo 'this is a test' > a
950 $ echo 'this is a test' > a
951 $ hg ci -Ama
951 $ hg ci -Ama
952 adding a
952 adding a
953 $ cat > ../rename.diff <<EOF
953 $ cat > ../rename.diff <<EOF
954 > diff --git a/foo/a b/foo/a
954 > diff --git a/foo/a b/foo/a
955 > deleted file mode 100644
955 > deleted file mode 100644
956 > --- a/foo/a
956 > --- a/foo/a
957 > +++ /dev/null
957 > +++ /dev/null
958 > @@ -1,1 +0,0 @@
958 > @@ -1,1 +0,0 @@
959 > -this is a test
959 > -this is a test
960 > diff --git a/foo/b b/foo/b
960 > diff --git a/foo/b b/foo/b
961 > new file mode 100644
961 > new file mode 100644
962 > --- /dev/null
962 > --- /dev/null
963 > +++ b/foo/b
963 > +++ b/foo/b
964 > @@ -0,0 +1,2 @@
964 > @@ -0,0 +1,2 @@
965 > +this is a test
965 > +this is a test
966 > +foo
966 > +foo
967 > EOF
967 > EOF
968 $ hg import --no-commit -v -s 1 ../rename.diff -p2
968 $ hg import --no-commit -v -s 1 ../rename.diff -p2
969 applying ../rename.diff
969 applying ../rename.diff
970 patching file a
970 patching file a
971 patching file b
971 patching file b
972 adding b
972 adding b
973 recording removal of a as rename to b (88% similar)
973 recording removal of a as rename to b (88% similar)
974 applied to working directory
974 applied to working directory
975 $ echo 'mod b' > b
975 $ echo 'mod b' > b
976 $ hg st -C
976 $ hg st -C
977 A b
977 A b
978 a
978 a
979 R a
979 R a
980 $ hg revert -a
980 $ hg revert -a
981 undeleting a
981 undeleting a
982 forgetting b
982 forgetting b
983 $ cat b
983 $ cat b
984 mod b
984 mod b
985 $ rm b
985 $ rm b
986 $ hg import --no-commit -v -s 100 ../rename.diff -p2
986 $ hg import --no-commit -v -s 100 ../rename.diff -p2
987 applying ../rename.diff
987 applying ../rename.diff
988 patching file a
988 patching file a
989 patching file b
989 patching file b
990 adding b
990 adding b
991 applied to working directory
991 applied to working directory
992 $ hg st -C
992 $ hg st -C
993 A b
993 A b
994 R a
994 R a
995 $ cd ..
995 $ cd ..
996
996
997
997
998 Issue1495: add empty file from the end of patch
998 Issue1495: add empty file from the end of patch
999
999
1000 $ hg init addemptyend
1000 $ hg init addemptyend
1001 $ cd addemptyend
1001 $ cd addemptyend
1002 $ touch a
1002 $ touch a
1003 $ hg addremove
1003 $ hg addremove
1004 adding a
1004 adding a
1005 $ hg ci -m "commit"
1005 $ hg ci -m "commit"
1006 $ cat > a.patch <<EOF
1006 $ cat > a.patch <<EOF
1007 > add a, b
1007 > add a, b
1008 > diff --git a/a b/a
1008 > diff --git a/a b/a
1009 > --- a/a
1009 > --- a/a
1010 > +++ b/a
1010 > +++ b/a
1011 > @@ -0,0 +1,1 @@
1011 > @@ -0,0 +1,1 @@
1012 > +a
1012 > +a
1013 > diff --git a/b b/b
1013 > diff --git a/b b/b
1014 > new file mode 100644
1014 > new file mode 100644
1015 > EOF
1015 > EOF
1016 $ hg import --no-commit a.patch
1016 $ hg import --no-commit a.patch
1017 applying a.patch
1017 applying a.patch
1018
1018
1019 apply a good patch followed by an empty patch (mainly to ensure
1019 apply a good patch followed by an empty patch (mainly to ensure
1020 that dirstate is *not* updated when import crashes)
1020 that dirstate is *not* updated when import crashes)
1021 $ hg update -q -C .
1021 $ hg update -q -C .
1022 $ rm b
1022 $ rm b
1023 $ touch empty.patch
1023 $ touch empty.patch
1024 $ hg import a.patch empty.patch
1024 $ hg import a.patch empty.patch
1025 applying a.patch
1025 applying a.patch
1026 applying empty.patch
1026 applying empty.patch
1027 transaction abort!
1027 transaction abort!
1028 rollback completed
1028 rollback completed
1029 abort: empty.patch: no diffs found
1029 abort: empty.patch: no diffs found
1030 [255]
1030 [255]
1031 $ hg tip --template '{rev} {desc|firstline}\n'
1031 $ hg tip --template '{rev} {desc|firstline}\n'
1032 0 commit
1032 0 commit
1033 $ hg -q status
1033 $ hg -q status
1034 M a
1034 M a
1035 $ cd ..
1035 $ cd ..
1036
1036
1037 create file when source is not /dev/null
1037 create file when source is not /dev/null
1038
1038
1039 $ cat > create.patch <<EOF
1039 $ cat > create.patch <<EOF
1040 > diff -Naur proj-orig/foo proj-new/foo
1040 > diff -Naur proj-orig/foo proj-new/foo
1041 > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800
1041 > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800
1042 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
1042 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
1043 > @@ -0,0 +1,1 @@
1043 > @@ -0,0 +1,1 @@
1044 > +a
1044 > +a
1045 > EOF
1045 > EOF
1046
1046
1047 some people have patches like the following too
1047 some people have patches like the following too
1048
1048
1049 $ cat > create2.patch <<EOF
1049 $ cat > create2.patch <<EOF
1050 > diff -Naur proj-orig/foo proj-new/foo
1050 > diff -Naur proj-orig/foo proj-new/foo
1051 > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800
1051 > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800
1052 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
1052 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
1053 > @@ -0,0 +1,1 @@
1053 > @@ -0,0 +1,1 @@
1054 > +a
1054 > +a
1055 > EOF
1055 > EOF
1056 $ hg init oddcreate
1056 $ hg init oddcreate
1057 $ cd oddcreate
1057 $ cd oddcreate
1058 $ hg import --no-commit ../create.patch
1058 $ hg import --no-commit ../create.patch
1059 applying ../create.patch
1059 applying ../create.patch
1060 $ cat foo
1060 $ cat foo
1061 a
1061 a
1062 $ rm foo
1062 $ rm foo
1063 $ hg revert foo
1063 $ hg revert foo
1064 $ hg import --no-commit ../create2.patch
1064 $ hg import --no-commit ../create2.patch
1065 applying ../create2.patch
1065 applying ../create2.patch
1066 $ cat foo
1066 $ cat foo
1067 a
1067 a
1068
1068
1069 $ cd ..
1069 $ cd ..
1070
1070
1071 Issue1859: first line mistaken for email headers
1071 Issue1859: first line mistaken for email headers
1072
1072
1073 $ hg init emailconfusion
1073 $ hg init emailconfusion
1074 $ cd emailconfusion
1074 $ cd emailconfusion
1075 $ cat > a.patch <<EOF
1075 $ cat > a.patch <<EOF
1076 > module: summary
1076 > module: summary
1077 >
1077 >
1078 > description
1078 > description
1079 >
1079 >
1080 >
1080 >
1081 > diff -r 000000000000 -r 9b4c1e343b55 test.txt
1081 > diff -r 000000000000 -r 9b4c1e343b55 test.txt
1082 > --- /dev/null
1082 > --- /dev/null
1083 > +++ b/a
1083 > +++ b/a
1084 > @@ -0,0 +1,1 @@
1084 > @@ -0,0 +1,1 @@
1085 > +a
1085 > +a
1086 > EOF
1086 > EOF
1087 $ hg import -d '0 0' a.patch
1087 $ hg import -d '0 0' a.patch
1088 applying a.patch
1088 applying a.patch
1089 $ hg parents -v
1089 $ hg parents -v
1090 changeset: 0:5a681217c0ad
1090 changeset: 0:5a681217c0ad
1091 tag: tip
1091 tag: tip
1092 user: test
1092 user: test
1093 date: Thu Jan 01 00:00:00 1970 +0000
1093 date: Thu Jan 01 00:00:00 1970 +0000
1094 files: a
1094 files: a
1095 description:
1095 description:
1096 module: summary
1096 module: summary
1097
1097
1098 description
1098 description
1099
1099
1100
1100
1101 $ cd ..
1101 $ cd ..
1102
1102
1103
1103
1104 in commit message
1104 in commit message
1105
1105
1106 $ hg init commitconfusion
1106 $ hg init commitconfusion
1107 $ cd commitconfusion
1107 $ cd commitconfusion
1108 $ cat > a.patch <<EOF
1108 $ cat > a.patch <<EOF
1109 > module: summary
1109 > module: summary
1110 >
1110 >
1111 > --- description
1111 > --- description
1112 >
1112 >
1113 > diff --git a/a b/a
1113 > diff --git a/a b/a
1114 > new file mode 100644
1114 > new file mode 100644
1115 > --- /dev/null
1115 > --- /dev/null
1116 > +++ b/a
1116 > +++ b/a
1117 > @@ -0,0 +1,1 @@
1117 > @@ -0,0 +1,1 @@
1118 > +a
1118 > +a
1119 > EOF
1119 > EOF
1120 > hg import -d '0 0' a.patch
1120 > hg import -d '0 0' a.patch
1121 > hg parents -v
1121 > hg parents -v
1122 > cd ..
1122 > cd ..
1123 >
1123 >
1124 > echo '% tricky header splitting'
1124 > echo '% tricky header splitting'
1125 > cat > trickyheaders.patch <<EOF
1125 > cat > trickyheaders.patch <<EOF
1126 > From: User A <user@a>
1126 > From: User A <user@a>
1127 > Subject: [PATCH] from: tricky!
1127 > Subject: [PATCH] from: tricky!
1128 >
1128 >
1129 > # HG changeset patch
1129 > # HG changeset patch
1130 > # User User B
1130 > # User User B
1131 > # Date 1266264441 18000
1131 > # Date 1266264441 18000
1132 > # Branch stable
1132 > # Branch stable
1133 > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0
1133 > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0
1134 > # Parent 0000000000000000000000000000000000000000
1134 > # Parent 0000000000000000000000000000000000000000
1135 > from: tricky!
1135 > from: tricky!
1136 >
1136 >
1137 > That is not a header.
1137 > That is not a header.
1138 >
1138 >
1139 > diff -r 000000000000 -r f2be6a1170ac foo
1139 > diff -r 000000000000 -r f2be6a1170ac foo
1140 > --- /dev/null
1140 > --- /dev/null
1141 > +++ b/foo
1141 > +++ b/foo
1142 > @@ -0,0 +1,1 @@
1142 > @@ -0,0 +1,1 @@
1143 > +foo
1143 > +foo
1144 > EOF
1144 > EOF
1145 applying a.patch
1145 applying a.patch
1146 changeset: 0:f34d9187897d
1146 changeset: 0:f34d9187897d
1147 tag: tip
1147 tag: tip
1148 user: test
1148 user: test
1149 date: Thu Jan 01 00:00:00 1970 +0000
1149 date: Thu Jan 01 00:00:00 1970 +0000
1150 files: a
1150 files: a
1151 description:
1151 description:
1152 module: summary
1152 module: summary
1153
1153
1154
1154
1155 % tricky header splitting
1155 % tricky header splitting
1156
1156
1157 $ hg init trickyheaders
1157 $ hg init trickyheaders
1158 $ cd trickyheaders
1158 $ cd trickyheaders
1159 $ hg import -d '0 0' ../trickyheaders.patch
1159 $ hg import -d '0 0' ../trickyheaders.patch
1160 applying ../trickyheaders.patch
1160 applying ../trickyheaders.patch
1161 $ hg export --git tip
1161 $ hg export --git tip
1162 # HG changeset patch
1162 # HG changeset patch
1163 # User User B
1163 # User User B
1164 # Date 0 0
1164 # Date 0 0
1165 # Thu Jan 01 00:00:00 1970 +0000
1165 # Thu Jan 01 00:00:00 1970 +0000
1166 # Node ID eb56ab91903632294ac504838508cb370c0901d2
1166 # Node ID eb56ab91903632294ac504838508cb370c0901d2
1167 # Parent 0000000000000000000000000000000000000000
1167 # Parent 0000000000000000000000000000000000000000
1168 from: tricky!
1168 from: tricky!
1169
1169
1170 That is not a header.
1170 That is not a header.
1171
1171
1172 diff --git a/foo b/foo
1172 diff --git a/foo b/foo
1173 new file mode 100644
1173 new file mode 100644
1174 --- /dev/null
1174 --- /dev/null
1175 +++ b/foo
1175 +++ b/foo
1176 @@ -0,0 +1,1 @@
1176 @@ -0,0 +1,1 @@
1177 +foo
1177 +foo
1178 $ cd ..
1178 $ cd ..
1179
1179
1180
1180
1181 Issue2102: hg export and hg import speak different languages
1181 Issue2102: hg export and hg import speak different languages
1182
1182
1183 $ hg init issue2102
1183 $ hg init issue2102
1184 $ cd issue2102
1184 $ cd issue2102
1185 $ mkdir -p src/cmd/gc
1185 $ mkdir -p src/cmd/gc
1186 $ touch src/cmd/gc/mksys.bash
1186 $ touch src/cmd/gc/mksys.bash
1187 $ hg ci -Am init
1187 $ hg ci -Am init
1188 adding src/cmd/gc/mksys.bash
1188 adding src/cmd/gc/mksys.bash
1189 $ hg import - <<EOF
1189 $ hg import - <<EOF
1190 > # HG changeset patch
1190 > # HG changeset patch
1191 > # User Rob Pike
1191 > # User Rob Pike
1192 > # Date 1216685449 25200
1192 > # Date 1216685449 25200
1193 > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98
1193 > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98
1194 > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84
1194 > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84
1195 > help management of empty pkg and lib directories in perforce
1195 > help management of empty pkg and lib directories in perforce
1196 >
1196 >
1197 > R=gri
1197 > R=gri
1198 > DELTA=4 (4 added, 0 deleted, 0 changed)
1198 > DELTA=4 (4 added, 0 deleted, 0 changed)
1199 > OCL=13328
1199 > OCL=13328
1200 > CL=13328
1200 > CL=13328
1201 >
1201 >
1202 > diff --git a/lib/place-holder b/lib/place-holder
1202 > diff --git a/lib/place-holder b/lib/place-holder
1203 > new file mode 100644
1203 > new file mode 100644
1204 > --- /dev/null
1204 > --- /dev/null
1205 > +++ b/lib/place-holder
1205 > +++ b/lib/place-holder
1206 > @@ -0,0 +1,2 @@
1206 > @@ -0,0 +1,2 @@
1207 > +perforce does not maintain empty directories.
1207 > +perforce does not maintain empty directories.
1208 > +this file helps.
1208 > +this file helps.
1209 > diff --git a/pkg/place-holder b/pkg/place-holder
1209 > diff --git a/pkg/place-holder b/pkg/place-holder
1210 > new file mode 100644
1210 > new file mode 100644
1211 > --- /dev/null
1211 > --- /dev/null
1212 > +++ b/pkg/place-holder
1212 > +++ b/pkg/place-holder
1213 > @@ -0,0 +1,2 @@
1213 > @@ -0,0 +1,2 @@
1214 > +perforce does not maintain empty directories.
1214 > +perforce does not maintain empty directories.
1215 > +this file helps.
1215 > +this file helps.
1216 > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
1216 > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
1217 > old mode 100644
1217 > old mode 100644
1218 > new mode 100755
1218 > new mode 100755
1219 > EOF
1219 > EOF
1220 applying patch from stdin
1220 applying patch from stdin
1221
1221
1222 #if execbit
1222 #if execbit
1223
1223
1224 $ hg sum
1224 $ hg sum
1225 parent: 1:d59915696727 tip
1225 parent: 1:d59915696727 tip
1226 help management of empty pkg and lib directories in perforce
1226 help management of empty pkg and lib directories in perforce
1227 branch: default
1227 branch: default
1228 commit: (clean)
1228 commit: (clean)
1229 update: (current)
1229 update: (current)
1230 phases: 2 draft
1230 phases: 2 draft
1231
1231
1232 $ hg diff --git -c tip
1232 $ hg diff --git -c tip
1233 diff --git a/lib/place-holder b/lib/place-holder
1233 diff --git a/lib/place-holder b/lib/place-holder
1234 new file mode 100644
1234 new file mode 100644
1235 --- /dev/null
1235 --- /dev/null
1236 +++ b/lib/place-holder
1236 +++ b/lib/place-holder
1237 @@ -0,0 +1,2 @@
1237 @@ -0,0 +1,2 @@
1238 +perforce does not maintain empty directories.
1238 +perforce does not maintain empty directories.
1239 +this file helps.
1239 +this file helps.
1240 diff --git a/pkg/place-holder b/pkg/place-holder
1240 diff --git a/pkg/place-holder b/pkg/place-holder
1241 new file mode 100644
1241 new file mode 100644
1242 --- /dev/null
1242 --- /dev/null
1243 +++ b/pkg/place-holder
1243 +++ b/pkg/place-holder
1244 @@ -0,0 +1,2 @@
1244 @@ -0,0 +1,2 @@
1245 +perforce does not maintain empty directories.
1245 +perforce does not maintain empty directories.
1246 +this file helps.
1246 +this file helps.
1247 diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
1247 diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
1248 old mode 100644
1248 old mode 100644
1249 new mode 100755
1249 new mode 100755
1250
1250
1251 #else
1251 #else
1252
1252
1253 $ hg sum
1253 $ hg sum
1254 parent: 1:28f089cc9ccc tip
1254 parent: 1:28f089cc9ccc tip
1255 help management of empty pkg and lib directories in perforce
1255 help management of empty pkg and lib directories in perforce
1256 branch: default
1256 branch: default
1257 commit: (clean)
1257 commit: (clean)
1258 update: (current)
1258 update: (current)
1259 phases: 2 draft
1259 phases: 2 draft
1260
1260
1261 $ hg diff --git -c tip
1261 $ hg diff --git -c tip
1262 diff --git a/lib/place-holder b/lib/place-holder
1262 diff --git a/lib/place-holder b/lib/place-holder
1263 new file mode 100644
1263 new file mode 100644
1264 --- /dev/null
1264 --- /dev/null
1265 +++ b/lib/place-holder
1265 +++ b/lib/place-holder
1266 @@ -0,0 +1,2 @@
1266 @@ -0,0 +1,2 @@
1267 +perforce does not maintain empty directories.
1267 +perforce does not maintain empty directories.
1268 +this file helps.
1268 +this file helps.
1269 diff --git a/pkg/place-holder b/pkg/place-holder
1269 diff --git a/pkg/place-holder b/pkg/place-holder
1270 new file mode 100644
1270 new file mode 100644
1271 --- /dev/null
1271 --- /dev/null
1272 +++ b/pkg/place-holder
1272 +++ b/pkg/place-holder
1273 @@ -0,0 +1,2 @@
1273 @@ -0,0 +1,2 @@
1274 +perforce does not maintain empty directories.
1274 +perforce does not maintain empty directories.
1275 +this file helps.
1275 +this file helps.
1276
1276
1277 /* The mode change for mksys.bash is missing here, because on platforms */
1277 /* The mode change for mksys.bash is missing here, because on platforms */
1278 /* that don't support execbits, mode changes in patches are ignored when */
1278 /* that don't support execbits, mode changes in patches are ignored when */
1279 /* they are imported. This is obviously also the reason for why the hash */
1279 /* they are imported. This is obviously also the reason for why the hash */
1280 /* in the created changeset is different to the one you see above the */
1280 /* in the created changeset is different to the one you see above the */
1281 /* #else clause */
1281 /* #else clause */
1282
1282
1283 #endif
1283 #endif
1284 $ cd ..
1284 $ cd ..
1285
1285
1286
1286
1287 diff lines looking like headers
1287 diff lines looking like headers
1288
1288
1289 $ hg init difflineslikeheaders
1289 $ hg init difflineslikeheaders
1290 $ cd difflineslikeheaders
1290 $ cd difflineslikeheaders
1291 $ echo a >a
1291 $ echo a >a
1292 $ echo b >b
1292 $ echo b >b
1293 $ echo c >c
1293 $ echo c >c
1294 $ hg ci -Am1
1294 $ hg ci -Am1
1295 adding a
1295 adding a
1296 adding b
1296 adding b
1297 adding c
1297 adding c
1298
1298
1299 $ echo "key: value" >>a
1299 $ echo "key: value" >>a
1300 $ echo "key: value" >>b
1300 $ echo "key: value" >>b
1301 $ echo "foo" >>c
1301 $ echo "foo" >>c
1302 $ hg ci -m2
1302 $ hg ci -m2
1303
1303
1304 $ hg up -C 0
1304 $ hg up -C 0
1305 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1305 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1306 $ hg diff --git -c1 >want
1306 $ hg diff --git -c1 >want
1307 $ hg diff -c1 | hg import --no-commit -
1307 $ hg diff -c1 | hg import --no-commit -
1308 applying patch from stdin
1308 applying patch from stdin
1309 $ hg diff --git >have
1309 $ hg diff --git >have
1310 $ diff want have
1310 $ diff want have
1311 $ cd ..
1311 $ cd ..
1312
1312
1313 import a unified diff with no lines of context (diff -U0)
1313 import a unified diff with no lines of context (diff -U0)
1314
1314
1315 $ hg init diffzero
1315 $ hg init diffzero
1316 $ cd diffzero
1316 $ cd diffzero
1317 $ cat > f << EOF
1317 $ cat > f << EOF
1318 > c2
1318 > c2
1319 > c4
1319 > c4
1320 > c5
1320 > c5
1321 > EOF
1321 > EOF
1322 $ hg commit -Am0
1322 $ hg commit -Am0
1323 adding f
1323 adding f
1324
1324
1325 $ hg import --no-commit - << EOF
1325 $ hg import --no-commit - << EOF
1326 > # HG changeset patch
1326 > # HG changeset patch
1327 > # User test
1327 > # User test
1328 > # Date 0 0
1328 > # Date 0 0
1329 > # Node ID f4974ab632f3dee767567b0576c0ec9a4508575c
1329 > # Node ID f4974ab632f3dee767567b0576c0ec9a4508575c
1330 > # Parent 8679a12a975b819fae5f7ad3853a2886d143d794
1330 > # Parent 8679a12a975b819fae5f7ad3853a2886d143d794
1331 > 1
1331 > 1
1332 > diff -r 8679a12a975b -r f4974ab632f3 f
1332 > diff -r 8679a12a975b -r f4974ab632f3 f
1333 > --- a/f Thu Jan 01 00:00:00 1970 +0000
1333 > --- a/f Thu Jan 01 00:00:00 1970 +0000
1334 > +++ b/f Thu Jan 01 00:00:00 1970 +0000
1334 > +++ b/f Thu Jan 01 00:00:00 1970 +0000
1335 > @@ -0,0 +1,1 @@
1335 > @@ -0,0 +1,1 @@
1336 > +c1
1336 > +c1
1337 > @@ -1,0 +3,1 @@
1337 > @@ -1,0 +3,1 @@
1338 > +c3
1338 > +c3
1339 > @@ -3,1 +4,0 @@
1339 > @@ -3,1 +4,0 @@
1340 > -c5
1340 > -c5
1341 > EOF
1341 > EOF
1342 applying patch from stdin
1342 applying patch from stdin
1343
1343
1344 $ cat f
1344 $ cat f
1345 c1
1345 c1
1346 c2
1346 c2
1347 c3
1347 c3
1348 c4
1348 c4
1349
1349
1350 $ cd ..
1350 $ cd ..
1351
1351
1352 commit message that looks like a diff header (issue1879)
1352 commit message that looks like a diff header (issue1879)
1353
1353
1354 $ hg init headerlikemsg
1354 $ hg init headerlikemsg
1355 $ cd headerlikemsg
1355 $ cd headerlikemsg
1356 $ touch empty
1356 $ touch empty
1357 $ echo nonempty >> nonempty
1357 $ echo nonempty >> nonempty
1358 $ hg ci -qAl - <<EOF
1358 $ hg ci -qAl - <<EOF
1359 > blah blah
1359 > blah blah
1360 > diff blah
1360 > diff blah
1361 > blah blah
1361 > blah blah
1362 > EOF
1362 > EOF
1363 $ hg --config diff.git=1 log -pv
1363 $ hg --config diff.git=1 log -pv
1364 changeset: 0:c6ef204ef767
1364 changeset: 0:c6ef204ef767
1365 tag: tip
1365 tag: tip
1366 user: test
1366 user: test
1367 date: Thu Jan 01 00:00:00 1970 +0000
1367 date: Thu Jan 01 00:00:00 1970 +0000
1368 files: empty nonempty
1368 files: empty nonempty
1369 description:
1369 description:
1370 blah blah
1370 blah blah
1371 diff blah
1371 diff blah
1372 blah blah
1372 blah blah
1373
1373
1374
1374
1375 diff --git a/empty b/empty
1375 diff --git a/empty b/empty
1376 new file mode 100644
1376 new file mode 100644
1377 diff --git a/nonempty b/nonempty
1377 diff --git a/nonempty b/nonempty
1378 new file mode 100644
1378 new file mode 100644
1379 --- /dev/null
1379 --- /dev/null
1380 +++ b/nonempty
1380 +++ b/nonempty
1381 @@ -0,0 +1,1 @@
1381 @@ -0,0 +1,1 @@
1382 +nonempty
1382 +nonempty
1383
1383
1384
1384
1385 (without --git, empty file is lost, but commit message should be preserved)
1385 (without --git, empty file is lost, but commit message should be preserved)
1386
1386
1387 $ hg init plain
1387 $ hg init plain
1388 $ hg export 0 | hg -R plain import -
1388 $ hg export 0 | hg -R plain import -
1389 applying patch from stdin
1389 applying patch from stdin
1390 $ hg --config diff.git=1 -R plain log -pv
1390 $ hg --config diff.git=1 -R plain log -pv
1391 changeset: 0:60a2d231e71f
1391 changeset: 0:60a2d231e71f
1392 tag: tip
1392 tag: tip
1393 user: test
1393 user: test
1394 date: Thu Jan 01 00:00:00 1970 +0000
1394 date: Thu Jan 01 00:00:00 1970 +0000
1395 files: nonempty
1395 files: nonempty
1396 description:
1396 description:
1397 blah blah
1397 blah blah
1398 diff blah
1398 diff blah
1399 blah blah
1399 blah blah
1400
1400
1401
1401
1402 diff --git a/nonempty b/nonempty
1402 diff --git a/nonempty b/nonempty
1403 new file mode 100644
1403 new file mode 100644
1404 --- /dev/null
1404 --- /dev/null
1405 +++ b/nonempty
1405 +++ b/nonempty
1406 @@ -0,0 +1,1 @@
1406 @@ -0,0 +1,1 @@
1407 +nonempty
1407 +nonempty
1408
1408
1409
1409
1410 (with --git, patch contents should be fully preserved)
1410 (with --git, patch contents should be fully preserved)
1411
1411
1412 $ hg init git
1412 $ hg init git
1413 $ hg --config diff.git=1 export 0 | hg -R git import -
1413 $ hg --config diff.git=1 export 0 | hg -R git import -
1414 applying patch from stdin
1414 applying patch from stdin
1415 $ hg --config diff.git=1 -R git log -pv
1415 $ hg --config diff.git=1 -R git log -pv
1416 changeset: 0:c6ef204ef767
1416 changeset: 0:c6ef204ef767
1417 tag: tip
1417 tag: tip
1418 user: test
1418 user: test
1419 date: Thu Jan 01 00:00:00 1970 +0000
1419 date: Thu Jan 01 00:00:00 1970 +0000
1420 files: empty nonempty
1420 files: empty nonempty
1421 description:
1421 description:
1422 blah blah
1422 blah blah
1423 diff blah
1423 diff blah
1424 blah blah
1424 blah blah
1425
1425
1426
1426
1427 diff --git a/empty b/empty
1427 diff --git a/empty b/empty
1428 new file mode 100644
1428 new file mode 100644
1429 diff --git a/nonempty b/nonempty
1429 diff --git a/nonempty b/nonempty
1430 new file mode 100644
1430 new file mode 100644
1431 --- /dev/null
1431 --- /dev/null
1432 +++ b/nonempty
1432 +++ b/nonempty
1433 @@ -0,0 +1,1 @@
1433 @@ -0,0 +1,1 @@
1434 +nonempty
1434 +nonempty
1435
1435
1436
1436
1437 $ cd ..
1437 $ cd ..
1438
1438
1439 no segfault while importing a unified diff which start line is zero but chunk
1439 no segfault while importing a unified diff which start line is zero but chunk
1440 size is non-zero
1440 size is non-zero
1441
1441
1442 $ hg init startlinezero
1442 $ hg init startlinezero
1443 $ cd startlinezero
1443 $ cd startlinezero
1444 $ echo foo > foo
1444 $ echo foo > foo
1445 $ hg commit -Amfoo
1445 $ hg commit -Amfoo
1446 adding foo
1446 adding foo
1447
1447
1448 $ hg import --no-commit - << EOF
1448 $ hg import --no-commit - << EOF
1449 > diff a/foo b/foo
1449 > diff a/foo b/foo
1450 > --- a/foo
1450 > --- a/foo
1451 > +++ b/foo
1451 > +++ b/foo
1452 > @@ -0,1 +0,1 @@
1452 > @@ -0,1 +0,1 @@
1453 > foo
1453 > foo
1454 > EOF
1454 > EOF
1455 applying patch from stdin
1455 applying patch from stdin
1456
1456
1457 $ cd ..
1457 $ cd ..
1458
1458
1459 Test corner case involving fuzz and skew
1459 Test corner case involving fuzz and skew
1460
1460
1461 $ hg init morecornercases
1461 $ hg init morecornercases
1462 $ cd morecornercases
1462 $ cd morecornercases
1463
1463
1464 $ cat > 01-no-context-beginning-of-file.diff <<EOF
1464 $ cat > 01-no-context-beginning-of-file.diff <<EOF
1465 > diff --git a/a b/a
1465 > diff --git a/a b/a
1466 > --- a/a
1466 > --- a/a
1467 > +++ b/a
1467 > +++ b/a
1468 > @@ -1,0 +1,1 @@
1468 > @@ -1,0 +1,1 @@
1469 > +line
1469 > +line
1470 > EOF
1470 > EOF
1471
1471
1472 $ cat > 02-no-context-middle-of-file.diff <<EOF
1472 $ cat > 02-no-context-middle-of-file.diff <<EOF
1473 > diff --git a/a b/a
1473 > diff --git a/a b/a
1474 > --- a/a
1474 > --- a/a
1475 > +++ b/a
1475 > +++ b/a
1476 > @@ -1,1 +1,1 @@
1476 > @@ -1,1 +1,1 @@
1477 > -2
1477 > -2
1478 > +add some skew
1478 > +add some skew
1479 > @@ -2,0 +2,1 @@
1479 > @@ -2,0 +2,1 @@
1480 > +line
1480 > +line
1481 > EOF
1481 > EOF
1482
1482
1483 $ cat > 03-no-context-end-of-file.diff <<EOF
1483 $ cat > 03-no-context-end-of-file.diff <<EOF
1484 > diff --git a/a b/a
1484 > diff --git a/a b/a
1485 > --- a/a
1485 > --- a/a
1486 > +++ b/a
1486 > +++ b/a
1487 > @@ -10,0 +10,1 @@
1487 > @@ -10,0 +10,1 @@
1488 > +line
1488 > +line
1489 > EOF
1489 > EOF
1490
1490
1491 $ cat > 04-middle-of-file-completely-fuzzed.diff <<EOF
1491 $ cat > 04-middle-of-file-completely-fuzzed.diff <<EOF
1492 > diff --git a/a b/a
1492 > diff --git a/a b/a
1493 > --- a/a
1493 > --- a/a
1494 > +++ b/a
1494 > +++ b/a
1495 > @@ -1,1 +1,1 @@
1495 > @@ -1,1 +1,1 @@
1496 > -2
1496 > -2
1497 > +add some skew
1497 > +add some skew
1498 > @@ -2,2 +2,3 @@
1498 > @@ -2,2 +2,3 @@
1499 > not matching, should fuzz
1499 > not matching, should fuzz
1500 > ... a bit
1500 > ... a bit
1501 > +line
1501 > +line
1502 > EOF
1502 > EOF
1503
1503
1504 $ cat > a <<EOF
1504 $ cat > a <<EOF
1505 > 1
1505 > 1
1506 > 2
1506 > 2
1507 > 3
1507 > 3
1508 > 4
1508 > 4
1509 > EOF
1509 > EOF
1510 $ hg ci -Am adda a
1510 $ hg ci -Am adda a
1511 $ for p in *.diff; do
1511 $ for p in *.diff; do
1512 > hg import -v --no-commit $p
1512 > hg import -v --no-commit $p
1513 > cat a
1513 > cat a
1514 > hg revert -aqC a
1514 > hg revert -aqC a
1515 > # patch -p1 < $p
1515 > # patch -p1 < $p
1516 > # cat a
1516 > # cat a
1517 > # hg revert -aC a
1517 > # hg revert -aC a
1518 > done
1518 > done
1519 applying 01-no-context-beginning-of-file.diff
1519 applying 01-no-context-beginning-of-file.diff
1520 patching file a
1520 patching file a
1521 applied to working directory
1521 applied to working directory
1522 1
1522 1
1523 line
1523 line
1524 2
1524 2
1525 3
1525 3
1526 4
1526 4
1527 applying 02-no-context-middle-of-file.diff
1527 applying 02-no-context-middle-of-file.diff
1528 patching file a
1528 patching file a
1529 Hunk #1 succeeded at 2 (offset 1 lines).
1529 Hunk #1 succeeded at 2 (offset 1 lines).
1530 Hunk #2 succeeded at 4 (offset 1 lines).
1530 Hunk #2 succeeded at 4 (offset 1 lines).
1531 applied to working directory
1531 applied to working directory
1532 1
1532 1
1533 add some skew
1533 add some skew
1534 3
1534 3
1535 line
1535 line
1536 4
1536 4
1537 applying 03-no-context-end-of-file.diff
1537 applying 03-no-context-end-of-file.diff
1538 patching file a
1538 patching file a
1539 Hunk #1 succeeded at 5 (offset -6 lines).
1539 Hunk #1 succeeded at 5 (offset -6 lines).
1540 applied to working directory
1540 applied to working directory
1541 1
1541 1
1542 2
1542 2
1543 3
1543 3
1544 4
1544 4
1545 line
1545 line
1546 applying 04-middle-of-file-completely-fuzzed.diff
1546 applying 04-middle-of-file-completely-fuzzed.diff
1547 patching file a
1547 patching file a
1548 Hunk #1 succeeded at 2 (offset 1 lines).
1548 Hunk #1 succeeded at 2 (offset 1 lines).
1549 Hunk #2 succeeded at 5 with fuzz 2 (offset 1 lines).
1549 Hunk #2 succeeded at 5 with fuzz 2 (offset 1 lines).
1550 applied to working directory
1550 applied to working directory
1551 1
1551 1
1552 add some skew
1552 add some skew
1553 3
1553 3
1554 4
1554 4
1555 line
1555 line
1556 $ cd ..
1556 $ cd ..
1557
1557
1558 Test partial application
1558 Test partial application
1559 ------------------------
1559 ------------------------
1560
1560
1561 prepare a stack of patches depending on each other
1561 prepare a stack of patches depending on each other
1562
1562
1563 $ hg init partial
1563 $ hg init partial
1564 $ cd partial
1564 $ cd partial
1565 $ cat << EOF > a
1565 $ cat << EOF > a
1566 > one
1566 > one
1567 > two
1567 > two
1568 > three
1568 > three
1569 > four
1569 > four
1570 > five
1570 > five
1571 > six
1571 > six
1572 > seven
1572 > seven
1573 > EOF
1573 > EOF
1574 $ hg add a
1574 $ hg add a
1575 $ echo 'b' > b
1575 $ echo 'b' > b
1576 $ hg add b
1576 $ hg add b
1577 $ hg commit -m 'initial' -u Babar
1577 $ hg commit -m 'initial' -u Babar
1578 $ cat << EOF > a
1578 $ cat << EOF > a
1579 > one
1579 > one
1580 > two
1580 > two
1581 > 3
1581 > 3
1582 > four
1582 > four
1583 > five
1583 > five
1584 > six
1584 > six
1585 > seven
1585 > seven
1586 > EOF
1586 > EOF
1587 $ hg commit -m 'three' -u Celeste
1587 $ hg commit -m 'three' -u Celeste
1588 $ cat << EOF > a
1588 $ cat << EOF > a
1589 > one
1589 > one
1590 > two
1590 > two
1591 > 3
1591 > 3
1592 > 4
1592 > 4
1593 > five
1593 > five
1594 > six
1594 > six
1595 > seven
1595 > seven
1596 > EOF
1596 > EOF
1597 $ hg commit -m 'four' -u Rataxes
1597 $ hg commit -m 'four' -u Rataxes
1598 $ cat << EOF > a
1598 $ cat << EOF > a
1599 > one
1599 > one
1600 > two
1600 > two
1601 > 3
1601 > 3
1602 > 4
1602 > 4
1603 > 5
1603 > 5
1604 > six
1604 > six
1605 > seven
1605 > seven
1606 > EOF
1606 > EOF
1607 $ echo bb >> b
1607 $ echo bb >> b
1608 $ hg commit -m 'five' -u Arthur
1608 $ hg commit -m 'five' -u Arthur
1609 $ echo 'Babar' > jungle
1609 $ echo 'Babar' > jungle
1610 $ hg add jungle
1610 $ hg add jungle
1611 $ hg ci -m 'jungle' -u Zephir
1611 $ hg ci -m 'jungle' -u Zephir
1612 $ echo 'Celeste' >> jungle
1612 $ echo 'Celeste' >> jungle
1613 $ hg ci -m 'extended jungle' -u Cornelius
1613 $ hg ci -m 'extended jungle' -u Cornelius
1614 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1614 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1615 @ extended jungle [Cornelius] 1: +1/-0
1615 @ extended jungle [Cornelius] 1: +1/-0
1616 |
1616 |
1617 o jungle [Zephir] 1: +1/-0
1617 o jungle [Zephir] 1: +1/-0
1618 |
1618 |
1619 o five [Arthur] 2: +2/-1
1619 o five [Arthur] 2: +2/-1
1620 |
1620 |
1621 o four [Rataxes] 1: +1/-1
1621 o four [Rataxes] 1: +1/-1
1622 |
1622 |
1623 o three [Celeste] 1: +1/-1
1623 o three [Celeste] 1: +1/-1
1624 |
1624 |
1625 o initial [Babar] 2: +8/-0
1625 o initial [Babar] 2: +8/-0
1626
1626
1627 Adding those config options should not change the output of diffstat. Bugfix #4755.
1627 Adding those config options should not change the output of diffstat. Bugfix #4755.
1628
1628
1629 $ hg log -r . --template '{diffstat}\n'
1629 $ hg log -r . --template '{diffstat}\n'
1630 1: +1/-0
1630 1: +1/-0
1631 $ hg log -r . --template '{diffstat}\n' --config diff.git=1 \
1631 $ hg log -r . --template '{diffstat}\n' --config diff.git=1 \
1632 > --config diff.noprefix=1
1632 > --config diff.noprefix=1
1633 1: +1/-0
1633 1: +1/-0
1634
1634
1635 Importing with some success and some errors:
1635 Importing with some success and some errors:
1636
1636
1637 $ hg update --rev 'desc(initial)'
1637 $ hg update --rev 'desc(initial)'
1638 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1638 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1639 $ hg export --rev 'desc(five)' | hg import --partial -
1639 $ hg export --rev 'desc(five)' | hg import --partial -
1640 applying patch from stdin
1640 applying patch from stdin
1641 patching file a
1641 patching file a
1642 Hunk #1 FAILED at 1
1642 Hunk #1 FAILED at 1
1643 1 out of 1 hunks FAILED -- saving rejects to file a.rej
1643 1 out of 1 hunks FAILED -- saving rejects to file a.rej
1644 patch applied partially
1644 patch applied partially
1645 (fix the .rej files and run `hg commit --amend`)
1645 (fix the .rej files and run `hg commit --amend`)
1646 [1]
1646 [1]
1647
1647
1648 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1648 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1649 @ five [Arthur] 1: +1/-0
1649 @ five [Arthur] 1: +1/-0
1650 |
1650 |
1651 | o extended jungle [Cornelius] 1: +1/-0
1651 | o extended jungle [Cornelius] 1: +1/-0
1652 | |
1652 | |
1653 | o jungle [Zephir] 1: +1/-0
1653 | o jungle [Zephir] 1: +1/-0
1654 | |
1654 | |
1655 | o five [Arthur] 2: +2/-1
1655 | o five [Arthur] 2: +2/-1
1656 | |
1656 | |
1657 | o four [Rataxes] 1: +1/-1
1657 | o four [Rataxes] 1: +1/-1
1658 | |
1658 | |
1659 | o three [Celeste] 1: +1/-1
1659 | o three [Celeste] 1: +1/-1
1660 |/
1660 |/
1661 o initial [Babar] 2: +8/-0
1661 o initial [Babar] 2: +8/-0
1662
1662
1663 $ hg export
1663 $ hg export
1664 # HG changeset patch
1664 # HG changeset patch
1665 # User Arthur
1665 # User Arthur
1666 # Date 0 0
1666 # Date 0 0
1667 # Thu Jan 01 00:00:00 1970 +0000
1667 # Thu Jan 01 00:00:00 1970 +0000
1668 # Node ID 26e6446bb2526e2be1037935f5fca2b2706f1509
1668 # Node ID 26e6446bb2526e2be1037935f5fca2b2706f1509
1669 # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e
1669 # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e
1670 five
1670 five
1671
1671
1672 diff -r 8e4f0351909e -r 26e6446bb252 b
1672 diff -r 8e4f0351909e -r 26e6446bb252 b
1673 --- a/b Thu Jan 01 00:00:00 1970 +0000
1673 --- a/b Thu Jan 01 00:00:00 1970 +0000
1674 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1674 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1675 @@ -1,1 +1,2 @@
1675 @@ -1,1 +1,2 @@
1676 b
1676 b
1677 +bb
1677 +bb
1678 $ hg status -c .
1678 $ hg status -c .
1679 C a
1679 C a
1680 C b
1680 C b
1681 $ ls
1681 $ ls
1682 a
1682 a
1683 a.rej
1683 a.rej
1684 b
1684 b
1685
1685
1686 Importing with zero success:
1686 Importing with zero success:
1687
1687
1688 $ hg update --rev 'desc(initial)'
1688 $ hg update --rev 'desc(initial)'
1689 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1689 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1690 $ hg export --rev 'desc(four)' | hg import --partial -
1690 $ hg export --rev 'desc(four)' | hg import --partial -
1691 applying patch from stdin
1691 applying patch from stdin
1692 patching file a
1692 patching file a
1693 Hunk #1 FAILED at 0
1693 Hunk #1 FAILED at 0
1694 1 out of 1 hunks FAILED -- saving rejects to file a.rej
1694 1 out of 1 hunks FAILED -- saving rejects to file a.rej
1695 patch applied partially
1695 patch applied partially
1696 (fix the .rej files and run `hg commit --amend`)
1696 (fix the .rej files and run `hg commit --amend`)
1697 [1]
1697 [1]
1698
1698
1699 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1699 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1700 @ four [Rataxes] 0: +0/-0
1700 @ four [Rataxes] 0: +0/-0
1701 |
1701 |
1702 | o five [Arthur] 1: +1/-0
1702 | o five [Arthur] 1: +1/-0
1703 |/
1703 |/
1704 | o extended jungle [Cornelius] 1: +1/-0
1704 | o extended jungle [Cornelius] 1: +1/-0
1705 | |
1705 | |
1706 | o jungle [Zephir] 1: +1/-0
1706 | o jungle [Zephir] 1: +1/-0
1707 | |
1707 | |
1708 | o five [Arthur] 2: +2/-1
1708 | o five [Arthur] 2: +2/-1
1709 | |
1709 | |
1710 | o four [Rataxes] 1: +1/-1
1710 | o four [Rataxes] 1: +1/-1
1711 | |
1711 | |
1712 | o three [Celeste] 1: +1/-1
1712 | o three [Celeste] 1: +1/-1
1713 |/
1713 |/
1714 o initial [Babar] 2: +8/-0
1714 o initial [Babar] 2: +8/-0
1715
1715
1716 $ hg export
1716 $ hg export
1717 # HG changeset patch
1717 # HG changeset patch
1718 # User Rataxes
1718 # User Rataxes
1719 # Date 0 0
1719 # Date 0 0
1720 # Thu Jan 01 00:00:00 1970 +0000
1720 # Thu Jan 01 00:00:00 1970 +0000
1721 # Node ID cb9b1847a74d9ad52e93becaf14b98dbcc274e1e
1721 # Node ID cb9b1847a74d9ad52e93becaf14b98dbcc274e1e
1722 # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e
1722 # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e
1723 four
1723 four
1724
1724
1725 $ hg status -c .
1725 $ hg status -c .
1726 C a
1726 C a
1727 C b
1727 C b
1728 $ ls
1728 $ ls
1729 a
1729 a
1730 a.rej
1730 a.rej
1731 b
1731 b
1732
1732
1733 Importing with unknown file:
1733 Importing with unknown file:
1734
1734
1735 $ hg update --rev 'desc(initial)'
1735 $ hg update --rev 'desc(initial)'
1736 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1736 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1737 $ hg export --rev 'desc("extended jungle")' | hg import --partial -
1737 $ hg export --rev 'desc("extended jungle")' | hg import --partial -
1738 applying patch from stdin
1738 applying patch from stdin
1739 unable to find 'jungle' for patching
1739 unable to find 'jungle' for patching
1740 (use '--prefix' to apply patch relative to the current directory)
1740 (use '--prefix' to apply patch relative to the current directory)
1741 1 out of 1 hunks FAILED -- saving rejects to file jungle.rej
1741 1 out of 1 hunks FAILED -- saving rejects to file jungle.rej
1742 patch applied partially
1742 patch applied partially
1743 (fix the .rej files and run `hg commit --amend`)
1743 (fix the .rej files and run `hg commit --amend`)
1744 [1]
1744 [1]
1745
1745
1746 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1746 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1747 @ extended jungle [Cornelius] 0: +0/-0
1747 @ extended jungle [Cornelius] 0: +0/-0
1748 |
1748 |
1749 | o four [Rataxes] 0: +0/-0
1749 | o four [Rataxes] 0: +0/-0
1750 |/
1750 |/
1751 | o five [Arthur] 1: +1/-0
1751 | o five [Arthur] 1: +1/-0
1752 |/
1752 |/
1753 | o extended jungle [Cornelius] 1: +1/-0
1753 | o extended jungle [Cornelius] 1: +1/-0
1754 | |
1754 | |
1755 | o jungle [Zephir] 1: +1/-0
1755 | o jungle [Zephir] 1: +1/-0
1756 | |
1756 | |
1757 | o five [Arthur] 2: +2/-1
1757 | o five [Arthur] 2: +2/-1
1758 | |
1758 | |
1759 | o four [Rataxes] 1: +1/-1
1759 | o four [Rataxes] 1: +1/-1
1760 | |
1760 | |
1761 | o three [Celeste] 1: +1/-1
1761 | o three [Celeste] 1: +1/-1
1762 |/
1762 |/
1763 o initial [Babar] 2: +8/-0
1763 o initial [Babar] 2: +8/-0
1764
1764
1765 $ hg export
1765 $ hg export
1766 # HG changeset patch
1766 # HG changeset patch
1767 # User Cornelius
1767 # User Cornelius
1768 # Date 0 0
1768 # Date 0 0
1769 # Thu Jan 01 00:00:00 1970 +0000
1769 # Thu Jan 01 00:00:00 1970 +0000
1770 # Node ID 1fb1f86bef43c5a75918178f8d23c29fb0a7398d
1770 # Node ID 1fb1f86bef43c5a75918178f8d23c29fb0a7398d
1771 # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e
1771 # Parent 8e4f0351909eae6b9cf68c2c076cb54c42b54b2e
1772 extended jungle
1772 extended jungle
1773
1773
1774 $ hg status -c .
1774 $ hg status -c .
1775 C a
1775 C a
1776 C b
1776 C b
1777 $ ls
1777 $ ls
1778 a
1778 a
1779 a.rej
1779 a.rej
1780 b
1780 b
1781 jungle.rej
1781 jungle.rej
1782
1782
1783 Importing multiple failing patches:
1783 Importing multiple failing patches:
1784
1784
1785 $ hg update --rev 'desc(initial)'
1785 $ hg update --rev 'desc(initial)'
1786 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1786 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1787 $ echo 'B' > b # just to make another commit
1787 $ echo 'B' > b # just to make another commit
1788 $ hg commit -m "a new base"
1788 $ hg commit -m "a new base"
1789 created new head
1789 created new head
1790 $ hg export --rev 'desc("four") + desc("extended jungle")' | hg import --partial -
1790 $ hg export --rev 'desc("four") + desc("extended jungle")' | hg import --partial -
1791 applying patch from stdin
1791 applying patch from stdin
1792 patching file a
1792 patching file a
1793 Hunk #1 FAILED at 0
1793 Hunk #1 FAILED at 0
1794 1 out of 1 hunks FAILED -- saving rejects to file a.rej
1794 1 out of 1 hunks FAILED -- saving rejects to file a.rej
1795 patch applied partially
1795 patch applied partially
1796 (fix the .rej files and run `hg commit --amend`)
1796 (fix the .rej files and run `hg commit --amend`)
1797 [1]
1797 [1]
1798 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1798 $ hg log -G --template '{desc|firstline} [{author}] {diffstat}\n'
1799 @ four [Rataxes] 0: +0/-0
1799 @ four [Rataxes] 0: +0/-0
1800 |
1800 |
1801 o a new base [test] 1: +1/-1
1801 o a new base [test] 1: +1/-1
1802 |
1802 |
1803 | o extended jungle [Cornelius] 0: +0/-0
1803 | o extended jungle [Cornelius] 0: +0/-0
1804 |/
1804 |/
1805 | o four [Rataxes] 0: +0/-0
1805 | o four [Rataxes] 0: +0/-0
1806 |/
1806 |/
1807 | o five [Arthur] 1: +1/-0
1807 | o five [Arthur] 1: +1/-0
1808 |/
1808 |/
1809 | o extended jungle [Cornelius] 1: +1/-0
1809 | o extended jungle [Cornelius] 1: +1/-0
1810 | |
1810 | |
1811 | o jungle [Zephir] 1: +1/-0
1811 | o jungle [Zephir] 1: +1/-0
1812 | |
1812 | |
1813 | o five [Arthur] 2: +2/-1
1813 | o five [Arthur] 2: +2/-1
1814 | |
1814 | |
1815 | o four [Rataxes] 1: +1/-1
1815 | o four [Rataxes] 1: +1/-1
1816 | |
1816 | |
1817 | o three [Celeste] 1: +1/-1
1817 | o three [Celeste] 1: +1/-1
1818 |/
1818 |/
1819 o initial [Babar] 2: +8/-0
1819 o initial [Babar] 2: +8/-0
1820
1820
1821 $ hg export
1821 $ hg export
1822 # HG changeset patch
1822 # HG changeset patch
1823 # User Rataxes
1823 # User Rataxes
1824 # Date 0 0
1824 # Date 0 0
1825 # Thu Jan 01 00:00:00 1970 +0000
1825 # Thu Jan 01 00:00:00 1970 +0000
1826 # Node ID a9d7b6d0ffbb4eb12b7d5939250fcd42e8930a1d
1826 # Node ID a9d7b6d0ffbb4eb12b7d5939250fcd42e8930a1d
1827 # Parent f59f8d2e95a8ca5b1b4ca64320140da85f3b44fd
1827 # Parent f59f8d2e95a8ca5b1b4ca64320140da85f3b44fd
1828 four
1828 four
1829
1829
1830 $ hg status -c .
1830 $ hg status -c .
1831 C a
1831 C a
1832 C b
1832 C b
1833
1833
1834 Importing some extra header
1834 Importing some extra header
1835 ===========================
1835 ===========================
1836
1836
1837 $ cat > $TESTTMP/parseextra.py <<EOF
1837 $ cat > $TESTTMP/parseextra.py <<EOF
1838 > import mercurial.patch
1838 > import mercurial.patch
1839 > import mercurial.cmdutil
1839 > import mercurial.cmdutil
1840 >
1840 >
1841 > def processfoo(repo, data, extra, opts):
1841 > def processfoo(repo, data, extra, opts):
1842 > if b'foo' in data:
1842 > if b'foo' in data:
1843 > extra[b'foo'] = data[b'foo']
1843 > extra[b'foo'] = data[b'foo']
1844 > def postimport(ctx):
1844 > def postimport(ctx):
1845 > if b'foo' in ctx.extra():
1845 > if b'foo' in ctx.extra():
1846 > ctx.repo().ui.write(b'imported-foo: %s\n' % ctx.extra()[b'foo'])
1846 > ctx.repo().ui.write(b'imported-foo: %s\n' % ctx.extra()[b'foo'])
1847 >
1847 >
1848 > mercurial.patch.patchheadermap.append((b'Foo', b'foo'))
1848 > mercurial.patch.patchheadermap.append((b'Foo', b'foo'))
1849 > mercurial.cmdutil.extrapreimport.append(b'foo')
1849 > mercurial.cmdutil.extrapreimport.append(b'foo')
1850 > mercurial.cmdutil.extrapreimportmap[b'foo'] = processfoo
1850 > mercurial.cmdutil.extrapreimportmap[b'foo'] = processfoo
1851 > mercurial.cmdutil.extrapostimport.append(b'foo')
1851 > mercurial.cmdutil.extrapostimport.append(b'foo')
1852 > mercurial.cmdutil.extrapostimportmap[b'foo'] = postimport
1852 > mercurial.cmdutil.extrapostimportmap[b'foo'] = postimport
1853 > EOF
1853 > EOF
1854 $ cat >> $HGRCPATH <<EOF
1854 $ cat >> $HGRCPATH <<EOF
1855 > [extensions]
1855 > [extensions]
1856 > parseextra=$TESTTMP/parseextra.py
1856 > parseextra=$TESTTMP/parseextra.py
1857 > EOF
1857 > EOF
1858 $ hg up -C tip
1858 $ hg up -C tip
1859 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1859 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1860 $ cat > $TESTTMP/foo.patch <<EOF
1860 $ cat > $TESTTMP/foo.patch <<EOF
1861 > # HG changeset patch
1861 > # HG changeset patch
1862 > # User Rataxes
1862 > # User Rataxes
1863 > # Date 0 0
1863 > # Date 0 0
1864 > # Thu Jan 01 00:00:00 1970 +0000
1864 > # Thu Jan 01 00:00:00 1970 +0000
1865 > # Foo bar
1865 > # Foo bar
1866 > height
1866 > height
1867 >
1867 >
1868 > --- a/a Thu Jan 01 00:00:00 1970 +0000
1868 > --- a/a Thu Jan 01 00:00:00 1970 +0000
1869 > +++ b/a Wed Oct 07 09:17:44 2015 +0000
1869 > +++ b/a Wed Oct 07 09:17:44 2015 +0000
1870 > @@ -5,3 +5,4 @@
1870 > @@ -5,3 +5,4 @@
1871 > five
1871 > five
1872 > six
1872 > six
1873 > seven
1873 > seven
1874 > +heigt
1874 > +heigt
1875 > EOF
1875 > EOF
1876 $ hg import $TESTTMP/foo.patch
1876 $ hg import $TESTTMP/foo.patch
1877 applying $TESTTMP/foo.patch
1877 applying $TESTTMP/foo.patch
1878 imported-foo: bar
1878 imported-foo: bar
1879 $ hg log --debug -r . | grep extra
1879 $ hg log --debug -r . | grep extra
1880 extra: branch=default
1880 extra: branch=default
1881 extra: foo=bar
1881 extra: foo=bar
1882
1882
1883 Warn the user that paths are relative to the root of
1883 Warn the user that paths are relative to the root of
1884 repository when file not found for patching
1884 repository when file not found for patching
1885
1885
1886 $ mkdir filedir
1886 $ mkdir filedir
1887 $ echo "file1" >> filedir/file1
1887 $ echo "file1" >> filedir/file1
1888 $ hg add filedir/file1
1888 $ hg add filedir/file1
1889 $ hg commit -m "file1"
1889 $ hg commit -m "file1"
1890 $ cd filedir
1890 $ cd filedir
1891 $ hg import -p 2 - <<EOF
1891 $ hg import -p 2 - <<EOF
1892 > # HG changeset patch
1892 > # HG changeset patch
1893 > # User test
1893 > # User test
1894 > # Date 0 0
1894 > # Date 0 0
1895 > file2
1895 > file2
1896 >
1896 >
1897 > diff --git a/filedir/file1 b/filedir/file1
1897 > diff --git a/filedir/file1 b/filedir/file1
1898 > --- a/filedir/file1
1898 > --- a/filedir/file1
1899 > +++ b/filedir/file1
1899 > +++ b/filedir/file1
1900 > @@ -1,1 +1,2 @@
1900 > @@ -1,1 +1,2 @@
1901 > file1
1901 > file1
1902 > +file2
1902 > +file2
1903 > EOF
1903 > EOF
1904 applying patch from stdin
1904 applying patch from stdin
1905 unable to find 'file1' for patching
1905 unable to find 'file1' for patching
1906 (use '--prefix' to apply patch relative to the current directory)
1906 (use '--prefix' to apply patch relative to the current directory)
1907 1 out of 1 hunks FAILED -- saving rejects to file file1.rej
1907 1 out of 1 hunks FAILED -- saving rejects to file file1.rej
1908 abort: patch failed to apply
1908 abort: patch failed to apply
1909 [255]
1909 [255]
1910
1910
1911 test import crash (issue5375)
1911 test import crash (issue5375)
1912 $ cd ..
1912 $ cd ..
1913 $ hg init repo
1913 $ hg init repo
1914 $ cd repo
1914 $ cd repo
1915 $ printf "diff --git a/a b/b\nrename from a\nrename to b" | hg import -
1915 $ printf "diff --git a/a b/b\nrename from a\nrename to b" | hg import -
1916 applying patch from stdin
1916 applying patch from stdin
1917 a not tracked!
1917 a not tracked!
1918 abort: source file 'a' does not exist
1918 abort: source file 'a' does not exist
1919 [255]
1919 [255]
General Comments 0
You need to be logged in to leave comments. Login now