Show More
@@ -408,14 +408,15 b' class queue:' | |||||
408 | def patch(self, repo, patchfile): |
|
408 | def patch(self, repo, patchfile): | |
409 | '''Apply patchfile to the working directory. |
|
409 | '''Apply patchfile to the working directory. | |
410 | patchfile: file name of patch''' |
|
410 | patchfile: file name of patch''' | |
|
411 | files = {} | |||
411 | try: |
|
412 | try: | |
412 |
|
|
413 | fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root, | |
413 |
|
|
414 | files=files) | |
414 | except Exception, inst: |
|
415 | except Exception, inst: | |
415 | self.ui.note(str(inst) + '\n') |
|
416 | self.ui.note(str(inst) + '\n') | |
416 | if not self.ui.verbose: |
|
417 | if not self.ui.verbose: | |
417 | self.ui.warn("patch failed, unable to continue (try -v)\n") |
|
418 | self.ui.warn("patch failed, unable to continue (try -v)\n") | |
418 |
return (False, |
|
419 | return (False, files, False) | |
419 |
|
420 | |||
420 | return (True, files, fuzz) |
|
421 | return (True, files, fuzz) | |
421 |
|
422 |
@@ -1656,8 +1656,12 b' def import_(ui, repo, patch1, *patches, ' | |||||
1656 | message = None |
|
1656 | message = None | |
1657 | ui.debug(_('message:\n%s\n') % message) |
|
1657 | ui.debug(_('message:\n%s\n') % message) | |
1658 |
|
1658 | |||
1659 | files, fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root) |
|
1659 | files = {} | |
1660 | files = patch.updatedir(ui, repo, files, wlock=wlock) |
|
1660 | try: | |
|
1661 | fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root, | |||
|
1662 | files=files) | |||
|
1663 | finally: | |||
|
1664 | files = patch.updatedir(ui, repo, files, wlock=wlock) | |||
1661 | repo.commit(files, message, user, date, wlock=wlock, lock=lock) |
|
1665 | repo.commit(files, message, user, date, wlock=wlock, lock=lock) | |
1662 | finally: |
|
1666 | finally: | |
1663 | os.unlink(tmpname) |
|
1667 | os.unlink(tmpname) |
@@ -266,14 +266,13 b' def dogitpatch(patchname, gitpatches, cw' | |||||
266 | tmpfp.close() |
|
266 | tmpfp.close() | |
267 | return patchname |
|
267 | return patchname | |
268 |
|
268 | |||
269 | def patch(patchname, ui, strip=1, cwd=None): |
|
269 | def patch(patchname, ui, strip=1, cwd=None, files={}): | |
270 | """apply the patch <patchname> to the working directory. |
|
270 | """apply the patch <patchname> to the working directory. | |
271 | a list of patched files is returned""" |
|
271 | a list of patched files is returned""" | |
272 |
|
272 | |||
273 | # helper function |
|
273 | # helper function | |
274 | def __patch(patchname): |
|
274 | def __patch(patchname): | |
275 | """patch and updates the files and fuzz variables""" |
|
275 | """patch and updates the files and fuzz variables""" | |
276 | files = {} |
|
|||
277 | fuzz = False |
|
276 | fuzz = False | |
278 |
|
277 | |||
279 | patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''), |
|
278 | patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''), | |
@@ -308,25 +307,24 b' def patch(patchname, ui, strip=1, cwd=No' | |||||
308 | if code: |
|
307 | if code: | |
309 | raise util.Abort(_("patch command failed: %s") % |
|
308 | raise util.Abort(_("patch command failed: %s") % | |
310 | util.explain_exit(code)[0]) |
|
309 | util.explain_exit(code)[0]) | |
311 |
return |
|
310 | return fuzz | |
312 |
|
311 | |||
313 | (dopatch, gitpatches) = readgitpatch(patchname) |
|
312 | (dopatch, gitpatches) = readgitpatch(patchname) | |
|
313 | for gp in gitpatches: | |||
|
314 | files[gp.path] = (gp.op, gp) | |||
314 |
|
315 | |||
315 |
|
|
316 | fuzz = False | |
316 | if dopatch: |
|
317 | if dopatch: | |
317 | if dopatch in ('filter', 'binary'): |
|
318 | if dopatch in ('filter', 'binary'): | |
318 | patchname = dogitpatch(patchname, gitpatches, cwd=cwd) |
|
319 | patchname = dogitpatch(patchname, gitpatches, cwd=cwd) | |
319 | try: |
|
320 | try: | |
320 | if dopatch != 'binary': |
|
321 | if dopatch != 'binary': | |
321 |
|
|
322 | fuzz = __patch(patchname) | |
322 | finally: |
|
323 | finally: | |
323 | if dopatch == 'filter': |
|
324 | if dopatch == 'filter': | |
324 | os.unlink(patchname) |
|
325 | os.unlink(patchname) | |
325 |
|
326 | |||
326 | for gp in gitpatches: |
|
327 | return fuzz | |
327 | files[gp.path] = (gp.op, gp) |
|
|||
328 |
|
||||
329 | return (files, fuzz) |
|
|||
330 |
|
328 | |||
331 | def diffopts(ui, opts={}): |
|
329 | def diffopts(ui, opts={}): | |
332 | return mdiff.diffopts( |
|
330 | return mdiff.diffopts( |
General Comments 0
You need to be logged in to leave comments.
Login now