~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_branch.py

MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
from bzrlib.upgrade import upgrade
42
42
from bzrlib.workingtree import WorkingTree
43
43
 
 
44
 
44
45
# TODO: Make a branch using basis branch, and check that it 
45
46
# doesn't request any files that could have been avoided, by 
46
47
# hooking into the Transport.
66
67
        except errors.UninitializableFormat:
67
68
            raise TestSkipped('Uninitializable branch format')
68
69
 
69
 
    def make_repository(self, relpath):
 
70
    def make_repository(self, relpath, shared=False):
70
71
        try:
71
72
            url = self.get_url(relpath)
72
73
            segments = url.split('/')
78
79
                except FileExists:
79
80
                    pass
80
81
            made_control = self.bzrdir_format.initialize(url)
81
 
            return made_control.create_repository()
 
82
            return made_control.create_repository(shared=shared)
82
83
        except UninitializableFormat:
83
84
            raise TestSkipped("Format %s is not initializable.")
84
85
 
271
272
                            'sig').read())
272
273
 
273
274
    def test_upgrade_preserves_signatures(self):
274
 
        # this is in the current test format
275
275
        wt = self.make_branch_and_tree('source')
276
276
        wt.commit('A', allow_pointless=True, rev_id='A')
277
277
        wt.branch.repository.sign_revision('A',
278
278
            bzrlib.gpg.LoopbackGPGStrategy(None))
279
279
        old_signature = wt.branch.repository.revision_store.get('A',
280
280
            'sig').read()
281
 
        upgrade(wt.basedir)
 
281
        try:
 
282
            upgrade(wt.basedir)
 
283
        except errors.UpToDateFormat:
 
284
            # this is in the most current format already.
 
285
            return
282
286
        wt = WorkingTree.open(wt.basedir)
283
287
        new_signature = wt.branch.repository.revision_store.get('A',
284
288
            'sig').read()
320
324
        self.assertEqual(committed.properties["branch-nick"], 
321
325
                         "My happy branch")
322
326
 
 
327
    def test_create_open_branch_uses_repository(self):
 
328
        try:
 
329
            repo = self.make_repository('.', shared=True)
 
330
        except errors.IncompatibleFormat:
 
331
            return
 
332
        repo.bzrdir.root_transport.mkdir('child')
 
333
        child_dir = self.bzrdir_format.initialize('child')
 
334
        try:
 
335
            child_branch = self.branch_format.initialize(child_dir)
 
336
        except errors.UninitializableFormat:
 
337
            # branch references are not default init'able.
 
338
            return
 
339
        self.assertEqual(repo.bzrdir.root_transport.base,
 
340
                         child_branch.repository.bzrdir.root_transport.base)
 
341
        child_branch = bzrlib.branch.Branch.open(self.get_url('child'))
 
342
        self.assertEqual(repo.bzrdir.root_transport.base,
 
343
                         child_branch.repository.bzrdir.root_transport.base)
 
344
 
323
345
 
324
346
class ChrootedTests(TestCaseWithBranch):
325
347
    """A support class that provides readonly urls outside the local namespace.