~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-02-21 16:43:22 UTC
  • mfrom: (1560 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1562.
  • Revision ID: john@arbash-meinel.com-20060221164322-b007aa882582a66e
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout.

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
 
95
96
 
96
97
    def test_fetch_revisions(self):
97
98
        """Test fetch-revision operation."""
98
 
        from bzrlib.fetch import Fetcher
99
99
        get_transport(self.get_url()).mkdir('b1')
100
100
        get_transport(self.get_url()).mkdir('b2')
101
101
        wt = self.make_branch_and_tree('b1')
106
106
        wt.commit('lala!', rev_id='revision-1', allow_pointless=False)
107
107
 
108
108
        mutter('start fetch')
109
 
        f = Fetcher(from_branch=b1, to_branch=b2)
110
 
        eq = self.assertEquals
111
 
        eq(f.count_copied, 1)
112
 
        eq(f._last_revision, 'revision-1')
 
109
        self.assertEqual((1, []), b2.fetch(b1))
113
110
 
114
111
        rev = b2.repository.get_revision('revision-1')
115
112
        tree = b2.repository.revision_tree('revision-1')
116
 
        eq(tree.get_file_text('foo-id'), 'hello')
 
113
        self.assertEqual(tree.get_file_text('foo-id'), 'hello')
117
114
 
118
115
    def get_unbalanced_tree_pair(self):
119
116
        """Return two branches, a and b, with one file in a."""
271
268
                            'sig').read())
272
269
 
273
270
    def test_upgrade_preserves_signatures(self):
274
 
        # this is in the current test format
275
271
        wt = self.make_branch_and_tree('source')
276
272
        wt.commit('A', allow_pointless=True, rev_id='A')
277
273
        wt.branch.repository.sign_revision('A',
278
274
            bzrlib.gpg.LoopbackGPGStrategy(None))
279
275
        old_signature = wt.branch.repository.revision_store.get('A',
280
276
            'sig').read()
281
 
        upgrade(wt.basedir)
 
277
        try:
 
278
            upgrade(wt.basedir)
 
279
        except errors.UpToDateFormat:
 
280
            # this is in the most current format already.
 
281
            return
282
282
        wt = WorkingTree.open(wt.basedir)
283
283
        new_signature = wt.branch.repository.revision_store.get('A',
284
284
            'sig').read()
320
320
        self.assertEqual(committed.properties["branch-nick"], 
321
321
                         "My happy branch")
322
322
 
 
323
    def test_create_open_branch_uses_repository(self):
 
324
        try:
 
325
            repo = self.make_repository('.', shared=True)
 
326
        except errors.IncompatibleFormat:
 
327
            return
 
328
        repo.bzrdir.root_transport.mkdir('child')
 
329
        child_dir = self.bzrdir_format.initialize('child')
 
330
        try:
 
331
            child_branch = self.branch_format.initialize(child_dir)
 
332
        except errors.UninitializableFormat:
 
333
            # branch references are not default init'able.
 
334
            return
 
335
        self.assertEqual(repo.bzrdir.root_transport.base,
 
336
                         child_branch.repository.bzrdir.root_transport.base)
 
337
        child_branch = bzrlib.branch.Branch.open(self.get_url('child'))
 
338
        self.assertEqual(repo.bzrdir.root_transport.base,
 
339
                         child_branch.repository.bzrdir.root_transport.base)
 
340
 
323
341
 
324
342
class ChrootedTests(TestCaseWithBranch):
325
343
    """A support class that provides readonly urls outside the local namespace.