# HG changeset patch # User bos@serpentine.internal.keyresearch.com # Date 2005-09-01 16:35:42 # Node ID 04d1ca8ae9ecc35fbfc5cd27af9094dcea9ae62b # Parent 6e165de907c586224454b60be75835385af89b7f Fortify the recognition of a diff header. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1009,7 +1009,8 @@ def import_(ui, repo, patch1, *patches, 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 @@ def import_(ui, repo, patch1, *patches, 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