1219
1219
child_pb.update('Apply phase', 0, 2)
1220
self._apply_removals(new_inventory_delta, mover)
1220
kind_changes = self._apply_removals(new_inventory_delta, mover)
1221
1221
child_pb.update('Apply phase', 1, 2)
1222
1222
modified_paths = self._apply_insertions(new_inventory_delta,
1223
mover, kind_changes)
1225
1225
mover.rollback()
1245
1245
tree_paths = list(self._tree_path_ids.iteritems())
1246
1246
tree_paths.sort(reverse=True)
1247
kind_changes = set()
1247
1248
child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1249
1250
for num, data in enumerate(tree_paths):
1251
1252
child_pb.update('removing file', num, len(tree_paths))
1252
1253
full_path = self._tree.abspath(path)
1253
1254
if trans_id in self._removed_contents:
1256
if (self.tree_kind(trans_id)
1257
!= self.final_kind(trans_id)):
1258
kind_changes.add(trans_id)
1254
1261
mover.pre_delete(full_path, os.path.join(self._deletiondir,
1256
1263
elif trans_id in self._new_name or trans_id in \
1274
1281
inventory_delta.append((path, None, file_id, None))
1276
1283
child_pb.finished()
1278
def _apply_insertions(self, inventory_delta, mover):
1286
def _apply_insertions(self, inventory_delta, mover, kind_changes):
1279
1287
"""Perform tree operations that insert directory/inventory names.
1281
1289
That is, create any files that need to be created, and restore from
1285
1293
If inventory_delta is None, no inventory delta is calculated, and
1286
1294
no list of modified paths is returned.
1296
kind_changes is a set of trans ids where the entry has changed
1297
kind, and so an inventory delta entry should be created for them.
1288
1299
new_paths = self.new_paths(filesystem_only=(inventory_delta is None))
1289
1300
modified_paths = []
1320
1331
if file_id is not None and (trans_id in self._new_id or
1321
1332
trans_id in self._new_name or
1322
1333
trans_id in self._new_parent
1323
or trans_id in self._new_executability):
1334
or trans_id in self._new_executability
1335
or trans_id in kind_changes):
1325
1337
kind = self.final_kind(trans_id)
1326
1338
except NoSuchFile:
1410
1422
self._transform = transform
1411
1423
self._final_paths = FinalPaths(transform)
1412
1424
self.__by_parent = None
1425
self._parent_ids = []
1414
1427
def _changes(self, file_id):
1415
1428
for changes in self._transform.iter_changes():
1423
1436
# InterTree.iter_changes.
1424
1437
return (changes is not None and changes[2])
1439
def _get_repository(self):
1440
repo = getattr(self._transform._tree, '_repository', None)
1442
repo = self._transform._tree.branch.repository
1445
def _iter_parent_trees(self):
1446
for revision_id in self.get_parent_ids():
1448
yield self.revision_tree(revision_id)
1449
except errors.NoSuchRevisionInTree:
1450
yield self._get_repository().revision_tree(revision_id)
1426
1452
def _get_file_revision(self, file_id, vf, tree_revision):
1427
return self._transform._tree._get_file_revision(file_id, vf,
1453
parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
1454
self._iter_parent_trees()]
1455
vf.add_lines((file_id, tree_revision), parent_keys,
1456
self.get_file(file_id).readlines())
1457
repo = self._get_repository()
1458
base_vf = repo.texts
1459
if base_vf not in vf.fallback_versionedfiles:
1460
vf.fallback_versionedfiles.append(base_vf)
1461
return tree_revision
1430
1463
def _stat_limbo_file(self, file_id):
1431
1464
trans_id = self._transform.trans_id_file_id(file_id)
1682
1715
return self._transform._tree.walkdirs(prefix)
1684
1717
def get_parent_ids(self):
1685
return self._transform._tree.get_parent_ids()
1718
return self._parent_ids
1720
def set_parent_ids(self, parent_ids):
1721
self._parent_ids = parent_ids
1687
1723
def get_revision_tree(self, revision_id):
1688
1724
return self._transform._tree.get_revision_tree(revision_id)