# HG changeset patch # User Patrick Mezard # Date 2009-04-11 19:15:27 # Node ID 04c62275cbc7501aad3bc5fdf8e138092e4ace84 # Parent f3ef8a352d83a60a64b9b32c5b8afa22529f268e convert: better mapfile parsing errors (issue1581/1) diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -333,8 +333,12 @@ class mapfile(dict): if err.errno != errno.ENOENT: raise return - for line in fp: - key, value = strutil.rsplit(line[:-1], ' ', 1) + for i, line in enumerate(fp): + try: + key, value = strutil.rsplit(line[:-1], ' ', 1) + except ValueError: + raise util.Abort(_('syntax error in %s(%d): key/value pair expected') + % (self.path, i+1)) if key not in self: self.order.append(key) super(mapfile, self).__setitem__(key, value) diff --git a/tests/test-convert-splicemap b/tests/test-convert-splicemap new file mode 100755 --- /dev/null +++ b/tests/test-convert-splicemap @@ -0,0 +1,51 @@ +#!/bin/sh + +echo "[extensions]" >> $HGRCPATH +echo "convert=" >> $HGRCPATH +echo 'hgext.graphlog =' >> $HGRCPATH + +glog() +{ + hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@" +} + +hg init repo1 +cd repo1 +echo a > a +hg ci -Am adda +echo b > b +echo a >> a +hg ci -Am addb +PARENTID1=`hg id --debug -i` +echo c > c +hg ci -Am addc +PARENTID2=`hg id --debug -i` +cd .. + +hg init repo2 +cd repo2 +echo b > a +echo d > d +hg ci -Am addaandd +CHILDID1=`hg id --debug -i` +echo d >> d +hg ci -Am changed +CHILDID2=`hg id --debug -i` +echo e > e +hg ci -Am adde +cd .. + +echo '% test invalid splicemap' +cat > splicemap < splicemap <