~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_merge_from_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-15 11:26:00 UTC
  • mfrom: (5757.7.7 knitpackrepo-6)
  • mto: This revision was merged to the branch mainline in revision 5801.
  • Revision ID: jelmer@samba.org-20110415112600-vrv2431lh3gi6wx2
MergeĀ knitpackrepo-6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
 
22
22
from bzrlib import (
 
23
    conflicts,
23
24
    errors,
24
 
    merge
 
25
    merge,
25
26
    )
26
27
from bzrlib.tests import per_workingtree
27
28
 
129
130
             ('add', ('file3', 'file3-id', 'file', 'file3 content\n')),
130
131
             ])
131
132
        bld_inner.build_snapshot(
 
133
            '4', ['1'],
 
134
            [('add', ('file4', 'file4-id', 'file', 'file4 content\n'))
 
135
             ])
 
136
        bld_inner.build_snapshot(
 
137
            '5', ['4'], [('rename', ('file4', 'dir/file4'))])
 
138
        bld_inner.build_snapshot(
132
139
            '3', ['1'], [('modify', ('file3-id', 'new file3 contents\n')),])
133
140
        bld_inner.build_snapshot(
134
141
            '2', ['1'],
207
214
                               'foo'],
208
215
                              outer)
209
216
 
 
217
    def test_file4_added_in_root(self):
 
218
        outer, inner = self.make_outer_tree()
 
219
        nb_conflicts = outer.merge_from_branch(inner, to_revision='4')
 
220
        # file4 could not be added to its original root, so it gets added to
 
221
        # the new root with a conflict.
 
222
        self.assertEqual(1, nb_conflicts)
 
223
        self.assertTreeLayout(['dir-outer',
 
224
                               'dir-outer/dir',
 
225
                               'dir-outer/dir/file1',
 
226
                               'dir-outer/file3',
 
227
                               'file4',
 
228
                               'foo'],
 
229
                              outer)
 
230
 
 
231
    def test_file4_added_then_renamed(self):
 
232
        outer, inner = self.make_outer_tree()
 
233
        # 1 conflict, because file4 can't be put into the old root
 
234
        self.assertEqual(1, outer.merge_from_branch(inner, to_revision='4'))
 
235
        try:
 
236
            outer.set_conflicts(conflicts.ConflictList())
 
237
        except errors.UnsupportedOperation:
 
238
            # WT2 doesn't have a separate list of conflicts to clear. It
 
239
            # actually says there is a conflict, but happily forgets all about
 
240
            # it.
 
241
            pass
 
242
        outer.commit('added file4')
 
243
        # And now file4 gets renamed into an existing dir
 
244
        nb_conflicts = outer.merge_from_branch(inner, to_revision='5')
 
245
        self.assertEqual(1, nb_conflicts)
 
246
        self.assertTreeLayout(['dir-outer',
 
247
                               'dir-outer/dir',
 
248
                               'dir-outer/dir/file1',
 
249
                               'dir-outer/dir/file4',
 
250
                               'dir-outer/file3',
 
251
                               'foo'],
 
252
                              outer)