262
262
def versionable_kind(kind):
263
263
return (kind in ('file', 'directory', 'symlink', 'tree-reference'))
265
def check(self, checker, rev_id, inv, tree):
265
def check(self, checker, rev_id, inv):
266
266
"""Check this inventory entry is intact.
268
268
This is a template method, override _check for kind specific
274
274
:param rev_id: Revision id from which this InventoryEntry was loaded.
275
275
Not necessarily the last-changed revision for this file.
276
276
:param inv: Inventory from which the entry was loaded.
277
:param tree: RevisionTree for this entry.
279
278
if self.parent_id is not None:
280
279
if not inv.has_id(self.parent_id):
281
280
raise BzrCheckError('missing parent {%s} in inventory for revision {%s}'
282
281
% (self.parent_id, rev_id))
283
self._check(checker, rev_id, tree)
282
checker._add_entry_to_text_key_references(inv, self)
283
self._check(checker, rev_id)
285
def _check(self, checker, rev_id, tree):
285
def _check(self, checker, rev_id):
286
286
"""Check this inventory entry for kind specific errors."""
287
raise BzrCheckError('unknown entry kind %r in revision {%s}' %
287
checker._report_items.append(
288
'unknown entry kind %r in revision {%s}' % (self.kind, rev_id))
291
291
"""Clone this inventory entry."""
404
404
'text_id', 'parent_id', 'children', 'executable',
405
405
'revision', 'symlink_target', 'reference_revision']
407
def _check(self, checker, rev_id, tree):
407
def _check(self, checker, rev_id):
408
408
"""See InventoryEntry._check"""
410
410
def __init__(self, file_id):
433
433
'text_id', 'parent_id', 'children', 'executable',
434
434
'revision', 'symlink_target', 'reference_revision']
436
def _check(self, checker, rev_id, tree):
436
def _check(self, checker, rev_id):
437
437
"""See InventoryEntry._check"""
438
if self.text_sha1 is not None or self.text_size is not None or self.text_id is not None:
439
raise BzrCheckError('directory {%s} has text in revision {%s}'
438
if (self.text_sha1 is not None or self.text_size is not None or
439
self.text_id is not None):
440
checker._report_items.append('directory {%s} has text in revision {%s}'
440
441
% (self.file_id, rev_id))
442
# Directories are stored as ''.
443
checker.add_pending_item(rev_id,
444
('texts', self.file_id, self.revision), 'text',
445
'da39a3ee5e6b4b0d3255bfef95601890afd80709')
443
448
other = InventoryDirectory(self.file_id, self.name, self.parent_id)
476
481
'text_id', 'parent_id', 'children', 'executable',
477
482
'revision', 'symlink_target', 'reference_revision']
479
def _check(self, checker, tree_revision_id, tree):
484
def _check(self, checker, tree_revision_id):
480
485
"""See InventoryEntry._check"""
481
key = (self.file_id, self.revision)
482
if key in checker.checked_texts:
483
prev_sha = checker.checked_texts[key]
484
if prev_sha == self.text_sha1:
487
'mismatched sha1 on {%s} in {%s} (%s != %s) %r' %
488
(self.file_id, tree_revision_id, prev_sha, self.text_sha1,
491
# We can't check the length, because Weave doesn't store that
492
# information, and the whole point of looking at the weave's
493
# sha1sum is that we don't have to extract the text.
494
if (self.text_sha1 != tree._repository.texts.get_sha1s([key])[key]):
495
raise BzrCheckError('text {%s} version {%s} wrong sha1' % key)
496
checker.checked_texts[key] = self.text_sha1
486
# TODO: check size too.
487
checker.add_pending_item(tree_revision_id,
488
('texts', self.file_id, self.revision), 'text',
490
if self.text_size is None:
491
checker._report_items.append(
492
'fileid {%s} in {%s} has None for text_size' % (self.file_id,
499
496
other = InventoryFile(self.file_id, self.name, self.parent_id)
597
594
'text_id', 'parent_id', 'children', 'executable',
598
595
'revision', 'symlink_target', 'reference_revision']
600
def _check(self, checker, rev_id, tree):
597
def _check(self, checker, rev_id):
601
598
"""See InventoryEntry._check"""
602
599
if self.text_sha1 is not None or self.text_size is not None or self.text_id is not None:
603
raise BzrCheckError('symlink {%s} has text in revision {%s}'
600
checker._report_items.append(
601
'symlink {%s} has text in revision {%s}'
604
602
% (self.file_id, rev_id))
605
603
if self.symlink_target is None:
606
raise BzrCheckError('symlink {%s} has no target in revision {%s}'
604
checker._report_items.append(
605
'symlink {%s} has no target in revision {%s}'
607
606
% (self.file_id, rev_id))
607
# Symlinks are stored as ''
608
checker.add_pending_item(tree_revision_id,
609
('texts', self.file_id, self.revision), 'text',
610
'da39a3ee5e6b4b0d3255bfef95601890afd80709')
610
613
other = InventoryLink(self.file_id, self.name, self.parent_id)