~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

[merge] up-to-date against bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
from bzrlib.trace import mutter
35
35
from bzrlib.errors import BzrCheckError, NoSuchRevision
36
36
from bzrlib.inventory import ROOT_ID
37
 
from bzrlib.branch import gen_root_id
38
37
 
39
38
 
40
39
class Check(object):
42
41
 
43
42
    def __init__(self, branch):
44
43
        self.branch = branch
 
44
        self.inventory_weave = branch._get_inventory_weave()
45
45
        self.checked_text_cnt = 0
46
46
        self.checked_rev_cnt = 0
47
47
        self.ghosts = []
54
54
 
55
55
    def check(self):
56
56
        self.branch.lock_read()
 
57
        self.progress = bzrlib.ui.ui_factory.progress_bar()
57
58
        try:
58
59
            self.history = self.branch.revision_history()
59
60
            if not len(self.history):
60
61
                # nothing to see here
61
62
                return
62
 
            self.planned_revisions = self.branch.get_ancestry(self.history[-1])
63
 
            self.planned_revisions.remove(None)
64
 
            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]))
65
71
    
66
 
            self.progress = bzrlib.ui.ui_factory.progress_bar()
67
 
            while revno < len(self.planned_revisions):
68
 
                rev_id = self.planned_revisions[revno]
69
 
                self.progress.update('checking revision', revno,
 
72
            for revno, rev_id in enumerate(self.planned_revisions):
 
73
                self.progress.update('checking revision', revno+1,
70
74
                                     len(self.planned_revisions))
71
 
                revno += 1
72
75
                self.check_one_rev(rev_id)
 
76
        finally:
73
77
            self.progress.clear()
74
 
        finally:
75
78
            self.branch.unlock()
76
79
 
77
80
    def report_results(self, verbose):