[Pkg-bazaar-commits] ./bzr/unstable r121: - progress indicator while checking
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:44:13 UTC 2009
------------------------------------------------------------
revno: 121
committer: mbp at sourcefrog.net
timestamp: Tue 2005-03-29 10:03:28 +1000
message:
- progress indicator while checking
- check file ids are not duplicated in the inventory
modified:
bzrlib/check.py
-------------- next part --------------
=== modified file 'bzrlib/check.py'
--- a/bzrlib/check.py 2005-03-28 13:20:38 +0000
+++ b/bzrlib/check.py 2005-03-29 00:03:28 +0000
@@ -20,7 +20,7 @@
######################################################################
# consistency checks
-
+import sys
from sets import Set
import bzrlib
@@ -28,13 +28,29 @@
from errors import bailout
-def check(branch):
- mutter('checking tree %r' % branch.base)
-
- mutter('checking revision history')
+def check(branch, progress=True):
+ out = sys.stdout
+
+ if progress:
+ def p(m):
+ mutter('checking ' + m)
+ out.write('\rchecking: %-50.50s' % m)
+ out.flush()
+ else:
+ def p(m):
+ mutter('checking ' + m)
+
+ p('history of %r' % branch.base)
last_ptr = None
checked_revs = Set()
- for rid in branch.revision_history():
+
+ history = branch.revision_history()
+ revno = 0
+ revcount = len(history)
+
+ for rid in history:
+ revno += 1
+ p('revision %d/%d' % (revno, revcount))
mutter(' revision {%s}' % rid)
rev = branch.get_revision(rid)
if rev.revision_id != rid:
@@ -49,20 +65,28 @@
## TODO: Check all the required fields are present on the revision.
inv = branch.get_inventory(rev.inventory_id)
- check_inventory(branch, inv)
-
- mutter('branch %s is OK' % branch.base)
-
-
-
-def check_inventory(branch, inv):
+ check_inventory(branch, inv, rid)
+
+ p('done')
+ if progress:
+ print
+
+
+
+def check_inventory(branch, inv, revid):
seen_ids = Set()
seen_names = Set()
for path, ie in inv.iter_entries():
if path in seen_names:
- bailout('duplicated path %r in inventory' % path)
+ bailout('duplicated path %r in inventory for revision {%s}' % (path, revid))
seen_names.add(path)
+
+ if ie.file_id in seen_ids:
+ bailout('duplicated file_id {%s} in inventory for revision {%s}'
+ % (ie.file_id, revid))
+ seen_ids.add(ie.file_id)
+
if ie.kind == 'file':
if not ie.text_id in branch.text_store:
bailout('text {%s} not in text_store' % ie.text_id)
More information about the Pkg-bazaar-commits
mailing list