84
84
hot_cache=hot_cache)
85
85
return creator.create(root=root)
87
def _create_many_commit_tree(self, root, in_cache=False):
88
tree = bzrdir.BzrDir.create_standalone_workingtree(root)
91
for i in xrange(1000):
92
tree.commit('no-changes commit %d' % i)
96
self._protect_files(root+'/.bzr')
100
87
def make_many_commit_tree(self, directory_name='.',
102
89
"""Create a tree with many commits.
104
91
No file changes are included. Not hardlinking the working tree,
105
92
because there are no working tree files.
107
cache_dir, is_cached = self.get_cache_dir('many_commit_tree')
108
if cache_dir is None:
109
return self._create_many_commit_tree(root=directory_name,
113
self._create_many_commit_tree(root=cache_dir, in_cache=True)
115
return self._clone_tree(cache_dir, directory_name,
119
def _create_heavily_merged_tree(self, root, in_cache=False):
122
except (IOError, OSError), e:
123
if e.errno not in (errno.EEXIST,):
126
tree = bzrdir.BzrDir.create_standalone_workingtree(
130
tree2 = tree.bzrdir.sprout(root + '/tree2').open_workingtree()
133
for i in xrange(250):
134
revision_id = tree.commit('no-changes commit %d-a' % i)
135
tree2.branch.fetch(tree.branch, revision_id)
136
tree2.set_pending_merges([revision_id])
137
revision_id = tree2.commit('no-changes commit %d-b' % i)
138
tree.branch.fetch(tree2.branch, revision_id)
139
tree.set_pending_merges([revision_id])
140
tree.set_pending_merges([])
146
self._protect_files(root+'/tree1/.bzr')
94
creator = SimpleManyCommitTreeCreator(self, link_bzr=hardlink)
95
return creator.create(root=directory_name)
149
97
def make_heavily_merged_tree(self, directory_name='.',
156
104
tree. Not hardlinking the working tree, because there are no working
159
cache_dir, is_cached = self.get_cache_dir('heavily_merged_tree')
160
if cache_dir is None:
162
return self._create_heavily_merged_tree(root=directory_name,
166
self._create_heavily_merged_tree(root=cache_dir, in_cache=True)
168
tree_dir = cache_dir + '/tree1'
169
return self._clone_tree(tree_dir, directory_name,
107
creator = HeavilyMergedTreeCreator(self, link_bzr=hardlink)
108
return creator.create(root=directory_name)
174
111
class TreeCreator(object):
406
343
class KernelLikeCommittedTreeCreator(TreeCreator):
344
"""Create a tree with ~10K files, and a single commit adding all of them"""
408
346
def __init__(self, test, link_working=False, link_bzr=False,
414
352
hot_cache=hot_cache)
416
354
def _create_tree(self, root, in_cache=False):
417
"""Create a kernel-like tree with the all files added
355
"""Create a kernel-like tree with all files committed
419
357
:param root: The root directory to create the files
420
358
:param in_cache: Is this being created in the cache dir?
371
class SimpleManyCommitTreeCreator(TreeCreator):
372
"""Create an empty tree with lots of commits"""
374
def __init__(self, test, link_bzr=False):
375
super(SimpleManyCommitTreeCreator, self).__init__(test,
376
tree_name='many_commit_tree',
381
def _create_tree(self, root, in_cache=False):
382
tree = bzrdir.BzrDir.create_standalone_workingtree(root)
385
for i in xrange(1000):
386
tree.commit('no-changes commit %d' % i)
390
self._protect_files(root+'/.bzr')
395
class HeavilyMergedTreeCreator(TreeCreator):
396
"""Create a tree in which almost every commit is a merge.
398
No file changes are included. This produces two trees,
399
one of which is returned. Except for the first commit, every
400
commit in its revision-history is a merge of another commit in the other
402
Not hardlinking the working tree, because there are no working tree files.
405
def __init__(self, test, link_bzr=True):
406
super(HeavilyMergedTreeCreator, self).__init__(test,
407
tree_name='heavily_merged_tree',
412
def _create_tree(self, root, in_cache=False):
415
except (IOError, OSError), e:
416
if e.errno not in (errno.EEXIST,):
419
tree = bzrdir.BzrDir.create_standalone_workingtree(root)
422
tree2 = tree.bzrdir.sprout(root + '/tree2').open_workingtree()
425
for i in xrange(250):
426
revision_id = tree.commit('no-changes commit %d-a' % i)
427
tree2.branch.fetch(tree.branch, revision_id)
428
tree2.set_pending_merges([revision_id])
429
revision_id = tree2.commit('no-changes commit %d-b' % i)
430
tree.branch.fetch(tree2.branch, revision_id)
431
tree.set_pending_merges([revision_id])
432
tree.set_pending_merges([])
438
self._protect_files(root+'/.bzr')
434
442
def test_suite():
435
443
"""Build and return a TestSuite which contains benchmark tests only."""