1
# Copyright (C) 2006 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Tree creator for many commits, but no changes"""
26
from bzrlib.benchmarks.tree_creator import TreeCreator
29
class HeavilyMergedTreeCreator(TreeCreator):
30
"""Create a tree in which almost every commit is a merge.
32
No file changes are included. This produces two trees,
33
one of which is returned. Except for the first commit, every
34
commit in its revision-history is a merge of another commit in the other
36
Not hardlinking the working tree, because there are no working tree files.
39
def __init__(self, test, link_bzr=True):
40
super(HeavilyMergedTreeCreator, self).__init__(test,
41
tree_name='heavily_merged_tree',
46
def _create_tree(self, root, in_cache=False):
49
except (IOError, OSError), e:
50
if e.errno not in (errno.EEXIST,):
53
tree = bzrdir.BzrDir.create_standalone_workingtree(root)
56
tree2 = tree.bzrdir.sprout(root + '/tree2').open_workingtree()
60
revision_id = tree.commit('no-changes commit %d-a' % i)
61
tree2.branch.fetch(tree.branch, revision_id)
62
tree2.add_parent_tree_id(revision_id)
63
revision_id = tree2.commit('no-changes commit %d-b' % i)
64
tree.branch.fetch(tree2.branch, revision_id)
65
tree.add_parent_tree_id(revision_id)
66
tree.set_parent_ids(tree.get_parent_ids()[:1])
72
self._protect_files(root+'/.bzr')