88
89
return self.build_helper([(10, 0), (10, 0), (10, 20)])
90
def test_build_20k_dirblocks(self):
91
def build_20k_dirstate_with_parents(self, num_parents):
92
"""Build a DirState file with 20k records and N parents.
94
With 1 parent, this is equivalent to after a simple commit. With 2 it
95
is equivalent to after a merge.
97
# All files are marked as changed in the same revision, and this occurs
98
# supposedly in the history of the current trees.
99
last_changed_id = generate_ids.gen_revision_id('joe@foo.com')
100
parent_revision_ids = [generate_ids.gen_revision_id('joe@foo.com')
101
for i in xrange(num_parents)]
102
# Start with a dirstate file with 0 parents
103
state = self.build_20k_dirstate()
106
# This invasively updates the internals of DirState to be fast,
107
# since we don't have an api other than passing in Revision Tree
108
# objects, but that requires having a real inventory, etc.
109
for entry in state._iter_entries():
110
minikind, fingerprint, size, is_exec, packed_stat = entry[1][0]
111
for parent_id in parent_revision_ids:
112
# Add a parent record for this record
113
entry[1].append((minikind, fingerprint, size, is_exec,
115
state._parents = parent_revision_ids
117
state._dirblock_state = dirstate.DirState.IN_MEMORY_MODIFIED
118
state._header_state = dirstate.DirState.IN_MEMORY_MODIFIED
125
def test_build_20k_dirstate(self):
91
126
state = self.time(self.build_20k_dirstate)
99
def test__py_read_dirblocks_20k_tree_no_parents(self):
100
state = self.build_20k_dirstate()
103
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
104
state._dirblock_state)
105
state._read_header_if_needed()
106
self.time(dirstate._py_read_dirblocks, state)
110
def test__c_read_dirblocks_20k_tree_no_parents(self):
111
self.requireFeature(CompiledDirstateHelpersFeature)
112
from bzrlib.compiled.dirstate_helpers import _c_read_dirblocks
113
state = self.build_20k_dirstate()
134
def test_build_20k_dirstate_1_parent(self):
135
state = self.time(self.build_20k_dirstate_with_parents, 1)
139
entries = list(state._iter_entries())
140
self.assertEqual(21111, len(entries))
144
def test_build_20k_dirstate_2_parents(self):
145
state = self.time(self.build_20k_dirstate_with_parents, 2)
149
entries = list(state._iter_entries())
150
self.assertEqual(21111, len(entries))
154
def test__py_read_dirblocks_20k_tree_0_parents(self):
155
state = self.build_20k_dirstate()
158
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
159
state._dirblock_state)
160
state._read_header_if_needed()
161
self.time(dirstate._py_read_dirblocks, state)
165
def test__c_read_dirblocks_20k_tree_0_parents(self):
166
self.requireFeature(CompiledDirstateHelpersFeature)
167
from bzrlib.compiled.dirstate_helpers import _c_read_dirblocks
168
state = self.build_20k_dirstate()
171
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
172
state._dirblock_state)
173
state._read_header_if_needed()
174
self.time(_c_read_dirblocks, state)
178
def test__py_read_dirblocks_20k_tree_1_parent(self):
179
state = self.build_20k_dirstate_with_parents(1)
182
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
183
state._dirblock_state)
184
state._read_header_if_needed()
185
self.time(dirstate._py_read_dirblocks, state)
189
def test__c_read_dirblocks_20k_tree_1_parent(self):
190
self.requireFeature(CompiledDirstateHelpersFeature)
191
from bzrlib.compiled.dirstate_helpers import _c_read_dirblocks
192
state = self.build_20k_dirstate_with_parents(1)
195
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
196
state._dirblock_state)
197
state._read_header_if_needed()
198
self.time(_c_read_dirblocks, state)
202
def test__py_read_dirblocks_20k_tree_2_parents(self):
203
state = self.build_20k_dirstate_with_parents(2)
206
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,
207
state._dirblock_state)
208
state._read_header_if_needed()
209
self.time(dirstate._py_read_dirblocks, state)
213
def test__c_read_dirblocks_20k_tree_2_parents(self):
214
self.requireFeature(CompiledDirstateHelpersFeature)
215
from bzrlib.compiled.dirstate_helpers import _c_read_dirblocks
216
state = self.build_20k_dirstate_with_parents(2)
114
217
state.lock_read()
116
219
self.assertEqual(dirstate.DirState.NOT_IN_MEMORY,