~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: Martin Pool
  • Date: 2005-05-30 03:14:07 UTC
  • Revision ID: mbp@sourcefrog.net-20050530031407-d37f43ff76a5e0d9
- tests for add --no-recurse

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