[PATCH stable] convert: tolerate trailing spaces on map files

Wagner Bruna wagner.bruna+mercurial at gmail.com
Fri Dec 2 23:40:47 UTC 2011


# HG changeset patch
# User Wagner Bruna <wbruna at softwareexpress.com.br>
# Date 1322869137 7200
# Branch stable
# Node ID 9794093fea36efd233821870ca96542410ee1b25
# Parent  2f2ca019569feddfc39eae4f1cda0b3da62d4e00
convert: tolerate trailing spaces on map files

A convert run with a branchmap made with

echo default namedbranch > branchmap

on Windows fails silently and surprisingly; it actually
adds a space after 'namedbranch', so it ends up mapping
"default namedbranch" to "".

This also affects splicemaps, since the same parser is used
for both.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -384,7 +384,7 @@ class mapfile(dict):
             return
         for i, line in enumerate(fp):
             try:
-                key, value = line.splitlines()[0].rsplit(' ', 1)
+                key, value = line.splitlines()[0].rstrip().rsplit(' ', 1)
             except ValueError:
                 raise util.Abort(
                     _('syntax error in %s(%d): key/value pair expected')
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
@@ -49,7 +49,7 @@ test invalid splicemap
 splice repo2 on repo1
 
   $ cat > splicemap <<EOF
-  > $CHILDID1 $PARENTID1
+  > $CHILDID1 $PARENTID1 
   > $CHILDID2 $PARENTID2,$CHILDID1
   > EOF
   $ hg clone repo1 target1



More information about the Mercurial-devel mailing list