~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Robert Collins
  • Date: 2005-08-24 12:13:13 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050824121313-f604a90d56310911
merge up with mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
 
18
import bzrlib.ui
18
19
 
19
20
def _update_store_entry(obj, obj_id, branch, store_name, store):
20
21
    """This is just a meta-function, which handles both revision entries
73
74
    _update_store_entry(inv, inv_id, branch,
74
75
            'inventory-store', branch.inventory_store)
75
76
 
 
77
 
76
78
def check(branch):
77
79
    """Run consistency checks on a branch.
78
80
 
83
85
    from bzrlib.trace import mutter
84
86
    from bzrlib.errors import BzrCheckError
85
87
    from bzrlib.osutils import fingerprint_file
86
 
    from bzrlib.progress import ProgressBar
87
88
    from bzrlib.inventory import ROOT_ID
88
89
    from bzrlib.branch import gen_root_id
89
90
 
90
91
    branch.lock_read()
91
92
 
92
93
    try:
93
 
        pb = ProgressBar(show_spinner=True)
94
94
        last_rev_id = None
95
95
 
96
96
        missing_inventory_sha_cnt = 0
104
104
        # for all texts checked, text_id -> sha1
105
105
        checked_texts = {}
106
106
 
 
107
        progress = bzrlib.ui.ui_factory.progress_bar()
 
108
 
107
109
        for rev_id in history:
108
110
            revno += 1
109
 
            pb.update('checking revision', revno, revcount)
 
111
            progress.update('checking revision', revno, revcount)
110
112
            # mutter('    revision {%s}' % rev_id)
111
113
            rev = branch.get_revision(rev_id)
112
114
            if rev.revision_id != rev_id:
173
175
            for file_id in inv:
174
176
                i += 1
175
177
                if i & 31 == 0:
176
 
                    pb.tick()
 
178
                    progress.tick()
177
179
 
178
180
                ie = inv[file_id]
179
181
 
202
204
                        raise BzrCheckError('directory {%s} has text in revision {%s}'
203
205
                                % (file_id, rev_id))
204
206
 
205
 
            pb.tick()
 
207
            progress.tick()
206
208
            for path, ie in inv.iter_entries():
207
209
                if path in seen_names:
208
210
                    raise BzrCheckError('duplicated path %s '
214
216
    finally:
215
217
        branch.unlock()
216
218
 
217
 
    pb.clear()
 
219
    progress.clear()
218
220
 
219
221
    print 'checked %d revisions, %d file texts' % (revcount, len(checked_texts))
220
222