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-]+:)') |
|
1013 |
1012 for patch in patches: |
1014 for patch in patches: |
1013 ui.status("applying %s\n" % patch) |
1015 ui.status("applying %s\n" % patch) |
1014 pf = os.path.join(d, patch) |
1016 pf = os.path.join(d, patch) |
1015 |
1017 |
1016 message = [] |
1018 message = [] |
1017 user = None |
1019 user = None |
1018 hgpatch = False |
1020 hgpatch = False |
1019 for line in file(pf): |
1021 for line in file(pf): |
1020 line = line.rstrip() |
1022 line = line.rstrip() |
|
1023 if not message and mailre.match(line) and not opts['mail_like']: |
|
1024 if len(line) > 35: line = line[:32] + '...' |
|
1025 raise util.Abort('first line looks like a ' |
|
1026 'mail header: ' + line) |
1021 if line.startswith("--- ") or line.startswith("diff -r"): |
1027 if line.startswith("--- ") or line.startswith("diff -r"): |
1022 break |
1028 break |
1023 elif hgpatch: |
1029 elif hgpatch: |
1024 # parse values when importing the result of an hg export |
1030 # parse values when importing the result of an hg export |
1025 if line.startswith("# User "): |
1031 if line.startswith("# User "): |
1660 "identify|id": (identify, [], 'hg identify'), |
1666 "identify|id": (identify, [], 'hg identify'), |
1661 "import|patch": |
1667 "import|patch": |
1662 (import_, |
1668 (import_, |
1663 [('p', 'strip', 1, 'path strip'), |
1669 [('p', 'strip', 1, 'path strip'), |
1664 ('f', 'force', None, 'skip check for outstanding changes'), |
1670 ('f', 'force', None, 'skip check for outstanding changes'), |
1665 ('b', 'base', "", 'base path')], |
1671 ('b', 'base', "", 'base path'), |
|
1672 ('m', 'mail-like', None, 'apply a patch that looks like email')], |
1666 "hg import [-f] [-p NUM] [-b BASE] PATCH..."), |
1673 "hg import [-f] [-p NUM] [-b BASE] PATCH..."), |
1667 "incoming|in": (incoming, |
1674 "incoming|in": (incoming, |
1668 [('p', 'patch', None, 'show patch')], |
1675 [('p', 'patch', None, 'show patch')], |
1669 'hg incoming [-p] [SOURCE]'), |
1676 'hg incoming [-p] [SOURCE]'), |
1670 "^init": (init, [], 'hg init [DEST]'), |
1677 "^init": (init, [], 'hg init [DEST]'), |