145
147
self._protect_files(root+'/.bzr')
151
class KernelLikeInventoryCreator(TreeCreator):
152
"""Return just the memory representation of a committed kernel-like tree"""
154
def __init__(self, test):
155
super(KernelLikeInventoryCreator, self).__init__(test,
156
tree_name='kernel_like_inventory',
161
def ensure_cached(self):
162
"""Make sure we have a cached version of the kernel-like inventory"""
163
cache_dir = self._get_cache_dir()
164
if cache_dir is None:
170
committed_creator = KernelLikeCommittedTreeCreator(self._test,
174
committed_creator.ensure_cached()
175
committed_cache_dir = committed_creator._get_cache_dir()
176
committed_tree = workingtree.WorkingTree.open(committed_cache_dir)
177
rev_tree = committed_tree.basis_tree()
179
f = open(cache_dir+'/inventory', 'wb')
181
xml5.serializer_v5.write_inventory(rev_tree.inventory, f)
186
"""Create a kernel like inventory
188
:return: An Inventory object.
190
cache_dir = self._get_cache_dir()
191
if cache_dir is None:
192
return self._create_and_return()
195
return self._open_cached(cache_dir)
197
def _create_and_return(self):
198
"""Create a kernel-like tree, and return its inventory"""
199
creator = KernelLikeCommittedTreeCreator(self._test,
203
tree = creator.create('.')
204
return tree.basis_tree().inventory
206
def _open_cached(self, cache_dir):
207
f = open(cache_dir + '/inventory', 'rb')
209
return xml5.serializer_v5.read_inventory(f)