~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Ian Clatworthy
  • Date: 2009-03-16 22:22:06 UTC
  • mfrom: (4145.2.1 bzr.faster-check)
  • mto: This revision was merged to the branch mainline in revision 4151.
  • Revision ID: ian.clatworthy@canonical.com-20090316222206-xgiuko42s5bui64z
faster check (Ian Clatworthy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        self.checked_weaves = set()
64
64
        self.unreferenced_versions = set()
65
65
        self.inconsistent_parents = []
 
66
        self.rich_roots = repository.supports_rich_root()
 
67
        self.text_key_references = {}
66
68
 
67
69
    def check(self):
68
70
        self.repository.lock_read()
209
211
        self.inventory_weave.check(progress_bar=self.progress)
210
212
        self.progress.update('checking text storage', 1, 2)
211
213
        self.repository.texts.check(progress_bar=self.progress)
212
 
        weave_checker = self.repository._get_versioned_file_checker()
 
214
        weave_checker = self.repository._get_versioned_file_checker(
 
215
            text_key_references=self.text_key_references)
213
216
        result = weave_checker.check_file_version_parents(
214
217
            self.repository.texts, progress_bar=self.progress)
215
218
        self.checked_weaves = weave_checker.file_ids
228
231
    def _check_revision_tree(self, rev_id):
229
232
        tree = self.repository.revision_tree(rev_id)
230
233
        inv = tree.inventory
231
 
        seen_ids = {}
232
 
        for file_id in inv:
 
234
        seen_ids = set()
 
235
        seen_names = set()
 
236
        for path, ie in inv.iter_entries():
 
237
            self._add_entry_to_text_key_references(inv, ie)
 
238
            file_id = ie.file_id
233
239
            if file_id in seen_ids:
234
240
                raise BzrCheckError('duplicated file_id {%s} '
235
241
                                    'in inventory for revision {%s}'
236
242
                                    % (file_id, rev_id))
237
 
            seen_ids[file_id] = True
238
 
        for file_id in inv:
239
 
            ie = inv[file_id]
 
243
            seen_ids.add(file_id)
240
244
            ie.check(self, rev_id, inv, tree)
241
 
        seen_names = {}
242
 
        for path, ie in inv.iter_entries():
243
245
            if path in seen_names:
244
246
                raise BzrCheckError('duplicated path %s '
245
247
                                    'in inventory for revision {%s}'
246
248
                                    % (path, rev_id))
247
 
            seen_names[path] = True
 
249
            seen_names.add(path)
 
250
 
 
251
    def _add_entry_to_text_key_references(self, inv, entry):
 
252
        if not self.rich_roots and entry == inv.root:
 
253
            return
 
254
        key = (entry.file_id, entry.revision)
 
255
        self.text_key_references.setdefault(key, False)
 
256
        if entry.revision == inv.revision_id:
 
257
            self.text_key_references[key] = True
248
258
 
249
259
 
250
260
@deprecated_function(deprecated_in((1,6,0)))