##// END OF EJS Templates
Make import command reject patches that resemble email messages....
bos@serpentine.internal.keyresearch.com -
r1190:737f9b90 default
parent child Browse files
Show More
@@ -251,11 +251,18 b' identify::'
251 import [-p <n> -b <base> -f] <patches>::
251 import [-p <n> -b <base> -f] <patches>::
252 Import a list of patches and commit them individually.
252 Import a list of patches and commit them individually.
253
253
254 If a patch looks like a mail message (its first line starts with
255 "From " or looks like an RFC822 header), it will not be applied
256 unless the -m option is used. The importer neither parses nor
257 discards mail headers, so use -m only to override the "mailness"
258 safety check, not to import a real mail message.
259
254 options:
260 options:
255 -p, --strip <n> directory strip option for patch. This has the same
261 -p, --strip <n> directory strip option for patch. This has the same
256 meaning as the corresponding patch option
262 meaning as the corresponding patch option
257 -b <path> base directory to read patches from
263 -b <path> base directory to read patches from
258 -f, --force skip check for outstanding uncommitted changes
264 -f, --force skip check for outstanding uncommitted changes
265 -m, --mail-like apply a patch that appears to be a mail message
259
266
260 aliases: patch
267 aliases: patch
261
268
@@ -1009,6 +1009,8 b' def import_(ui, repo, patch1, *patches, '
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)
@@ -1018,6 +1020,10 b' def import_(ui, repo, patch1, *patches, '
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:
@@ -1662,7 +1668,8 b' table = {'
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')],
General Comments 0
You need to be logged in to leave comments. Login now