44
from bzrlib.graph import DictParentsProvider, Graph, StackedParentsProvider
43
from bzrlib.graph import DictParentsProvider, Graph, _StackedParentsProvider
45
44
from bzrlib.transport.memory import MemoryTransport
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
54
53
adapter_registry = Registry()
176
175
self.parents = None
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.'
185
178
class AdapterFactory(ContentFactory):
186
179
"""A content factory to adapt between key prefix's."""
837
830
raise NotImplementedError(self.add_lines)
839
def _add_text(self, key, parents, text, nostore_sha=None, random_id=False):
840
"""Add a text to the store.
842
This is a private function for use by CommitBuilder.
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
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.
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,
869
832
def add_mpdiffs(self, records):
870
833
"""Add mpdiffs to this VersionedFile.
913
876
raise NotImplementedError(self.annotate)
915
878
def check(self, progress_bar=None):
916
"""Check this object for integrity.
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
879
"""Check this object for integrity."""
926
880
raise NotImplementedError(self.check)
1138
1092
result.append((prefix + (origin,), line))
1141
def get_annotator(self):
1142
return annotate.Annotator(self)
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():
1151
if keys is not None:
1152
return self.get_record_stream(keys, 'unordered', True)
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
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,)