comparison mercurial/patch.py @ 2907:b70740aefa4d

Unify mq and hg patch invocation. This makes patch a little less verbose by default, so the tests had to be updated.
author Brendan Cully <brendan@kublai.com>
date Tue, 15 Aug 2006 11:28:50 -0700
parents 8b02af865990
children ef8ee4477019 addb58e3b41c
comparison
equal deleted inserted replaced
2906:68cea0b8f992 2907:b70740aefa4d
213 raise 213 raise
214 214
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)
228 patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') 229 patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch')
229 args = [] 230 args = []
235 if dopatch == 'filter': 236 if dopatch == 'filter':
236 False and os.unlink(patchname) 237 False and os.unlink(patchname)
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") %
247 util.explain_exit(code)[0]) 263 util.explain_exit(code)[0])
248 264
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):
256 '''print diff of changes to files between two nodes, or node and 272 '''print diff of changes to files between two nodes, or node and
257 working directory. 273 working directory.