617
619
def supports_content_filtering(self):
622
def _content_filter_stack(self, path=None, file_id=None):
623
"""The stack of content filters for a path if filtering is supported.
625
Readers will be applied in first-to-last order.
626
Writers will be applied in last-to-first order.
627
Either the path or the file-id needs to be provided.
629
:param path: path relative to the root of the tree
631
:param file_id: file_id or None if unknown
632
:return: the list of filters - [] if there are none
634
filter_pref_names = filters._get_registered_names()
635
if len(filter_pref_names) == 0:
638
path = self.id2path(file_id)
639
prefs = self.iter_search_rules([path], filter_pref_names).next()
640
stk = filters._get_filter_stack_for(prefs)
641
if 'filters' in debug.debug_flags:
642
note("*** %s content-filter: %s => %r" % (path,prefs,stk))
645
def _content_filter_stack_provider(self):
646
"""A function that returns a stack of ContentFilters.
648
The function takes a path (relative to the top of the tree) and a
649
file-id as parameters.
651
:return: None if content filtering is not supported by this tree.
653
if self.supports_content_filtering():
654
return lambda path, file_id: \
655
self._content_filter_stack(path, file_id)
620
659
def iter_search_rules(self, path_names, pref_names=None,
621
660
_default_searcher=rules._per_user_searcher):
622
661
"""Find the preferences for filenames in a tree.
931
970
if kind[0] != kind[1]:
932
971
changed_content = True
933
972
elif from_kind == 'file':
934
from_size = self.source._file_size(from_entry, from_stat)
935
to_size = self.target._file_size(to_entry, to_stat)
936
if from_size != to_size:
937
changed_content = True
938
elif (self.source.get_file_sha1(file_id, from_path, from_stat) !=
973
if (self.source.get_file_sha1(file_id, from_path, from_stat) !=
939
974
self.target.get_file_sha1(file_id, to_path, to_stat)):
940
975
changed_content = True
941
976
elif from_kind == 'symlink':