~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_tree.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
62
62
    calls = []
63
63
 
64
64
    def compare(self, want_unchanged=False, specific_files=None,
65
 
        extra_trees=None, require_versioned=False):
 
65
        extra_trees=None, require_versioned=False, include_root=False):
66
66
        self.calls.append(
67
67
            ('compare', self.source, self.target, want_unchanged,
68
 
             specific_files, extra_trees, require_versioned)
 
68
             specific_files, extra_trees, require_versioned, 
 
69
             include_root)
69
70
            )
70
71
    
71
72
    @classmethod
79
80
        """This test tests the way Tree.compare() uses InterTree."""
80
81
        old_optimisers = InterTree._optimisers
81
82
        try:
82
 
            InterTree._optimisers = set()
 
83
            InterTree._optimisers = []
83
84
            RecordingOptimiser.calls = []
84
85
            InterTree.register_optimiser(RecordingOptimiser)
85
86
            tree = self.make_branch_and_tree('1')
88
89
            # trivial usage
89
90
            tree.changes_from(tree2)
90
91
            # pass in all optional arguments by position
91
 
            tree.changes_from(tree2, 'unchanged', 'specific', 'extra', 'require')
 
92
            tree.changes_from(tree2, 'unchanged', 'specific', 'extra', 
 
93
                              'require', True)
92
94
            # pass in all optional arguments by keyword
93
95
            tree.changes_from(tree2,
94
96
                specific_files='specific',
95
97
                want_unchanged='unchanged',
96
98
                extra_trees='extra',
97
99
                require_versioned='require',
 
100
                include_root=True,
98
101
                )
99
102
        finally:
100
103
            InterTree._optimisers = old_optimisers
101
104
        self.assertEqual(
102
105
            [
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
             ('compare', tree2, tree, False, None, None, False, False),
 
107
             ('compare', tree2, tree, 'unchanged', 'specific', 'extra',
 
108
              'require', True),
 
109
             ('compare', tree2, tree, 'unchanged', 'specific', 'extra',
 
110
              'require', True),
106
111
            ], RecordingOptimiser.calls)
 
112
 
 
113
    def test_changes_from_with_root(self):
 
114
        """Ensure the include_root option does what's expected."""
 
115
        wt = self.make_branch_and_tree('.')
 
116
        delta = wt.changes_from(wt.basis_tree())
 
117
        self.assertEqual(len(delta.added), 0)
 
118
        delta = wt.changes_from(wt.basis_tree(), wt, include_root=True)
 
119
        self.assertEqual(len(delta.added), 1)
 
120
        self.assertEqual(delta.added[0][0], '')