Rev 2557: Give a cleaner error when failing to decode knit index entry. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jun 27 09:07:25 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2557
revision-id: pqm at pqm.ubuntu.com-20070627080723-ci6ghe3bsm0snyit
parent: pqm at pqm.ubuntu.com-20070627051257-kgk2thfvi2k3k37o
parent: mbp at sourcefrog.net-20070627073753-rrxu5bbux3vi5yda
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-06-27 09:07:23 +0100
message:
Give a cleaner error when failing to decode knit index entry.
modified:
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
------------------------------------------------------------
revno: 2555.2.1
merged: mbp at sourcefrog.net-20070627073753-rrxu5bbux3vi5yda
parent: pqm at pqm.ubuntu.com-20070627023032-h316n5k05g1nqqem
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: knit-index-reader
timestamp: Wed 2007-06-27 17:37:53 +1000
message:
Give a cleaner error when failing to decode knit index entry.
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2007-06-21 03:29:39 +0000
+++ b/bzrlib/knit.py 2007-06-27 07:37:53 +0000
@@ -1185,14 +1185,26 @@
# or a different failure, and raise. RBC 20060407
continue
- parents = []
- for value in rec[4:-1]:
- if value[0] == '.':
- # uncompressed reference
- parent_id = value[1:]
- else:
- parent_id = history[int(value)]
- parents.append(parent_id)
+ try:
+ parents = []
+ for value in rec[4:-1]:
+ if value[0] == '.':
+ # uncompressed reference
+ parent_id = value[1:]
+ else:
+ parent_id = history[int(value)]
+ parents.append(parent_id)
+ except (IndexError, ValueError), e:
+ # The parent could not be decoded to get its parent row. This
+ # at a minimum will cause this row to have wrong parents, or
+ # even to apply a delta to the wrong base and decode
+ # incorrectly. its therefore not usable, and because we have
+ # encountered a situation where a new knit index had this
+ # corrupt we can't asssume that no other rows referring to the
+ # index of this record actually mean the subsequent uncorrupt
+ # one, so we error.
+ raise errors.KnitCorrupt(self._filename,
+ "line %r: %s" % (rec, e))
version_id, options, pos, size = rec[:4]
version_id = version_id
More information about the bazaar-commits
mailing list