/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 breezy/tests/test_merge.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
        with merger.make_preview_transform() as tt:
138
138
            self.assertEqual([], tt.find_conflicts())
139
139
            preview = tt.get_preview_tree()
140
 
            self.assertEqual(wt.get_root_id(), preview.get_root_id())
 
140
            self.assertEqual(wt.path2id(''), preview.path2id(''))
141
141
 
142
142
    def test_merge_unrelated_retains_root(self):
143
143
        wt = self.make_branch_and_tree('tree')
149
149
        with transform.TransformPreview(wt) as merger.tt:
150
150
            merger._compute_transform()
151
151
            new_root_id = merger.tt.final_file_id(merger.tt.root)
152
 
            self.assertEqual(wt.get_root_id(), new_root_id)
 
152
            self.assertEqual(wt.path2id(''), new_root_id)
153
153
 
154
154
    def test_create_rename(self):
155
155
        """Rename an inventory entry while creating the file"""
511
511
        self.build_tree(['a'])
512
512
        tree.add('a')
513
513
        first_rev = tree.commit("added a")
514
 
        old_root_id = tree.get_root_id()
 
514
        old_root_id = tree.path2id('')
515
515
        merger = _mod_merge.Merger.from_revision_ids(tree,
516
516
                                                     _mod_revision.NULL_REVISION,
517
517
                                                     first_rev)
3179
3179
        :param merge_as: the path in a tree to add the new directory as.
3180
3180
        :returns: the conflicts from 'do_merge'.
3181
3181
        """
3182
 
        operation = cleanup.OperationWithCleanups(self._merge_into)
3183
 
        return operation.run(location, merge_as)
3184
 
 
3185
 
    def _merge_into(self, op, location, merge_as):
3186
 
        # Open and lock the various tree and branch objects
3187
 
        wt, subdir_relpath = WorkingTree.open_containing(merge_as)
3188
 
        op.add_cleanup(wt.lock_write().unlock)
3189
 
        branch_to_merge, subdir_to_merge = _mod_branch.Branch.open_containing(
3190
 
            location)
3191
 
        op.add_cleanup(branch_to_merge.lock_read().unlock)
3192
 
        other_tree = branch_to_merge.basis_tree()
3193
 
        op.add_cleanup(other_tree.lock_read().unlock)
3194
 
        # Perform the merge
3195
 
        merger = _mod_merge.MergeIntoMerger(
3196
 
            this_tree=wt, other_tree=other_tree, other_branch=branch_to_merge,
3197
 
            target_subdir=subdir_relpath, source_subpath=subdir_to_merge)
3198
 
        merger.set_base_revision(_mod_revision.NULL_REVISION, branch_to_merge)
3199
 
        conflicts = merger.do_merge()
3200
 
        merger.set_pending()
3201
 
        return conflicts
 
3182
        with cleanup.ExitStack() as stack:
 
3183
            # Open and lock the various tree and branch objects
 
3184
            wt, subdir_relpath = WorkingTree.open_containing(merge_as)
 
3185
            stack.enter_context(wt.lock_write())
 
3186
            branch_to_merge, subdir_to_merge = _mod_branch.Branch.open_containing(
 
3187
                location)
 
3188
            stack.enter_context(branch_to_merge.lock_read())
 
3189
            other_tree = branch_to_merge.basis_tree()
 
3190
            stack.enter_context(other_tree.lock_read())
 
3191
            # Perform the merge
 
3192
            merger = _mod_merge.MergeIntoMerger(
 
3193
                this_tree=wt, other_tree=other_tree, other_branch=branch_to_merge,
 
3194
                target_subdir=subdir_relpath, source_subpath=subdir_to_merge)
 
3195
            merger.set_base_revision(_mod_revision.NULL_REVISION, branch_to_merge)
 
3196
            conflicts = merger.do_merge()
 
3197
            merger.set_pending()
 
3198
            return conflicts
3202
3199
 
3203
3200
    def assertTreeEntriesEqual(self, expected_entries, tree):
3204
3201
        """Assert that 'tree' contains the expected inventory entries.