[Pkg-bazaar-commits] ./bzr/unstable r125: - check progress indicator for file texts
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:51:12 UTC 2009
------------------------------------------------------------
revno: 125
committer: mbp at sourcefrog.net
timestamp: Tue 2005-03-29 10:32:52 +1000
message:
- check progress indicator for file texts
- avoid re-reading file texts that have already been checked
modified:
bzrlib/check.py
-------------- next part --------------
=== modified file 'bzrlib/check.py'
--- a/bzrlib/check.py 2005-03-29 00:23:20 +0000
+++ b/bzrlib/check.py 2005-03-29 00:32:52 +0000
@@ -47,6 +47,8 @@
history = branch.revision_history()
revno = 0
revcount = len(history)
+
+ checked_texts = {}
for rid in history:
revno += 1
@@ -65,51 +67,59 @@
## TODO: Check all the required fields are present on the revision.
inv = branch.get_inventory(rev.inventory_id)
- check_inventory(branch, inv, rid)
+ seen_ids = Set()
+ seen_names = Set()
+
+ p('revision %d/%d file ids' % (revno, revcount))
+ for file_id in inv:
+ if file_id in seen_ids:
+ bailout('duplicated file_id {%s} in inventory for revision {%s}'
+ % (file_id, revid))
+ seen_ids.add(file_id)
+
+ i = 0
+ len_inv = len(inv)
+ for file_id in inv:
+ i += 1
+ if (i % 100) == 0:
+ p('revision %d/%d file text %d/%d' % (revno, revcount, i, len_inv))
+
+ ie = inv[file_id]
+
+ if ie.parent_id != None:
+ if ie.parent_id not in seen_ids:
+ bailout('missing parent {%s} in inventory for revision {%s}'
+ % (ie.parent_id, revid))
+
+ if ie.kind == 'file':
+ if ie.text_id in checked_texts:
+ fp = checked_texts[ie.text_id]
+ else:
+ if not ie.text_id in branch.text_store:
+ bailout('text {%s} not in text_store' % ie.text_id)
+
+ tf = branch.text_store[ie.text_id]
+ fp = osutils.fingerprint_file(tf)
+ checked_texts[ie.text_id] = fp
+
+ if ie.text_size != fp['size']:
+ bailout('text {%s} wrong size' % ie.text_id)
+ if ie.text_sha1 != fp['sha1']:
+ bailout('text {%s} wrong sha1' % ie.text_id)
+ elif ie.kind == 'directory':
+ if ie.text_sha1 != None or ie.text_size != None or ie.text_id != None:
+ bailout('directory {%s} has text in revision {%s}'
+ % (file_id, revid))
+
+ p('revision %d/%d file paths' % (revno, revcount))
+ for path, ie in inv.iter_entries():
+ if path in seen_names:
+ bailout('duplicated path %r in inventory for revision {%s}' % (path, revid))
+ seen_names.add(path)
+
p('done')
if progress:
print
-
-def check_inventory(branch, inv, revid):
- seen_ids = Set()
- seen_names = Set()
-
- for file_id in inv:
- if file_id in seen_ids:
- bailout('duplicated file_id {%s} in inventory for revision {%s}'
- % (file_id, revid))
- seen_ids.add(file_id)
-
-
- for file_id in inv:
- ie = inv[file_id]
-
- if ie.parent_id != None:
- if ie.parent_id not in seen_ids:
- bailout('missing parent {%s} in inventory for revision {%s}'
- % (ie.parent_id, revid))
-
- if ie.kind == 'file':
- if not ie.text_id in branch.text_store:
- bailout('text {%s} not in text_store' % ie.text_id)
-
- tf = branch.text_store[ie.text_id]
- fp = osutils.fingerprint_file(tf)
- if ie.text_size != fp['size']:
- bailout('text {%s} wrong size' % ie.text_id)
- if ie.text_sha1 != fp['sha1']:
- bailout('text {%s} wrong sha1' % ie.text_id)
- elif ie.kind == 'directory':
- if ie.text_sha1 != None or ie.text_size != None or ie.text_id != None:
- bailout('directory {%s} has text in revision {%s}'
- % (file_id, revid))
-
-
- for path, ie in inv.iter_entries():
- if path in seen_names:
- bailout('duplicated path %r in inventory for revision {%s}' % (path, revid))
- seen_names.add(path)
-
More information about the Pkg-bazaar-commits
mailing list