##// 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 251 import [-p <n> -b <base> -f] <patches>::
252 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 260 options:
255 261 -p, --strip <n> directory strip option for patch. This has the same
256 262 meaning as the corresponding patch option
257 263 -b <path> base directory to read patches from
258 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 267 aliases: patch
261 268
@@ -1009,6 +1009,8 b' def import_(ui, repo, patch1, *patches, '
1009 1009 d = opts["base"]
1010 1010 strip = opts["strip"]
1011 1011
1012 mailre = re.compile(r'(From |[\w-]+:)')
1013
1012 1014 for patch in patches:
1013 1015 ui.status("applying %s\n" % patch)
1014 1016 pf = os.path.join(d, patch)
@@ -1018,6 +1020,10 b' def import_(ui, repo, patch1, *patches, '
1018 1020 hgpatch = False
1019 1021 for line in file(pf):
1020 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 1027 if line.startswith("--- ") or line.startswith("diff -r"):
1022 1028 break
1023 1029 elif hgpatch:
@@ -1662,7 +1668,8 b' table = {'
1662 1668 (import_,
1663 1669 [('p', 'strip', 1, 'path strip'),
1664 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 1673 "hg import [-f] [-p NUM] [-b BASE] PATCH..."),
1667 1674 "incoming|in": (incoming,
1668 1675 [('p', 'patch', None, 'show patch')],
General Comments 0
You need to be logged in to leave comments. Login now