/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/benchmarks/tree_creator/kernel_like.py

First attempt to merge .dev and resolve the conflicts (but tests are 
failing)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
import os
21
21
 
22
22
from bzrlib import (
23
 
    add,
24
23
    bzrdir,
25
24
    osutils,
26
25
    workingtree,
31
30
 
32
31
 
33
32
class KernelLikeTreeCreator(TreeCreator):
34
 
    """Create a basic tree with ~10k unversioned files""" 
 
33
    """Create a basic tree with ~10k unversioned files"""
35
34
 
36
35
    def __init__(self, test, link_working=False, url=None):
37
36
        super(KernelLikeTreeCreator, self).__init__(test,
97
96
 
98
97
 
99
98
class KernelLikeAddedTreeCreator(TreeCreator):
 
99
    """Create a tree with ~10k versioned but not committed files"""
100
100
 
101
101
    def __init__(self, test, link_working=False, hot_cache=True):
102
102
        super(KernelLikeAddedTreeCreator, self).__init__(test,
118
118
        # Add everything to it
119
119
        tree.lock_write()
120
120
        try:
121
 
            add.smart_add_tree(tree, [root], recurse=True, save=True)
 
121
            tree.smart_add([root], recurse=True, save=True)
122
122
            if in_cache:
123
123
                self._protect_files(root+'/.bzr')
124
124
        finally:
188
188
        finally:
189
189
            f.close()
190
190
 
191
 
    def create(self):
 
191
    def create(self, root=None):
192
192
        """Create a kernel like inventory
193
193
 
 
194
        :param root: Exists to mimic the base class, but this class
 
195
            returns only an in-memory Inventory, so it should always be None.
194
196
        :return: An Inventory object.
195
197
        """
196
198
        cache_dir = self._get_cache_dir()
207
209
                                                 link_bzr=True,
208
210
                                                 hot_cache=False)
209
211
        tree = creator.create('.')
210
 
        return tree.basis_tree().inventory
 
212
        basis = tree.basis_tree()
 
213
        basis.lock_read()
 
214
        try:
 
215
            return basis.inventory
 
216
        finally:
 
217
            basis.unlock()
211
218
 
212
219
    def _open_cached(self, cache_dir):
213
220
        f = open(cache_dir + '/inventory', 'rb')