/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/repofmt/weaverepo.py

  • Committer: Jelmer Vernooij
  • Date: 2011-02-25 15:24:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5690.
  • Revision ID: jelmer@samba.org-20110225152422-d1pjdfnzsw5ufe2x
Fix tests on Debian GNU/kFreeBSD by treating it like other FreeBSD-kernel-based systems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
ghosts.
21
21
"""
22
22
 
 
23
import gzip
23
24
import os
24
25
from cStringIO import StringIO
25
26
import urllib
29
30
from bzrlib import (
30
31
    xml5,
31
32
    graph as _mod_graph,
 
33
    ui,
32
34
    )
33
35
""")
34
36
from bzrlib import (
38
40
    lockable_files,
39
41
    lockdir,
40
42
    osutils,
41
 
    revision as _mod_revision,
 
43
    symbol_versioning,
42
44
    trace,
 
45
    tuned_gzip,
43
46
    urlutils,
44
47
    versionedfile,
45
48
    weave,
48
51
from bzrlib.decorators import needs_read_lock, needs_write_lock
49
52
from bzrlib.repository import (
50
53
    CommitBuilder,
 
54
    InterRepository,
 
55
    InterSameDataRepository,
51
56
    MetaDirVersionedFileRepository,
52
57
    MetaDirRepositoryFormat,
53
58
    Repository,
54
59
    RepositoryFormat,
55
60
    )
56
61
from bzrlib.store.text import TextStore
57
 
from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
58
62
from bzrlib.versionedfile import (
59
63
    AbsentContentFactory,
60
64
    FulltextContentFactory,
273
277
    _fetch_order = 'topological'
274
278
    _fetch_reconcile = True
275
279
    fast_deltas = False
 
280
    supports_leaving_lock = False
276
281
 
277
282
    def initialize(self, a_bzrdir, shared=False, _internal=False):
278
283
        """Create a weave repository."""
337
342
    has been removed.
338
343
    """
339
344
 
 
345
    supports_funky_characters = False
 
346
 
340
347
    _matchingbzrdir = bzrdir.BzrDirFormat4()
341
348
 
342
349
    def get_format_description(self):
386
393
 
387
394
    _versionedfile_class = weave.WeaveFile
388
395
    _matchingbzrdir = bzrdir.BzrDirFormat5()
 
396
    supports_funky_characters = False
 
397
 
389
398
    @property
390
399
    def _serializer(self):
391
400
        return xml5.serializer_v5
431
440
 
432
441
    _versionedfile_class = weave.WeaveFile
433
442
    _matchingbzrdir = bzrdir.BzrDirFormat6()
 
443
    supports_funky_characters = False
434
444
    @property
435
445
    def _serializer(self):
436
446
        return xml5.serializer_v5
480
490
    _versionedfile_class = weave.WeaveFile
481
491
    supports_ghosts = False
482
492
    supports_chks = False
 
493
    supports_funky_characters = False
483
494
 
484
495
    _fetch_order = 'topological'
485
496
    _fetch_reconcile = True
587
598
            raise ValueError('bad idea to put / in %r' % (key,))
588
599
        text = ''.join(lines)
589
600
        if self._compressed:
590
 
            text = bytes_to_gzip(text)
 
601
            text = tuned_gzip.bytes_to_gzip(text)
591
602
        path = self._map(key)
592
603
        self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True)
593
604
 
635
646
            else:
636
647
                return None
637
648
        if compressed:
638
 
            text = GzipFile(mode='rb', fileobj=StringIO(text)).read()
 
649
            text = gzip.GzipFile(mode='rb', fileobj=StringIO(text)).read()
639
650
        return text
640
651
 
641
652
    def _map(self, key):
738
749
        paths = list(relpaths)
739
750
        return set([self._mapper.unmap(path) for path in paths])
740
751
 
741
 
_legacy_formats = [RepositoryFormat4(),
742
 
                   RepositoryFormat5(),
743
 
                   RepositoryFormat6()]
 
752
 
 
753
class InterWeaveRepo(InterSameDataRepository):
 
754
    """Optimised code paths between Weave based repositories.
 
755
    """
 
756
 
 
757
    @classmethod
 
758
    def _get_repo_format_to_test(self):
 
759
        return RepositoryFormat7()
 
760
 
 
761
    @staticmethod
 
762
    def is_compatible(source, target):
 
763
        """Be compatible with known Weave formats.
 
764
 
 
765
        We don't test for the stores being of specific types because that
 
766
        could lead to confusing results, and there is no need to be
 
767
        overly general.
 
768
        """
 
769
        try:
 
770
            return (isinstance(source._format, (RepositoryFormat5,
 
771
                                                RepositoryFormat6,
 
772
                                                RepositoryFormat7)) and
 
773
                    isinstance(target._format, (RepositoryFormat5,
 
774
                                                RepositoryFormat6,
 
775
                                                RepositoryFormat7)))
 
776
        except AttributeError:
 
777
            return False
 
778
 
 
779
    @needs_write_lock
 
780
    def copy_content(self, revision_id=None):
 
781
        """See InterRepository.copy_content()."""
 
782
        # weave specific optimised path:
 
783
        try:
 
784
            self.target.set_make_working_trees(self.source.make_working_trees())
 
785
        except (errors.RepositoryUpgradeRequired, NotImplemented):
 
786
            pass
 
787
        # FIXME do not peek!
 
788
        if self.source._transport.listable():
 
789
            pb = ui.ui_factory.nested_progress_bar()
 
790
            try:
 
791
                self.target.texts.insert_record_stream(
 
792
                    self.source.texts.get_record_stream(
 
793
                        self.source.texts.keys(), 'topological', False))
 
794
                pb.update('Copying inventory', 0, 1)
 
795
                self.target.inventories.insert_record_stream(
 
796
                    self.source.inventories.get_record_stream(
 
797
                        self.source.inventories.keys(), 'topological', False))
 
798
                self.target.signatures.insert_record_stream(
 
799
                    self.source.signatures.get_record_stream(
 
800
                        self.source.signatures.keys(),
 
801
                        'unordered', True))
 
802
                self.target.revisions.insert_record_stream(
 
803
                    self.source.revisions.get_record_stream(
 
804
                        self.source.revisions.keys(),
 
805
                        'topological', True))
 
806
            finally:
 
807
                pb.finished()
 
808
        else:
 
809
            self.target.fetch(self.source, revision_id=revision_id)
 
810
 
 
811
    @needs_read_lock
 
812
    def search_missing_revision_ids(self,
 
813
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
 
814
            find_ghosts=True, revision_ids=None, if_present_ids=None):
 
815
        """See InterRepository.search_missing_revision_ids()."""
 
816
        # we want all revisions to satisfy revision_id in source.
 
817
        # but we don't want to stat every file here and there.
 
818
        # we want then, all revisions other needs to satisfy revision_id
 
819
        # checked, but not those that we have locally.
 
820
        # so the first thing is to get a subset of the revisions to
 
821
        # satisfy revision_id in source, and then eliminate those that
 
822
        # we do already have.
 
823
        # this is slow on high latency connection to self, but as this
 
824
        # disk format scales terribly for push anyway due to rewriting
 
825
        # inventory.weave, this is considered acceptable.
 
826
        # - RBC 20060209
 
827
        if symbol_versioning.deprecated_passed(revision_id):
 
828
            symbol_versioning.warn(
 
829
                'search_missing_revision_ids(revision_id=...) was '
 
830
                'deprecated in 2.4.  Use revision_ids=[...] instead.',
 
831
                DeprecationWarning, stacklevel=2)
 
832
            if revision_ids is not None:
 
833
                raise AssertionError(
 
834
                    'revision_ids is mutually exclusive with revision_id')
 
835
            if revision_id is not None:
 
836
                revision_ids = [revision_id]
 
837
        del revision_id
 
838
        source_ids_set = self._present_source_revisions_for(
 
839
            revision_ids, if_present_ids)
 
840
        # source_ids is the worst possible case we may need to pull.
 
841
        # now we want to filter source_ids against what we actually
 
842
        # have in target, but don't try to check for existence where we know
 
843
        # we do not have a revision as that would be pointless.
 
844
        target_ids = set(self.target._all_possible_ids())
 
845
        possibly_present_revisions = target_ids.intersection(source_ids_set)
 
846
        actually_present_revisions = set(
 
847
            self.target._eliminate_revisions_not_present(possibly_present_revisions))
 
848
        required_revisions = source_ids_set.difference(actually_present_revisions)
 
849
        if revision_ids is not None:
 
850
            # we used get_ancestry to determine source_ids then we are assured all
 
851
            # revisions referenced are present as they are installed in topological order.
 
852
            # and the tip revision was validated by get_ancestry.
 
853
            result_set = required_revisions
 
854
        else:
 
855
            # if we just grabbed the possibly available ids, then
 
856
            # we only have an estimate of whats available and need to validate
 
857
            # that against the revision records.
 
858
            result_set = set(
 
859
                self.source._eliminate_revisions_not_present(required_revisions))
 
860
        return self.source.revision_ids_to_search_result(result_set)
 
861
 
 
862
 
 
863
InterRepository.register_optimiser(InterWeaveRepo)
 
864
 
 
865
 
 
866
def get_extra_interrepo_test_combinations():
 
867
    from bzrlib.repofmt import knitrepo
 
868
    return [(InterRepository, RepositoryFormat5(),
 
869
        knitrepo.RepositoryFormatKnit3())]