Output more detailed error on corrupt LocalStatus

When our LocalStatus cache is corrupt, ie e.g. it contains lines not in
the form number:number, we would previously just raise a ValueError
stating things like "too many values". In case we encounter clearly
corrupt LocalStatus cache entries, clearly raise an exception stating
the filename and the line, so that people can attempt to repair it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-05-04 19:44:01 +02:00 committed by Nicolas Sebrecht
parent 50f0fbb421
commit b1ff307674

View File

@ -77,8 +77,13 @@ class LocalStatusFolder(BaseFolder):
assert(line == magicline)
for line in file.xreadlines():
line = line.strip()
try:
uid, flags = line.split(':')
uid = long(uid)
except ValueError, e:
errstr = "Corrupt line '%s' in cache file '%s'" % (line, self.filename)
self.ui.warn(errstr)
raise ValueError(errstr)
flags = [x for x in flags]
self.messagelist[uid] = {'uid': uid, 'flags': flags}
file.close()