##// END OF EJS Templates
Unify mq and hg patch invocation....
Brendan Cully -
r2919:b70740ae default
parent child Browse files
Show More
@@ -400,39 +400,15 b' class queue:'
400 '''Apply patchfile to the working directory.
400 '''Apply patchfile to the working directory.
401 patchfile: file name of patch'''
401 patchfile: file name of patch'''
402 try:
402 try:
403 pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch')
403 (files, fuzz) = patch.patch(patchfile, self.ui, strip=1,
404 f = os.popen("%s -d %s -p1 --no-backup-if-mismatch < %s" %
404 cwd=repo.root)
405 (pp, util.shellquote(repo.root), util.shellquote(patchfile)))
405 except Exception, inst:
406 except:
406 self.ui.note(str(inst) + '\n')
407 if not self.ui.verbose:
407 self.ui.warn("patch failed, unable to continue (try -v)\n")
408 self.ui.warn("patch failed, unable to continue (try -v)\n")
408 return (None, [], False)
409 return (False, [], False)
409 files = []
410 fuzz = False
411 for l in f:
412 l = l.rstrip('\r\n');
413 if self.ui.verbose:
414 self.ui.warn(l + "\n")
415 if l[:14] == 'patching file ':
416 pf = os.path.normpath(util.parse_patch_output(l))
417 if pf not in files:
418 files.append(pf)
419 printed_file = False
420 file_str = l
421 elif l.find('with fuzz') >= 0:
422 if not printed_file:
423 self.ui.warn(file_str + '\n')
424 printed_file = True
425 self.ui.warn(l + '\n')
426 fuzz = True
427 elif l.find('saving rejects to file') >= 0:
428 self.ui.warn(l + '\n')
429 elif l.find('FAILED') >= 0:
430 if not printed_file:
431 self.ui.warn(file_str + '\n')
432 printed_file = True
433 self.ui.warn(l + '\n')
434
410
435 return (not f.close(), files, fuzz)
411 return (True, files.keys(), fuzz)
436
412
437 def apply(self, repo, series, list=False, update_status=True,
413 def apply(self, repo, series, list=False, update_status=True,
438 strict=False, patchdir=None, merge=None, wlock=None):
414 strict=False, patchdir=None, merge=None, wlock=None):
@@ -1681,7 +1681,7 b' def import_(ui, repo, patch1, *patches, '
1681 message = None
1681 message = None
1682 ui.debug(_('message:\n%s\n') % message)
1682 ui.debug(_('message:\n%s\n') % message)
1683
1683
1684 files = patch.patch(strip, tmpname, ui, cwd=repo.root)
1684 files, fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root)
1685 removes = []
1685 removes = []
1686 if len(files) > 0:
1686 if len(files) > 0:
1687 cfiles = files.keys()
1687 cfiles = files.keys()
@@ -215,13 +215,14 b' def dogitpatch(patchname, gitpatches):'
215 tmpfp.close()
215 tmpfp.close()
216 return patchname
216 return patchname
217
217
218 def patch(strip, patchname, ui, cwd=None):
218 def patch(patchname, ui, strip=1, cwd=None):
219 """apply the patch <patchname> to the working directory.
219 """apply the patch <patchname> to the working directory.
220 a list of patched files is returned"""
220 a list of patched files is returned"""
221
221
222 (dopatch, gitpatches) = readgitpatch(patchname)
222 (dopatch, gitpatches) = readgitpatch(patchname)
223
223
224 files = {}
224 files = {}
225 fuzz = False
225 if dopatch:
226 if dopatch:
226 if dopatch == 'filter':
227 if dopatch == 'filter':
227 patchname = dogitpatch(patchname, gitpatches)
228 patchname = dogitpatch(patchname, gitpatches)
@@ -237,10 +238,25 b' def patch(strip, patchname, ui, cwd=None'
237
238
238 for line in fp:
239 for line in fp:
239 line = line.rstrip()
240 line = line.rstrip()
240 ui.status("%s\n" % line)
241 ui.note(line + '\n')
241 if line.startswith('patching file '):
242 if line.startswith('patching file '):
242 pf = util.parse_patch_output(line)
243 pf = util.parse_patch_output(line)
244 printed_file = False
243 files.setdefault(pf, (None, None))
245 files.setdefault(pf, (None, None))
246 elif line.find('with fuzz') >= 0:
247 fuzz = True
248 if not printed_file:
249 ui.warn(pf + '\n')
250 printed_file = True
251 ui.warn(line + '\n')
252 elif line.find('saving rejects to file') >= 0:
253 ui.warn(line + '\n')
254 elif line.find('FAILED') >= 0:
255 if not printed_file:
256 ui.warn(pf + '\n')
257 printed_file = True
258 ui.warn(line + '\n')
259
244 code = fp.close()
260 code = fp.close()
245 if code:
261 if code:
246 raise util.Abort(_("patch command failed: %s") %
262 raise util.Abort(_("patch command failed: %s") %
@@ -249,7 +265,7 b' def patch(strip, patchname, ui, cwd=None'
249 for gp in gitpatches:
265 for gp in gitpatches:
250 files[gp.path] = (gp.op, gp)
266 files[gp.path] = (gp.op, gp)
251
267
252 return files
268 return (files, fuzz)
253
269
254 def diff(repo, node1=None, node2=None, files=None, match=util.always,
270 def diff(repo, node1=None, node2=None, files=None, match=util.always,
255 fp=None, changes=None, opts=None):
271 fp=None, changes=None, opts=None):
@@ -1,6 +1,5 b''
1 % new file
1 % new file
2 applying patch from stdin
2 applying patch from stdin
3 patching file new
4 % chmod +x
3 % chmod +x
5 applying patch from stdin
4 applying patch from stdin
6 % copy
5 % copy
@@ -14,15 +13,12 b' new'
14 rename
13 rename
15 % delete
14 % delete
16 applying patch from stdin
15 applying patch from stdin
17 patching file copyx
18 new
16 new
19 rename
17 rename
20 % regular diff
18 % regular diff
21 applying patch from stdin
19 applying patch from stdin
22 patching file rename
23 % copy and modify
20 % copy and modify
24 applying patch from stdin
21 applying patch from stdin
25 patching file copy2
26 a
22 a
27 a
23 a
28 b
24 b
@@ -30,7 +26,6 b' a'
30 a
26 a
31 % rename and modify
27 % rename and modify
32 applying patch from stdin
28 applying patch from stdin
33 patching file rename2
34 copy2: No such file or directory
29 copy2: No such file or directory
35 a
30 a
36 a
31 a
@@ -8,7 +8,6 b' adding file changes'
8 added 1 changesets with 2 changes to 2 files
8 added 1 changesets with 2 changes to 2 files
9 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
9 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
10 applying ../tip.patch
10 applying ../tip.patch
11 patching file a
12 % message should be same
11 % message should be same
13 summary: second change
12 summary: second change
14 % committer should be same
13 % committer should be same
@@ -21,7 +20,6 b' adding file changes'
21 added 1 changesets with 2 changes to 2 files
20 added 1 changesets with 2 changes to 2 files
22 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
21 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 applying ../tip.patch
22 applying ../tip.patch
24 patching file a
25 transaction abort!
23 transaction abort!
26 rollback completed
24 rollback completed
27 % import of plain diff should be ok with message
25 % import of plain diff should be ok with message
@@ -32,7 +30,6 b' adding file changes'
32 added 1 changesets with 2 changes to 2 files
30 added 1 changesets with 2 changes to 2 files
33 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
31 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 applying ../tip.patch
32 applying ../tip.patch
35 patching file a
36 % import from stdin
33 % import from stdin
37 requesting all changes
34 requesting all changes
38 adding changesets
35 adding changesets
@@ -41,7 +38,6 b' adding file changes'
41 added 1 changesets with 2 changes to 2 files
38 added 1 changesets with 2 changes to 2 files
42 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 applying patch from stdin
40 applying patch from stdin
44 patching file a
45 % override commit message
41 % override commit message
46 requesting all changes
42 requesting all changes
47 adding changesets
43 adding changesets
@@ -50,7 +46,6 b' adding file changes'
50 added 1 changesets with 2 changes to 2 files
46 added 1 changesets with 2 changes to 2 files
51 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
52 applying patch from stdin
48 applying patch from stdin
53 patching file a
54 summary: override
49 summary: override
55 % plain diff in email, subject, message body
50 % plain diff in email, subject, message body
56 requesting all changes
51 requesting all changes
@@ -60,7 +55,6 b' adding file changes'
60 added 1 changesets with 2 changes to 2 files
55 added 1 changesets with 2 changes to 2 files
61 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
56 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 applying ../msg.patch
57 applying ../msg.patch
63 patching file a
64 user: email patcher
58 user: email patcher
65 summary: email patch
59 summary: email patch
66 % plain diff in email, no subject, message body
60 % plain diff in email, no subject, message body
@@ -71,7 +65,6 b' adding file changes'
71 added 1 changesets with 2 changes to 2 files
65 added 1 changesets with 2 changes to 2 files
72 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
66 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
73 applying patch from stdin
67 applying patch from stdin
74 patching file a
75 % plain diff in email, subject, no message body
68 % plain diff in email, subject, no message body
76 requesting all changes
69 requesting all changes
77 adding changesets
70 adding changesets
@@ -80,7 +73,6 b' adding file changes'
80 added 1 changesets with 2 changes to 2 files
73 added 1 changesets with 2 changes to 2 files
81 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
74 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 applying patch from stdin
75 applying patch from stdin
83 patching file a
84 % plain diff in email, no subject, no message body, should fail
76 % plain diff in email, no subject, no message body, should fail
85 requesting all changes
77 requesting all changes
86 adding changesets
78 adding changesets
@@ -89,7 +81,6 b' adding file changes'
89 added 1 changesets with 2 changes to 2 files
81 added 1 changesets with 2 changes to 2 files
90 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 applying patch from stdin
83 applying patch from stdin
92 patching file a
93 transaction abort!
84 transaction abort!
94 rollback completed
85 rollback completed
95 % hg export in email, should use patch header
86 % hg export in email, should use patch header
@@ -100,7 +91,6 b' adding file changes'
100 added 1 changesets with 2 changes to 2 files
91 added 1 changesets with 2 changes to 2 files
101 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 applying patch from stdin
93 applying patch from stdin
103 patching file a
104 summary: second change
94 summary: second change
105 % hg import in a subdirectory
95 % hg import in a subdirectory
106 requesting all changes
96 requesting all changes
@@ -110,7 +100,6 b' adding file changes'
110 added 1 changesets with 2 changes to 2 files
100 added 1 changesets with 2 changes to 2 files
111 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
112 applying ../../../tip.patch
102 applying ../../../tip.patch
113 patching file a
114 % message should be 'subdir change'
103 % message should be 'subdir change'
115 summary: subdir change
104 summary: subdir change
116 % committer should be 'someoneelse'
105 % committer should be 'someoneelse'
General Comments 0
You need to be logged in to leave comments. Login now