85
85
self.build_tree(files)
88
def _cache_kernel_like_tree(self):
89
"""Create the kernel_like_tree cache dir if it doesn't exist"""
90
cache_dir, is_cached = self.get_cache_dir('kernel_like_tree')
94
self._make_kernel_files(root=cache_dir)
95
self._protect_files(cache_dir)
88
98
def _link_or_copy_kernel_files(self, root, do_link=True):
89
99
"""Hardlink the kernel files from the cached location.
101
111
self._make_kernel_files(root=root)
104
cache_dir, is_cached = self.get_cache_dir('kernel_like_tree')
107
self._make_kernel_files(root=cache_dir)
108
self._protect_files(cache_dir)
114
cache_dir = self._cache_kernel_like_tree()
110
116
# Hardlinking the target directory is *much* faster (7s => <1s).
111
117
osutils.copy_tree(cache_dir, root,
156
162
if kind == 'file':
157
163
os.chmod(abspath, 0440)
165
def _cache_kernel_like_added_tree(self):
166
cache_dir, is_cached = self.get_cache_dir('kernel_like_added_tree')
170
# Get a basic tree with working files
171
tree = self.make_kernel_like_tree(root=cache_dir,
172
hardlink_working=True)
173
# Add everything to it
174
add.smart_add_tree(tree, [cache_dir], recurse=True, save=True)
176
self._protect_files(cache_dir+'/.bzr')
159
179
def make_kernel_like_added_tree(self, root='.',
160
180
hardlink_working=True):
161
181
"""Make a kernel like tree, with all files added
168
188
# There isn't much underneath .bzr, so we don't support hardlinking
169
189
# it. Testing showed there wasn't much gain, and there is potentially
170
190
# a problem if someone modifies something underneath us.
171
cache_dir, is_cached = self.get_cache_dir('kernel_like_added_tree')
173
# Get a basic tree with working files
174
tree = self.make_kernel_like_tree(root=cache_dir,
175
hardlink_working=True)
176
# Add everything to it
177
add.smart_add_tree(tree, [cache_dir], recurse=True, save=True)
179
self._protect_files(cache_dir+'/.bzr')
191
cache_dir = self._cache_kernel_like_added_tree()
181
193
self._clone_tree(cache_dir, root,
182
194
link_working=hardlink_working)
183
195
return workingtree.WorkingTree.open(root)
197
def _cache_kernel_like_committed_tree(self):
198
cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree')
202
# Get a basic tree with working files
203
tree = self.make_kernel_like_added_tree(root=cache_dir,
204
hardlink_working=True)
205
tree.commit('first post', rev_id='r1')
207
self._protect_files(cache_dir+'/.bzr')
185
210
def make_kernel_like_committed_tree(self, root='.',
186
211
hardlink_working=True,
187
212
hardlink_bzr=False):
194
219
:param hardlink_bzr: Hardlink the .bzr directory. For readonly
195
220
operations this is safe, and shaves off a lot of setup time
197
cache_dir, is_cached = self.get_cache_dir('kernel_like_committed_tree')
199
# Get a basic tree with working files
200
tree = self.make_kernel_like_added_tree(root=cache_dir,
201
hardlink_working=True)
202
tree.commit('first post', rev_id='r1')
204
self._protect_files(cache_dir+'/.bzr')
222
cache_dir = self._cache_kernel_like_committed_tree()
206
224
# Now we have a cached tree, just copy it
207
225
self._clone_tree(cache_dir, root,