/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Aaron Bentley
  • Date: 2007-02-09 07:16:20 UTC
  • mfrom: (2272 +trunk)
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20070209071620-gp2n7vtjyb0f2x1e
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
from StringIO import StringIO
19
19
 
20
 
from bzrlib import conflicts
 
20
from bzrlib import (
 
21
    conflicts,
 
22
    merge as _mod_merge,
 
23
    option,
 
24
    )
21
25
from bzrlib.branch import Branch
22
26
from bzrlib.builtins import merge
23
27
from bzrlib.conflicts import ConflictList, TextConflict
24
28
from bzrlib.errors import UnrelatedBranches, NoCommits, BzrCommandError
25
29
from bzrlib.merge import transform_tree, merge_inner
26
 
from bzrlib.osutils import pathjoin
 
30
from bzrlib.osutils import pathjoin, file_kind
27
31
from bzrlib.revision import common_ancestor
28
32
from bzrlib.tests import TestCaseWithTransport
29
33
from bzrlib.trace import (enable_test_log, disable_test_log)
192
196
        tree.merge_from_branch(tree2.branch)
193
197
        self.assertFileEqual('text2', 'tree/sub-tree/file')
194
198
 
 
199
    def test_merge_with_missing(self):
 
200
        tree_a = self.make_branch_and_tree('tree_a')
 
201
        self.build_tree_contents([('tree_a/file', 'content_1')])
 
202
        tree_a.add('file')
 
203
        tree_a.commit('commit base')
 
204
        base_tree = tree_a.basis_tree()
 
205
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
206
        self.build_tree_contents([('tree_a/file', 'content_2')])
 
207
        tree_a.commit('commit other')
 
208
        other_tree = tree_a.basis_tree()
 
209
        os.unlink('tree_b/file')
 
210
        merge_inner(tree_b.branch, other_tree, base_tree, this_tree=tree_b)
 
211
 
 
212
    def test_merge_kind_change(self):
 
213
        tree_a = self.make_branch_and_tree('tree_a')
 
214
        self.build_tree_contents([('tree_a/file', 'content_1')])
 
215
        tree_a.add('file', 'file-id')
 
216
        tree_a.commit('added file')
 
217
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
218
        os.unlink('tree_a/file')
 
219
        self.build_tree(['tree_a/file/'])
 
220
        tree_a.commit('changed file to directory')
 
221
        tree_b.merge_from_branch(tree_a.branch)
 
222
        self.assertEqual('directory', file_kind('tree_b/file'))
 
223
        tree_b.revert([])
 
224
        self.assertEqual('file', file_kind('tree_b/file'))
 
225
        self.build_tree_contents([('tree_b/file', 'content_2')])
 
226
        tree_b.commit('content change')
 
227
        tree_b.merge_from_branch(tree_a.branch)
 
228
        self.assertEqual(tree_b.conflicts(),
 
229
                         [conflicts.ContentsConflict('file',
 
230
                          file_id='file-id')])
 
231
    
 
232
    def test_merge_type_registry(self):
 
233
        merge_type_option = option.Option.OPTIONS['merge-type']
 
234
        self.assertFalse('merge4' in [x[0] for x in 
 
235
                        merge_type_option.iter_switches()])
 
236
        registry = _mod_merge.get_merge_type_registry()
 
237
        registry.register_lazy('merge4', 'bzrlib.merge', 'Merge4Merger',
 
238
                               'time-travelling merge')
 
239
        self.assertTrue('merge4' in [x[0] for x in 
 
240
                        merge_type_option.iter_switches()])
 
241
        registry.remove('merge4')
 
242
        self.assertFalse('merge4' in [x[0] for x in 
 
243
                        merge_type_option.iter_switches()])