~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-10-16 02:42:33 UTC
  • mfrom: (2906.1.1 reconcile-speed)
  • Revision ID: pqm@pqm.ubuntu.com-20071016024233-6fmmyqoh0cfnsni8
(Andrew Bennetts) Speed up reconcile by not repeatedly fetching the full inventories, by cache heads and parents queries, and by fetching revision trees in batches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        # maps (file-id, version) -> sha1; used by InventoryFile._check
57
57
        self.checked_texts = {}
58
58
        self.checked_weaves = {}
59
 
        self.unreferenced_versions = set()
 
59
        self.revision_versions = _mod_repository._RevisionTextVersionCache(
 
60
            self.repository)
 
61
        self.unreferenced_ancestors = set()
60
62
        self.inconsistent_parents = []
61
63
 
62
64
    def check(self):
78
80
                revno += 1
79
81
                self.check_one_rev(rev_id)
80
82
            # check_weaves is done after the revision scan so that
81
 
            # revision index is known to be valid.
 
83
            # revision_versions is pre-populated
82
84
            self.check_weaves()
83
85
        finally:
84
86
            self.progress.finished()
110
112
        note('%6d file-ids', len(self.checked_weaves))
111
113
        note('%6d unique file texts', self.checked_text_cnt)
112
114
        note('%6d repeated file texts', self.repeated_text_cnt)
113
 
        note('%6d unreferenced text versions',
114
 
             len(self.unreferenced_versions))
 
115
        note('%6d unreferenced text ancestors',
 
116
             len(self.unreferenced_ancestors))
115
117
        if self.missing_inventory_sha_cnt:
116
118
            note('%6d revisions are missing inventory_sha1',
117
119
                 self.missing_inventory_sha_cnt)
132
134
                    for linker in linkers:
133
135
                        note('       * %s', linker)
134
136
            if verbose:
135
 
                for file_id, revision_id in self.unreferenced_versions:
136
 
                    log_error('unreferenced version: {%s} in %s', revision_id,
 
137
                for file_id, revision_id in self.unreferenced_ancestors:
 
138
                    log_error('unreferenced ancestor: {%s} in %s', revision_id,
137
139
                        file_id)
138
140
        if len(self.inconsistent_parents):
139
141
            note('%6d inconsistent parents', len(self.inconsistent_parents))
202
204
        self.inventory_weave.check(progress_bar=self.progress)
203
205
        files_in_revisions = {}
204
206
        revisions_of_files = {}
205
 
        weave_checker = self.repository._get_versioned_file_checker()
206
207
        for i, weave_id in enumerate(weave_ids):
207
208
            self.progress.update('checking versionedfile', i, n_weaves)
208
209
            w = self.repository.weave_store.get_weave(weave_id,
209
210
                    self.repository.get_transaction())
210
211
            # No progress here, because it looks ugly.
211
212
            w.check()
 
213
 
 
214
            weave_checker = self.repository.get_versioned_file_checker(
 
215
                self.planned_revisions, self.revision_versions)
212
216
            result = weave_checker.check_file_version_parents(w, weave_id)
213
 
            bad_parents, unused_versions = result
214
 
            bad_parents = bad_parents.items()
215
 
            for revision_id, (weave_parents, correct_parents) in bad_parents:
 
217
 
 
218
            for revision_id, (weave_parents,correct_parents) in result.items():
216
219
                self.inconsistent_parents.append(
217
220
                    (revision_id, weave_id, weave_parents, correct_parents))
218
 
            for revision_id in unused_versions:
219
 
                self.unreferenced_versions.add((weave_id, revision_id))
 
221
                unreferenced_parents = set(weave_parents)-set(correct_parents)
 
222
                for unreferenced_parent in unreferenced_parents:
 
223
                    self.unreferenced_ancestors.add(
 
224
                        (weave_id, unreferenced_parent))
220
225
            self.checked_weaves[weave_id] = True
221
226
 
222
227
    def _check_revision_tree(self, rev_id):
223
228
        tree = self.repository.revision_tree(rev_id)
 
229
        self.revision_versions.add_revision_text_versions(tree)
224
230
        inv = tree.inventory
225
231
        seen_ids = {}
226
232
        for file_id in inv: