~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/weaverepo.py

  • Committer: Benoît Pierre
  • Date: 2009-02-24 00:25:32 UTC
  • mfrom: (4035 +trunk)
  • mto: (4056.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 4058.
  • Revision ID: benoit.pierre@gmail.com-20090224002532-i2f64ou15pa7if2y
Merge with upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
 
83
83
        def get_store(name, compressed=True, prefixed=False):
84
84
            # 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 
 
85
            # or entirely uncompressed is tidy, but breaks upgrade from
 
86
            # some existing branches where there's a mixture; we probably
87
87
            # still want the option to look for both.
88
88
            relpath = self._escape(name)
89
89
            store = TextStore(a_bzrdir.transport.clone(relpath),
95
95
        # not broken out yet because the controlweaves|inventory_store
96
96
        # and texts bits are still different.
97
97
        if isinstance(_format, RepositoryFormat4):
98
 
            # cannot remove these - there is still no consistent api 
 
98
            # cannot remove these - there is still no consistent api
99
99
            # which allows access to this old info.
100
100
            self.inventory_store = get_store('inventory-store')
101
101
            self._text_store = get_store('text-store')
112
112
 
113
113
    @needs_read_lock
114
114
    def _all_revision_ids(self):
115
 
        """Returns a list of all the revision ids in the repository. 
 
115
        """Returns a list of all the revision ids in the repository.
116
116
 
117
 
        These are in as much topological order as the underlying store can 
 
117
        These are in as much topological order as the underlying store can
118
118
        present: for weaves ghosts may lead to a lack of correctness until
119
119
        the reweave updates the parents list.
120
120
        """
192
192
class WeaveMetaDirRepository(MetaDirVersionedFileRepository):
193
193
    """A subclass of MetaDirRepository to set weave specific policy."""
194
194
 
195
 
    @property
196
 
    def _serializer(self):
197
 
        return xml5.serializer_v5
198
 
 
199
195
    def __init__(self, _format, a_bzrdir, control_files):
200
196
        super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files)
201
197
        self._fetch_order = 'topological'
202
198
        self._fetch_reconcile = True
 
199
        self._serializer = _format._serializer
203
200
 
204
201
    @needs_read_lock
205
202
    def _all_possible_ids(self):
210
207
 
211
208
    @needs_read_lock
212
209
    def _all_revision_ids(self):
213
 
        """Returns a list of all the revision ids in the repository. 
 
210
        """Returns a list of all the revision ids in the repository.
214
211
 
215
 
        These are in as much topological order as the underlying store can 
 
212
        These are in as much topological order as the underlying store can
216
213
        present: for weaves ghosts may lead to a lack of correctness until
217
214
        the reweave updates the parents list.
218
215
        """
282
279
        if not _internal:
283
280
            # always initialized when the bzrdir is.
284
281
            return self.open(a_bzrdir, _found=True)
285
 
        
 
282
 
286
283
        # Create an empty weave
287
284
        sio = StringIO()
288
285
        weavefile.write_weave_v5(weave.Weave(), sio)
289
286
        empty_weave = sio.getvalue()
290
287
 
291
288
        mutter('creating repository in %s.', a_bzrdir.transport.base)
292
 
        
 
289
 
293
290
        # FIXME: RBC 20060125 don't peek under the covers
294
291
        # NB: no need to escape relative paths that are url safe.
295
292
        control_files = lockable_files.LockableFiles(a_bzrdir.transport,
355
352
        """Format 4 is not supported.
356
353
 
357
354
        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 
 
355
        conversion logic is expensive - so doing it on the fly was not
359
356
        feasible.
360
357
        """
361
358
        return False
390
387
 
391
388
    _versionedfile_class = weave.WeaveFile
392
389
    _matchingbzrdir = bzrdir.BzrDirFormat5()
 
390
    @property
 
391
    def _serializer(self):
 
392
        return xml5.serializer_v5
393
393
 
394
394
    def __init__(self):
395
395
        super(RepositoryFormat5, self).__init__()
400
400
        """See RepositoryFormat.get_format_description()."""
401
401
        return "Weave repository format 5"
402
402
 
 
403
    def network_name(self):
 
404
        """The network name for this format is the control dirs disk label."""
 
405
        return self._matchingbzrdir.get_format_string()
 
406
 
403
407
    def _get_inventories(self, repo_transport, repo, name='inventory'):
404
408
        mapper = versionedfile.ConstantMapper(name)
405
409
        return versionedfile.ThunkedVersionedFiles(repo_transport,
406
410
            weave.WeaveFile, mapper, repo.is_locked)
407
411
 
408
412
    def _get_revisions(self, repo_transport, repo):
409
 
        from bzrlib.xml5 import serializer_v5
410
413
        return RevisionTextStore(repo_transport.clone('revision-store'),
411
 
            serializer_v5, False, versionedfile.PrefixMapper(),
 
414
            xml5.serializer_v5, False, versionedfile.PrefixMapper(),
412
415
            repo.is_locked, repo.is_write_locked)
413
416
 
414
417
    def _get_signatures(self, repo_transport, repo):
434
437
 
435
438
    _versionedfile_class = weave.WeaveFile
436
439
    _matchingbzrdir = bzrdir.BzrDirFormat6()
 
440
    @property
 
441
    def _serializer(self):
 
442
        return xml5.serializer_v5
437
443
 
438
444
    def __init__(self):
439
445
        super(RepositoryFormat6, self).__init__()
444
450
        """See RepositoryFormat.get_format_description()."""
445
451
        return "Weave repository format 6"
446
452
 
 
453
    def network_name(self):
 
454
        """The network name for this format is the control dirs disk label."""
 
455
        return self._matchingbzrdir.get_format_string()
 
456
 
447
457
    def _get_inventories(self, repo_transport, repo, name='inventory'):
448
458
        mapper = versionedfile.ConstantMapper(name)
449
459
        return versionedfile.ThunkedVersionedFiles(repo_transport,
450
460
            weave.WeaveFile, mapper, repo.is_locked)
451
461
 
452
462
    def _get_revisions(self, repo_transport, repo):
453
 
        from bzrlib.xml5 import serializer_v5
454
463
        return RevisionTextStore(repo_transport.clone('revision-store'),
455
 
            serializer_v5, False, versionedfile.HashPrefixMapper(),
 
464
            xml5.serializer_v5, False, versionedfile.HashPrefixMapper(),
456
465
            repo.is_locked, repo.is_write_locked)
457
466
 
458
467
    def _get_signatures(self, repo_transport, repo):
481
490
 
482
491
    _versionedfile_class = weave.WeaveFile
483
492
    supports_ghosts = False
 
493
    @property
 
494
    def _serializer(self):
 
495
        return xml5.serializer_v5
484
496
 
485
497
    def get_format_string(self):
486
498
        """See RepositoryFormat.get_format_string()."""
499
511
            weave.WeaveFile, mapper, repo.is_locked)
500
512
 
501
513
    def _get_revisions(self, repo_transport, repo):
502
 
        from bzrlib.xml5 import serializer_v5
503
514
        return RevisionTextStore(repo_transport.clone('revision-store'),
504
 
            serializer_v5, True, versionedfile.HashPrefixMapper(),
 
515
            xml5.serializer_v5, True, versionedfile.HashPrefixMapper(),
505
516
            repo.is_locked, repo.is_write_locked)
506
517
 
507
518
    def _get_signatures(self, repo_transport, repo):
528
539
 
529
540
        mutter('creating repository in %s.', a_bzrdir.transport.base)
530
541
        dirs = ['revision-store', 'weaves']
531
 
        files = [('inventory.weave', StringIO(empty_weave)), 
 
542
        files = [('inventory.weave', StringIO(empty_weave)),
532
543
                 ]
533
544
        utf8_files = [('format', self.get_format_string())]
534
 
 
 
545
 
535
546
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
536
547
        return self.open(a_bzrdir=a_bzrdir, _found=True)
537
548
 
538
549
    def open(self, a_bzrdir, _found=False, _override_transport=None):
539
550
        """See RepositoryFormat.open().
540
 
        
 
551
 
541
552
        :param _override_transport: INTERNAL USE ONLY. Allows opening the
542
553
                                    repository at a slightly different url
543
554
                                    than normal. I.e. during 'upgrade'.
664
675
                continue
665
676
            result[key] = parents
666
677
        return result
667
 
    
 
678
 
668
679
    def get_record_stream(self, keys, sort_order, include_delta_closure):
669
680
        for key in keys:
670
681
            text, parents = self._load_text_parents(key)
704
715
                continue
705
716
            result[key] = None
706
717
        return result
707
 
    
 
718
 
708
719
    def get_record_stream(self, keys, sort_order, include_delta_closure):
709
720
        for key in keys:
710
721
            text = self._load_text(key)