/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Andrew Bennetts
  • Date: 2010-08-12 04:19:07 UTC
  • mto: This revision was merged to the branch mainline in revision 5377.
  • Revision ID: andrew.bennetts@canonical.com-20100812041907-lgauj5jm4voyjxbm
Don't traceback if a repository doesn't support reconcile_canonicalize_chks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1085
1085
                parent_lines, left_parent_blocks))
1086
1086
        return diffs
1087
1087
 
 
1088
    def get_annotator(self):
 
1089
        return annotate.Annotator(self)
 
1090
 
1088
1091
    missing_keys = index._missing_keys_from_parent_map
1089
1092
 
1090
1093
    def _extract_blocks(self, version_id, source, target):
1159
1162
            result.append((prefix + (origin,), line))
1160
1163
        return result
1161
1164
 
1162
 
    def get_annotator(self):
1163
 
        return annotate.Annotator(self)
1164
 
 
1165
1165
    def check(self, progress_bar=None, keys=None):
1166
1166
        """See VersionedFiles.check()."""
1167
1167
        # XXX: This is over-enthusiastic but as we only thunk for Weaves today
1624
1624
                yield (l, key)
1625
1625
 
1626
1626
 
 
1627
class NoDupeAddLinesDecorator(object):
 
1628
    """Decorator for a VersionedFiles that skips doing an add_lines if the key
 
1629
    is already present.
 
1630
    """
 
1631
 
 
1632
    def __init__(self, store):
 
1633
        self._store = store
 
1634
 
 
1635
    def add_lines(self, key, parents, lines, parent_texts=None,
 
1636
            left_matching_blocks=None, nostore_sha=None, random_id=False,
 
1637
            check_content=True):
 
1638
        """See VersionedFiles.add_lines.
 
1639
        
 
1640
        This implementation may return None as the third element of the return
 
1641
        value when the original store wouldn't.
 
1642
        """
 
1643
        if nostore_sha:
 
1644
            raise NotImplementedError(
 
1645
                "NoDupeAddLinesDecorator.add_lines does not implement the "
 
1646
                "nostore_sha behaviour.")
 
1647
        if key[-1] is None:
 
1648
            sha1 = osutils.sha_strings(lines)
 
1649
            key = ("sha1:" + sha1,)
 
1650
        else:
 
1651
            sha1 = None
 
1652
        if key in self._store.get_parent_map([key]):
 
1653
            # This key has already been inserted, so don't do it again.
 
1654
            if sha1 is None:
 
1655
                sha1 = osutils.sha_strings(lines)
 
1656
            return sha1, sum(map(len, lines)), None
 
1657
        return self._store.add_lines(key, parents, lines,
 
1658
                parent_texts=parent_texts,
 
1659
                left_matching_blocks=left_matching_blocks,
 
1660
                nostore_sha=nostore_sha, random_id=random_id,
 
1661
                check_content=check_content)
 
1662
 
 
1663
    def __getattr__(self, name):
 
1664
        return getattr(self._store, name)
 
1665
 
 
1666
 
1627
1667
def network_bytes_to_kind_and_offset(network_bytes):
1628
1668
    """Strip of a record kind from the front of network_bytes.
1629
1669