diff hgext/convert/common.py @ 8047:04c62275cbc7

convert: better mapfile parsing errors (issue1581/1)
author Patrick Mezard <pmezard@gmail.com>
date Sat, 11 Apr 2009 21:15:27 +0200
parents 3b8f2750efcf
children b7cdfa2527be
line wrap: on
line diff
--- a/hgext/convert/common.py	Sat Apr 11 20:49:47 2009 +0200
+++ b/hgext/convert/common.py	Sat Apr 11 21:15:27 2009 +0200
@@ -333,8 +333,12 @@
             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)