# HG changeset patch # User Brendan Cully # Date 1266518761 28800 # Node ID a27af7229850d3e095aeb5a6d794abcb3d9deb75 # Parent e96597c8d0eae1e0a1d0c11757d2bf8cde741da8 import: if in doubt, consume stream until start of diff This prevents a header-like line in the message body from causing a spurious split. diff -r e96597c8d0ea -r a27af7229850 mercurial/patch.py --- a/mercurial/patch.py Thu Feb 18 10:32:51 2010 +0100 +++ b/mercurial/patch.py Thu Feb 18 10:46:01 2010 -0800 @@ -157,8 +157,8 @@ if line.split(':', 1)[0].lower() in mimeheaders: # let email parser handle this return mimesplit(stream, cur) - elif inheader: - # No evil headers seen, split by hand + elif line.startswith('--- ') and inheader: + # No evil headers seen by diff start, split by hand return headersplit(stream, cur) # Not enough info, keep reading diff -r e96597c8d0ea -r a27af7229850 tests/test-import --- a/tests/test-import Thu Feb 18 10:32:51 2010 +0100 +++ b/tests/test-import Thu Feb 18 10:46:01 2010 -0800 @@ -372,3 +372,30 @@ hg parents -v cd .. +echo '% tricky header splitting' +cat > trickyheaders.patch < +Subject: [PATCH] from: tricky! + +# HG changeset patch +# User User B +# Date 1266264441 18000 +# Branch stable +# Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0 +# Parent 0000000000000000000000000000000000000000 +from: tricky! + +That is not a header. + +diff -r 000000000000 -r f2be6a1170ac foo +--- /dev/null ++++ b/foo +@@ -0,0 +1,1 @@ ++foo +EOF + +hg init trickyheaders +cd trickyheaders +hg import -d '0 0' ../trickyheaders.patch +hg export --git tip +cd .. diff -r e96597c8d0ea -r a27af7229850 tests/test-import.out --- a/tests/test-import.out Thu Feb 18 10:32:51 2010 +0100 +++ b/tests/test-import.out Thu Feb 18 10:46:01 2010 -0800 @@ -314,3 +314,20 @@ description +% tricky header splitting +applying ../trickyheaders.patch +# HG changeset patch +# User User B +# Date 0 0 +# Node ID eb56ab91903632294ac504838508cb370c0901d2 +# Parent 0000000000000000000000000000000000000000 +from: tricky! + +That is not a header. + +diff --git a/foo b/foo +new file mode 100644 +--- /dev/null ++++ b/foo +@@ -0,0 +1,1 @@ ++foo