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