69
71
self.assertEqual('2', target.open_workingtree().last_revision())
70
72
self.assertTrue(target.open_branch().repository.has_revision('2'))
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)
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'])
88
tree_a.commit('commit a-1', rev_id='a-1')
89
f = open('repo/a/file', 'ab')
90
f.write('more stuff\n')
92
tree_a.commit('commit a-2', rev_id='a-2')
94
tree_b = make_shared_tree('b')
95
self.build_tree(['repo/b/file'])
97
tree_b.commit('commit b-1', rev_id='b-1')
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'))
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'))