77
73
text_store = get_store('text-store')
78
74
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)
119
76
def get_commit_builder(self, branch, parents, config, timestamp=None,
120
77
timezone=None, committer=None, revprops=None,
121
78
revision_id=None):
122
79
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
123
result = WeaveCommitBuilder(self, parents, config, timestamp, timezone,
124
committer, revprops, revision_id)
125
self.start_write_group()
129
def get_revisions(self, revision_ids):
130
revs = self._get_revisions(revision_ids)
131
# weave corruption can lead to absent revision markers that should be
133
# the following test is reasonably cheap (it needs a single weave read)
134
# and the weave is cached in read transactions. In write transactions
135
# it is not cached but typically we only read a small number of
136
# revisions. For knits when they are introduced we will probably want
137
# to ensure that caching write transactions are in use.
138
inv = self.get_inventory_weave()
140
self._check_revision_parents(rev, inv)
144
def get_revision_graph(self, revision_id=None):
145
"""Return a dictionary containing the revision graph.
147
:param revision_id: The revision_id to get a graph from. If None, then
148
the entire revision graph is returned. This is a deprecated mode of
149
operation and will be removed in the future.
150
:return: a dictionary of revision_id->revision_parents_list.
152
if 'evil' in debug.debug_flags:
154
"get_revision_graph scales with size of history.")
155
# special case NULL_REVISION
156
if revision_id == _mod_revision.NULL_REVISION:
158
a_weave = self.get_inventory_weave()
159
all_revisions = self._eliminate_revisions_not_present(
161
entire_graph = dict([(node, tuple(a_weave.get_parents(node))) for
162
node in all_revisions])
163
if revision_id is None:
165
elif revision_id not in entire_graph:
166
raise errors.NoSuchRevision(self, revision_id)
168
# add what can be reached from revision_id
170
pending = set([revision_id])
171
while len(pending) > 0:
173
result[node] = entire_graph[node]
174
for revision_id in result[node]:
175
if revision_id not in result:
176
pending.add(revision_id)
179
def has_revisions(self, revision_ids):
180
"""See Repository.has_revisions()."""
182
transaction = self.get_transaction()
183
for revision_id in revision_ids:
184
if self._revision_store.has_revision_id(revision_id, transaction):
185
result.add(revision_id)
80
return Repository.get_commit_builder(self, branch, parents, config,
81
timestamp, timezone, committer, revprops, revision_id)
189
84
def is_shared(self):
206
101
"""Returns the policy for making working trees on new branches."""
209
def revision_graph_can_have_wrong_parents(self):
210
# XXX: This is an old format that we don't support full checking on, so
211
# just claim that checking for this inconsistency is not required.
215
105
class WeaveMetaDirRepository(MetaDirRepository):
216
106
"""A subclass of MetaDirRepository to set weave specific policy."""
218
108
_serializer = xml5.serializer_v5
221
def _all_possible_ids(self):
222
"""Return all the possible revisions that we could find."""
223
if 'evil' in debug.debug_flags:
224
mutter_callsite(3, "_all_possible_ids scales with size of history.")
225
return self.get_inventory_weave().versions()
228
def _all_revision_ids(self):
229
"""Returns a list of all the revision ids in the repository.
231
These are in as much topological order as the underlying store can
232
present: for weaves ghosts may lead to a lack of correctness until
233
the reweave updates the parents list.
235
if self._revision_store.text_store.listable():
236
return self._revision_store.all_revision_ids(self.get_transaction())
237
result = self._all_possible_ids()
238
# TODO: jam 20070210 Ensure that _all_possible_ids returns non-unicode
239
# ids. (It should, since _revision_store's API should change to
240
# return utf8 revision_ids)
241
return self._eliminate_revisions_not_present(result)
243
def _check_revision_parents(self, revision, inventory):
244
"""Private to Repository and Fetch.
246
This checks the parentage of revision in an inventory weave for
247
consistency and is only applicable to inventory-weave-for-ancestry
248
using repository formats & fetchers.
250
weave_parents = inventory.get_parents(revision.revision_id)
251
weave_names = inventory.versions()
252
for parent_id in revision.parent_ids:
253
if parent_id in weave_names:
254
# this parent must not be a ghost.
255
if not parent_id in weave_parents:
257
raise errors.CorruptRepository(self)
259
110
def get_commit_builder(self, branch, parents, config, timestamp=None,
260
111
timezone=None, committer=None, revprops=None,
261
112
revision_id=None):
262
113
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
263
result = WeaveCommitBuilder(self, parents, config, timestamp, timezone,
264
committer, revprops, revision_id)
265
self.start_write_group()
269
def get_revision(self, revision_id):
270
"""Return the Revision object for a named revision"""
271
# TODO: jam 20070210 get_revision_reconcile should do this for us
272
r = self.get_revision_reconcile(revision_id)
273
# weave corruption can lead to absent revision markers that should be
275
# the following test is reasonably cheap (it needs a single weave read)
276
# and the weave is cached in read transactions. In write transactions
277
# it is not cached but typically we only read a small number of
278
# revisions. For knits when they are introduced we will probably want
279
# to ensure that caching write transactions are in use.
280
inv = self.get_inventory_weave()
281
self._check_revision_parents(r, inv)
285
def get_revision_graph(self, revision_id=None):
286
"""Return a dictionary containing the revision graph.
288
:param revision_id: The revision_id to get a graph from. If None, then
289
the entire revision graph is returned. This is a deprecated mode of
290
operation and will be removed in the future.
291
:return: a dictionary of revision_id->revision_parents_list.
293
if 'evil' in debug.debug_flags:
295
"get_revision_graph scales with size of history.")
296
# special case NULL_REVISION
297
if revision_id == _mod_revision.NULL_REVISION:
299
a_weave = self.get_inventory_weave()
300
all_revisions = self._eliminate_revisions_not_present(
302
entire_graph = dict([(node, tuple(a_weave.get_parents(node))) for
303
node in all_revisions])
304
if revision_id is None:
306
elif revision_id not in entire_graph:
307
raise errors.NoSuchRevision(self, revision_id)
309
# add what can be reached from revision_id
311
pending = set([revision_id])
312
while len(pending) > 0:
314
result[node] = entire_graph[node]
315
for revision_id in result[node]:
316
if revision_id not in result:
317
pending.add(revision_id)
320
def has_revisions(self, revision_ids):
321
"""See Repository.has_revisions()."""
323
transaction = self.get_transaction()
324
for revision_id in revision_ids:
325
if self._revision_store.has_revision_id(revision_id, transaction):
326
result.add(revision_id)
329
def revision_graph_can_have_wrong_parents(self):
330
# XXX: This is an old format that we don't support full checking on, so
331
# just claim that checking for this inconsistency is not required.
114
return MetaDirRepository.get_commit_builder(self, branch, parents,
115
config, timestamp, timezone, committer, revprops, revision_id)
335
118
class PreSplitOutRepositoryFormat(RepositoryFormat):