~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Robert Collins
  • Date: 2005-11-27 22:38:34 UTC
  • mfrom: (1185.33.36 bzr.dev)
  • Revision ID: robertc@robertcollins.net-20051127223834-d00ecca0d0b9384a
Merge from mpool, adjusting check to retain HTTP support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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:
 
59
            self.progress.update('retrieving inventory', 0, 0)
 
60
            # do not put in init, as it should be done with progess,
 
61
            # and inside the lock.
 
62
            self.inventory_weave = self.branch._get_inventory_weave()
58
63
            self.history = self.branch.revision_history()
59
64
            if not len(self.history):
60
65
                # nothing to see here
61
66
                return
62
 
            self.planned_revisions = self.branch.get_ancestry(self.history[-1])
63
 
            self.planned_revisions.remove(None)
 
67
            self.plan_revisions()
64
68
            revno = 0
65
 
    
66
 
            self.progress = bzrlib.ui.ui_factory.progress_bar()
67
69
            while revno < len(self.planned_revisions):
68
70
                rev_id = self.planned_revisions[revno]
69
71
                self.progress.update('checking revision', revno,
70
72
                                     len(self.planned_revisions))
71
73
                revno += 1
72
74
                self.check_one_rev(rev_id)
73
 
            self.progress.clear()
74
75
        finally:
 
76
            self.progress.clear()
75
77
            self.branch.unlock()
76
78
 
 
79
    def plan_revisions(self):
 
80
        if not self.branch.revision_store.listable():
 
81
            self.planned_revisions = self.branch.get_ancestry(self.history[-1])
 
82
            self.planned_revisions.remove(None)
 
83
            # FIXME progress bars should support this more nicely.
 
84
            self.progress.clear()
 
85
            print ("Checking reachable history -"
 
86
                   " for a complete check use a local branch.")
 
87
            return
 
88
        
 
89
        self.planned_revisions = set(self.branch.revision_store)
 
90
        inventoried = set(self.inventory_weave.names())
 
91
        awol = self.planned_revisions - inventoried
 
92
        if len(awol) > 0:
 
93
            raise BzrCheckError('Stored revisions missing from inventory'
 
94
                '{%s}' % ','.join([f for f in awol]))
 
95
        self.planned_revisions = list(self.planned_revisions)
 
96
 
77
97
    def report_results(self, verbose):
78
98
        note('checked branch %s format %d',
79
99
             self.branch.base, 
143
163
                    missing_links = self.missing_parent_links.get(parent, [])
144
164
                    missing_links.append(rev_id)
145
165
                    self.missing_parent_links[parent] = missing_links
146
 
                    # list based so slow, TODO have a planned_revisions list and set.
 
166
                    # list based so somewhat slow,
 
167
                    # TODO have a planned_revisions list and set.
147
168
                    if self.branch.has_revision(parent):
148
169
                        missing_ancestry = self.branch.get_ancestry(parent)
149
170
                        for missing in missing_ancestry: