~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2006-02-15 08:11:37 UTC
  • mto: (1534.1.24 integration)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060215081137-4c27377517e96dd1
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        """Construct the current default format repository in a_bzrdir."""
84
84
        return RepositoryFormat.get_default_format().initialize(a_bzrdir)
85
85
 
86
 
    def __init__(self, transport, branch_format, _format=None, a_bzrdir=None):
 
86
    def __init__(self, _format, a_bzrdir):
87
87
        object.__init__(self)
88
 
        if transport is not None:
89
 
            warn("Repository.__init__(..., transport=XXX): The transport parameter is "
90
 
                 "deprecated and was never in a supported release. Please use "
91
 
                 "bzrdir.open_repository() or bzrdir.open_branch().repository.",
92
 
                 DeprecationWarning,
93
 
                 stacklevel=2)
94
 
            self.control_files = LockableFiles(transport.clone(bzrlib.BZRDIR), 'README')
95
 
        else: 
96
 
            # TODO: clone into repository if needed
97
 
            self.control_files = LockableFiles(a_bzrdir.get_repository_transport(None), 'README')
 
88
        if isinstance(_format, (RepositoryFormat4,
 
89
                                RepositoryFormat5,
 
90
                                RepositoryFormat6)):
 
91
            # legacy: use a common control files.
 
92
            self.control_files = a_bzrdir._control_files
 
93
        else:
 
94
            self.control_files = LockableFiles(a_bzrdir.get_repository_transport(None),
 
95
                                               'lock')
98
96
 
99
97
        dir_mode = self.control_files._dir_mode
100
98
        file_mode = self.control_files._file_mode
115
113
                ws.enable_cache = True
116
114
            return ws
117
115
 
118
 
 
119
116
        def get_store(name, compressed=True, prefixed=False):
120
117
            # FIXME: This approach of assuming stores are all entirely compressed
121
118
            # or entirely uncompressed is tidy, but breaks upgrade from 
136
133
            #    store = bzrlib.store.CachedStore(store, cache_path)
137
134
            return store
138
135
 
139
 
        if branch_format is not None:
140
 
            # circular dependencies:
141
 
            from bzrlib.branch import (BzrBranchFormat4,
142
 
                                       BzrBranchFormat5,
143
 
                                       BzrBranchFormat6,
144
 
                                       )
145
 
            if isinstance(branch_format, BzrBranchFormat4):
146
 
                self._format = RepositoryFormat4()
147
 
            elif isinstance(branch_format, BzrBranchFormat5):
148
 
                self._format = RepositoryFormat5()
149
 
            elif isinstance(branch_format, BzrBranchFormat6):
150
 
                self._format = RepositoryFormat6()
151
 
            
152
 
 
153
136
        if isinstance(self._format, RepositoryFormat4):
154
137
            self.inventory_store = get_store('inventory-store')
155
138
            self.text_store = get_store('text-store')
702
685
        if not _found:
703
686
            # we are being called directly and must probe.
704
687
            raise NotImplementedError
705
 
        return Repository(None, branch_format=None, _format=self, a_bzrdir=a_bzrdir)
 
688
        return Repository(_format=self, a_bzrdir=a_bzrdir)
706
689
 
707
690
    @classmethod
708
691
    def register_format(klass, format):
735
718
 
736
719
        if not _internal:
737
720
            # always initialized when the bzrdir is.
738
 
            return Repository(None, branch_format=None, _format=self, a_bzrdir=a_bzrdir)
 
721
            return Repository(_format=self, a_bzrdir=a_bzrdir)
739
722
        
740
723
        # Create an empty weave
741
724
        sio = StringIO()
759
742
                control_files.put(file, content)
760
743
        finally:
761
744
            control_files.unlock()
762
 
        return Repository(None, branch_format=None, _format=self, a_bzrdir=a_bzrdir)
 
745
        return Repository(_format=self, a_bzrdir=a_bzrdir)
763
746
 
764
747
 
765
748
class RepositoryFormat4(PreSplitOutRepositoryFormat):
873
856
                control_files.put_utf8('shared-storage', '')
874
857
        finally:
875
858
            control_files.unlock()
876
 
        return Repository(None, branch_format=None, _format=self, a_bzrdir=a_bzrdir)
 
859
        return Repository(_format=self, a_bzrdir=a_bzrdir)
877
860
 
878
861
    def __init__(self):
879
862
        super(RepositoryFormat7, self).__init__()