69
77
text_store = get_store('text-store')
70
78
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files, _revision_store, control_store, text_store)
81
def _all_possible_ids(self):
82
"""Return all the possible revisions that we could find."""
83
if 'evil' in debug.debug_flags:
84
mutter_callsite(3, "_all_possible_ids scales with size of history.")
85
return self.get_inventory_weave().versions()
88
def _all_revision_ids(self):
89
"""Returns a list of all the revision ids in the repository.
91
These are in as much topological order as the underlying store can
92
present: for weaves ghosts may lead to a lack of correctness until
93
the reweave updates the parents list.
95
if self._revision_store.text_store.listable():
96
return self._revision_store.all_revision_ids(self.get_transaction())
97
result = self._all_possible_ids()
98
# TODO: jam 20070210 Ensure that _all_possible_ids returns non-unicode
99
# ids. (It should, since _revision_store's API should change to
100
# return utf8 revision_ids)
101
return self._eliminate_revisions_not_present(result)
103
def _check_revision_parents(self, revision, inventory):
104
"""Private to Repository and Fetch.
106
This checks the parentage of revision in an inventory weave for
107
consistency and is only applicable to inventory-weave-for-ancestry
108
using repository formats & fetchers.
110
weave_parents = inventory.get_parents(revision.revision_id)
111
weave_names = inventory.versions()
112
for parent_id in revision.parent_ids:
113
if parent_id in weave_names:
114
# this parent must not be a ghost.
115
if not parent_id in weave_parents:
117
raise errors.CorruptRepository(self)
72
119
def get_commit_builder(self, branch, parents, config, timestamp=None,
73
120
timezone=None, committer=None, revprops=None,
74
121
revision_id=None):
75
122
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
76
return Repository.get_commit_builder(self, branch, parents, config,
77
timestamp, timezone, committer, revprops, revision_id)
123
revision_id = osutils.safe_revision_id(revision_id)
124
result = WeaveCommitBuilder(self, parents, config, timestamp, timezone,
125
committer, revprops, revision_id)
126
self.start_write_group()
130
def get_revisions(self, revision_ids):
131
revs = self._get_revisions(revision_ids)
132
# weave corruption can lead to absent revision markers that should be
134
# the following test is reasonably cheap (it needs a single weave read)
135
# and the weave is cached in read transactions. In write transactions
136
# it is not cached but typically we only read a small number of
137
# revisions. For knits when they are introduced we will probably want
138
# to ensure that caching write transactions are in use.
139
inv = self.get_inventory_weave()
141
self._check_revision_parents(rev, inv)
145
def get_revision_graph(self, revision_id=None):
146
"""Return a dictionary containing the revision graph.
148
:param revision_id: The revision_id to get a graph from. If None, then
149
the entire revision graph is returned. This is a deprecated mode of
150
operation and will be removed in the future.
151
:return: a dictionary of revision_id->revision_parents_list.
153
if 'evil' in debug.debug_flags:
155
"get_revision_graph scales with size of history.")
156
# special case NULL_REVISION
157
if revision_id == _mod_revision.NULL_REVISION:
159
revision_id = osutils.safe_revision_id(revision_id)
160
a_weave = self.get_inventory_weave()
161
all_revisions = self._eliminate_revisions_not_present(
163
entire_graph = dict([(node, tuple(a_weave.get_parents(node))) for
164
node in all_revisions])
165
if revision_id is None:
167
elif revision_id not in entire_graph:
168
raise errors.NoSuchRevision(self, revision_id)
170
# add what can be reached from revision_id
172
pending = set([revision_id])
173
while len(pending) > 0:
175
result[node] = entire_graph[node]
176
for revision_id in result[node]:
177
if revision_id not in result:
178
pending.add(revision_id)
80
182
def is_shared(self):
104
206
_serializer = xml5.serializer_v5
209
def _all_possible_ids(self):
210
"""Return all the possible revisions that we could find."""
211
if 'evil' in debug.debug_flags:
212
mutter_callsite(3, "_all_possible_ids scales with size of history.")
213
return self.get_inventory_weave().versions()
216
def _all_revision_ids(self):
217
"""Returns a list of all the revision ids in the repository.
219
These are in as much topological order as the underlying store can
220
present: for weaves ghosts may lead to a lack of correctness until
221
the reweave updates the parents list.
223
if self._revision_store.text_store.listable():
224
return self._revision_store.all_revision_ids(self.get_transaction())
225
result = self._all_possible_ids()
226
# TODO: jam 20070210 Ensure that _all_possible_ids returns non-unicode
227
# ids. (It should, since _revision_store's API should change to
228
# return utf8 revision_ids)
229
return self._eliminate_revisions_not_present(result)
231
def _check_revision_parents(self, revision, inventory):
232
"""Private to Repository and Fetch.
234
This checks the parentage of revision in an inventory weave for
235
consistency and is only applicable to inventory-weave-for-ancestry
236
using repository formats & fetchers.
238
weave_parents = inventory.get_parents(revision.revision_id)
239
weave_names = inventory.versions()
240
for parent_id in revision.parent_ids:
241
if parent_id in weave_names:
242
# this parent must not be a ghost.
243
if not parent_id in weave_parents:
245
raise errors.CorruptRepository(self)
106
247
def get_commit_builder(self, branch, parents, config, timestamp=None,
107
248
timezone=None, committer=None, revprops=None,
108
249
revision_id=None):
109
250
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
110
return MetaDirRepository.get_commit_builder(self, branch, parents,
111
config, timestamp, timezone, committer, revprops, revision_id)
251
revision_id = osutils.safe_revision_id(revision_id)
252
result = WeaveCommitBuilder(self, parents, config, timestamp, timezone,
253
committer, revprops, revision_id)
254
self.start_write_group()
258
def get_revision(self, revision_id):
259
"""Return the Revision object for a named revision"""
260
# TODO: jam 20070210 get_revision_reconcile should do this for us
261
revision_id = osutils.safe_revision_id(revision_id)
262
r = self.get_revision_reconcile(revision_id)
263
# weave corruption can lead to absent revision markers that should be
265
# the following test is reasonably cheap (it needs a single weave read)
266
# and the weave is cached in read transactions. In write transactions
267
# it is not cached but typically we only read a small number of
268
# revisions. For knits when they are introduced we will probably want
269
# to ensure that caching write transactions are in use.
270
inv = self.get_inventory_weave()
271
self._check_revision_parents(r, inv)
275
def get_revision_graph(self, revision_id=None):
276
"""Return a dictionary containing the revision graph.
278
:param revision_id: The revision_id to get a graph from. If None, then
279
the entire revision graph is returned. This is a deprecated mode of
280
operation and will be removed in the future.
281
:return: a dictionary of revision_id->revision_parents_list.
283
if 'evil' in debug.debug_flags:
285
"get_revision_graph scales with size of history.")
286
# special case NULL_REVISION
287
if revision_id == _mod_revision.NULL_REVISION:
289
revision_id = osutils.safe_revision_id(revision_id)
290
a_weave = self.get_inventory_weave()
291
all_revisions = self._eliminate_revisions_not_present(
293
entire_graph = dict([(node, tuple(a_weave.get_parents(node))) for
294
node in all_revisions])
295
if revision_id is None:
297
elif revision_id not in entire_graph:
298
raise errors.NoSuchRevision(self, revision_id)
300
# add what can be reached from revision_id
302
pending = set([revision_id])
303
while len(pending) > 0:
305
result[node] = entire_graph[node]
306
for revision_id in result[node]:
307
if revision_id not in result:
308
pending.add(revision_id)
114
312
class PreSplitOutRepositoryFormat(RepositoryFormat):