--- a/hgext/convert/convcmd.py Wed Apr 24 18:26:37 2013 -0700
+++ b/hgext/convert/convcmd.py Thu Apr 25 11:50:26 2013 -0700
@@ -121,9 +121,17 @@
self.splicemap = self.parsesplicemap(opts.get('splicemap'))
self.branchmap = mapfile(ui, opts.get('branchmap'))
+ def parsesplicemap(self, path):
+ """ check and validate the splicemap format and
+ return a child/parents dictionary.
+ Format checking has two parts.
+ 1. generic format which is same across all source types
+ 2. specific format checking which may be different for
+ different source type. This logic is implemented in
+ checkrevformat function in source files like
+ hg.py, subversion.py etc.
+ """
- def parsesplicemap(self, path):
- """Parse a splicemap, return a child/parents dictionary."""
if not path:
return {}
m = {}
@@ -136,18 +144,28 @@
continue
try:
child, parents = line.split(' ', 1)
+ self.source.checkrevformat(child)
parents = parents.replace(',', ' ').split()
+ # check if number of parents are upto 2 max
+ if (len(parents) > 2):
+ raise util.Abort(_('syntax error in %s(%d): child '\
+ 'parent1[,parent2] expected') \
+ % (path, i + 1))
+ for parent in parents:
+ self.source.checkrevformat(parent)
except ValueError:
- raise util.Abort(_('syntax error in %s(%d): child parent1'
- '[,parent2] expected') % (path, i + 1))
+ raise util.Abort(_('syntax error in %s(%d): child '\
+ 'parent1[,parent2] expected') \
+ % (path, i + 1))
pp = []
for p in parents:
if p not in pp:
pp.append(p)
m[child] = pp
- except IOError, e:
- if e.errno != errno.ENOENT:
- raise
+ # if file does not exist or error reading, exit
+ except IOError:
+ raise util.Abort(_('splicemap file not found or error reading %s:')
+ % path)
return m