~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Creating a test case for bug 43713, bzr branch does the right thing

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import bzrlib.branch
23
23
import bzrlib.bzrdir
 
24
from bzrlib.repository import RepositoryFormatKnit1
24
25
from bzrlib.tests.blackbox import ExternalBase
 
26
from bzrlib.workingtree import WorkingTree
25
27
 
26
28
 
27
29
class TestBranch(ExternalBase):
69
71
        self.assertEqual('2', target.open_workingtree().last_revision())
70
72
        self.assertTrue(target.open_branch().repository.has_revision('2'))
71
73
 
 
74
    def test_branch_only_copies_history(self):
 
75
        # Knit branches should only push the history for the current revision.
 
76
        format = bzrlib.bzrdir.BzrDirMetaFormat1()
 
77
        format.repository_format = RepositoryFormatKnit1()
 
78
        shared_repo = self.make_repository('repo', format=format, shared=True)
 
79
        shared_repo.set_make_working_trees(True)
 
80
 
 
81
        def make_shared_tree(path):
 
82
            shared_repo.bzrdir.root_transport.mkdir(path)
 
83
            shared_repo.bzrdir.create_branch_convenience('repo/' + path)
 
84
            return WorkingTree.open('repo/' + path)
 
85
        tree_a = make_shared_tree('a')
 
86
        self.build_tree(['repo/a/file'])
 
87
        tree_a.add('file')
 
88
        tree_a.commit('commit a-1', rev_id='a-1')
 
89
        f = open('repo/a/file', 'ab')
 
90
        f.write('more stuff\n')
 
91
        f.close()
 
92
        tree_a.commit('commit a-2', rev_id='a-2')
 
93
 
 
94
        tree_b = make_shared_tree('b')
 
95
        self.build_tree(['repo/b/file'])
 
96
        tree_b.add('file')
 
97
        tree_b.commit('commit b-1', rev_id='b-1')
 
98
 
 
99
        self.assertTrue(shared_repo.has_revision('a-1'))
 
100
        self.assertTrue(shared_repo.has_revision('a-2'))
 
101
        self.assertTrue(shared_repo.has_revision('b-1'))
 
102
 
 
103
        # Now that we have a repository with shared files, make sure
 
104
        # that things aren't copied out by a 'branch'
 
105
        self.run_bzr('branch', 'repo/b', 'branch-b')
 
106
        pushed_tree = WorkingTree.open('branch-b')
 
107
        pushed_repo = pushed_tree.branch.repository
 
108
        self.assertFalse(pushed_repo.has_revision('a-1'))
 
109
        self.assertFalse(pushed_repo.has_revision('a-2'))
 
110
        self.assertTrue(pushed_repo.has_revision('b-1'))
 
111
 
72
112