24
24
from bzrlib.branch import Branch
25
25
from bzrlib.bzrdir import BzrDir
26
from bzrlib.conflicts import ConflictList
27
from bzrlib.delta import compare_trees
26
28
from bzrlib.osutils import abspath
27
29
from bzrlib.tests.blackbox import ExternalBase
30
import bzrlib.urlutils as urlutils
28
31
from bzrlib.workingtree import WorkingTree
141
144
os.chdir('branch_b')
142
145
out = self.runbzr('merge', retcode=3)
143
146
self.assertEquals(out,
144
('','bzr: ERROR: No merge branch known or specified.\n'))
147
('','bzr: ERROR: No location specified or remembered\n'))
145
148
# test implicit --remember when no parent set, this merge conflicts
146
149
self.build_tree(['d'])
152
155
# test implicit --remember after resolving conflict
153
156
tree_b.commit('commit d')
154
157
out, err = self.runbzr('merge')
155
self.assertEquals(out, 'Using saved branch: ../branch_a\n')
159
base = urlutils.local_path_from_url(branch_a.base)
160
self.assertEquals(out, 'Merging from remembered location %s\n' % (base,))
156
161
self.assertEquals(err, 'All changes applied successfully.\n')
157
162
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
158
163
# re-open tree as external runbzr modified it
167
172
# re-open tree as external runbzr modified it
168
173
tree_b = branch_b.bzrdir.open_workingtree()
169
174
tree_b.commit('merge branch_c')
176
def test_merge_bundle(self):
177
from bzrlib.testament import Testament
178
tree_a = self.make_branch_and_tree('branch_a')
179
f = file('branch_a/a', 'wb')
183
tree_a.commit('message')
185
tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree()
186
f = file('branch_a/a', 'wb')
189
tree_a.commit('message')
191
f = file('branch_b/a', 'wb')
194
tree_b.commit('message')
196
file('../bundle', 'wb').write(self.runbzr('bundle ../branch_a')[0])
197
os.chdir('../branch_a')
198
self.runbzr('merge ../bundle', retcode=1)
199
testament_a = Testament.from_revision(tree_a.branch.repository,
200
tree_b.last_revision())
201
testament_b = Testament.from_revision(tree_b.branch.repository,
202
tree_b.last_revision())
203
self.assertEqualDiff(testament_a.as_text(),
204
testament_b.as_text())
205
tree_a.set_conflicts(ConflictList())
206
tree_a.commit('message')
207
# it is legal to attempt to merge an already-merged bundle
208
output = self.runbzr('merge ../bundle')[1]
209
# but it does nothing
210
self.assertFalse(compare_trees(tree_a.basis_tree(),
211
tree_a).has_changed())
212
self.assertEqual('Nothing to do.\n', output)