Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 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 |
comparison
equal
deleted
inserted
replaced
1192:6e165de907c5 | 1193:04d1ca8ae9ec |
---|---|
1007 return 1 | 1007 return 1 |
1008 | 1008 |
1009 d = opts["base"] | 1009 d = opts["base"] |
1010 strip = opts["strip"] | 1010 strip = opts["strip"] |
1011 | 1011 |
1012 mailre = re.compile(r'(From |[\w-]+:)') | 1012 mailre = re.compile(r'(?:From |[\w-]+:)') |
1013 diffre = re.compile(r'(?:diff -|--- .*\s+\w+ \w+ +\d+ \d+:\d+:\d+ \d+)') | |
1013 | 1014 |
1014 for patch in patches: | 1015 for patch in patches: |
1015 ui.status("applying %s\n" % patch) | 1016 ui.status("applying %s\n" % patch) |
1016 pf = os.path.join(d, patch) | 1017 pf = os.path.join(d, patch) |
1017 | 1018 |
1022 line = line.rstrip() | 1023 line = line.rstrip() |
1023 if not message and mailre.match(line) and not opts['mail_like']: | 1024 if not message and mailre.match(line) and not opts['mail_like']: |
1024 if len(line) > 35: line = line[:32] + '...' | 1025 if len(line) > 35: line = line[:32] + '...' |
1025 raise util.Abort('first line looks like a ' | 1026 raise util.Abort('first line looks like a ' |
1026 'mail header: ' + line) | 1027 'mail header: ' + line) |
1027 if line.startswith("--- ") or line.startswith("diff -r"): | 1028 if diffre.match(line): |
1028 break | 1029 break |
1029 elif hgpatch: | 1030 elif hgpatch: |
1030 # parse values when importing the result of an hg export | 1031 # parse values when importing the result of an hg export |
1031 if line.startswith("# User "): | 1032 if line.startswith("# User "): |
1032 user = line[7:] | 1033 user = line[7:] |