~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-05 15:31:34 UTC
  • mto: (4343.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4344.
  • Revision ID: v.ladeuil+lp@free.fr-20090505153134-q4bp4is9gywsmzrv
Clean up test for log formats.

* bzrlib/tests/blackbox/test_logformats.py:
Update tests to actual style.

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
34
    groupcompress,
36
35
    index,
41
40
    revision,
42
41
    ui,
43
42
    )
44
 
from bzrlib.graph import DictParentsProvider, Graph, StackedParentsProvider
 
43
from bzrlib.graph import DictParentsProvider, Graph, _StackedParentsProvider
45
44
from bzrlib.transport.memory import MemoryTransport
46
45
""")
47
46
from bzrlib.inter import InterObject
48
47
from bzrlib.registry import Registry
49
48
from bzrlib.symbol_versioning import *
50
49
from bzrlib.textmerge import TextMerge
51
 
from bzrlib import bencode
 
50
from bzrlib.util import bencode
52
51
 
53
52
 
54
53
adapter_registry = Registry()
175
174
        self.key = key
176
175
        self.parents = None
177
176
 
178
 
    def get_bytes_as(self, storage_kind):
179
 
        raise ValueError('A request was made for key: %s, but that'
180
 
                         ' content is not available, and the calling'
181
 
                         ' code does not handle if it is missing.'
182
 
                         % (self.key,))
183
 
 
184
177
 
185
178
class AdapterFactory(ContentFactory):
186
179
    """A content factory to adapt between key prefix's."""
836
829
        """
837
830
        raise NotImplementedError(self.add_lines)
838
831
 
839
 
    def _add_text(self, key, parents, text, nostore_sha=None, random_id=False):
840
 
        """Add a text to the store.
841
 
 
842
 
        This is a private function for use by CommitBuilder.
843
 
 
844
 
        :param key: The key tuple of the text to add. If the last element is
845
 
            None, a CHK string will be generated during the addition.
846
 
        :param parents: The parents key tuples of the text to add.
847
 
        :param text: A string containing the text to be committed.
848
 
        :param nostore_sha: Raise ExistingContent and do not add the lines to
849
 
            the versioned file if the digest of the lines matches this.
850
 
        :param random_id: If True a random id has been selected rather than
851
 
            an id determined by some deterministic process such as a converter
852
 
            from a foreign VCS. When True the backend may choose not to check
853
 
            for uniqueness of the resulting key within the versioned file, so
854
 
            this should only be done when the result is expected to be unique
855
 
            anyway.
856
 
        :param check_content: If True, the lines supplied are verified to be
857
 
            bytestrings that are correctly formed lines.
858
 
        :return: The text sha1, the number of bytes in the text, and an opaque
859
 
                 representation of the inserted version which can be provided
860
 
                 back to future _add_text calls in the parent_texts dictionary.
861
 
        """
862
 
        # The default implementation just thunks over to .add_lines(),
863
 
        # inefficient, but it works.
864
 
        return self.add_lines(key, parents, osutils.split_lines(text),
865
 
                              nostore_sha=nostore_sha,
866
 
                              random_id=random_id,
867
 
                              check_content=True)
868
 
 
869
832
    def add_mpdiffs(self, records):
870
833
        """Add mpdiffs to this VersionedFile.
871
834
 
913
876
        raise NotImplementedError(self.annotate)
914
877
 
915
878
    def check(self, progress_bar=None):
916
 
        """Check this object for integrity.
917
 
        
918
 
        :param progress_bar: A progress bar to output as the check progresses.
919
 
        :param keys: Specific keys within the VersionedFiles to check. When
920
 
            this parameter is not None, check() becomes a generator as per
921
 
            get_record_stream. The difference to get_record_stream is that
922
 
            more or deeper checks will be performed.
923
 
        :return: None, or if keys was supplied a generator as per
924
 
            get_record_stream.
925
 
        """
 
879
        """Check this object for integrity."""
926
880
        raise NotImplementedError(self.check)
927
881
 
928
882
    @staticmethod
1138
1092
            result.append((prefix + (origin,), line))
1139
1093
        return result
1140
1094
 
1141
 
    def get_annotator(self):
1142
 
        return annotate.Annotator(self)
1143
 
 
1144
 
    def check(self, progress_bar=None, keys=None):
 
1095
    def check(self, progress_bar=None):
1145
1096
        """See VersionedFiles.check()."""
1146
 
        # XXX: This is over-enthusiastic but as we only thunk for Weaves today
1147
 
        # this is tolerable. Ideally we'd pass keys down to check() and 
1148
 
        # have the older VersiondFile interface updated too.
1149
1097
        for prefix, vf in self._iter_all_components():
1150
1098
            vf.check()
1151
 
        if keys is not None:
1152
 
            return self.get_record_stream(keys, 'unordered', True)
1153
1099
 
1154
1100
    def get_parent_map(self, keys):
1155
1101
        """Get a map of the parents of keys.
1387
1333
            result[revision.NULL_REVISION] = ()
1388
1334
        self._providers = self._providers[:1] + self.fallback_versionedfiles
1389
1335
        result.update(
1390
 
            StackedParentsProvider(self._providers).get_parent_map(keys))
 
1336
            _StackedParentsProvider(self._providers).get_parent_map(keys))
1391
1337
        for key, parents in result.iteritems():
1392
1338
            if parents == ():
1393
1339
                result[key] = (revision.NULL_REVISION,)