~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: mbp at sourcefrog
  • Date: 2005-04-08 05:39:46 UTC
  • Revision ID: mbp@sourcefrog.net-20050408053946-1cb3415e1f8f58493034a5cf
- import lovely urlgrabber library

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# consistency checks
22
22
 
23
23
import sys
 
24
from sets import Set
24
25
 
25
26
from trace import mutter
26
27
from errors import bailout
29
30
def check(branch, progress=True):
30
31
    out = sys.stdout
31
32
 
32
 
    # TODO: factor out
33
 
    if not (hasattr(out, 'isatty') and out.isatty()):
34
 
        progress=False
35
 
 
36
33
    if progress:
37
34
        def p(m):
38
35
            mutter('checking ' + m)
44
41
 
45
42
    p('history of %r' % branch.base)
46
43
    last_ptr = None
47
 
    checked_revs = {}
 
44
    checked_revs = Set()
48
45
    
49
46
    history = branch.revision_history()
50
47
    revno = 0
64
61
        last_ptr = rid
65
62
        if rid in checked_revs:
66
63
            bailout('repeated revision {%s}' % rid)
67
 
        checked_revs[rid] = True
 
64
        checked_revs.add(rid)
68
65
 
69
66
        ## TODO: Check all the required fields are present on the revision.
70
67
 
71
68
        inv = branch.get_inventory(rev.inventory_id)
72
 
        seen_ids = {}
73
 
        seen_names = {}
 
69
        seen_ids = Set()
 
70
        seen_names = Set()
74
71
 
75
72
        p('revision %d/%d file ids' % (revno, revcount))
76
73
        for file_id in inv:
77
74
            if file_id in seen_ids:
78
75
                bailout('duplicated file_id {%s} in inventory for revision {%s}'
79
76
                        % (file_id, rid))
80
 
            seen_ids[file_id] = True
 
77
            seen_ids.add(file_id)
81
78
 
82
79
        i = 0
83
80
        len_inv = len(inv)
117
114
        for path, ie in inv.iter_entries():
118
115
            if path in seen_names:
119
116
                bailout('duplicated path %r in inventory for revision {%s}' % (path, revid))
120
 
            seen_names[path] = True
 
117
            seen_names.add(path)
121
118
 
122
119
 
123
120
    p('done')
124
121
    if progress:
125
122
        print 
126
 
    print 'checked %d revisions, %d file texts' % (revcount, len(checked_texts))
 
123
 
127
124