627
629
def supports_content_filtering(self):
632
def _content_filter_stack(self, path=None, file_id=None):
633
"""The stack of content filters for a path if filtering is supported.
635
Readers will be applied in first-to-last order.
636
Writers will be applied in last-to-first order.
637
Either the path or the file-id needs to be provided.
639
:param path: path relative to the root of the tree
641
:param file_id: file_id or None if unknown
642
:return: the list of filters - [] if there are none
644
filter_pref_names = filters._get_registered_names()
645
if len(filter_pref_names) == 0:
648
path = self.id2path(file_id)
649
prefs = self.iter_search_rules([path], filter_pref_names).next()
650
stk = filters._get_filter_stack_for(prefs)
651
if 'filters' in debug.debug_flags:
652
note("*** %s content-filter: %s => %r" % (path,prefs,stk))
655
def _content_filter_stack_provider(self):
656
"""A function that returns a stack of ContentFilters.
658
The function takes a path (relative to the top of the tree) and a
659
file-id as parameters.
661
:return: None if content filtering is not supported by this tree.
663
if self.supports_content_filtering():
664
return lambda path, file_id: \
665
self._content_filter_stack(path, file_id)
630
669
def iter_search_rules(self, path_names, pref_names=None,
631
670
_default_searcher=rules._per_user_searcher):
632
671
"""Find the preferences for filenames in a tree.
941
980
if kind[0] != kind[1]:
942
981
changed_content = True
943
982
elif from_kind == 'file':
944
from_size = self.source._file_size(from_entry, from_stat)
945
to_size = self.target._file_size(to_entry, to_stat)
946
if from_size != to_size:
947
changed_content = True
948
elif (self.source.get_file_sha1(file_id, from_path, from_stat) !=
983
if (self.source.get_file_sha1(file_id, from_path, from_stat) !=
949
984
self.target.get_file_sha1(file_id, to_path, to_stat)):
950
985
changed_content = True
951
986
elif from_kind == 'symlink':