13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Deprecated weave-based repository formats.
83
84
def get_store(name, compressed=True, prefixed=False):
84
85
# FIXME: This approach of assuming stores are all entirely compressed
85
# or entirely uncompressed is tidy, but breaks upgrade from
86
# some existing branches where there's a mixture; we probably
86
# or entirely uncompressed is tidy, but breaks upgrade from
87
# some existing branches where there's a mixture; we probably
87
88
# still want the option to look for both.
88
89
relpath = self._escape(name)
89
90
store = TextStore(a_bzrdir.transport.clone(relpath),
95
96
# not broken out yet because the controlweaves|inventory_store
96
97
# and texts bits are still different.
97
98
if isinstance(_format, RepositoryFormat4):
98
# cannot remove these - there is still no consistent api
99
# cannot remove these - there is still no consistent api
99
100
# which allows access to this old info.
100
101
self.inventory_store = get_store('inventory-store')
101
102
self._text_store = get_store('text-store')
102
103
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files)
103
self._fetch_order = 'topological'
104
self._fetch_reconcile = True
107
106
def _all_possible_ids(self):
114
113
def _all_revision_ids(self):
115
"""Returns a list of all the revision ids in the repository.
114
"""Returns a list of all the revision ids in the repository.
117
These are in as much topological order as the underlying store can
116
These are in as much topological order as the underlying store can
118
117
present: for weaves ghosts may lead to a lack of correctness until
119
118
the reweave updates the parents list.
192
191
class WeaveMetaDirRepository(MetaDirVersionedFileRepository):
193
192
"""A subclass of MetaDirRepository to set weave specific policy."""
196
def _serializer(self):
197
return xml5.serializer_v5
199
194
def __init__(self, _format, a_bzrdir, control_files):
200
195
super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files)
201
self._fetch_order = 'topological'
202
self._fetch_reconcile = True
196
self._serializer = _format._serializer
205
199
def _all_possible_ids(self):
212
206
def _all_revision_ids(self):
213
"""Returns a list of all the revision ids in the repository.
207
"""Returns a list of all the revision ids in the repository.
215
These are in as much topological order as the underlying store can
209
These are in as much topological order as the underlying store can
216
210
present: for weaves ghosts may lead to a lack of correctness until
217
211
the reweave updates the parents list.
273
267
supports_tree_reference = False
274
268
supports_ghosts = False
275
269
supports_external_lookups = False
270
supports_chks = False
271
_fetch_order = 'topological'
272
_fetch_reconcile = True
277
275
def initialize(self, a_bzrdir, shared=False, _internal=False):
278
276
"""Create a weave repository."""
282
280
if not _internal:
283
281
# always initialized when the bzrdir is.
284
282
return self.open(a_bzrdir, _found=True)
286
284
# Create an empty weave
288
286
weavefile.write_weave_v5(weave.Weave(), sio)
289
287
empty_weave = sio.getvalue()
291
289
mutter('creating repository in %s.', a_bzrdir.transport.base)
293
291
# FIXME: RBC 20060125 don't peek under the covers
294
292
# NB: no need to escape relative paths that are url safe.
295
293
control_files = lockable_files.LockableFiles(a_bzrdir.transport,
301
299
transport.mkdir_multi(['revision-store', 'weaves'],
302
300
mode=a_bzrdir._get_dir_mode())
303
transport.put_bytes_non_atomic('inventory.weave', empty_weave)
301
transport.put_bytes_non_atomic('inventory.weave', empty_weave,
302
mode=a_bzrdir._get_file_mode())
305
304
control_files.unlock()
306
305
return self.open(a_bzrdir, _found=True)
318
317
result.signatures = self._get_signatures(repo_transport, result)
319
318
result.inventories = self._get_inventories(repo_transport, result)
320
319
result.texts = self._get_texts(repo_transport, result)
320
result.chk_bytes = None
323
def check_conversion_target(self, target_format):
327
324
class RepositoryFormat4(PreSplitOutRepositoryFormat):
328
325
"""Bzr repository format 4.
339
336
_matchingbzrdir = bzrdir.BzrDirFormat4()
342
super(RepositoryFormat4, self).__init__()
343
self._fetch_order = 'topological'
344
self._fetch_reconcile = True
346
338
def get_format_description(self):
347
339
"""See RepositoryFormat.get_format_description()."""
348
340
return "Repository format 4"
355
347
"""Format 4 is not supported.
357
349
It is not supported because the model changed from 4 to 5 and the
358
conversion logic is expensive - so doing it on the fly was not
350
conversion logic is expensive - so doing it on the fly was not
391
383
_versionedfile_class = weave.WeaveFile
392
384
_matchingbzrdir = bzrdir.BzrDirFormat5()
395
super(RepositoryFormat5, self).__init__()
396
self._fetch_order = 'topological'
397
self._fetch_reconcile = True
386
def _serializer(self):
387
return xml5.serializer_v5
399
389
def get_format_description(self):
400
390
"""See RepositoryFormat.get_format_description()."""
401
391
return "Weave repository format 5"
393
def network_name(self):
394
"""The network name for this format is the control dirs disk label."""
395
return self._matchingbzrdir.get_format_string()
403
397
def _get_inventories(self, repo_transport, repo, name='inventory'):
404
398
mapper = versionedfile.ConstantMapper(name)
405
399
return versionedfile.ThunkedVersionedFiles(repo_transport,
406
400
weave.WeaveFile, mapper, repo.is_locked)
408
402
def _get_revisions(self, repo_transport, repo):
409
from bzrlib.xml5 import serializer_v5
410
403
return RevisionTextStore(repo_transport.clone('revision-store'),
411
serializer_v5, False, versionedfile.PrefixMapper(),
404
xml5.serializer_v5, False, versionedfile.PrefixMapper(),
412
405
repo.is_locked, repo.is_write_locked)
414
407
def _get_signatures(self, repo_transport, repo):
435
428
_versionedfile_class = weave.WeaveFile
436
429
_matchingbzrdir = bzrdir.BzrDirFormat6()
439
super(RepositoryFormat6, self).__init__()
440
self._fetch_order = 'topological'
441
self._fetch_reconcile = True
431
def _serializer(self):
432
return xml5.serializer_v5
443
434
def get_format_description(self):
444
435
"""See RepositoryFormat.get_format_description()."""
445
436
return "Weave repository format 6"
438
def network_name(self):
439
"""The network name for this format is the control dirs disk label."""
440
return self._matchingbzrdir.get_format_string()
447
442
def _get_inventories(self, repo_transport, repo, name='inventory'):
448
443
mapper = versionedfile.ConstantMapper(name)
449
444
return versionedfile.ThunkedVersionedFiles(repo_transport,
450
445
weave.WeaveFile, mapper, repo.is_locked)
452
447
def _get_revisions(self, repo_transport, repo):
453
from bzrlib.xml5 import serializer_v5
454
448
return RevisionTextStore(repo_transport.clone('revision-store'),
455
serializer_v5, False, versionedfile.HashPrefixMapper(),
449
xml5.serializer_v5, False, versionedfile.HashPrefixMapper(),
456
450
repo.is_locked, repo.is_write_locked)
458
452
def _get_signatures(self, repo_transport, repo):
482
476
_versionedfile_class = weave.WeaveFile
483
477
supports_ghosts = False
478
supports_chks = False
480
_fetch_order = 'topological'
481
_fetch_reconcile = True
484
def _serializer(self):
485
return xml5.serializer_v5
485
487
def get_format_string(self):
486
488
"""See RepositoryFormat.get_format_string()."""
490
492
"""See RepositoryFormat.get_format_description()."""
491
493
return "Weave repository format 7"
493
def check_conversion_target(self, target_format):
496
495
def _get_inventories(self, repo_transport, repo, name='inventory'):
497
496
mapper = versionedfile.ConstantMapper(name)
498
497
return versionedfile.ThunkedVersionedFiles(repo_transport,
499
498
weave.WeaveFile, mapper, repo.is_locked)
501
500
def _get_revisions(self, repo_transport, repo):
502
from bzrlib.xml5 import serializer_v5
503
501
return RevisionTextStore(repo_transport.clone('revision-store'),
504
serializer_v5, True, versionedfile.HashPrefixMapper(),
502
xml5.serializer_v5, True, versionedfile.HashPrefixMapper(),
505
503
repo.is_locked, repo.is_write_locked)
507
505
def _get_signatures(self, repo_transport, repo):
529
527
mutter('creating repository in %s.', a_bzrdir.transport.base)
530
528
dirs = ['revision-store', 'weaves']
531
files = [('inventory.weave', StringIO(empty_weave)),
529
files = [('inventory.weave', StringIO(empty_weave)),
533
531
utf8_files = [('format', self.get_format_string())]
535
533
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
536
534
return self.open(a_bzrdir=a_bzrdir, _found=True)
538
536
def open(self, a_bzrdir, _found=False, _override_transport=None):
539
537
"""See RepositoryFormat.open().
541
539
:param _override_transport: INTERNAL USE ONLY. Allows opening the
542
540
repository at a slightly different url
543
541
than normal. I.e. during 'upgrade'.
556
554
result.signatures = self._get_signatures(repo_transport, result)
557
555
result.inventories = self._get_inventories(repo_transport, result)
558
556
result.texts = self._get_texts(repo_transport, result)
557
result.chk_bytes = None
559
558
result._transport = repo_transport
665
664
result[key] = parents
667
def get_known_graph_ancestry(self, keys):
668
"""Get a KnownGraph instance with the ancestry of keys."""
670
parent_map = self.get_parent_map(keys)
671
kg = _mod_graph.KnownGraph(parent_map)
668
674
def get_record_stream(self, keys, sort_order, include_delta_closure):
670
676
text, parents = self._load_text_parents(key)
682
688
path, ext = os.path.splitext(relpath)
685
if '.sig' not in relpath:
691
if not relpath.endswith('.sig'):
686
692
relpaths.add(relpath)
687
693
paths = list(relpaths)
688
694
return set([self._mapper.unmap(path) for path in paths])