1981
1981
executable = None
1982
1982
if kind == 'symlink':
1983
1983
link_or_sha1 = os.readlink(limbo_name).decode(osutils._fs_enc)
1984
if supports_executable():
1985
executable = tt._new_executability.get(trans_id, executable)
1984
executable = tt._new_executability.get(trans_id, executable)
1986
1985
return kind, size, executable, link_or_sha1
1988
1987
def iter_changes(self, from_tree, include_unchanged=False,
2301
2300
new_desired_files = desired_files
2303
2302
iter = accelerator_tree.iter_changes(tree, include_unchanged=True)
2304
unchanged = dict((f, p[1]) for (f, p, c, v, d, n, k, e)
2305
in iter if not (c or e[0] != e[1]))
2303
unchanged = [(f, p[1]) for (f, p, c, v, d, n, k, e)
2304
in iter if not (c or e[0] != e[1])]
2305
if accelerator_tree.supports_content_filtering():
2306
unchanged = [(f, p) for (f, p) in unchanged
2307
if not accelerator_tree.iter_search_rules([p]).next()]
2308
unchanged = dict(unchanged)
2306
2309
new_desired_files = []
2308
2311
for file_id, (trans_id, tree_path) in desired_files:
2431
2434
tt.create_directory(trans_id)
2434
def create_from_tree(tt, trans_id, tree, file_id, bytes=None):
2435
"""Create new file contents according to tree contents."""
2437
def create_from_tree(tt, trans_id, tree, file_id, bytes=None,
2438
filter_tree_path=None):
2439
"""Create new file contents according to tree contents.
2441
:param filter_tree_path: the tree path to use to lookup
2442
content filters to apply to the bytes output in the working tree.
2443
This only applies if the working tree supports content filtering.
2436
2445
kind = tree.kind(file_id)
2437
2446
if kind == 'directory':
2438
2447
tt.create_directory(trans_id)
2443
2452
bytes = tree_file.readlines()
2445
2454
tree_file.close()
2456
if wt.supports_content_filtering() and filter_tree_path is not None:
2457
filters = wt._content_filter_stack(filter_tree_path)
2458
bytes = filtered_output_bytes(bytes, filters,
2459
ContentFilterContext(filter_tree_path, tree))
2446
2460
tt.create_file(bytes, trans_id)
2447
2461
elif kind == "symlink":
2448
2462
tt.create_symlink(tree.get_symlink_target(file_id), trans_id)
2639
2653
tt.adjust_path(name[1], parent_trans, trans_id)
2640
2654
if executable[0] != executable[1] and kind[1] == "file":
2641
2655
tt.set_executability(executable[1], trans_id)
2642
for (trans_id, mode_id), bytes in target_tree.iter_files_bytes(
2644
tt.create_file(bytes, trans_id, mode_id)
2656
if working_tree.supports_content_filtering():
2657
for index, ((trans_id, mode_id), bytes) in enumerate(
2658
target_tree.iter_files_bytes(deferred_files)):
2659
file_id = deferred_files[index][0]
2660
# We're reverting a tree to the target tree so using the
2661
# target tree to find the file path seems the best choice
2662
# here IMO - Ian C 27/Oct/2009
2663
filter_tree_path = target_tree.id2path(file_id)
2664
filters = working_tree._content_filter_stack(filter_tree_path)
2665
bytes = filtered_output_bytes(bytes, filters,
2666
ContentFilterContext(filter_tree_path, working_tree))
2667
tt.create_file(bytes, trans_id, mode_id)
2669
for (trans_id, mode_id), bytes in target_tree.iter_files_bytes(
2671
tt.create_file(bytes, trans_id, mode_id)
2646
2673
if basis_tree is not None:
2647
2674
basis_tree.unlock()