/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/plugins/weave_fmt/repository.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from bzrlib.lazy_import import lazy_import
29
29
lazy_import(globals(), """
 
30
import itertools
 
31
 
30
32
from bzrlib import (
31
33
    xml5,
32
34
    graph as _mod_graph,
34
36
    )
35
37
""")
36
38
from bzrlib import (
37
 
    bzrdir,
38
39
    debug,
39
40
    errors,
40
41
    lockable_files,
41
42
    lockdir,
42
43
    osutils,
 
44
    symbol_versioning,
43
45
    trace,
44
46
    tuned_gzip,
45
47
    urlutils,
49
51
    )
50
52
from bzrlib.decorators import needs_read_lock, needs_write_lock
51
53
from bzrlib.repository import (
52
 
    CommitBuilder,
53
54
    InterRepository,
54
 
    InterSameDataRepository,
55
 
    MetaDirVersionedFileRepository,
56
 
    MetaDirRepositoryFormat,
57
 
    Repository,
58
55
    RepositoryFormat,
59
56
    )
60
57
from bzrlib.store.text import TextStore
63
60
    FulltextContentFactory,
64
61
    VersionedFiles,
65
62
    )
66
 
 
67
 
 
68
 
class AllInOneRepository(Repository):
 
63
from bzrlib.vf_repository import (
 
64
    InterSameDataRepository,
 
65
    VersionedFileCommitBuilder,
 
66
    VersionedFileRepository,
 
67
    VersionedFileRepositoryFormat,
 
68
    MetaDirVersionedFileRepository,
 
69
    MetaDirVersionedFileRepositoryFormat,
 
70
    )
 
71
 
 
72
from bzrlib.plugins.weave_fmt import bzrdir as weave_bzrdir
 
73
 
 
74
 
 
75
class AllInOneRepository(VersionedFileRepository):
69
76
    """Legacy support - the repository behaviour for all-in-one branches."""
70
77
 
71
78
    @property
143
150
 
144
151
    def get_commit_builder(self, branch, parents, config, timestamp=None,
145
152
                           timezone=None, committer=None, revprops=None,
146
 
                           revision_id=None):
 
153
                           revision_id=None, lossy=False):
147
154
        self._check_ascii_revisionid(revision_id, self.get_commit_builder)
148
 
        result = CommitBuilder(self, parents, config, timestamp, timezone,
149
 
                              committer, revprops, revision_id)
 
155
        result = VersionedFileCommitBuilder(self, parents, config, timestamp,
 
156
            timezone, committer, revprops, revision_id, lossy=lossy)
150
157
        self.start_write_group()
151
158
        return result
152
159
 
186
193
        """Returns the policy for making working trees on new branches."""
187
194
        return True
188
195
 
189
 
    def revision_graph_can_have_wrong_parents(self):
190
 
        # XXX: This is an old format that we don't support full checking on, so
191
 
        # just claim that checking for this inconsistency is not required.
192
 
        return False
193
 
 
194
196
 
195
197
class WeaveMetaDirRepository(MetaDirVersionedFileRepository):
196
198
    """A subclass of MetaDirRepository to set weave specific policy."""
237
239
 
238
240
    def get_commit_builder(self, branch, parents, config, timestamp=None,
239
241
                           timezone=None, committer=None, revprops=None,
240
 
                           revision_id=None):
 
242
                           revision_id=None, lossy=False):
241
243
        self._check_ascii_revisionid(revision_id, self.get_commit_builder)
242
 
        result = CommitBuilder(self, parents, config, timestamp, timezone,
243
 
                              committer, revprops, revision_id)
 
244
        result = VersionedFileCommitBuilder(self, parents, config, timestamp,
 
245
            timezone, committer, revprops, revision_id, lossy=lossy)
244
246
        self.start_write_group()
245
247
        return result
246
248
 
261
263
        return self.inventories.add_lines((revision_id,), final_parents, lines,
262
264
            check_content=check_content)[0]
263
265
 
264
 
    def revision_graph_can_have_wrong_parents(self):
265
 
        return False
266
 
 
267
 
 
268
 
class PreSplitOutRepositoryFormat(RepositoryFormat):
 
266
 
 
267
class PreSplitOutRepositoryFormat(VersionedFileRepositoryFormat):
269
268
    """Base class for the pre split out repository formats."""
270
269
 
271
270
    rich_root_data = False
276
275
    _fetch_order = 'topological'
277
276
    _fetch_reconcile = True
278
277
    fast_deltas = False
 
278
    supports_leaving_lock = False
 
279
    # XXX: This is an old format that we don't support full checking on, so
 
280
    # just claim that checking for this inconsistency is not required.
 
281
    revision_graph_can_have_wrong_parents = False
279
282
 
280
283
    def initialize(self, a_bzrdir, shared=False, _internal=False):
281
284
        """Create a weave repository."""
327
330
        result.chk_bytes = None
328
331
        return result
329
332
 
 
333
    def is_deprecated(self):
 
334
        return True
 
335
 
330
336
 
331
337
class RepositoryFormat4(PreSplitOutRepositoryFormat):
332
338
    """Bzr repository format 4.
342
348
 
343
349
    supports_funky_characters = False
344
350
 
345
 
    _matchingbzrdir = bzrdir.BzrDirFormat4()
 
351
    _matchingbzrdir = weave_bzrdir.BzrDirFormat4()
346
352
 
347
353
    def get_format_description(self):
348
354
        """See RepositoryFormat.get_format_description()."""
366
372
        return None
367
373
 
368
374
    def _get_revisions(self, repo_transport, repo):
369
 
        from bzrlib.xml4 import serializer_v4
 
375
        from bzrlib.plugins.weave_fmt.xml4 import serializer_v4
370
376
        return RevisionTextStore(repo_transport.clone('revision-store'),
371
377
            serializer_v4, True, versionedfile.PrefixMapper(),
372
378
            repo.is_locked, repo.is_write_locked)
390
396
    """
391
397
 
392
398
    _versionedfile_class = weave.WeaveFile
393
 
    _matchingbzrdir = bzrdir.BzrDirFormat5()
 
399
    _matchingbzrdir = weave_bzrdir.BzrDirFormat5()
394
400
    supports_funky_characters = False
395
401
 
396
402
    @property
437
443
    """
438
444
 
439
445
    _versionedfile_class = weave.WeaveFile
440
 
    _matchingbzrdir = bzrdir.BzrDirFormat6()
 
446
    _matchingbzrdir = weave_bzrdir.BzrDirFormat6()
441
447
    supports_funky_characters = False
442
448
    @property
443
449
    def _serializer(self):
473
479
            weave.WeaveFile, mapper, repo.is_locked)
474
480
 
475
481
 
476
 
class RepositoryFormat7(MetaDirRepositoryFormat):
 
482
class RepositoryFormat7(MetaDirVersionedFileRepositoryFormat):
477
483
    """Bzr repository 7.
478
484
 
479
485
    This repository format has:
488
494
    _versionedfile_class = weave.WeaveFile
489
495
    supports_ghosts = False
490
496
    supports_chks = False
 
497
    supports_funky_characters = False
 
498
    revision_graph_can_have_wrong_parents = False
491
499
 
492
500
    _fetch_order = 'topological'
493
501
    _fetch_reconcile = True
570
578
        result._transport = repo_transport
571
579
        return result
572
580
 
 
581
    def is_deprecated(self):
 
582
        return True
 
583
 
573
584
 
574
585
class TextVersionedFiles(VersionedFiles):
575
586
    """Just-a-bunch-of-files based VersionedFile stores."""
621
632
                    record, record.get_bytes_as(record.storage_kind)))
622
633
                try:
623
634
                    self.add_lines(record.key, None, lines)
624
 
                except RevisionAlreadyPresent:
 
635
                except errors.RevisionAlreadyPresent:
625
636
                    pass
626
637
 
627
638
    def _load_text(self, key):
806
817
            self.target.fetch(self.source, revision_id=revision_id)
807
818
 
808
819
    @needs_read_lock
809
 
    def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
810
 
        """See InterRepository.missing_revision_ids()."""
 
820
    def search_missing_revision_ids(self,
 
821
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
 
822
            find_ghosts=True, revision_ids=None, if_present_ids=None,
 
823
            limit=None):
 
824
        """See InterRepository.search_missing_revision_ids()."""
811
825
        # we want all revisions to satisfy revision_id in source.
812
826
        # but we don't want to stat every file here and there.
813
827
        # we want then, all revisions other needs to satisfy revision_id
819
833
        # disk format scales terribly for push anyway due to rewriting
820
834
        # inventory.weave, this is considered acceptable.
821
835
        # - RBC 20060209
822
 
        if revision_id is not None:
823
 
            source_ids = self.source.get_ancestry(revision_id)
824
 
            if source_ids[0] is not None:
825
 
                raise AssertionError()
826
 
            source_ids.pop(0)
827
 
        else:
828
 
            source_ids = self.source._all_possible_ids()
829
 
        source_ids_set = set(source_ids)
 
836
        if symbol_versioning.deprecated_passed(revision_id):
 
837
            symbol_versioning.warn(
 
838
                'search_missing_revision_ids(revision_id=...) was '
 
839
                'deprecated in 2.4.  Use revision_ids=[...] instead.',
 
840
                DeprecationWarning, stacklevel=2)
 
841
            if revision_ids is not None:
 
842
                raise AssertionError(
 
843
                    'revision_ids is mutually exclusive with revision_id')
 
844
            if revision_id is not None:
 
845
                revision_ids = [revision_id]
 
846
        del revision_id
 
847
        source_ids_set = self._present_source_revisions_for(
 
848
            revision_ids, if_present_ids)
830
849
        # source_ids is the worst possible case we may need to pull.
831
850
        # now we want to filter source_ids against what we actually
832
851
        # have in target, but don't try to check for existence where we know
836
855
        actually_present_revisions = set(
837
856
            self.target._eliminate_revisions_not_present(possibly_present_revisions))
838
857
        required_revisions = source_ids_set.difference(actually_present_revisions)
839
 
        if revision_id is not None:
 
858
        if revision_ids is not None:
840
859
            # we used get_ancestry to determine source_ids then we are assured all
841
860
            # revisions referenced are present as they are installed in topological order.
842
861
            # and the tip revision was validated by get_ancestry.
847
866
            # that against the revision records.
848
867
            result_set = set(
849
868
                self.source._eliminate_revisions_not_present(required_revisions))
 
869
        if limit is not None:
 
870
            topo_ordered = self.get_graph().iter_topo_order(result_set)
 
871
            result_set = set(itertools.islice(topo_ordered, limit))
850
872
        return self.source.revision_ids_to_search_result(result_set)
851
873
 
852
874
 
853
 
_legacy_formats = [RepositoryFormat4(),
854
 
                   RepositoryFormat5(),
855
 
                   RepositoryFormat6()]
856
 
 
857
 
 
858
875
InterRepository.register_optimiser(InterWeaveRepo)
 
876
 
 
877
 
 
878
def get_extra_interrepo_test_combinations():
 
879
    from bzrlib.repofmt import knitrepo
 
880
    return [(InterRepository, RepositoryFormat5(),
 
881
        knitrepo.RepositoryFormatKnit3())]