69
65
"""Copy this versioned file to name on transport."""
70
66
raise NotImplementedError(self.copy_to)
72
@deprecated_method(zero_eight)
74
"""Return a list of all the versions in this versioned file.
76
Please use versionedfile.versions() now.
78
return self.versions()
80
68
def versions(self):
81
69
"""Return a unsorted list of versions."""
82
70
raise NotImplementedError(self.versions)
125
113
new_full[-1] = new_full[-1][:-1]
126
114
self.add_lines(version_id, parents, new_full)
128
def add_lines(self, version_id, parents, lines, parent_texts=None):
116
def add_lines(self, version_id, parents, lines, parent_texts=None,
117
left_matching_blocks=None):
129
118
"""Add a single text on top of the versioned file.
131
120
Must raise RevisionAlreadyPresent if the new version is
138
127
version_id to allow delta optimisations.
139
128
VERY IMPORTANT: the texts must be those returned
140
129
by add_lines or data corruption can be caused.
130
:param left_matching_blocks: a hint about which areas are common
131
between the text and its left-hand-parent. The format is
132
the SequenceMatcher.get_matching_blocks format.
141
133
:return: An opaque representation of the inserted version which can be
142
134
provided back to future add_lines calls in the parent_texts
145
137
version_id = osutils.safe_revision_id(version_id)
146
138
parents = [osutils.safe_revision_id(v) for v in parents]
147
139
self._check_write_ok()
148
return self._add_lines(version_id, parents, lines, parent_texts)
140
return self._add_lines(version_id, parents, lines, parent_texts,
141
left_matching_blocks)
150
def _add_lines(self, version_id, parents, lines, parent_texts):
143
def _add_lines(self, version_id, parents, lines, parent_texts,
144
left_matching_blocks):
151
145
"""Helper to do the class specific add_lines."""
152
146
raise NotImplementedError(self.add_lines)
298
292
mpdiff. mpdiff should be a MultiParent instance.
301
for version, parents, expected_sha1, mpdiff in records:
302
mpvf = multiparent.MultiMemoryVersionedFile()
303
needed_parents = [p for p in parents if not mpvf.has_version(p)]
304
parent_lines = self._get_lf_split_line_list(needed_parents)
305
for parent_id, lines in zip(needed_parents, parent_lines):
306
mpvf.add_version(lines, parent_id, [])
307
mpvf.add_diff(mpdiff, version, parents)
308
lines = mpvf.get_line_list([version])[0]
309
version_text = self.add_lines(version, parents, lines, vf_parents)
295
mpvf = multiparent.MultiMemoryVersionedFile()
297
for version, parent_ids, expected_sha1, mpdiff in records:
298
versions.append(version)
299
mpvf.add_diff(mpdiff, version, parent_ids)
300
needed_parents = set()
301
for version, parent_ids, expected_sha1, mpdiff in records:
302
needed_parents.update(p for p in parent_ids
303
if not mpvf.has_version(p))
304
for parent_id, lines in zip(needed_parents,
305
self._get_lf_split_line_list(needed_parents)):
306
mpvf.add_version(lines, parent_id, [])
307
for (version, parent_ids, expected_sha1, mpdiff), lines in\
308
zip(records, mpvf.get_line_list(versions)):
309
if len(parent_ids) == 1:
310
left_matching_blocks = list(mpdiff.get_matching_blocks(0,
311
mpvf.get_diff(parent_ids[0]).num_lines()))
313
left_matching_blocks = None
314
version_text = self.add_lines(version, parent_ids, lines,
315
vf_parents, left_matching_blocks=left_matching_blocks)
310
316
vf_parents[version] = version_text
311
if expected_sha1 != self.get_sha1(version):
317
for (version, parent_ids, expected_sha1, mpdiff), sha1 in\
318
zip(records, self.get_sha1s(versions)):
319
if expected_sha1 != sha1:
312
320
raise errors.VersionedFileInvalidChecksum(version)
314
322
def get_sha1(self, version_id):
414
422
raise NotImplementedError(self.get_graph_with_ghosts)
416
@deprecated_method(zero_eight)
417
def parent_names(self, version):
418
"""Return version names for parents of a version.
420
See get_parents for the current api.
422
return self.get_parents(version)
424
424
def get_parents(self, version_id):
425
425
"""Return version names for parents of a version.
522
522
self.finished = True
524
@deprecated_method(zero_eight)
525
def walk(self, version_ids=None):
526
"""Walk the versioned file as a weave-like structure, for
527
versions relative to version_ids. Yields sequence of (lineno,
528
insert, deletes, text) for each relevant line.
530
Must raise RevisionNotPresent if any of the specified versions
531
are not present in the file history.
533
:param version_ids: the version_ids to walk with respect to. If not
534
supplied the entire weave-like structure is walked.
536
walk is deprecated in favour of iter_lines_added_or_present_in_versions
538
raise NotImplementedError(self.walk)
540
@deprecated_method(zero_eight)
541
def iter_names(self):
542
"""Walk the names list."""
543
return iter(self.versions())
545
524
def plan_merge(self, ver_a, ver_b):
546
525
"""Return pseudo-annotation indicating how the two versions merge.