changeset 1193:04d1ca8ae9ec

Fortify the recognition of a diff header.
author bos@serpentine.internal.keyresearch.com
date Thu, 01 Sep 2005 09:35:42 -0700
parents 6e165de907c5
children c165cbf56bb1
files mercurial/commands.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Sep 01 09:11:25 2005 -0700
+++ b/mercurial/commands.py	Thu Sep 01 09:35:42 2005 -0700
@@ -1009,7 +1009,8 @@
     d = opts["base"]
     strip = opts["strip"]
 
-    mailre = re.compile(r'(From |[\w-]+:)')
+    mailre = re.compile(r'(?:From |[\w-]+:)')
+    diffre = re.compile(r'(?:diff -|--- .*\s+\w+ \w+ +\d+ \d+:\d+:\d+ \d+)')
 
     for patch in patches:
         ui.status("applying %s\n" % patch)
@@ -1024,7 +1025,7 @@
                 if len(line) > 35: line = line[:32] + '...'
                 raise util.Abort('first line looks like a '
                                  'mail header: ' + line)
-            if line.startswith("--- ") or line.startswith("diff -r"):
+            if diffre.match(line):
                 break
             elif hgpatch:
                 # parse values when importing the result of an hg export