~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Martin Pool
  • Date: 2005-09-22 06:28:55 UTC
  • Revision ID: mbp@sourcefrog.net-20050922062855-a29aa53982b752d6
- try to avoid checking texts repeatedly

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
        self.checked_text_cnt = 0
49
49
        self.checked_rev_cnt = 0
 
50
        self.repeated_text_cnt = 0
50
51
        self.missing_inventory_sha_cnt = 0
51
52
        self.missing_revision_cnt = 0
 
53
        # maps (file-id, version) -> sha1
 
54
        self.checked_texts = {}
52
55
 
53
56
        history = branch.revision_history()
54
57
        revno = 0
70
73
             self.branch.base, 
71
74
             self.branch._branch_format)
72
75
 
73
 
        note('checked %d revisions, %d file texts',
74
 
             self.checked_rev_cnt,
75
 
             self.checked_text_cnt)
76
 
 
 
76
        note('%6d revisions', self.checked_rev_cnt)
 
77
        note('%6d unique file texts', self.checked_text_cnt)
 
78
        note('%6d repeated file texts', self.repeated_text_cnt)
77
79
        if self.missing_inventory_sha_cnt:
78
80
            note('%d revisions are missing inventory_sha1',
79
81
                 self.missing_inventory_sha_cnt)
80
 
 
81
82
        if self.missing_revision_cnt:
82
83
            note('%d revisions are mentioned but not present',
83
84
                 self.missing_revision_cnt)
155
156
                raise BzrCheckError('missing parent {%s} in inventory for revision {%s}'
156
157
                        % (ie.parent_id, rev_id))
157
158
        if ie.kind == 'file':
 
159
            text_version = ie.text_version
 
160
            t = (file_id, text_version)
 
161
            if t in self.checked_texts:
 
162
                prev_sha = self.checked_texts[t] 
 
163
                if prev_sha != ie.text_sha1:
 
164
                    raise BzrCheckError('mismatched sha1 on {%s} in {%s}' %
 
165
                                        (file_id, rev_id))
 
166
                else:
 
167
                    self.repeated_text_cnt += 1
158
168
            text = tree.get_file_text(file_id)
159
169
            self.checked_text_cnt += 1 
160
170
            if ie.text_size != len(text):
161
171
                raise BzrCheckError('text {%s} wrong size' % ie.text_id)
162
172
            if ie.text_sha1 != sha_string(text):
163
173
                raise BzrCheckError('text {%s} wrong sha1' % ie.text_id)
 
174
            self.checked_texts[t] = ie.text_sha1
164
175
        elif ie.kind == 'directory':
165
176
            if ie.text_sha1 != None or ie.text_size != None or ie.text_id != None:
166
177
                raise BzrCheckError('directory {%s} has text in revision {%s}'