65
69
"""Copy this versioned file to name on transport."""
66
70
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()
68
80
def versions(self):
69
81
"""Return a unsorted list of versions."""
70
82
raise NotImplementedError(self.versions)
113
125
new_full[-1] = new_full[-1][:-1]
114
126
self.add_lines(version_id, parents, new_full)
116
def add_lines(self, version_id, parents, lines, parent_texts=None,
117
left_matching_blocks=None):
128
def add_lines(self, version_id, parents, lines, parent_texts=None):
118
129
"""Add a single text on top of the versioned file.
120
131
Must raise RevisionAlreadyPresent if the new version is
127
138
version_id to allow delta optimisations.
128
139
VERY IMPORTANT: the texts must be those returned
129
140
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.
133
141
:return: An opaque representation of the inserted version which can be
134
142
provided back to future add_lines calls in the parent_texts
137
145
version_id = osutils.safe_revision_id(version_id)
138
146
parents = [osutils.safe_revision_id(v) for v in parents]
139
147
self._check_write_ok()
140
return self._add_lines(version_id, parents, lines, parent_texts,
141
left_matching_blocks)
148
return self._add_lines(version_id, parents, lines, parent_texts)
143
def _add_lines(self, version_id, parents, lines, parent_texts,
144
left_matching_blocks):
150
def _add_lines(self, version_id, parents, lines, parent_texts):
145
151
"""Helper to do the class specific add_lines."""
146
152
raise NotImplementedError(self.add_lines)
299
298
mpdiff. mpdiff should be a MultiParent instance.
302
mpvf = multiparent.MultiMemoryVersionedFile()
304
for version, parent_ids, expected_sha1, mpdiff in records:
305
versions.append(version)
306
mpvf.add_diff(mpdiff, version, parent_ids)
307
needed_parents = set()
308
for version, parent_ids, expected_sha1, mpdiff in records:
309
needed_parents.update(p for p in parent_ids
310
if not mpvf.has_version(p))
311
for parent_id, lines in zip(needed_parents,
312
self._get_lf_split_line_list(needed_parents)):
313
mpvf.add_version(lines, parent_id, [])
314
for (version, parent_ids, expected_sha1, mpdiff), lines in\
315
zip(records, mpvf.get_line_list(versions)):
316
if len(parent_ids) == 1:
317
left_matching_blocks = list(mpdiff.get_matching_blocks(0,
318
mpvf.get_diff(parent_ids[0]).num_lines()))
320
left_matching_blocks = None
321
version_text = self.add_lines(version, parent_ids, lines,
322
vf_parents, left_matching_blocks=left_matching_blocks)
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)
323
310
vf_parents[version] = version_text
324
for (version, parent_ids, expected_sha1, mpdiff), sha1 in\
325
zip(records, self.get_sha1s(versions)):
326
if expected_sha1 != sha1:
311
if expected_sha1 != self.get_sha1(version):
327
312
raise errors.VersionedFileInvalidChecksum(version)
329
314
def get_sha1(self, version_id):
405
390
:param version_ids: Versions to select.
406
391
None means retrieve all versions.
408
394
if version_ids is None:
409
return dict(self.iter_parents(self.versions()))
411
pending = set(osutils.safe_revision_id(v) for v in version_ids)
413
this_iteration = pending
415
for version, parents in self.iter_parents(this_iteration):
416
result[version] = parents
395
for version in self.versions():
396
result[version] = self.get_parents(version)
398
pending = set(osutils.safe_revision_id(v) for v in version_ids)
400
version = pending.pop()
401
if version in result:
403
parents = self.get_parents(version)
417
404
for parent in parents:
418
405
if parent in result:
420
407
pending.add(parent)
408
result[version] = parents
423
411
def get_graph_with_ghosts(self):
429
417
raise NotImplementedError(self.get_graph_with_ghosts)
419
@deprecated_method(zero_eight)
420
def parent_names(self, version):
421
"""Return version names for parents of a version.
423
See get_parents for the current api.
425
return self.get_parents(version)
431
427
def get_parents(self, version_id):
432
428
"""Return version names for parents of a version.
506
502
raise NotImplementedError(self.iter_lines_added_or_present_in_versions)
508
def iter_parents(self, version_ids):
509
"""Iterate through the parents for many version ids.
511
:param version_ids: An iterable yielding version_ids.
512
:return: An iterator that yields (version_id, parents). Requested
513
version_ids not present in the versioned file are simply skipped.
514
The order is undefined, allowing for different optimisations in
515
the underlying implementation.
517
for version_id in version_ids:
519
yield version_id, tuple(self.get_parents(version_id))
520
except errors.RevisionNotPresent:
523
504
def transaction_finished(self):
524
505
"""The transaction that this file was opened in has finished.
529
510
self.finished = True
512
@deprecated_method(zero_eight)
513
def walk(self, version_ids=None):
514
"""Walk the versioned file as a weave-like structure, for
515
versions relative to version_ids. Yields sequence of (lineno,
516
insert, deletes, text) for each relevant line.
518
Must raise RevisionNotPresent if any of the specified versions
519
are not present in the file history.
521
:param version_ids: the version_ids to walk with respect to. If not
522
supplied the entire weave-like structure is walked.
524
walk is deprecated in favour of iter_lines_added_or_present_in_versions
526
raise NotImplementedError(self.walk)
528
@deprecated_method(zero_eight)
529
def iter_names(self):
530
"""Walk the names list."""
531
return iter(self.versions())
531
533
def plan_merge(self, ver_a, ver_b):
532
534
"""Return pseudo-annotation indicating how the two versions merge.