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
######################################################################
25
from trace import mutter
26
from errors import bailout
30
mutter('checking tree %r' % branch.base)
32
mutter('checking revision history')
34
for rid in branch.revision_history():
35
mutter(' revision {%s}' % rid)
36
rev = branch.get_revision(rid)
37
if rev.revision_id != rid:
38
bailout('wrong internal revision id in revision {%s}' % rid)
39
if rev.precursor != last_ptr:
40
bailout('mismatched precursor in revision {%s}' % rid)
43
#mutter("checking tree")
44
#check_patches_exist()
45
#check_patch_chaining()
46
#check_patch_uniqueness()
49
mutter('branch %s is OK' % branch.base)
51
## TODO: Check that previous-inventory and previous-manifest
52
## are the same as those stored in the previous changeset.
54
## TODO: Check all patches present in patch directory are
55
## mentioned in patch history; having an orphaned patch only gives
58
## TODO: Check cached data is consistent with data reconstructed
61
## TODO: Check no control files are versioned.
63
## TODO: Check that the before-hash of each file in a later
64
## revision matches the after-hash in the previous revision to
68
def check_inventory():
69
mutter("checking inventory file and ids...")
73
for l in controlfile('inventory').readlines():
76
bailout("malformed inventory line: " + `l`)
79
if file_id in seen_ids:
80
bailout("duplicated file id " + file_id)
83
if name in seen_names:
84
bailout("duplicated file name in inventory: " + quotefn(name))
87
if is_control_file(name):
88
raise BzrError("control file %s present in inventory" % quotefn(name))
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)
98
def check_patch_chaining():
99
"""Check ancestry of patches and history file is consistent"""
100
mutter("checking patch chaining...")
102
for pid in revision_history():
103
log_prev = read_patch_header(pid).precursor
105
bailout("inconsistent precursor links on " + pid)
109
def check_patch_uniqueness():
110
"""Make sure no patch is listed twice in the history.
112
This should be implied by having correct ancestry but I'll check it
114
mutter("checking history for duplicates...")
116
for pid in revision_history():
118
bailout("patch " + pid + " appears twice in history")