28
28
from unittest import TestSuite
31
import bzrlib.errors as errors
31
32
from bzrlib.inter import InterObject
32
33
from bzrlib.symbol_versioning import *
33
34
from bzrlib.transport.memory import MemoryTransport
49
50
Texts are identified by a version-id string.
53
def __init__(self, access_mode):
55
self._access_mode = access_mode
52
57
def copy_to(self, name, transport):
53
58
"""Copy this versioned file to name on transport."""
54
59
raise NotImplementedError(self.copy_to)
80
85
already present in file history.
82
87
Must raise RevisionNotPresent if any of the given parents are
83
not present in file history."""
88
not present in file history.
90
self._check_write_ok()
91
return self._add_lines(version_id, parents, lines)
93
def _add_lines(self, version_id, parents, lines):
94
"""Helper to do the class specific add_lines."""
84
95
raise NotImplementedError(self.add_lines)
86
97
def add_lines_with_ghosts(self, version_id, parents, lines):
87
98
"""Add lines to the versioned file, allowing ghosts to be present."""
99
self._check_write_ok()
100
return self._add_lines_with_ghosts(version_id, parents, lines)
102
def _add_lines_with_ghosts(self, version_id, parents, lines):
103
"""Helper to do class specific add_lines_with_ghosts."""
88
104
raise NotImplementedError(self.add_lines_with_ghosts)
90
106
def check(self, progress_bar=None):
91
107
"""Check the versioned file for integrity."""
92
108
raise NotImplementedError(self.check)
110
def _check_write_ok(self):
111
"""Is the versioned file marked as 'finished' ? Raise if it is."""
113
raise errors.OutSideTransaction()
114
if self._access_mode != 'w':
115
raise errors.ReadOnlyObjectDirtiedError(self)
94
117
def clear_cache(self):
95
118
"""Remove any data cached in the versioned file object."""
103
126
Must raise RevisionAlreadyPresent if the new version is
104
127
already present in file history."""
128
self._check_write_ok()
129
return self._clone_text(new_version_id, old_version_id, parents)
131
def _clone_text(self, new_version_id, old_version_id, parents):
132
"""Helper function to do the _clone_text work."""
105
133
raise NotImplementedError(self.clone_text)
107
135
def create_empty(self, name, transport, mode=None):
121
149
the parents list must be a superset of the current
152
self._check_write_ok()
153
return self._fix_parents(version, new_parents)
155
def _fix_parents(self, version, new_parents):
156
"""Helper for fix_parents."""
124
157
raise NotImplementedError(self.fix_parents)
126
159
def get_suffixes(self):
255
289
raise NotImplementedError(self.iter_lines_added_or_present_in_versions)
291
def transaction_finished(self):
292
"""The transaction that this file was opened in has finished.
294
This records self.finished = True and should cause all mutating
257
299
@deprecated_method(zero_eight)
258
300
def walk(self, version_ids=None):
259
301
"""Walk the versioned file as a weave-like structure, for