~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2006-03-03 03:09:07 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060303030907-6af33664f8791e78
Move responsibility for repository.has_revision into RevisionStore

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from bzrlib.symbol_versioning import *
34
34
from bzrlib.trace import mutter
35
35
from bzrlib.tree import RevisionTree
 
36
from bzrlib.tsort import topo_sort
36
37
from bzrlib.testament import Testament
37
38
from bzrlib.tree import EmptyTree
38
39
import bzrlib.ui
65
66
        present: for weaves ghosts may lead to a lack of correctness until
66
67
        the reweave updates the parents list.
67
68
        """
 
69
        if self.revision_store.listable():
 
70
            # yes this is slow, but its complete.
 
71
            result_graph = {}
 
72
            for rev_id in self.revision_store:
 
73
                rev = self.get_revision(rev_id)
 
74
                result_graph[rev_id] = rev.parent_ids
 
75
            return topo_sort(result_graph.items())
68
76
        result = self._all_possible_ids()
69
77
        return self._eliminate_revisions_not_present(result)
70
78
 
100
108
        # the following are part of the public API for Repository:
101
109
        self.bzrdir = a_bzrdir
102
110
        self.control_files = control_files
103
 
        self.revision_store = revision_store
 
111
        # backwards compatible until we fully transition
 
112
        self.revision_store = revision_store.text_store
 
113
        self._revision_store = revision_store
104
114
        self.text_store = text_store
105
115
        # backwards compatability
106
116
        self.weave_store = text_store
171
181
        self.copy_content_into(result, revision_id, basis)
172
182
        return result
173
183
 
 
184
    @needs_read_lock
174
185
    def has_revision(self, revision_id):
175
 
        """True if this branch has a copy of the revision.
176
 
 
177
 
        This does not necessarily imply the revision is merge
178
 
        or on the mainline."""
179
 
        return (revision_id is None
180
 
                or self.revision_store.has_id(revision_id))
 
186
        """True if this repository has a copy of the revision."""
 
187
        return self._revision_store.has_revision_id(revision_id,
 
188
                                                    self.get_transaction())
181
189
 
182
190
    @needs_read_lock
183
191
    def get_revision_xml_file(self, revision_id):
506
514
        else:
507
515
            raise errors.BzrError('unreachable code: unexpected repository'
508
516
                                  ' format.')
509
 
        revision_store.register_suffix('sig')
510
517
        super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files, revision_store, text_store)
511
518
 
512
519
 
605
612
        """Return the revision store object for this a_bzrdir."""
606
613
        raise NotImplementedError(self._get_revision_store)
607
614
 
608
 
    def _get_rev_store(self,
609
 
                   transport,
610
 
                   control_files,
611
 
                   name,
612
 
                   compressed=True,
613
 
                   prefixed=False):
 
615
    def _get_text_rev_store(self,
 
616
                            transport,
 
617
                            control_files,
 
618
                            name,
 
619
                            compressed=True,
 
620
                            prefixed=False):
614
621
        """Common logic for getting a revision store for a repository.
615
622
        
616
623
        see self._get_revision_store for the subclass-overridable method to 
617
624
        get the store for a repository.
618
625
        """
 
626
        from bzrlib.store.revision.text import TextRevisionStore
619
627
        dir_mode = control_files._dir_mode
620
628
        file_mode = control_files._file_mode
621
 
        revision_store =TextStore(transport.clone(name),
622
 
                                  prefixed=prefixed,
623
 
                                  compressed=compressed,
624
 
                                  dir_mode=dir_mode,
625
 
                                  file_mode=file_mode)
626
 
        revision_store.register_suffix('sig')
 
629
        text_store =TextStore(transport.clone(name),
 
630
                              prefixed=prefixed,
 
631
                              compressed=compressed,
 
632
                              dir_mode=dir_mode,
 
633
                              file_mode=file_mode)
 
634
        text_store.register_suffix('sig')
 
635
        revision_store = TextRevisionStore(text_store)
627
636
        return revision_store
628
637
 
629
638
    def _get_versioned_file_store(self,
774
783
 
775
784
    def _get_revision_store(self, repo_transport, control_files):
776
785
        """See RepositoryFormat._get_revision_store()."""
777
 
        return self._get_rev_store(repo_transport,
778
 
                                   control_files,
779
 
                                   'revision-store')
 
786
        return self._get_text_rev_store(repo_transport,
 
787
                                        control_files,
 
788
                                        'revision-store')
780
789
 
781
790
    def _get_text_store(self, transport, control_files):
782
791
        """See RepositoryFormat._get_text_store()."""
798
807
    def _get_revision_store(self, repo_transport, control_files):
799
808
        """See RepositoryFormat._get_revision_store()."""
800
809
        """Return the revision store object for this a_bzrdir."""
801
 
        return self._get_rev_store(repo_transport,
802
 
                                   control_files,
803
 
                                   'revision-store',
804
 
                                   compressed=False)
 
810
        return self._get_text_rev_store(repo_transport,
 
811
                                        control_files,
 
812
                                        'revision-store',
 
813
                                        compressed=False)
805
814
 
806
815
    def _get_text_store(self, transport, control_files):
807
816
        """See RepositoryFormat._get_text_store()."""
823
832
 
824
833
    def _get_revision_store(self, repo_transport, control_files):
825
834
        """See RepositoryFormat._get_revision_store()."""
826
 
        return self._get_rev_store(repo_transport,
827
 
                                   control_files,
828
 
                                   'revision-store',
829
 
                                   compressed=False,
830
 
                                   prefixed=True)
 
835
        return self._get_text_rev_store(repo_transport,
 
836
                                        control_files,
 
837
                                        'revision-store',
 
838
                                        compressed=False,
 
839
                                        prefixed=True)
831
840
 
832
841
    def _get_text_store(self, transport, control_files):
833
842
        """See RepositoryFormat._get_text_store()."""
853
862
 
854
863
    def _get_revision_store(self, repo_transport, control_files):
855
864
        """See RepositoryFormat._get_revision_store()."""
856
 
        return self._get_rev_store(repo_transport,
857
 
                                   control_files,
858
 
                                   'revision-store',
859
 
                                   compressed=False,
860
 
                                   prefixed=True,
861
 
                                   )
 
865
        return self._get_text_rev_store(repo_transport,
 
866
                                        control_files,
 
867
                                        'revision-store',
 
868
                                        compressed=False,
 
869
                                        prefixed=True,
 
870
                                        )
862
871
 
863
872
    def open(self, a_bzrdir, _found=False, _override_transport=None):
864
873
        """See RepositoryFormat.open().