~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-26 15:21:01 UTC
  • mfrom: (6165.2.3 avoid-revision-history)
  • mto: This revision was merged to the branch mainline in revision 6216.
  • Revision ID: jelmer@samba.org-20110926152101-afcxw1hikybyivfd
merge avoid-revision-history.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from StringIO import StringIO
19
19
 
20
20
from bzrlib import (
 
21
    branch as _mod_branch,
 
22
    cleanup,
21
23
    conflicts,
22
24
    errors,
 
25
    inventory,
23
26
    knit,
24
27
    memorytree,
25
28
    merge as _mod_merge,
26
29
    option,
27
 
    progress,
 
30
    revision as _mod_revision,
28
31
    tests,
29
32
    transform,
30
33
    versionedfile,
32
35
from bzrlib.conflicts import ConflictList, TextConflict
33
36
from bzrlib.errors import UnrelatedBranches, NoCommits
34
37
from bzrlib.merge import transform_tree, merge_inner, _PlanMerge
35
 
from bzrlib.osutils import pathjoin, file_kind
 
38
from bzrlib.osutils import basename, pathjoin, file_kind
36
39
from bzrlib.tests import (
 
40
    features,
37
41
    TestCaseWithMemoryTransport,
38
42
    TestCaseWithTransport,
39
43
    test_merge_core,
87
91
        os.chdir('branch2')
88
92
        self.run_bzr('merge ../branch1/baz', retcode=3)
89
93
        self.run_bzr('merge ../branch1/foo')
90
 
        self.failUnlessExists('foo')
91
 
        self.failIfExists('bar')
 
94
        self.assertPathExists('foo')
 
95
        self.assertPathDoesNotExist('bar')
92
96
        wt2 = WorkingTree.open('.') # opens branch2
93
97
        self.assertEqual([tip], wt2.get_parent_ids())
94
98
 
118
122
        finally:
119
123
            wt1.unlock()
120
124
 
 
125
    def test_merge_into_null_tree(self):
 
126
        wt = self.make_branch_and_tree('tree')
 
127
        null_tree = wt.basis_tree()
 
128
        self.build_tree(['tree/file'])
 
129
        wt.add('file')
 
130
        wt.commit('tree with root')
 
131
        merger = _mod_merge.Merge3Merger(null_tree, null_tree, null_tree, wt,
 
132
                                         this_branch=wt.branch,
 
133
                                         do_merge=False)
 
134
        with merger.make_preview_transform() as tt:
 
135
            self.assertEqual([], tt.find_conflicts())
 
136
            preview = tt.get_preview_tree()
 
137
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
 
138
 
 
139
    def test_merge_unrelated_retains_root(self):
 
140
        wt = self.make_branch_and_tree('tree')
 
141
        other_tree = self.make_branch_and_tree('other')
 
142
        self.addCleanup(other_tree.lock_read().unlock)
 
143
        merger = _mod_merge.Merge3Merger(wt, wt, wt.basis_tree(), other_tree,
 
144
                                         this_branch=wt.branch,
 
145
                                         do_merge=False)
 
146
        with transform.TransformPreview(wt) as merger.tt:
 
147
            merger._compute_transform()
 
148
            new_root_id = merger.tt.final_file_id(merger.tt.root)
 
149
            self.assertEqual(wt.get_root_id(), new_root_id)
 
150
 
121
151
    def test_create_rename(self):
122
152
        """Rename an inventory entry while creating the file"""
123
153
        tree =self.make_branch_and_tree('.')
154
184
        log = StringIO()
155
185
        merge_inner(tree_b.branch, tree_a, tree_b.basis_tree(),
156
186
                    this_tree=tree_b, ignore_zero=True)
157
 
        self.failUnless('All changes applied successfully.\n' not in
 
187
        self.assertTrue('All changes applied successfully.\n' not in
158
188
            self.get_log())
159
189
        tree_b.revert()
160
190
        merge_inner(tree_b.branch, tree_a, tree_b.basis_tree(),
161
191
                    this_tree=tree_b, ignore_zero=False)
162
 
        self.failUnless('All changes applied successfully.\n' in self.get_log())
 
192
        self.assertTrue('All changes applied successfully.\n' in self.get_log())
163
193
 
164
194
    def test_merge_inner_conflicts(self):
165
195
        tree_a = self.make_branch_and_tree('a')
384
414
                             '>>>>>>> MERGE-SOURCE\n',
385
415
                             'this/file')
386
416
 
 
417
    def test_merge_reverse_revision_range(self):
 
418
        tree = self.make_branch_and_tree(".")
 
419
        tree.lock_write()
 
420
        self.addCleanup(tree.unlock)
 
421
        self.build_tree(['a'])
 
422
        tree.add('a')
 
423
        first_rev = tree.commit("added a")
 
424
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
 
425
                                          _mod_revision.NULL_REVISION,
 
426
                                          first_rev)
 
427
        merger.merge_type = _mod_merge.Merge3Merger
 
428
        merger.interesting_files = 'a'
 
429
        conflict_count = merger.do_merge()
 
430
        self.assertEqual(0, conflict_count)
 
431
 
 
432
        self.assertPathDoesNotExist("a")
 
433
        tree.revert()
 
434
        self.assertPathExists("a")
 
435
 
387
436
    def test_make_merger(self):
388
437
        this_tree = self.make_branch_and_tree('this')
389
438
        this_tree.commit('rev1', rev_id='rev1')
453
502
        finally:
454
503
            tree_file.close()
455
504
 
 
505
    def test_merge_require_tree_root(self):
 
506
        tree = self.make_branch_and_tree(".")
 
507
        tree.lock_write()
 
508
        self.addCleanup(tree.unlock)
 
509
        self.build_tree(['a'])
 
510
        tree.add('a')
 
511
        first_rev = tree.commit("added a")
 
512
        old_root_id = tree.get_root_id()
 
513
        merger = _mod_merge.Merger.from_revision_ids(None, tree,
 
514
                                          _mod_revision.NULL_REVISION,
 
515
                                          first_rev)
 
516
        merger.merge_type = _mod_merge.Merge3Merger
 
517
        conflict_count = merger.do_merge()
 
518
        self.assertEqual(0, conflict_count)
 
519
        self.assertEquals(set([old_root_id]), tree.all_file_ids())
 
520
        tree.set_parent_ids([])
 
521
 
456
522
    def test_merge_add_into_deleted_root(self):
457
523
        # Yes, people actually do this.  And report bugs if it breaks.
458
524
        source = self.make_branch_and_tree('source', format='rich-root-pack')
1267
1333
        self.assertEqual(['B-id', 'C-id', 'F-id'],
1268
1334
                         [t.get_revision_id() for t in merger._lca_trees])
1269
1335
 
 
1336
    def test_find_base_new_root_criss_cross(self):
 
1337
        # A   B
 
1338
        # |\ /|
 
1339
        # | X |
 
1340
        # |/ \|
 
1341
        # C   D
 
1342
        
 
1343
        builder = self.get_builder()
 
1344
        builder.build_snapshot('A-id', None,
 
1345
            [('add', ('', None, 'directory', None))])
 
1346
        builder.build_snapshot('B-id', [],
 
1347
            [('add', ('', None, 'directory', None))])
 
1348
        builder.build_snapshot('D-id', ['A-id', 'B-id'], [])
 
1349
        builder.build_snapshot('C-id', ['A-id', 'B-id'], [])
 
1350
        merger = self.make_Merger(builder, 'D-id')
 
1351
        self.assertEqual('A-id', merger.base_rev_id)
 
1352
        self.assertTrue(merger._is_criss_cross)
 
1353
        self.assertEqual(['A-id', 'B-id'], [t.get_revision_id()
 
1354
                                            for t in merger._lca_trees])
 
1355
 
1270
1356
    def test_no_criss_cross_passed_to_merge_type(self):
1271
1357
        class LCATreesMerger(LoggingMerger):
1272
1358
            supports_lca_trees = True
1804
1890
        builder.build_snapshot('C-id', ['A-id'], [])
1805
1891
        builder.build_snapshot('E-id', ['C-id', 'B-id'],
1806
1892
            [('unversion', 'a-id'),
 
1893
             ('flush', None),
1807
1894
             ('add', (u'a', 'a-id', 'directory', None))])
1808
1895
        builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1809
1896
        merge_obj = self.make_merge_obj(builder, 'E-id')
1827
1914
        builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1828
1915
        builder.build_snapshot('D-id', ['B-id', 'C-id'],
1829
1916
            [('unversion', 'a-id'),
 
1917
             ('flush', None),
1830
1918
             ('add', (u'a', 'a-id', 'directory', None))])
1831
1919
        merge_obj = self.make_merge_obj(builder, 'E-id')
1832
1920
        entries = list(merge_obj._entries_lca())
2095
2183
        self.assertTrue(wt.is_executable('foo-id'))
2096
2184
 
2097
2185
    def test_create_symlink(self):
2098
 
        self.requireFeature(tests.SymlinkFeature)
 
2186
        self.requireFeature(features.SymlinkFeature)
2099
2187
        #   A
2100
2188
        #  / \
2101
2189
        # B   C
2160
2248
                             wt.get_file_text('foo-id'))
2161
2249
 
2162
2250
    def test_modified_symlink(self):
2163
 
        self.requireFeature(tests.SymlinkFeature)
 
2251
        self.requireFeature(features.SymlinkFeature)
2164
2252
        #   A       Create symlink foo => bar
2165
2253
        #  / \
2166
2254
        # B   C     B relinks foo => baz
2205
2293
        self.assertEqual('bing', wt.get_symlink_target('foo-id'))
2206
2294
 
2207
2295
    def test_renamed_symlink(self):
2208
 
        self.requireFeature(tests.SymlinkFeature)
 
2296
        self.requireFeature(features.SymlinkFeature)
2209
2297
        #   A       Create symlink foo => bar
2210
2298
        #  / \
2211
2299
        # B   C     B renames foo => barry
2261
2349
        self.assertEqual('blah', wt.id2path('foo-id'))
2262
2350
 
2263
2351
    def test_symlink_no_content_change(self):
2264
 
        self.requireFeature(tests.SymlinkFeature)
 
2352
        self.requireFeature(features.SymlinkFeature)
2265
2353
        #   A       Create symlink foo => bar
2266
2354
        #  / \
2267
2355
        # B   C     B relinks foo => baz
2312
2400
        self.assertEqual('bing', wt.get_symlink_target('foo-id'))
2313
2401
 
2314
2402
    def test_symlink_this_changed_kind(self):
2315
 
        self.requireFeature(tests.SymlinkFeature)
 
2403
        self.requireFeature(features.SymlinkFeature)
2316
2404
        #   A       Nothing
2317
2405
        #  / \
2318
2406
        # B   C     B creates symlink foo => bar
2365
2453
 
2366
2454
    def test_symlink_all_wt(self):
2367
2455
        """Check behavior if all trees are Working Trees."""
2368
 
        self.requireFeature(tests.SymlinkFeature)
 
2456
        self.requireFeature(features.SymlinkFeature)
2369
2457
        # The big issue is that entry.symlink_target is None for WorkingTrees.
2370
2458
        # So we need to make sure we handle that case correctly.
2371
2459
        #   A   foo => bar
2840
2928
 
2841
2929
    def get_merger_factory(self):
2842
2930
        # Allows  the inner methods to access the test attributes
2843
 
        test = self
 
2931
        calls = self.calls
2844
2932
 
2845
2933
        class FooMerger(_mod_merge.ConfigurableFileMerger):
2846
2934
            name_prefix = "foo"
2847
2935
            default_files = ['bar']
2848
2936
 
2849
2937
            def merge_text(self, params):
2850
 
                test.calls.append('merge_text')
 
2938
                calls.append('merge_text')
2851
2939
                return ('not_applicable', None)
2852
2940
 
2853
2941
        def factory(merger):
2887
2975
                        base=False, other=False)
2888
2976
        return builder
2889
2977
 
 
2978
    def test_uses_this_branch(self):
 
2979
        builder = self.make_text_conflict()
 
2980
        tt = builder.make_preview_transform()
 
2981
        self.addCleanup(tt.finalize)
 
2982
 
2890
2983
    def test_affected_files_cached(self):
2891
2984
        """Ensures that the config variable is cached"""
2892
2985
        builder = self.make_text_conflict()
2912
3005
        conflicts = builder.merge()
2913
3006
        # The hook should not call the merge_text() method
2914
3007
        self.assertEqual([], self.calls)
 
3008
 
 
3009
 
 
3010
class TestMergeIntoBase(tests.TestCaseWithTransport):
 
3011
 
 
3012
    def setup_simple_branch(self, relpath, shape=None, root_id=None):
 
3013
        """One commit, containing tree specified by optional shape.
 
3014
        
 
3015
        Default is empty tree (just root entry).
 
3016
        """
 
3017
        if root_id is None:
 
3018
            root_id = '%s-root-id' % (relpath,)
 
3019
        wt = self.make_branch_and_tree(relpath)
 
3020
        wt.set_root_id(root_id)
 
3021
        if shape is not None:
 
3022
            adjusted_shape = [relpath + '/' + elem for elem in shape]
 
3023
            self.build_tree(adjusted_shape)
 
3024
            ids = ['%s-%s-id' % (relpath, basename(elem.rstrip('/')))
 
3025
                   for elem in shape]
 
3026
            wt.add(shape, ids=ids)
 
3027
        rev_id = 'r1-%s' % (relpath,)
 
3028
        wt.commit("Initial commit of %s" % (relpath,), rev_id=rev_id)
 
3029
        self.assertEqual(root_id, wt.path2id(''))
 
3030
        return wt
 
3031
 
 
3032
    def setup_two_branches(self, custom_root_ids=True):
 
3033
        """Setup 2 branches, one will be a library, the other a project."""
 
3034
        if custom_root_ids:
 
3035
            root_id = None
 
3036
        else:
 
3037
            root_id = inventory.ROOT_ID
 
3038
        project_wt = self.setup_simple_branch(
 
3039
            'project', ['README', 'dir/', 'dir/file.c'],
 
3040
            root_id)
 
3041
        lib_wt = self.setup_simple_branch(
 
3042
            'lib1', ['README', 'Makefile', 'foo.c'], root_id)
 
3043
 
 
3044
        return project_wt, lib_wt
 
3045
 
 
3046
    def do_merge_into(self, location, merge_as):
 
3047
        """Helper for using MergeIntoMerger.
 
3048
        
 
3049
        :param location: location of directory to merge from, either the
 
3050
            location of a branch or of a path inside a branch.
 
3051
        :param merge_as: the path in a tree to add the new directory as.
 
3052
        :returns: the conflicts from 'do_merge'.
 
3053
        """
 
3054
        operation = cleanup.OperationWithCleanups(self._merge_into)
 
3055
        return operation.run(location, merge_as)
 
3056
 
 
3057
    def _merge_into(self, op, location, merge_as):
 
3058
        # Open and lock the various tree and branch objects
 
3059
        wt, subdir_relpath = WorkingTree.open_containing(merge_as)
 
3060
        op.add_cleanup(wt.lock_write().unlock)
 
3061
        branch_to_merge, subdir_to_merge = _mod_branch.Branch.open_containing(
 
3062
            location)
 
3063
        op.add_cleanup(branch_to_merge.lock_read().unlock)
 
3064
        other_tree = branch_to_merge.basis_tree()
 
3065
        op.add_cleanup(other_tree.lock_read().unlock)
 
3066
        # Perform the merge
 
3067
        merger = _mod_merge.MergeIntoMerger(this_tree=wt, other_tree=other_tree,
 
3068
            other_branch=branch_to_merge, target_subdir=subdir_relpath,
 
3069
            source_subpath=subdir_to_merge)
 
3070
        merger.set_base_revision(_mod_revision.NULL_REVISION, branch_to_merge)
 
3071
        conflicts = merger.do_merge()
 
3072
        merger.set_pending()
 
3073
        return conflicts
 
3074
 
 
3075
    def assertTreeEntriesEqual(self, expected_entries, tree):
 
3076
        """Assert that 'tree' contains the expected inventory entries.
 
3077
 
 
3078
        :param expected_entries: sequence of (path, file-id) pairs.
 
3079
        """
 
3080
        files = [(path, ie.file_id) for path, ie in tree.iter_entries_by_dir()]
 
3081
        self.assertEqual(expected_entries, files)
 
3082
 
 
3083
 
 
3084
class TestMergeInto(TestMergeIntoBase):
 
3085
 
 
3086
    def test_newdir_with_unique_roots(self):
 
3087
        """Merge a branch with a unique root into a new directory."""
 
3088
        project_wt, lib_wt = self.setup_two_branches()
 
3089
        self.do_merge_into('lib1', 'project/lib1')
 
3090
        project_wt.lock_read()
 
3091
        self.addCleanup(project_wt.unlock)
 
3092
        # The r1-lib1 revision should be merged into this one
 
3093
        self.assertEqual(['r1-project', 'r1-lib1'], project_wt.get_parent_ids())
 
3094
        self.assertTreeEntriesEqual(
 
3095
            [('', 'project-root-id'),
 
3096
             ('README', 'project-README-id'),
 
3097
             ('dir', 'project-dir-id'),
 
3098
             ('lib1', 'lib1-root-id'),
 
3099
             ('dir/file.c', 'project-file.c-id'),
 
3100
             ('lib1/Makefile', 'lib1-Makefile-id'),
 
3101
             ('lib1/README', 'lib1-README-id'),
 
3102
             ('lib1/foo.c', 'lib1-foo.c-id'),
 
3103
            ], project_wt)
 
3104
 
 
3105
    def test_subdir(self):
 
3106
        """Merge a branch into a subdirectory of an existing directory."""
 
3107
        project_wt, lib_wt = self.setup_two_branches()
 
3108
        self.do_merge_into('lib1', 'project/dir/lib1')
 
3109
        project_wt.lock_read()
 
3110
        self.addCleanup(project_wt.unlock)
 
3111
        # The r1-lib1 revision should be merged into this one
 
3112
        self.assertEqual(['r1-project', 'r1-lib1'], project_wt.get_parent_ids())
 
3113
        self.assertTreeEntriesEqual(
 
3114
            [('', 'project-root-id'),
 
3115
             ('README', 'project-README-id'),
 
3116
             ('dir', 'project-dir-id'),
 
3117
             ('dir/file.c', 'project-file.c-id'),
 
3118
             ('dir/lib1', 'lib1-root-id'),
 
3119
             ('dir/lib1/Makefile', 'lib1-Makefile-id'),
 
3120
             ('dir/lib1/README', 'lib1-README-id'),
 
3121
             ('dir/lib1/foo.c', 'lib1-foo.c-id'),
 
3122
            ], project_wt)
 
3123
 
 
3124
    def test_newdir_with_repeat_roots(self):
 
3125
        """If the file-id of the dir to be merged already exists a new ID will
 
3126
        be allocated to let the merge happen.
 
3127
        """
 
3128
        project_wt, lib_wt = self.setup_two_branches(custom_root_ids=False)
 
3129
        root_id = project_wt.path2id('')
 
3130
        self.do_merge_into('lib1', 'project/lib1')
 
3131
        project_wt.lock_read()
 
3132
        self.addCleanup(project_wt.unlock)
 
3133
        # The r1-lib1 revision should be merged into this one
 
3134
        self.assertEqual(['r1-project', 'r1-lib1'], project_wt.get_parent_ids())
 
3135
        new_lib1_id = project_wt.path2id('lib1')
 
3136
        self.assertNotEqual(None, new_lib1_id)
 
3137
        self.assertTreeEntriesEqual(
 
3138
            [('', root_id),
 
3139
             ('README', 'project-README-id'),
 
3140
             ('dir', 'project-dir-id'),
 
3141
             ('lib1', new_lib1_id),
 
3142
             ('dir/file.c', 'project-file.c-id'),
 
3143
             ('lib1/Makefile', 'lib1-Makefile-id'),
 
3144
             ('lib1/README', 'lib1-README-id'),
 
3145
             ('lib1/foo.c', 'lib1-foo.c-id'),
 
3146
            ], project_wt)
 
3147
 
 
3148
    def test_name_conflict(self):
 
3149
        """When the target directory name already exists a conflict is
 
3150
        generated and the original directory is renamed to foo.moved.
 
3151
        """
 
3152
        dest_wt = self.setup_simple_branch('dest', ['dir/', 'dir/file.txt'])
 
3153
        src_wt = self.setup_simple_branch('src', ['README'])
 
3154
        conflicts = self.do_merge_into('src', 'dest/dir')
 
3155
        self.assertEqual(1, conflicts)
 
3156
        dest_wt.lock_read()
 
3157
        self.addCleanup(dest_wt.unlock)
 
3158
        # The r1-lib1 revision should be merged into this one
 
3159
        self.assertEqual(['r1-dest', 'r1-src'], dest_wt.get_parent_ids())
 
3160
        self.assertTreeEntriesEqual(
 
3161
            [('', 'dest-root-id'),
 
3162
             ('dir', 'src-root-id'),
 
3163
             ('dir.moved', 'dest-dir-id'),
 
3164
             ('dir/README', 'src-README-id'),
 
3165
             ('dir.moved/file.txt', 'dest-file.txt-id'),
 
3166
            ], dest_wt)
 
3167
 
 
3168
    def test_file_id_conflict(self):
 
3169
        """A conflict is generated if the merge-into adds a file (or other
 
3170
        inventory entry) with a file-id that already exists in the target tree.
 
3171
        """
 
3172
        dest_wt = self.setup_simple_branch('dest', ['file.txt'])
 
3173
        # Make a second tree with a file-id that will clash with file.txt in
 
3174
        # dest.
 
3175
        src_wt = self.make_branch_and_tree('src')
 
3176
        self.build_tree(['src/README'])
 
3177
        src_wt.add(['README'], ids=['dest-file.txt-id'])
 
3178
        src_wt.commit("Rev 1 of src.", rev_id='r1-src')
 
3179
        conflicts = self.do_merge_into('src', 'dest/dir')
 
3180
        # This is an edge case that shouldn't happen to users very often.  So
 
3181
        # we don't care really about the exact presentation of the conflict,
 
3182
        # just that there is one.
 
3183
        self.assertEqual(1, conflicts)
 
3184
 
 
3185
    def test_only_subdir(self):
 
3186
        """When the location points to just part of a tree, merge just that
 
3187
        subtree.
 
3188
        """
 
3189
        dest_wt = self.setup_simple_branch('dest')
 
3190
        src_wt = self.setup_simple_branch(
 
3191
            'src', ['hello.txt', 'dir/', 'dir/foo.c'])
 
3192
        conflicts = self.do_merge_into('src/dir', 'dest/dir')
 
3193
        dest_wt.lock_read()
 
3194
        self.addCleanup(dest_wt.unlock)
 
3195
        # The r1-lib1 revision should NOT be merged into this one (this is a
 
3196
        # partial merge).
 
3197
        self.assertEqual(['r1-dest'], dest_wt.get_parent_ids())
 
3198
        self.assertTreeEntriesEqual(
 
3199
            [('', 'dest-root-id'),
 
3200
             ('dir', 'src-dir-id'),
 
3201
             ('dir/foo.c', 'src-foo.c-id'),
 
3202
            ], dest_wt)
 
3203
 
 
3204
    def test_only_file(self):
 
3205
        """An edge case: merge just one file, not a whole dir."""
 
3206
        dest_wt = self.setup_simple_branch('dest')
 
3207
        two_file_wt = self.setup_simple_branch(
 
3208
            'two-file', ['file1.txt', 'file2.txt'])
 
3209
        conflicts = self.do_merge_into('two-file/file1.txt', 'dest/file1.txt')
 
3210
        dest_wt.lock_read()
 
3211
        self.addCleanup(dest_wt.unlock)
 
3212
        # The r1-lib1 revision should NOT be merged into this one
 
3213
        self.assertEqual(['r1-dest'], dest_wt.get_parent_ids())
 
3214
        self.assertTreeEntriesEqual(
 
3215
            [('', 'dest-root-id'), ('file1.txt', 'two-file-file1.txt-id')],
 
3216
            dest_wt)
 
3217
 
 
3218
    def test_no_such_source_path(self):
 
3219
        """PathNotInTree is raised if the specified path in the source tree
 
3220
        does not exist.
 
3221
        """
 
3222
        dest_wt = self.setup_simple_branch('dest')
 
3223
        two_file_wt = self.setup_simple_branch('src', ['dir/'])
 
3224
        self.assertRaises(_mod_merge.PathNotInTree, self.do_merge_into,
 
3225
            'src/no-such-dir', 'dest/foo')
 
3226
        dest_wt.lock_read()
 
3227
        self.addCleanup(dest_wt.unlock)
 
3228
        # The dest tree is unmodified.
 
3229
        self.assertEqual(['r1-dest'], dest_wt.get_parent_ids())
 
3230
        self.assertTreeEntriesEqual([('', 'dest-root-id')], dest_wt)
 
3231
 
 
3232
    def test_no_such_target_path(self):
 
3233
        """PathNotInTree is also raised if the specified path in the target
 
3234
        tree does not exist.
 
3235
        """
 
3236
        dest_wt = self.setup_simple_branch('dest')
 
3237
        two_file_wt = self.setup_simple_branch('src', ['file.txt'])
 
3238
        self.assertRaises(_mod_merge.PathNotInTree, self.do_merge_into,
 
3239
            'src', 'dest/no-such-dir/foo')
 
3240
        dest_wt.lock_read()
 
3241
        self.addCleanup(dest_wt.unlock)
 
3242
        # The dest tree is unmodified.
 
3243
        self.assertEqual(['r1-dest'], dest_wt.get_parent_ids())
 
3244
        self.assertTreeEntriesEqual([('', 'dest-root-id')], dest_wt)