24
24
from bzrlib.branch import Branch
25
25
from bzrlib.bzrdir import BzrDir
26
from bzrlib.conflicts import ConflictList
27
26
from bzrlib.osutils import abspath
28
27
from bzrlib.tests.blackbox import ExternalBase
29
import bzrlib.urlutils as urlutils
30
28
from bzrlib.workingtree import WorkingTree
143
141
os.chdir('branch_b')
144
142
out = self.runbzr('merge', retcode=3)
145
143
self.assertEquals(out,
146
('','bzr: ERROR: No location specified or remembered\n'))
144
('','bzr: ERROR: No merge branch known or specified.\n'))
147
145
# test implicit --remember when no parent set, this merge conflicts
148
146
self.build_tree(['d'])
154
152
# test implicit --remember after resolving conflict
155
153
tree_b.commit('commit d')
156
154
out, err = self.runbzr('merge')
158
base = urlutils.local_path_from_url(branch_a.base)
159
self.assertEquals(out, 'Merging from remembered location %s\n' % (base,))
155
self.assertEquals(out, 'Using saved branch: ../branch_a\n')
160
156
self.assertEquals(err, 'All changes applied successfully.\n')
161
157
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
162
158
# re-open tree as external runbzr modified it
201
197
tree_b.last_revision())
202
198
self.assertEqualDiff(testament_a.as_text(),
203
199
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)
212
def test_merge_uncommitted(self):
213
"""Check that merge --uncommitted behaves properly"""
214
tree_a = self.make_branch_and_tree('a')
215
self.build_tree(['a/file_1', 'a/file_2'])
216
tree_a.add(['file_1', 'file_2'])
217
tree_a.commit('commit 1')
218
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
219
self.failUnlessExists('b/file_1')
220
tree_a.rename_one('file_1', 'file_i')
221
tree_a.commit('commit 2')
222
tree_a.rename_one('file_2', 'file_ii')
224
self.run_bzr('merge', '../a', '--uncommitted')
225
self.failUnlessExists('file_1')
226
self.failUnlessExists('file_ii')
228
self.run_bzr_error(('Cannot use --uncommitted and --revision',),
229
'merge', '../a', '--uncommitted', '-r1')