1019
1020
self.rename_count += 1
1020
1021
if trans_id in self._new_contents:
1021
1022
modified_paths.append(full_path)
1022
del self._new_contents[trans_id]
1023
completed_new.append(trans_id)
1024
1025
if trans_id in self._new_id:
1025
1026
if kind is None:
1066
1067
child_pb.finished()
1068
for trans_id in completed_new:
1069
del self._new_contents[trans_id]
1067
1070
return modified_paths
1069
1072
def _set_executability(self, path, entry, trans_id):
1319
1322
return file_ids
1322
def build_tree(tree, wt):
1325
def build_tree(tree, wt, accelerator_tree=None):
1323
1326
"""Create working tree for a branch, using a TreeTransform.
1325
1328
This function should be used on empty trees, having a tree root at most.
1332
1335
- Otherwise, if the content on disk matches the content we are building,
1333
1336
it is silently replaced.
1334
1337
- Otherwise, conflict resolution will move the old file to 'oldname.moved'.
1339
:param tree: The tree to convert wt into a copy of
1340
:param wt: The working tree that files will be placed into
1341
:param accelerator_tree: A tree which can be used for retrieving file
1342
contents more quickly than tree itself, i.e. a workingtree. tree
1343
will be used for cases where accelerator_tree's content is different.
1336
1345
wt.lock_tree_write()
1338
1347
tree.lock_read()
1340
return _build_tree(tree, wt)
1349
if accelerator_tree is not None:
1350
accelerator_tree.lock_read()
1352
return _build_tree(tree, wt, accelerator_tree)
1354
if accelerator_tree is not None:
1355
accelerator_tree.unlock()
1347
def _build_tree(tree, wt):
1362
def _build_tree(tree, wt, accelerator_tree):
1348
1363
"""See build_tree."""
1349
1364
if len(wt.inventory) > 1: # more than just a root
1350
1365
raise errors.WorkingTreeAlreadyPopulated(base=wt.basedir)
1421
1436
old_parent = tt.trans_id_tree_path(tree_path)
1422
1437
_reparent_children(tt, old_parent, new_trans_id)
1423
1438
for num, (trans_id, bytes) in enumerate(
1424
tree.iter_files_bytes(deferred_contents)):
1439
_iter_files_bytes_accelerated(tree, accelerator_tree,
1440
deferred_contents)):
1425
1441
tt.create_file(bytes, trans_id)
1426
1442
pb.update('Adding file contents',
1427
1443
(num + len(tree.inventory) - len(deferred_contents)),
1439
1455
wt.add_conflicts(conflicts)
1440
1456
except errors.UnsupportedOperation:
1458
result = tt.apply(no_conflicts=True)
1445
1461
top_pb.finished()
1465
def _iter_files_bytes_accelerated(tree, accelerator_tree, desired_files):
1466
if accelerator_tree is None:
1467
new_desired_files = desired_files
1469
iter = accelerator_tree._iter_changes(tree, include_unchanged=True)
1470
unchanged = dict((f, p[1]) for (f, p, c, v, d, n, k, e)
1472
new_desired_files = []
1473
for file_id, identifier in desired_files:
1474
accelerator_path = unchanged.get(file_id)
1475
if accelerator_path is None:
1476
new_desired_files.append((file_id, identifier))
1478
contents = accelerator_tree.get_file(file_id, accelerator_path)
1481
contents_bytes = (contents.read(),)
1484
yield identifier, contents_bytes
1485
for result in tree.iter_files_bytes(new_desired_files):
1449
1489
def _reparent_children(tt, old_parent, new_parent):
1450
1490
for child in tt.iter_tree_children(old_parent):
1451
1491
tt.adjust_path(tt.final_name(child), new_parent, child)