~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-11-22 23:41:03 UTC
  • mfrom: (2988.1.9 reconcile.memory)
  • Revision ID: pqm@pqm.ubuntu.com-20071122234103-fn117zncqrqv39me
(robertc) Improve the performance of reconcile and reduce its memory
        consumption. (Robert Collins)

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.revision_versions = _mod_repository._RevisionTextVersionCache(
60
 
            self.repository)
61
 
        self.unreferenced_ancestors = set()
 
59
        self.unreferenced_versions = set()
62
60
        self.inconsistent_parents = []
63
 
        self.dangling_versions = set()
64
61
 
65
62
    def check(self):
66
63
        self.repository.lock_read()
81
78
                revno += 1
82
79
                self.check_one_rev(rev_id)
83
80
            # check_weaves is done after the revision scan so that
84
 
            # revision_versions is pre-populated
 
81
            # revision index is known to be valid.
85
82
            self.check_weaves()
86
83
        finally:
87
84
            self.progress.finished()
113
110
        note('%6d file-ids', len(self.checked_weaves))
114
111
        note('%6d unique file texts', self.checked_text_cnt)
115
112
        note('%6d repeated file texts', self.repeated_text_cnt)
116
 
        note('%6d unreferenced text ancestors',
117
 
             len(self.unreferenced_ancestors))
 
113
        note('%6d unreferenced text versions',
 
114
             len(self.unreferenced_versions))
118
115
        if self.missing_inventory_sha_cnt:
119
116
            note('%6d revisions are missing inventory_sha1',
120
117
                 self.missing_inventory_sha_cnt)
135
132
                    for linker in linkers:
136
133
                        note('       * %s', linker)
137
134
            if verbose:
138
 
                for file_id, revision_id in self.unreferenced_ancestors:
139
 
                    log_error('unreferenced ancestor: {%s} in %s', revision_id,
 
135
                for file_id, revision_id in self.unreferenced_versions:
 
136
                    log_error('unreferenced version: {%s} in %s', revision_id,
140
137
                        file_id)
141
138
        if len(self.inconsistent_parents):
142
139
            note('%6d inconsistent parents', len(self.inconsistent_parents))
157
154
                        '       %s has wrong parents in index: '
158
155
                        '%r should be %r',
159
156
                        revision_id, index_parents, actual_parents)
160
 
        if self.dangling_versions:
161
 
            note('%6d file versions are not referenced by their inventory',
162
 
                 len(self.dangling_versions))
163
157
 
164
158
    def check_one_rev(self, rev_id):
165
159
        """Check one revision.
208
202
        self.inventory_weave.check(progress_bar=self.progress)
209
203
        files_in_revisions = {}
210
204
        revisions_of_files = {}
 
205
        weave_checker = self.repository.get_versioned_file_checker()
211
206
        for i, weave_id in enumerate(weave_ids):
212
207
            self.progress.update('checking versionedfile', i, n_weaves)
213
208
            w = self.repository.weave_store.get_weave(weave_id,
214
209
                    self.repository.get_transaction())
215
210
            # No progress here, because it looks ugly.
216
211
            w.check()
217
 
 
218
 
            weave_checker = self.repository.get_versioned_file_checker(
219
 
                self.planned_revisions, self.revision_versions)
220
 
            result = weave_checker.check_file_version_parents(w, weave_id)
221
 
            bad_parents, dangling_versions = result
 
212
            result = weave_checker.check_file_version_parents(w, weave_id,
 
213
                self.planned_revisions)
 
214
            bad_parents, unused_versions = result
222
215
            bad_parents = bad_parents.items()
223
 
            for revision_id, (weave_parents,correct_parents) in bad_parents:
 
216
            for revision_id, (weave_parents, correct_parents) in bad_parents:
224
217
                self.inconsistent_parents.append(
225
218
                    (revision_id, weave_id, weave_parents, correct_parents))
226
 
                if weave_parents is None:
227
 
                    weave_parents = []
228
 
                unreferenced_parents = set(weave_parents)-set(correct_parents)
229
 
                for unreferenced_parent in unreferenced_parents:
230
 
                    self.unreferenced_ancestors.add(
231
 
                        (weave_id, unreferenced_parent))
232
 
            self.dangling_versions.update(dangling_versions)
 
219
            for revision_id in unused_versions:
 
220
                self.unreferenced_versions.add((weave_id, revision_id))
233
221
            self.checked_weaves[weave_id] = True
234
222
 
235
223
    def _check_revision_tree(self, rev_id):
236
224
        tree = self.repository.revision_tree(rev_id)
237
 
        self.revision_versions.add_revision_text_versions(tree)
238
225
        inv = tree.inventory
239
226
        seen_ids = {}
240
227
        for file_id in inv: