335
335
elif kind == 'directory':
336
336
# add this entry to the parent map.
337
337
parent_ies[(dirname + '/' + name).strip('/')] = inv_entry
338
elif kind == 'tree-reference':
339
inv_entry.reference_revision = link_or_sha1
341
assert 'unknown kind'
338
342
# These checks cost us around 40ms on a 55k entry tree
339
343
assert file_id not in inv_byid, ('file_id %s already in'
340
344
' inventory as %s' % (file_id, inv_byid[file_id]))
1204
1208
def __get_matchingbzrdir(self):
1205
1209
# please test against something that will let us do tree references
1206
1210
return bzrdir.format_registry.make_bzrdir(
1207
'experimental-reference-dirstate')
1211
'dirstate-with-subtree')
1209
1213
_matchingbzrdir = property(__get_matchingbzrdir)
2181
2185
InterTree.register_optimiser(InterDirStateTree)
2188
class Converter3to4(object):
2189
"""Perform an in-place upgrade of format 3 to format 4 trees."""
2192
self.target_format = WorkingTreeFormat4()
2194
def convert(self, tree):
2195
# lock the control files not the tree, so that we dont get tree
2196
# on-unlock behaviours, and so that noone else diddles with the
2197
# tree during upgrade.
2198
tree._control_files.lock_write()
2200
self.create_dirstate_data(tree)
2201
self.update_format(tree)
2202
self.remove_xml_files(tree)
2204
tree._control_files.unlock()
2206
def create_dirstate_data(self, tree):
2207
"""Create the dirstate based data for tree."""
2208
local_path = tree.bzrdir.get_workingtree_transport(None
2209
).local_abspath('dirstate')
2210
state = dirstate.DirState.from_tree(tree, local_path)
2214
def remove_xml_files(self, tree):
2215
"""Remove the oldformat 3 data."""
2216
transport = tree.bzrdir.get_workingtree_transport(None)
2217
for path in ['basis-inventory-cache', 'inventory', 'last-revision',
2218
'pending-merges', 'stat-cache']:
2220
transport.delete(path)
2221
except errors.NoSuchFile:
2222
# some files are optional - just deal.
2225
def update_format(self, tree):
2226
"""Change the format marker."""
2227
tree._control_files.put_utf8('format',
2228
self.target_format.get_format_string())