31
31
from bzrlib.inter import InterObject
32
32
from bzrlib.symbol_versioning import *
33
from bzrlib.transport.memory import MemoryTransport
34
from bzrlib.tsort import topo_sort
35
37
class VersionedFile(object):
85
87
already present in file history."""
86
88
raise NotImplementedError(self.clone_text)
90
def create_empty(self, name, transport, mode=None):
91
"""Create a new versioned file of this exact type.
93
:param name: the file name
94
:param transport: the transport
95
:param mode: optional file mode.
97
raise NotImplementedError(self.create_empty)
88
99
def get_text(self, version_id):
89
100
"""Return version contents as a text string.
112
123
version_ids = [version_ids]
113
124
raise NotImplementedError(self.get_ancestry)
115
def get_graph(self, version_id):
118
Must raise RevisionNotPresent if version is not present in
120
raise NotImplementedError(self.get_graph)
127
"""Return a graph for the entire versioned file."""
129
for version in self.versions():
130
result[version] = self.get_parents(version)
122
133
@deprecated_method(zero_eight)
123
134
def parent_names(self, version):
156
167
Must raise RevisionNotPresent if any of the specified versions
157
168
are not present in the other files history."""
158
raise NotImplementedError(self.join)
169
return InterVersionedFile.get(other, self).join(pb, msg, version_ids)
160
171
def walk(self, version_ids=None):
161
172
"""Walk the versioned file as a weave-like structure, for
289
300
_optimisers = set()
290
301
"""The available optimised InterVersionedFile types."""
303
def join(self, pb=None, msg=None, version_ids=None):
304
"""Integrate versions from self.source into self.target.
306
If version_ids is None all versions from source should be
307
incorporated into this versioned file.
309
Must raise RevisionNotPresent if any of the specified versions
310
are not present in the other files history.
313
# - make a temporary versioned file of type target
314
# - insert the source content into it one at a time
316
# Make a new target-format versioned file.
317
temp_source = self.target.create_empty("temp", MemoryTransport())
318
graph = self.source.get_graph()
319
order = topo_sort(graph.items())
320
for version in order:
321
temp_source.add_lines(version,
322
self.source.get_parents(version),
323
self.source.get_lines(version))
325
# this should hit the native code path for target
326
return self.target.join(temp_source, pb, msg, version_ids)
293
329
class InterVersionedFileTestProviderAdapter(object):
294
330
"""A tool to generate a suite testing multiple inter versioned-file classes.