~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

Merge from mpool.

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.inventory_weave = branch._get_inventory_weave()
44
45
        self.checked_text_cnt = 0
45
46
        self.checked_rev_cnt = 0
46
47
        self.ghosts = []
53
54
 
54
55
    def check(self):
55
56
        self.branch.lock_read()
 
57
        self.progress = bzrlib.ui.ui_factory.progress_bar()
56
58
        try:
57
59
            self.history = self.branch.revision_history()
58
60
            if not len(self.history):
59
61
                # nothing to see here
60
62
                return
61
 
            self.planned_revisions = self.branch.get_ancestry(self.history[-1])
62
 
            self.planned_revisions.remove(None)
63
 
            revno = 0
 
63
            if not self.branch.revision_store.listable():
 
64
                raise BzrCheckError("Branch must be local")
 
65
            self.planned_revisions = set(self.branch.revision_store)
 
66
            inventoried = set(self.inventory_weave.names())
 
67
            awol = self.planned_revisions - inventoried
 
68
            if len(awol) > 0:
 
69
                raise BzrCheckError('Stored revisions missing from inventory'
 
70
                    '{%s}' % ','.join([f for f in awol]))
64
71
    
65
 
            self.progress = bzrlib.ui.ui_factory.progress_bar()
66
 
            while revno < len(self.planned_revisions):
67
 
                rev_id = self.planned_revisions[revno]
68
 
                self.progress.update('checking revision', revno,
 
72
            for revno, rev_id in enumerate(self.planned_revisions):
 
73
                self.progress.update('checking revision', revno+1,
69
74
                                     len(self.planned_revisions))
70
 
                revno += 1
71
75
                self.check_one_rev(rev_id)
 
76
        finally:
72
77
            self.progress.clear()
73
 
        finally:
74
78
            self.branch.unlock()
75
79
 
76
80
    def report_results(self, verbose):