~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

Merge in bzrdir work to enable checkout improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
    def __init__(self, branch):
43
43
        self.branch = branch
 
44
        self.repository = branch.repository
44
45
        self.checked_text_cnt = 0
45
46
        self.checked_rev_cnt = 0
46
47
        self.ghosts = []
59
60
            self.progress.update('retrieving inventory', 0, 0)
60
61
            # do not put in init, as it should be done with progess,
61
62
            # and inside the lock.
62
 
            self.inventory_weave = self.branch._get_inventory_weave()
 
63
            self.inventory_weave = self.branch.repository.get_inventory_weave()
63
64
            self.history = self.branch.revision_history()
64
65
            if not len(self.history):
65
66
                # nothing to see here
78
79
            self.branch.unlock()
79
80
 
80
81
    def plan_revisions(self):
81
 
        if not self.branch.revision_store.listable():
82
 
            self.planned_revisions = self.branch.get_ancestry(self.history[-1])
 
82
        repository = self.branch.repository
 
83
        if not repository.revision_store.listable():
 
84
            self.planned_revisions = repository.get_ancestry(self.history[-1])
83
85
            self.planned_revisions.remove(None)
84
86
            # FIXME progress bars should support this more nicely.
85
87
            self.progress.clear()
87
89
                   " for a complete check use a local branch.")
88
90
            return
89
91
        
90
 
        self.planned_revisions = set(self.branch.revision_store)
 
92
        self.planned_revisions = set(repository.revision_store)
91
93
        inventoried = set(self.inventory_weave.names())
92
94
        awol = self.planned_revisions - inventoried
93
95
        if len(awol) > 0:
96
98
        self.planned_revisions = list(self.planned_revisions)
97
99
 
98
100
    def report_results(self, verbose):
99
 
        note('checked branch %s format %d',
 
101
        note('checked branch %s format %s',
100
102
             self.branch.base, 
101
 
             self.branch._branch_format)
 
103
             self.branch._format)
102
104
 
103
105
        note('%6d revisions', self.checked_rev_cnt)
104
106
        note('%6d unique file texts', self.checked_text_cnt)
140
142
            rev_history_position = None
141
143
        last_rev_id = None
142
144
        if rev_history_position:
143
 
            rev = branch.get_revision(rev_id)
 
145
            rev = branch.repository.get_revision(rev_id)
144
146
            if rev_history_position > 0:
145
147
                last_rev_id = self.history[rev_history_position - 1]
146
148
        else:
147
 
            rev = branch.get_revision(rev_id)
 
149
            rev = branch.repository.get_revision(rev_id)
148
150
                
149
151
        if rev.revision_id != rev_id:
150
152
            raise BzrCheckError('wrong internal revision id in revision {%s}'
168
170
                    # list based so somewhat slow,
169
171
                    # TODO have a planned_revisions list and set.
170
172
                    if self.branch.has_revision(parent):
171
 
                        missing_ancestry = self.branch.get_ancestry(parent)
 
173
                        missing_ancestry = self.repository.get_ancestry(parent)
172
174
                        for missing in missing_ancestry:
173
175
                            if (missing is not None 
174
176
                                and missing not in self.planned_revisions):
181
183
                                % (rev_id, last_rev_id))
182
184
 
183
185
        if rev.inventory_sha1:
184
 
            inv_sha1 = branch.get_inventory_sha1(rev_id)
 
186
            inv_sha1 = branch.repository.get_inventory_sha1(rev_id)
185
187
            if inv_sha1 != rev.inventory_sha1:
186
188
                raise BzrCheckError('Inventory sha1 hash doesn\'t match'
187
189
                    ' value in revision {%s}' % rev_id)
196
198
        """
197
199
        n_weaves = 1
198
200
        weave_ids = []
199
 
        if self.branch.weave_store.listable():
200
 
            weave_ids = list(self.branch.weave_store)
 
201
        if self.branch.repository.weave_store.listable():
 
202
            weave_ids = list(self.branch.repository.weave_store)
201
203
            n_weaves = len(weave_ids)
202
204
        self.progress.update('checking weave', 0, n_weaves)
203
205
        self.inventory_weave.check(progress_bar=self.progress)
204
206
        for i, weave_id in enumerate(weave_ids):
205
207
            self.progress.update('checking weave', i, n_weaves)
206
 
            w = self.branch.weave_store.get_weave(weave_id,
207
 
                    self.branch.get_transaction())
 
208
            w = self.branch.repository.weave_store.get_weave(weave_id,
 
209
                    self.branch.repository.get_transaction())
208
210
            # No progress here, because it looks ugly.
209
211
            w.check()
210
212
            self.checked_weaves[weave_id] = True
211
213
 
212
214
    def _check_revision_tree(self, rev_id):
213
 
        tree = self.branch.revision_tree(rev_id)
 
215
        tree = self.branch.repository.revision_tree(rev_id)
214
216
        inv = tree.inventory
215
217
        seen_ids = {}
216
218
        for file_id in inv: