~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/check.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-28 11:30:12 UTC
  • Revision ID: mbp@sourcefrog.net-20050328113012-dcde8d593e4236f7
check revisions are not duplicated in history

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# consistency checks
22
22
 
23
23
 
 
24
from sets import Set
 
25
 
24
26
import bzrlib
25
27
from trace import mutter
26
28
from errors import bailout
31
33
 
32
34
    mutter('checking revision history')
33
35
    last_ptr = None
 
36
    checked_revs = Set()
34
37
    for rid in branch.revision_history():
35
38
        mutter('    revision {%s}' % rid)
36
39
        rev = branch.get_revision(rid)
39
42
        if rev.precursor != last_ptr:
40
43
            bailout('mismatched precursor in revision {%s}' % rid)
41
44
        last_ptr = rid
 
45
        if rid in checked_revs:
 
46
            bailout('repeated revision {%s}' % rid)
 
47
        checked_revs.add(rid)
42
48
 
43
 
    #mutter("checking tree")
44
 
    #check_patches_exist()
45
 
    #check_patch_chaining()
46
 
    #check_patch_uniqueness()
47
49
    #check_inventory()
48
50
 
49
51
    mutter('branch %s is OK' % branch.base)
86
88
        
87
89
        if is_control_file(name):
88
90
            raise BzrError("control file %s present in inventory" % quotefn(name))
89
 
 
90
 
 
91
 
def check_patches_exist():
92
 
    """Check constraint of current version: all patches exist"""
93
 
    mutter("checking all patches are present...")
94
 
    for pid in revision_history():
95
 
        read_patch_header(pid)
96
 
 
97
 
 
98
 
def check_patch_chaining():
99
 
    """Check ancestry of patches and history file is consistent"""
100
 
    mutter("checking patch chaining...")
101
 
    prev = None
102
 
    for pid in revision_history():
103
 
        log_prev = read_patch_header(pid).precursor
104
 
        if log_prev != prev:
105
 
            bailout("inconsistent precursor links on " + pid)
106
 
        prev = pid
107
 
 
108
 
 
109
 
def check_patch_uniqueness():
110
 
    """Make sure no patch is listed twice in the history.
111
 
 
112
 
    This should be implied by having correct ancestry but I'll check it
113
 
    anyhow."""
114
 
    mutter("checking history for duplicates...")
115
 
    seen = Set()
116
 
    for pid in revision_history():
117
 
        if pid in seen:
118
 
            bailout("patch " + pid + " appears twice in history")
119
 
        seen.add(pid)
120
 
        
121