32
34
pb = ProgressBar(show_spinner=True)
36
37
missing_inventory_sha_cnt = 0
38
missing_revision_sha_cnt = 0
38
40
history = branch.revision_history()
40
42
revcount = len(history)
44
# for all texts checked, text_id -> sha1
44
47
for rev_id in history:
47
50
mutter(' revision {%s}' % rev_id)
48
51
rev = branch.get_revision(rev_id)
49
52
if rev.revision_id != rev_id:
50
raise BzrCheckError('wrong internal revision id in revision {%s}' % rev_id)
51
if rev.precursor != last_ptr:
52
raise BzrCheckError('mismatched precursor in revision {%s}' % rev_id)
54
if rev_id in checked_revs:
55
raise BzrCheckError('repeated revision {%s}' % rev_id)
56
checked_revs[rev_id] = True
53
raise BzrCheckError('wrong internal revision id in revision {%s}'
56
# check the previous history entry is a parent of this entry
58
if last_rev_id is None:
59
raise BzrCheckError("revision {%s} has %d parents, but is the "
61
% (rev_id, len(rev.parents)))
62
for prr in rev.parents:
63
if prr.revision_id == last_rev_id:
66
raise BzrCheckError("previous revision {%s} not listed among "
68
% (last_rev_id, rev_id))
70
for prr in rev.parents:
71
if prr.revision_sha1 is None:
72
missing_revision_sha_cnt += 1
74
prid = prr.revision_id
75
actual_sha = branch.get_revision_sha1(prid)
76
if prr.revision_sha1 != actual_sha:
77
raise BzrCheckError("mismatched revision sha1 for "
78
"parent {%s} of {%s}: %s vs %s"
80
prr.revision_sha1, actual_sha))
82
raise BzrCheckError("revision {%s} has no parents listed but preceded "
84
% (rev_id, last_rev_id))
58
86
## TODO: Check all the required fields are present on the revision.
135
164
print 'checked %d revisions, %d file texts' % (revcount, len(checked_texts))
136
166
if missing_inventory_sha_cnt:
137
167
print '%d revisions are missing inventory_sha1' % missing_inventory_sha_cnt
169
if missing_revision_sha_cnt:
170
print '%d parent links are missing revision_sha1' % missing_revision_sha_cnt
172
if (missing_inventory_sha_cnt
173
or missing_revision_sha_cnt):
138
174
print ' (use "bzr upgrade" to fix them)'