Rev 5728: Change the asserts into ValueError checks. in http://bazaar.launchpad.net/~jameinel/bzr/2.4-cheaper-iter-entries-by-dir
John Arbash Meinel
john at arbash-meinel.com
Sat Mar 19 08:21:16 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.4-cheaper-iter-entries-by-dir
------------------------------------------------------------
revno: 5728
revision-id: john at arbash-meinel.com-20110319082100-l5w627s2ypwsulhw
parent: john at arbash-meinel.com-20110318115158-6s4xs41w01x3xcxv
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-cheaper-iter-entries-by-dir
timestamp: Sat 2011-03-19 09:21:00 +0100
message:
Change the asserts into ValueError checks.
-------------- next part --------------
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2011-03-18 11:51:58 +0000
+++ b/bzrlib/inventory.py 2011-03-19 08:21:00 +0000
@@ -2001,7 +2001,11 @@
pid_items = self.parent_id_basename_to_file_id.iteritems()
for key, child_file_id in pid_items:
if key == ('', ''): # This is the root
- assert child_file_id == self.root_id
+ if child_file_id != self.root_id:
+ raise ValueError('Data inconsistency detected.'
+ ' We expected data with key ("","") to match'
+ ' the root id, but %s != %s'
+ % (child_file_id, self.root_id))
continue
parent_id, basename = key
ie = cache[child_file_id]
@@ -2009,14 +2013,27 @@
parent_ie = last_parent_ie
else:
parent_ie = cache[parent_id]
- assert parent_ie.kind == 'directory'
+ if parent_ie.kind != 'directory':
+ raise ValueError('Data inconsistency detected.'
+ ' An entry in the parent_id_basename_to_file_id map'
+ ' has parent_id {%s} but the kind of that object'
+ ' is %r not "directory"' % (parent_id, parent_ie.kind))
if parent_ie._children is None:
parent_ie._children = {}
- assert basename not in parent_ie._children
- assert basename == ie.name
+ if basename in parent_ie._children:
+ raise ValueError('Data inconsistency detected.'
+ ' Two entries with basename %r were found'
+ ' in the parent entry {%s}'
+ % (basename, parent_id))
+ if basename != ie.name:
+ raise ValueError('Data inconsistency detected.'
+ ' In the parent_id_basename_to_file_id map, file_id'
+ ' {%s} is listed as having basename %r, but in the'
+ ' id_to_entry map it is %r'
+ % (child_file_id, basename, ie.name))
parent_ie._children[basename] = ie
self._fully_cached = True
-
+
def iter_changes(self, basis):
"""Generate a Tree.iter_changes change list between this and basis.
More information about the bazaar-commits
mailing list