diff 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
line wrap: on
line diff
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -215,13 +215,14 @@ def dogitpatch(patchname, gitpatches):
     tmpfp.close()
     return patchname
 
-def patch(strip, patchname, ui, cwd=None):
+def patch(patchname, ui, strip=1, cwd=None):
     """apply the patch <patchname> to the working directory.
     a list of patched files is returned"""
 
     (dopatch, gitpatches) = readgitpatch(patchname)
 
     files = {}
+    fuzz = False
     if dopatch:
         if dopatch == 'filter':
             patchname = dogitpatch(patchname, gitpatches)
@@ -237,10 +238,25 @@ def patch(strip, patchname, ui, cwd=None
 
         for line in fp:
             line = line.rstrip()
-            ui.status("%s\n" % line)
+            ui.note(line + '\n')
             if line.startswith('patching file '):
                 pf = util.parse_patch_output(line)
+                printed_file = False
                 files.setdefault(pf, (None, None))
+            elif line.find('with fuzz') >= 0:
+                fuzz = True
+                if not printed_file:
+                    ui.warn(pf + '\n')
+                    printed_file = True
+                ui.warn(line + '\n')
+            elif line.find('saving rejects to file') >= 0:
+                ui.warn(line + '\n')
+            elif line.find('FAILED') >= 0:
+                if not printed_file:
+                    ui.warn(pf + '\n')
+                    printed_file = True
+                ui.warn(line + '\n')
+            
         code = fp.close()
         if code:
             raise util.Abort(_("patch command failed: %s") %
@@ -249,7 +265,7 @@ def patch(strip, patchname, ui, cwd=None
     for gp in gitpatches:
         files[gp.path] = (gp.op, gp)
 
-    return files
+    return (files, fuzz)
 
 def diff(repo, node1=None, node2=None, files=None, match=util.always,
          fp=None, changes=None, opts=None):