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