~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-29 04:27:55 UTC
  • mfrom: (1852.9.7 Tree.changes_from().)
  • Revision ID: pqm@pqm.ubuntu.com-20060729042755-7a24d6edaaa13a32
(robertc) Add InterTree and Tree.changes_from, a replacement API for delta.compare_trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
 
62
62
    calls = []
63
63
 
64
 
    def compare(self):
65
 
        self.calls.append(('compare', self.source, self.target))
 
64
    def compare(self, want_unchanged=False, specific_files=None,
 
65
        extra_trees=None, require_versioned=False):
 
66
        self.calls.append(
 
67
            ('compare', self.source, self.target, want_unchanged,
 
68
             specific_files, extra_trees, require_versioned)
 
69
            )
66
70
    
67
71
    @classmethod
68
72
    def is_compatible(klass, source, target):
72
76
class TestTree(TestCaseWithTransport):
73
77
 
74
78
    def test_compare_calls_InterTree_compare(self):
 
79
        """This test tests the way Tree.compare() uses InterTree."""
75
80
        old_optimisers = InterTree._optimisers
76
81
        try:
77
82
            InterTree._optimisers = set()
79
84
            InterTree.register_optimiser(RecordingOptimiser)
80
85
            tree = self.make_branch_and_tree('1')
81
86
            tree2 = self.make_branch_and_tree('2')
 
87
            # do a series of calls:
 
88
            # trivial usage
82
89
            tree.changes_from(tree2)
 
90
            # pass in all optional arguments by position
 
91
            tree.changes_from(tree2, 'unchanged', 'specific', 'extra', 'require')
 
92
            # pass in all optional arguments by keyword
 
93
            tree.changes_from(tree2,
 
94
                specific_files='specific',
 
95
                want_unchanged='unchanged',
 
96
                extra_trees='extra',
 
97
                require_versioned='require',
 
98
                )
83
99
        finally:
84
100
            InterTree._optimisers = old_optimisers
85
 
        self.assertEqual([('compare', tree2, tree)], RecordingOptimiser.calls)
 
101
        self.assertEqual(
 
102
            [
 
103
             ('compare', tree2, tree, False, None, None, False),
 
104
             ('compare', tree2, tree, 'unchanged', 'specific', 'extra', 'require'),
 
105
             ('compare', tree2, tree, 'unchanged', 'specific', 'extra', 'require'),
 
106
            ], RecordingOptimiser.calls)