93
98
from bzrlib.fetch import Fetcher
94
99
get_transport(self.get_url()).mkdir('b1')
95
100
get_transport(self.get_url()).mkdir('b2')
96
b1 = self.make_branch('b1')
101
wt = self.make_branch_and_tree('b1')
97
103
b2 = self.make_branch('b2')
98
wt = WorkingTree.create(b1, 'b1')
99
104
file('b1/foo', 'w').write('hello')
100
105
wt.add(['foo'], ['foo-id'])
101
106
wt.commit('lala!', rev_id='revision-1', allow_pointless=False)
113
118
def get_unbalanced_tree_pair(self):
114
119
"""Return two branches, a and b, with one file in a."""
115
120
get_transport(self.get_url()).mkdir('a')
116
br_a = self.make_branch('a')
117
tree_a = WorkingTree.create(br_a, 'a')
121
tree_a = self.make_branch_and_tree('a')
118
122
file('a/b', 'wb').write('b')
120
124
tree_a.commit("silly commit", rev_id='A')
122
126
get_transport(self.get_url()).mkdir('b')
123
br_b = self.make_branch('b')
124
tree_b = WorkingTree.create(br_b, 'b')
127
tree_b = self.make_branch_and_tree('b')
125
128
return tree_a, tree_b
127
130
def get_balanced_branch_pair(self):
128
131
"""Returns br_a, br_b as with one commit in a, and b has a's stores."""
129
132
tree_a, tree_b = self.get_unbalanced_tree_pair()
130
tree_a.branch.repository.push_stores(tree_b.branch.repository)
133
tree_b.branch.repository.fetch(tree_a.branch.repository)
131
134
return tree_a, tree_b
133
136
def test_clone_branch(self):
136
139
tree_b.commit("silly commit")
138
141
# this fails to test that the history from a was not used.
139
br_c = tree_a.branch.clone('c', basis_branch=tree_b.branch)
142
dir_c = tree_a.bzrdir.clone('c', basis=tree_b.bzrdir)
140
143
self.assertEqual(tree_a.branch.revision_history(),
141
br_c.revision_history())
144
dir_c.open_branch().revision_history())
143
146
def test_clone_partial(self):
144
147
"""Copy only part of the history of a branch."""
145
get_transport(self.get_url()).mkdir('a')
146
br_a = self.make_branch('a')
147
wt = WorkingTree.create(br_a, "a")
148
self.build_tree(['a/one'])
150
wt.commit('commit one', rev_id='u@d-1')
151
self.build_tree(['a/two'])
153
wt.commit('commit two', rev_id='u@d-2')
154
br_b = br_a.clone('b', revision='u@d-1')
155
self.assertEqual(br_b.last_revision(), 'u@d-1')
156
self.assertTrue(os.path.exists('b/one'))
157
self.assertFalse(os.path.exists('b/two'))
148
# TODO: RBC 20060208 test with a revision not on revision-history.
149
# what should that behaviour be ? Emailed the list.
150
wt_a = self.make_branch_and_tree('a')
151
self.build_tree(['a/one'])
153
wt_a.commit('commit one', rev_id='1')
154
self.build_tree(['a/two'])
156
wt_a.commit('commit two', rev_id='2')
157
repo_b = self.make_repository('b')
158
wt_a.bzrdir.open_repository().copy_content_into(repo_b)
159
br_b = wt_a.bzrdir.open_branch().clone(repo_b.bzrdir, revision_id='1')
160
self.assertEqual(br_b.last_revision(), '1')
162
def test_sprout_partial(self):
163
# test sprouting with a prefix of the revision-history.
164
# also needs not-on-revision-history behaviour defined.
165
wt_a = self.make_branch_and_tree('a')
166
self.build_tree(['a/one'])
168
wt_a.commit('commit one', rev_id='1')
169
self.build_tree(['a/two'])
171
wt_a.commit('commit two', rev_id='2')
172
repo_b = self.make_repository('b')
173
wt_a.bzrdir.open_repository().copy_content_into(repo_b)
174
br_b = wt_a.bzrdir.open_branch().sprout(repo_b.bzrdir, revision_id='1')
175
self.assertEqual(br_b.last_revision(), '1')
177
def test_clone_branch_nickname(self):
178
# test the nick name is preserved always
179
raise TestSkipped('XXX branch cloning is not yet tested..')
181
def test_clone_branch_parent(self):
182
# test the parent is preserved always
183
raise TestSkipped('XXX branch cloning is not yet tested..')
185
def test_sprout_branch_nickname(self):
186
# test the nick name is reset always
187
raise TestSkipped('XXX branch sprouting is not yet tested..')
189
def test_sprout_branch_parent(self):
190
source = self.make_branch('source')
191
target = source.bzrdir.sprout(self.get_url('target')).open_branch()
192
self.assertEqual(source.bzrdir.root_transport.base, target.get_parent())
159
194
def test_record_initial_ghost_merge(self):
160
195
"""A pending merge with no revision present is still a merge."""
161
branch = self.get_branch()
162
wt = WorkingTree.create(branch, ".")
196
wt = self.make_branch_and_tree('.')
163
198
wt.add_pending_merge('non:existent@rev--ision--0--2')
164
199
wt.commit('pretend to merge nonexistent-revision', rev_id='first')
165
200
rev = branch.repository.get_revision(branch.last_revision())
277
312
def test_commit_nicks(self):
278
313
"""Nicknames are committed to the revision"""
279
314
get_transport(self.get_url()).mkdir('bzr.dev')
280
branch = self.make_branch('bzr.dev')
315
wt = self.make_branch_and_tree('bzr.dev')
281
317
branch.nick = "My happy branch"
282
WorkingTree.create(branch, 'bzr.dev').commit('My commit respect da nick.')
318
wt.commit('My commit respect da nick.')
283
319
committed = branch.repository.get_revision(branch.last_revision())
284
320
self.assertEqual(committed.properties["branch-nick"],
285
321
"My happy branch")