~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Matt Nordhoff
  • Date: 2009-06-23 05:12:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4474.
  • Revision ID: mnordhoff@mattnordhoff.com-20090623051207-fksdtbzkwtnrw9dd
Update _add_text docstrings that still referred to add_text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import urllib
31
31
 
32
32
from bzrlib import (
33
 
    annotate,
34
33
    errors,
35
 
    graph as _mod_graph,
36
34
    groupcompress,
37
35
    index,
38
36
    knit,
42
40
    revision,
43
41
    ui,
44
42
    )
45
 
from bzrlib.graph import DictParentsProvider, Graph, StackedParentsProvider
 
43
from bzrlib.graph import DictParentsProvider, Graph, _StackedParentsProvider
46
44
from bzrlib.transport.memory import MemoryTransport
47
45
""")
48
46
from bzrlib.inter import InterObject
49
47
from bzrlib.registry import Registry
50
48
from bzrlib.symbol_versioning import *
51
49
from bzrlib.textmerge import TextMerge
52
 
from bzrlib import bencode
 
50
from bzrlib.util import bencode
53
51
 
54
52
 
55
53
adapter_registry = Registry()
176
174
        self.key = key
177
175
        self.parents = None
178
176
 
179
 
    def get_bytes_as(self, storage_kind):
180
 
        raise ValueError('A request was made for key: %s, but that'
181
 
                         ' content is not available, and the calling'
182
 
                         ' code does not handle if it is missing.'
183
 
                         % (self.key,))
184
 
 
185
177
 
186
178
class AdapterFactory(ContentFactory):
187
179
    """A content factory to adapt between key prefix's."""
914
906
        raise NotImplementedError(self.annotate)
915
907
 
916
908
    def check(self, progress_bar=None):
917
 
        """Check this object for integrity.
918
 
        
919
 
        :param progress_bar: A progress bar to output as the check progresses.
920
 
        :param keys: Specific keys within the VersionedFiles to check. When
921
 
            this parameter is not None, check() becomes a generator as per
922
 
            get_record_stream. The difference to get_record_stream is that
923
 
            more or deeper checks will be performed.
924
 
        :return: None, or if keys was supplied a generator as per
925
 
            get_record_stream.
926
 
        """
 
909
        """Check this object for integrity."""
927
910
        raise NotImplementedError(self.check)
928
911
 
929
912
    @staticmethod
942
925
            if '\n' in line[:-1]:
943
926
                raise errors.BzrBadParameterContainsNewline("lines")
944
927
 
945
 
    def get_known_graph_ancestry(self, keys):
946
 
        """Get a KnownGraph instance with the ancestry of keys."""
947
 
        # most basic implementation is a loop around get_parent_map
948
 
        pending = set(keys)
949
 
        parent_map = {}
950
 
        while pending:
951
 
            this_parent_map = self.get_parent_map(pending)
952
 
            parent_map.update(this_parent_map)
953
 
            pending = set()
954
 
            map(pending.update, this_parent_map.itervalues())
955
 
            pending = pending.difference(parent_map)
956
 
        kg = _mod_graph.KnownGraph(parent_map)
957
 
        return kg
958
 
 
959
928
    def get_parent_map(self, keys):
960
929
        """Get a map of the parents of keys.
961
930
 
1153
1122
            result.append((prefix + (origin,), line))
1154
1123
        return result
1155
1124
 
1156
 
    def get_annotator(self):
1157
 
        return annotate.Annotator(self)
1158
 
 
1159
 
    def check(self, progress_bar=None, keys=None):
 
1125
    def check(self, progress_bar=None):
1160
1126
        """See VersionedFiles.check()."""
1161
 
        # XXX: This is over-enthusiastic but as we only thunk for Weaves today
1162
 
        # this is tolerable. Ideally we'd pass keys down to check() and 
1163
 
        # have the older VersiondFile interface updated too.
1164
1127
        for prefix, vf in self._iter_all_components():
1165
1128
            vf.check()
1166
 
        if keys is not None:
1167
 
            return self.get_record_stream(keys, 'unordered', True)
1168
1129
 
1169
1130
    def get_parent_map(self, keys):
1170
1131
        """Get a map of the parents of keys.
1402
1363
            result[revision.NULL_REVISION] = ()
1403
1364
        self._providers = self._providers[:1] + self.fallback_versionedfiles
1404
1365
        result.update(
1405
 
            StackedParentsProvider(self._providers).get_parent_map(keys))
 
1366
            _StackedParentsProvider(self._providers).get_parent_map(keys))
1406
1367
        for key, parents in result.iteritems():
1407
1368
            if parents == ():
1408
1369
                result[key] = (revision.NULL_REVISION,)
1586
1547
            record.get_bytes_as(record.storage_kind) call.
1587
1548
        """
1588
1549
        self._bytes_iterator = bytes_iterator
1589
 
        self._kind_factory = {
1590
 
            'fulltext': fulltext_network_to_record,
1591
 
            'groupcompress-block': groupcompress.network_block_to_records,
1592
 
            'knit-ft-gz': knit.knit_network_to_record,
1593
 
            'knit-delta-gz': knit.knit_network_to_record,
1594
 
            'knit-annotated-ft-gz': knit.knit_network_to_record,
1595
 
            'knit-annotated-delta-gz': knit.knit_network_to_record,
1596
 
            'knit-delta-closure': knit.knit_delta_closure_to_records,
 
1550
        self._kind_factory = {'knit-ft-gz':knit.knit_network_to_record,
 
1551
            'knit-delta-gz':knit.knit_network_to_record,
 
1552
            'knit-annotated-ft-gz':knit.knit_network_to_record,
 
1553
            'knit-annotated-delta-gz':knit.knit_network_to_record,
 
1554
            'knit-delta-closure':knit.knit_delta_closure_to_records,
 
1555
            'fulltext':fulltext_network_to_record,
 
1556
            'groupcompress-block':groupcompress.network_block_to_records,
1597
1557
            }
1598
1558
 
1599
1559
    def read(self):