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