149
149
if self._partial_revision_history_cache[-1] == _mod_revision.NULL_REVISION:
150
150
self._partial_revision_history_cache.pop()
152
def _get_check_refs(self):
153
"""Get the references needed for check().
157
revid = self.last_revision()
158
return [('revision-existence', revid), ('lefthand-distance', revid)]
153
161
def open(base, _unsupported=False, possible_transports=None):
154
162
"""Open the branch rooted at base.
1222
1230
Callers will typically also want to check the repository.
1232
:param refs: Calculated refs for this branch as specified by
1233
branch._get_check_refs()
1224
1234
:return: A BranchCheckResult.
1226
ret = BranchCheckResult(self)
1227
mainline_parent_id = None
1236
result = BranchCheckResult(self)
1228
1237
last_revno, last_revision_id = self.last_revision_info()
1229
real_rev_history = []
1231
for revid in self.repository.iter_reverse_revision_history(
1233
real_rev_history.append(revid)
1234
except errors.RevisionNotPresent:
1235
ret.ghosts_in_mainline = True
1237
ret.ghosts_in_mainline = False
1238
real_rev_history.reverse()
1239
if len(real_rev_history) != last_revno:
1240
raise errors.BzrCheckError('revno does not match len(mainline)'
1241
' %s != %s' % (last_revno, len(real_rev_history)))
1242
# TODO: We should probably also check that real_rev_history actually
1243
# matches self.revision_history()
1244
for revision_id in real_rev_history:
1246
revision = self.repository.get_revision(revision_id)
1247
except errors.NoSuchRevision, e:
1248
raise errors.BzrCheckError("mainline revision {%s} not in repository"
1250
# In general the first entry on the revision history has no parents.
1251
# But it's not illegal for it to have parents listed; this can happen
1252
# in imports from Arch when the parents weren't reachable.
1253
if mainline_parent_id is not None:
1254
if mainline_parent_id not in revision.parent_ids:
1255
raise errors.BzrCheckError("previous revision {%s} not listed among "
1257
% (mainline_parent_id, revision_id))
1258
mainline_parent_id = revision_id
1238
actual_revno = refs[('lefthand-distance', last_revision_id)]
1239
if actual_revno != last_revno:
1240
result.errors.append(errors.BzrCheckError(
1241
'revno does not match len(mainline) %s != %s' % (
1242
last_revno, actual_revno)))
1243
# TODO: We should probably also check that self.revision_history
1244
# matches the repository for older branch formats.
1245
# If looking for the code that cross-checks repository parents against
1246
# the iter_reverse_revision_history output, that is now a repository
1261
1250
def _get_checkout_format(self):
1262
1251
"""Return the most suitable metadir for a checkout of this branch.
2847
2836
:param verbose: Requests more detailed display of what was checked,
2850
note('checked branch %s format %s',
2852
self.branch._format)
2853
if self.ghosts_in_mainline:
2854
note('branch contains ghosts in mainline')
2839
note('checked branch %s format %s', self.branch.base,
2840
self.branch._format)
2841
for error in self.errors:
2842
note('found error:%s', error)
2857
2845
class Converter5to6(object):