145
153
self._protect_files(root+'/.bzr')
157
class KernelLikeInventoryCreator(TreeCreator):
158
"""Return just the memory representation of a committed kernel-like tree"""
160
def __init__(self, test):
161
super(KernelLikeInventoryCreator, self).__init__(test,
162
tree_name='kernel_like_inventory',
167
def ensure_cached(self):
168
"""Make sure we have a cached version of the kernel-like inventory"""
169
cache_dir = self._get_cache_dir()
170
if cache_dir is None:
176
committed_creator = KernelLikeCommittedTreeCreator(self._test,
180
committed_creator.ensure_cached()
181
committed_cache_dir = committed_creator._get_cache_dir()
182
committed_tree = workingtree.WorkingTree.open(committed_cache_dir)
183
rev_tree = committed_tree.basis_tree()
185
f = open(cache_dir+'/inventory', 'wb')
187
xml5.serializer_v5.write_inventory(rev_tree.inventory, f)
192
"""Create a kernel like inventory
194
:return: An Inventory object.
196
cache_dir = self._get_cache_dir()
197
if cache_dir is None:
198
return self._create_and_return()
201
return self._open_cached(cache_dir)
203
def _create_and_return(self):
204
"""Create a kernel-like tree, and return its inventory"""
205
creator = KernelLikeCommittedTreeCreator(self._test,
209
tree = creator.create('.')
210
return tree.basis_tree().inventory
212
def _open_cached(self, cache_dir):
213
f = open(cache_dir + '/inventory', 'rb')
215
return xml5.serializer_v5.read_inventory(f)