[PATCH STABLE] convert: ignore blank lines in mapfiles (issue3286)
Patrick Mezard
patrick at mezard.eu
Tue Feb 28 09:12:08 UTC 2012
# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1330419995 -3600
# Branch stable
# Node ID 0b0423495e913345823b54a3b40dc3d5297718f4
# Parent 280e834c9d15b0d65a0ee24374671e0cd2147f4e
convert: ignore blank lines in mapfiles (issue3286)
diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -385,8 +385,12 @@
raise
return
for i, line in enumerate(fp):
+ line = line.splitlines()[0].rstrip()
+ if not line:
+ # Ignore blank lines
+ continue
try:
- key, value = line.splitlines()[0].rstrip().rsplit(' ', 1)
+ key, value = line.rsplit(' ', 1)
except ValueError:
raise util.Abort(
_('syntax error in %s(%d): key/value pair expected')
@@ -418,8 +422,12 @@
try:
fp = open(path, 'r')
for i, line in enumerate(fp):
+ line = line.splitlines()[0].rstrip()
+ if not line:
+ # Ignore blank lines
+ continue
try:
- child, parents = line.splitlines()[0].rstrip().split(' ', 1)
+ child, parents = line.split(' ', 1)
parents = parents.replace(',', ' ').split()
except ValueError:
raise util.Abort(_('syntax error in %s(%d): child parent1'
diff --git a/tests/test-convert-splicemap.t b/tests/test-convert-splicemap.t
--- a/tests/test-convert-splicemap.t
+++ b/tests/test-convert-splicemap.t
@@ -67,10 +67,12 @@
$ cat > splicemap <<EOF
> $CHILDID1 $PARENTID1
> $CHILDID2 $PARENTID2,$CHILDID1
+ >
> EOF
$ cat splicemap
527cdedf31fbd5ea708aa14eeecf53d4676f38db 6d4c2037ddc2cb2627ac3a244ecce35283268f8e
e4ea00df91897da3079a10fab658c1eddba6617b e55c719b85b60e5102fac26110ba626e7cb6b7dc,527cdedf31fbd5ea708aa14eeecf53d4676f38db
+
$ hg clone repo1 target1
updating to branch default
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-convert-svn-branches.t b/tests/test-convert-svn-branches.t
--- a/tests/test-convert-svn-branches.t
+++ b/tests/test-convert-svn-branches.t
@@ -14,6 +14,8 @@
$ cat > branchmap <<EOF
> old3 newbranch
+ >
+ >
> EOF
$ hg convert --branchmap=branchmap --datesort -r 10 svn-repo A-hg
initializing destination A-hg repository
More information about the Mercurial-devel
mailing list