[PATCH STABLE] convert: tolerate spaces between splicemap parent ids (issue3203)

Patrick Mezard patrick at mezard.eu
Wed Feb 15 04:29:11 CST 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1329301284 -3600
# Branch stable
# Node ID 170c387393f8be0dd3589b2ce66ee8cf850de6fd
# Parent  f7e0d95d0a0bc5545f3dad40b9ceaee362d7c553
convert: tolerate spaces between splicemap parent ids (issue3203)

Splicemap lines are documented in hg help convert like:

  key parent1, parent2

but parsed like:

  key, parents = line.strip().rsplit(' ', 1)
  parents = parents.replace(',', ' ').split()

The rsplit() call was introduced to handle spaces in keys for the generic
mapfile format. Spaces can appear in svn identifiers since they contain path
components. This logic makes less sense with splicemap since svn identifiers
can also appear on the right side, even if it is a bit less likely. Given the
parsing is theorically broken, I would rather follow what is documented already
and is correct in the main case where all identifiers are hg hashes. Also,
using svn identifiers in a splicemap sounds difficult as they are not easily
accessible.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -419,7 +419,7 @@
         fp = open(path, 'r')
         for i, line in enumerate(fp):
             try:
-                child, parents = line.splitlines()[0].rstrip().rsplit(' ', 1)
+                child, parents = line.splitlines()[0].rstrip().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
@@ -123,11 +123,11 @@
 the bug should be exhibited with all conversion orders.
 
   $ cat > ../splicemap <<EOF
-  > $(hg id -r 2 -i --debug) $(hg id -r 1 -i --debug),$(hg id -r 3 -i --debug)
+  > $(hg id -r 2 -i --debug) $(hg id -r 1 -i --debug), $(hg id -r 3 -i --debug)
   > EOF
   $ cd ..
   $ cat splicemap
-  7c364e7fa7d70ae525610c016317ed717b519d97 717d54d67e6c31fd75ffef2ff3042bdd98418437,102a90ea7b4a3361e4082ed620918c261189a36a
+  7c364e7fa7d70ae525610c016317ed717b519d97 717d54d67e6c31fd75ffef2ff3042bdd98418437, 102a90ea7b4a3361e4082ed620918c261189a36a
 
 Test regular conversion
 


More information about the Mercurial-devel mailing list