~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_missing.py

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 18:59:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504185936-1mjdoqmtz74xe5mg
A C implementation of _fields_to_entry_0_parents drops the time from 400ms to 330ms for a 21k-entry tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
 
19
19
 
20
 
from bzrlib.missing import (
21
 
    find_unmerged,
22
 
    iter_log_data,
23
 
    iter_log_revisions,
24
 
    )
25
 
from bzrlib.symbol_versioning import zero_seventeen
 
20
from bzrlib.builtins import merge
 
21
from bzrlib.missing import find_unmerged, iter_log_data
26
22
from bzrlib.tests import TestCaseWithTransport
27
23
from bzrlib.workingtree import WorkingTree
28
24
 
51
47
        self.assertEqual(find_unmerged(original, puller), ([], []))
52
48
        self.assertEqual(find_unmerged(original, merger), ([(2, u'b'), 
53
49
                                                            (3, u'c')], []))
54
 
        merger_tree.merge_from_branch(original)
 
50
        merge(['original', -1], [None, None], this_dir='merger')
55
51
        self.assertEqual(find_unmerged(original, merger), ([(2, u'b'), 
56
52
                                                            (3, u'c')], []))
57
53
        merger_tree.commit('d', rev_id='d')
80
76
 
81
77
        base_extra, child_extra = find_unmerged(base_tree.branch,
82
78
                                                child_tree.branch)
83
 
        results = list(self.applyDeprecated(zero_seventeen, iter_log_data,
84
 
                            base_extra,
85
 
                            base_tree.branch.repository,
86
 
                            verbose=True))
 
79
        results = list(iter_log_data(base_extra, base_tree.branch.repository,
 
80
                                     verbose=True))
87
81
        self.assertEqual([], results)
88
82
 
89
 
        results = list(self.applyDeprecated(zero_seventeen, iter_log_data,
90
 
                            child_extra,
91
 
                            child_tree.branch.repository,
92
 
                            verbose=True))
 
83
        results = list(iter_log_data(child_extra, child_tree.branch.repository,
 
84
                                     verbose=True))
93
85
        self.assertEqual(4, len(results))
94
86
 
95
87
        r0,r1,r2,r3 = results
127
119
        self.assertEqual([('b', 'c', 'b-id', 'file', False, False)],
128
120
                         delta3.renamed)
129
121
        self.assertEqual([], delta3.modified)
130
 
 
131
 
    def test_iter_log_revisions(self):
132
 
        base_tree = self.make_branch_and_tree('base')
133
 
        self.build_tree(['base/a'])
134
 
        base_tree.add(['a'], ['a-id'])
135
 
        base_tree.commit('add a', rev_id='b-1')
136
 
 
137
 
        child_tree = base_tree.bzrdir.sprout('child').open_workingtree()
138
 
 
139
 
        self.build_tree(['child/b'])
140
 
        child_tree.add(['b'], ['b-id'])
141
 
        child_tree.commit('adding b', rev_id='c-2')
142
 
 
143
 
        child_tree.remove(['a'])
144
 
        child_tree.commit('removing a', rev_id='c-3')
145
 
 
146
 
        self.build_tree_contents([('child/b', 'new contents for b\n')])
147
 
        child_tree.commit('modifying b', rev_id='c-4')
148
 
 
149
 
        child_tree.rename_one('b', 'c')
150
 
        child_tree.commit('rename b=>c', rev_id='c-5')
151
 
 
152
 
        base_extra, child_extra = find_unmerged(base_tree.branch,
153
 
                                                child_tree.branch)
154
 
        results = list(iter_log_revisions(base_extra, 
155
 
                            base_tree.branch.repository,
156
 
                            verbose=True))
157
 
        self.assertEqual([], results)
158
 
 
159
 
        results = list(iter_log_revisions(child_extra,
160
 
                            child_tree.branch.repository,
161
 
                            verbose=True))
162
 
        self.assertEqual(4, len(results))
163
 
 
164
 
        r0,r1,r2,r3 = results
165
 
 
166
 
        self.assertEqual((2, 'c-2'), (r0.revno, r0.rev.revision_id))
167
 
        self.assertEqual((3, 'c-3'), (r1.revno, r1.rev.revision_id))
168
 
        self.assertEqual((4, 'c-4'), (r2.revno, r2.rev.revision_id))
169
 
        self.assertEqual((5, 'c-5'), (r3.revno, r3.rev.revision_id))
170
 
 
171
 
        delta0 = r0.delta
172
 
        self.assertNotEqual(None, delta0)
173
 
        self.assertEqual([('b', 'b-id', 'file')], delta0.added)
174
 
        self.assertEqual([], delta0.removed)
175
 
        self.assertEqual([], delta0.renamed)
176
 
        self.assertEqual([], delta0.modified)
177
 
 
178
 
        delta1 = r1.delta
179
 
        self.assertNotEqual(None, delta1)
180
 
        self.assertEqual([], delta1.added)
181
 
        self.assertEqual([('a', 'a-id', 'file')], delta1.removed)
182
 
        self.assertEqual([], delta1.renamed)
183
 
        self.assertEqual([], delta1.modified)
184
 
 
185
 
        delta2 = r2.delta
186
 
        self.assertNotEqual(None, delta2)
187
 
        self.assertEqual([], delta2.added)
188
 
        self.assertEqual([], delta2.removed)
189
 
        self.assertEqual([], delta2.renamed)
190
 
        self.assertEqual([('b', 'b-id', 'file', True, False)], delta2.modified)
191
 
 
192
 
        delta3 = r3.delta
193
 
        self.assertNotEqual(None, delta3)
194
 
        self.assertEqual([], delta3.added)
195
 
        self.assertEqual([], delta3.removed)
196
 
        self.assertEqual([('b', 'c', 'b-id', 'file', False, False)],
197
 
                         delta3.renamed)
198
 
        self.assertEqual([], delta3.modified)