2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
1908.2.16
by John Arbash Meinel
Move all the new TreeCreator classes into separate files. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
||
17 |
"""Tree creator for many commits, but no changes"""
|
|
18 |
||
19 |
import errno |
|
20 |
import os |
|
21 |
||
22 |
from bzrlib import ( |
|
23 |
bzrdir, |
|
24 |
)
|
|
25 |
||
26 |
from bzrlib.benchmarks.tree_creator import TreeCreator |
|
27 |
||
28 |
||
29 |
class HeavilyMergedTreeCreator(TreeCreator): |
|
30 |
"""Create a tree in which almost every commit is a merge.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
31 |
|
32 |
No file changes are included. This produces two trees,
|
|
1908.2.16
by John Arbash Meinel
Move all the new TreeCreator classes into separate files. |
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
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
35 |
tree.
|
1908.2.16
by John Arbash Meinel
Move all the new TreeCreator classes into separate files. |
36 |
Not hardlinking the working tree, because there are no working tree files.
|
37 |
"""
|
|
38 |
||
39 |
def __init__(self, test, link_bzr=True): |
|
40 |
super(HeavilyMergedTreeCreator, self).__init__(test, |
|
41 |
tree_name='heavily_merged_tree', |
|
42 |
link_bzr=link_bzr, |
|
43 |
link_working=False, |
|
44 |
hot_cache=True) |
|
45 |
||
46 |
def _create_tree(self, root, in_cache=False): |
|
47 |
try: |
|
48 |
os.mkdir(root) |
|
49 |
except (IOError, OSError), e: |
|
50 |
if e.errno not in (errno.EEXIST,): |
|
51 |
raise
|
|
52 |
||
53 |
tree = bzrdir.BzrDir.create_standalone_workingtree(root) |
|
54 |
tree.lock_write() |
|
55 |
try: |
|
56 |
tree2 = tree.bzrdir.sprout(root + '/tree2').open_workingtree() |
|
57 |
tree2.lock_write() |
|
58 |
try: |
|
59 |
for i in xrange(250): |
|
60 |
revision_id = tree.commit('no-changes commit %d-a' % i) |
|
61 |
tree2.branch.fetch(tree.branch, revision_id) |
|
1908.6.7
by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly. |
62 |
tree2.add_parent_tree_id(revision_id) |
1908.2.16
by John Arbash Meinel
Move all the new TreeCreator classes into separate files. |
63 |
revision_id = tree2.commit('no-changes commit %d-b' % i) |
64 |
tree.branch.fetch(tree2.branch, revision_id) |
|
1908.6.7
by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly. |
65 |
tree.add_parent_tree_id(revision_id) |
66 |
tree.set_parent_ids(tree.get_parent_ids()[:1]) |
|
1908.2.16
by John Arbash Meinel
Move all the new TreeCreator classes into separate files. |
67 |
finally: |
68 |
tree2.unlock() |
|
69 |
finally: |
|
70 |
tree.unlock() |
|
71 |
if in_cache: |
|
72 |
self._protect_files(root+'/.bzr') |
|
73 |
return tree |
|
74 |
||
75 |