[PATCH] patch: be more tolerant with "Parent" header (issue3356)
Patrick Mezard
patrick at mezard.eu
Fri Apr 20 12:21:03 CDT 2012
# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1334941914 -7200
# Branch stable
# Node ID 1f75c1decdebdfe164741fb64d97a206d9d3b226
# Parent ee553e6cd8c445ff40ed15ca0ab1b9a3636a9ddc
patch: be more tolerant with "Parent" header (issue3356)
Here is how export and mq write the "Parent" header:
mq: # Parent XXXXX
export: # Parent XXXXX
then import expects exactly 2 spaces while mq tolerates one or more. So "hg
import --exact" truncates mq generated patches header by one character and
fails. This patch aligns import "Parent" header parsing on mq one. I do not
expect spaces in parent references anytime soon.
Reported by Stefan Ring <stefanrin at gmail.com>
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -230,7 +230,7 @@
elif line.startswith("# Node ID "):
nodeid = line[10:]
elif line.startswith("# Parent "):
- parents.append(line[10:])
+ parents.append(line[9:].lstrip())
elif not line.startswith("# "):
hgpatchheader = False
elif line == '---' and gitsendmail:
diff --git a/tests/test-impexp-branch.t b/tests/test-impexp-branch.t
--- a/tests/test-impexp-branch.t
+++ b/tests/test-impexp-branch.t
@@ -1,3 +1,6 @@
+ $ echo '[extensions]' >> $HGRCPATH
+ $ echo 'mq =' >> $HGRCPATH
+
$ cat >findbranch.py <<EOF
> import re, sys
>
@@ -55,3 +58,14 @@
applying ../r0.patch
$ hg import --exact ../r1.patch
applying ../r1.patch
+
+Test --exact and patch header separators (issue3356)
+
+ $ hg strip --no-backup .
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ >>> import re
+ >>> p = file('../r1.patch', 'rb').read()
+ >>> p = re.sub(r'Parent\s+', 'Parent ', p)
+ >>> file('../r1-ws.patch', 'wb').write(p)
+ $ hg import --exact ../r1-ws.patch
+ applying ../r1-ws.patch
More information about the Mercurial-devel
mailing list