1
# Copyright (C) 2004, 2005 by Martin Pool
2
# Copyright (C) 2005 by Canonical Ltd
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
######################################################################
29
bzrlib.errors.bailout("check failed: %r != %r" % (a, b))
31
def check(branch, verbose=True):
32
print 'checking tree %r' % branch.base
34
print 'checking entire revision history is present'
36
for rid in branch.revision_history():
37
print ' revision {%s}' % rid
38
rev = branch.get_revision(rid)
39
_ass(rev.revision_id, rid)
40
_ass(rev.precursor, last_ptr)
43
#mutter("checking tree")
44
#check_patches_exist()
45
#check_patch_chaining()
46
#check_patch_uniqueness()
48
print ("tree looks OK")
49
## TODO: Check that previous-inventory and previous-manifest
50
## are the same as those stored in the previous changeset.
52
## TODO: Check all patches present in patch directory are
53
## mentioned in patch history; having an orphaned patch only gives
56
## TODO: Check cached data is consistent with data reconstructed
59
## TODO: Check no control files are versioned.
61
## TODO: Check that the before-hash of each file in a later
62
## revision matches the after-hash in the previous revision to
66
def check_inventory():
67
mutter("checking inventory file and ids...")
71
for l in controlfile('inventory').readlines():
74
bailout("malformed inventory line: " + `l`)
77
if file_id in seen_ids:
78
bailout("duplicated file id " + file_id)
81
if name in seen_names:
82
bailout("duplicated file name in inventory: " + quotefn(name))
85
if is_control_file(name):
86
raise BzrError("control file %s present in inventory" % quotefn(name))
89
def check_patches_exist():
90
"""Check constraint of current version: all patches exist"""
91
mutter("checking all patches are present...")
92
for pid in revision_history():
93
read_patch_header(pid)
96
def check_patch_chaining():
97
"""Check ancestry of patches and history file is consistent"""
98
mutter("checking patch chaining...")
100
for pid in revision_history():
101
log_prev = read_patch_header(pid).precursor
103
bailout("inconsistent precursor links on " + pid)
107
def check_patch_uniqueness():
108
"""Make sure no patch is listed twice in the history.
110
This should be implied by having correct ancestry but I'll check it
112
mutter("checking history for duplicates...")
114
for pid in revision_history():
116
bailout("patch " + pid + " appears twice in history")