~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        """See RepositoryFormat.get_format_string()."""
70
70
        return "Sample .bzr repository format."
71
71
 
72
 
    def initialize(self, a_bzrdir):
 
72
    def initialize(self, a_bzrdir, shared=False):
73
73
        """Initialize a repository in a BzrDir"""
74
74
        t = a_bzrdir.get_repository_transport(self)
75
75
        t.put('format', StringIO(self.get_format_string()))
144
144
    def test_disk_layout(self):
145
145
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
146
146
        repo = repository.RepositoryFormat7().initialize(control)
147
 
        # we want:
148
 
        # format 'Bazaar-NG Repository format 7'
149
 
        # lock ''
150
 
        # inventory.weave == empty_weave
151
 
        # empty revision-store directory
152
 
        # empty weaves directory
153
 
        t = control.get_repository_transport(None)
154
 
        self.assertEqualDiff('Bazaar-NG Repository format 7',
155
 
                             t.get('format').read())
156
 
        self.assertEqualDiff('', t.get('lock').read())
 
147
        # in case of side effects of locking.
 
148
        repo.lock_write()
 
149
        repo.unlock()
 
150
        # we want:
 
151
        # format 'Bazaar-NG Repository format 7'
 
152
        # lock ''
 
153
        # inventory.weave == empty_weave
 
154
        # empty revision-store directory
 
155
        # empty weaves directory
 
156
        t = control.get_repository_transport(None)
 
157
        self.assertEqualDiff('Bazaar-NG Repository format 7',
 
158
                             t.get('format').read())
 
159
        self.assertEqualDiff('', t.get('lock').read())
 
160
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
161
        self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
 
162
        self.assertEqualDiff('# bzr weave file v5\n'
 
163
                             'w\n'
 
164
                             'W\n',
 
165
                             t.get('inventory.weave').read())
 
166
 
 
167
    def test_shared_disk_layout(self):
 
168
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
169
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
170
        # we want:
 
171
        # format 'Bazaar-NG Repository format 7'
 
172
        # lock ''
 
173
        # inventory.weave == empty_weave
 
174
        # empty revision-store directory
 
175
        # empty weaves directory
 
176
        # a 'shared-storage' marker file.
 
177
        t = control.get_repository_transport(None)
 
178
        self.assertEqualDiff('Bazaar-NG Repository format 7',
 
179
                             t.get('format').read())
 
180
        self.assertEqualDiff('', t.get('lock').read())
 
181
        self.assertEqualDiff('', t.get('shared-storage').read())
 
182
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
183
        self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
 
184
        self.assertEqualDiff('# bzr weave file v5\n'
 
185
                             'w\n'
 
186
                             'W\n',
 
187
                             t.get('inventory.weave').read())
 
188
 
 
189
    def test_shared_no_tree_disk_layout(self):
 
190
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
191
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
192
        repo.set_make_working_trees(False)
 
193
        # we want:
 
194
        # format 'Bazaar-NG Repository format 7'
 
195
        # lock ''
 
196
        # inventory.weave == empty_weave
 
197
        # empty revision-store directory
 
198
        # empty weaves directory
 
199
        # a 'shared-storage' marker file.
 
200
        t = control.get_repository_transport(None)
 
201
        self.assertEqualDiff('Bazaar-NG Repository format 7',
 
202
                             t.get('format').read())
 
203
        self.assertEqualDiff('', t.get('lock').read())
 
204
        self.assertEqualDiff('', t.get('shared-storage').read())
 
205
        self.assertEqualDiff('', t.get('no-working-trees').read())
 
206
        repo.set_make_working_trees(True)
 
207
        self.assertFalse(t.has('no-working-trees'))
157
208
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
158
209
        self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
159
210
        self.assertEqualDiff('# bzr weave file v5\n'