~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_merge.py

[merge] bzr.dev 2294

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
23
23
 
24
24
from bzrlib.branch import Branch
25
25
from bzrlib.bzrdir import BzrDir
26
 
from bzrlib.conflicts import ConflictList
27
 
from bzrlib.osutils import abspath
 
26
from bzrlib.conflicts import ConflictList, ContentsConflict
 
27
from bzrlib.osutils import abspath, file_kind
28
28
from bzrlib.tests.blackbox import ExternalBase
29
29
import bzrlib.urlutils as urlutils
30
30
from bzrlib.workingtree import WorkingTree
169
169
        
170
170
        base = urlutils.local_path_from_url(branch_a.base)
171
171
        self.assertEquals(out, 'Merging from remembered location %s\n' % (base,))
172
 
        self.assertEquals(err, 'All changes applied successfully.\n')
 
172
        self.assertEquals(err, '+N  b\nAll changes applied successfully.\n')
173
173
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
174
174
        # re-open tree as external runbzr modified it
175
175
        tree_b = branch_b.bzrdir.open_workingtree()
177
177
        # test explicit --remember
178
178
        out, err = self.runbzr('merge ../branch_c --remember')
179
179
        self.assertEquals(out, '')
180
 
        self.assertEquals(err, 'All changes applied successfully.\n')
 
180
        self.assertEquals(err, '+N  c\nAll changes applied successfully.\n')
181
181
        self.assertEquals(abspath(branch_b.get_parent()),
182
182
                          abspath(branch_c.bzrdir.root_transport.base))
183
183
        # re-open tree as external runbzr modified it
232
232
        tree_a.rename_one('file_1', 'file_i')
233
233
        tree_a.commit('commit 2')
234
234
        tree_a.rename_one('file_2', 'file_ii')
235
 
        os.chdir('b')
236
 
        self.run_bzr('merge', '../a', '--uncommitted')
237
 
        self.failUnlessExists('file_1')
238
 
        self.failUnlessExists('file_ii')
 
235
        ## os.chdir('b')
 
236
        self.run_bzr('merge', 'a', '--uncommitted', '-d', 'b')
 
237
        self.failUnlessExists('b/file_1')
 
238
        self.failUnlessExists('b/file_ii')
239
239
        tree_b.revert([])
240
 
        self.run_bzr_error(('Cannot use --uncommitted and --revision',), 
241
 
                           'merge', '../a', '--uncommitted', '-r1')
 
240
        self.run_bzr_error(('Cannot use --uncommitted and --revision',),
 
241
                           'merge', '/a', '--uncommitted', '-r1',
 
242
                           '-d', 'b')
242
243
 
243
244
    def pullable_branch(self):
244
245
        os.mkdir('a')
269
270
        self.assertContainsRe(err, '1 revision\\(s\\) pulled')
270
271
        tree_a = WorkingTree.open('.')
271
272
        self.assertEqual([self.id2], tree_a.get_parent_ids())
 
273
 
 
274
    def test_merge_kind_change(self):
 
275
        tree_a = self.make_branch_and_tree('tree_a')
 
276
        self.build_tree_contents([('tree_a/file', 'content_1')])
 
277
        tree_a.add('file', 'file-id')
 
278
        tree_a.commit('added file')
 
279
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
280
        os.unlink('tree_a/file')
 
281
        self.build_tree(['tree_a/file/'])
 
282
        tree_a.commit('changed file to directory')
 
283
        os.chdir('tree_b')
 
284
        self.run_bzr('merge', '../tree_a')
 
285
        self.assertEqual('directory', file_kind('file'))
 
286
        tree_b.revert([])
 
287
        self.assertEqual('file', file_kind('file'))
 
288
        self.build_tree_contents([('file', 'content_2')])
 
289
        tree_b.commit('content change')
 
290
        self.run_bzr('merge', '../tree_a', retcode=1)
 
291
        self.assertEqual(tree_b.conflicts(),
 
292
                         [ContentsConflict('file', file_id='file-id')])