~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_into.py

  • Committer: Andrew Bennetts
  • Date: 2010-06-25 06:47:40 UTC
  • mto: (5050.3.16 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: andrew.bennetts@canonical.com-20100625064740-k93ngat248kdcqdm
Remove merge_into_helper for now, as it currently has no callers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Whitebox testing for merge_into functionality."""
18
18
 
19
19
from bzrlib import (
 
20
    branch as _mod_branch,
20
21
    cleanup,
21
22
    inventory,
22
23
    merge,
23
24
    osutils,
 
25
    revision as _mod_revision,
24
26
    tests,
 
27
    workingtree,
25
28
    )
26
29
 
27
30
 
61
64
 
62
65
        return project_wt, lib_wt
63
66
 
64
 
    def do_merge_into(self, location, merge_as=None):
65
 
        """Invoke merge_into_helper."""
66
 
        operation = cleanup.OperationWithCleanups(merge.merge_into_helper)
67
 
        return operation.run_simple(location, operation.add_cleanup, merge_as)
 
67
    def do_merge_into(self, location, merge_as):
 
68
        """Helper for using MergeIntoMerger.
 
69
        
 
70
        :param location: location of directory to merge from, either the
 
71
            location of a branch or of a path inside a branch.
 
72
        :param merge_as: the path in a tree to add the new directory as.
 
73
        :returns: the conflicts from 'do_merge'.
 
74
        """
 
75
        operation = cleanup.OperationWithCleanups(self._merge_into)
 
76
        return operation.run(location, merge_as)
 
77
 
 
78
    def _merge_into(self, op, location, merge_as):
 
79
        # Open and lock the various tree and branch objects
 
80
        wt, subdir_relpath = workingtree.WorkingTree.open_containing(merge_as)
 
81
        op.add_cleanup(wt.lock_write().unlock)
 
82
        branch_to_merge, subdir_to_merge = _mod_branch.Branch.open_containing(
 
83
            location)
 
84
        op.add_cleanup(branch_to_merge.lock_read().unlock)
 
85
        other_tree = branch_to_merge.basis_tree()
 
86
        op.add_cleanup(other_tree.lock_read().unlock)
 
87
        # Perform the merge
 
88
        merger = merge.MergeIntoMerger(this_tree=wt, other_tree=other_tree,
 
89
            other_branch=branch_to_merge, target_subdir=subdir_relpath,
 
90
            source_subpath=subdir_to_merge)
 
91
        merger.set_base_revision(_mod_revision.NULL_REVISION, branch_to_merge)
 
92
        conflicts = merger.do_merge()
 
93
        merger.set_pending()
 
94
        return conflicts
68
95
 
69
96
    def assertTreeEntriesEqual(self, expected_entries, tree):
70
97
        """Assert that 'tree' contains the expected inventory entries.