13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Tree classes, representing directory at point in time.
97
95
want_unversioned=want_unversioned,
98
@symbol_versioning.deprecated_method(symbol_versioning.one_three)
99
def _iter_changes(self, *args, **kwargs):
100
return self.iter_changes(*args, **kwargs)
100
102
def iter_changes(self, from_tree, include_unchanged=False,
101
103
specific_files=None, pb=None, extra_trees=None,
102
104
require_versioned=True, want_unversioned=False):
544
546
for child in getattr(entry, 'children', {}).itervalues():
545
547
yield child.file_id
549
@symbol_versioning.deprecated_method(symbol_versioning.one_six)
550
def print_file(self, file_id):
551
"""Print file with id `file_id` to stdout."""
553
sys.stdout.write(self.get_file_text(file_id))
547
555
def lock_read(self):
619
627
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)
659
630
def iter_search_rules(self, path_names, pref_names=None,
660
631
_default_searcher=rules._per_user_searcher):
661
632
"""Find the preferences for filenames in a tree.
969
941
if kind[0] != kind[1]:
970
942
changed_content = True
971
943
elif from_kind == 'file':
972
if (self.source.get_file_sha1(file_id, from_path, from_stat) !=
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) !=
973
949
self.target.get_file_sha1(file_id, to_path, to_stat)):
974
950
changed_content = True
975
951
elif from_kind == 'symlink':
976
952
if (self.source.get_symlink_target(file_id) !=
977
953
self.target.get_symlink_target(file_id)):
978
954
changed_content = True
979
# XXX: Yes, the indentation below is wrong. But fixing it broke
980
# test_merge.TestMergerEntriesLCAOnDisk.
981
# test_nested_tree_subtree_renamed_and_modified. We'll wait for
982
# the fix from bzr.dev -- vila 2009026
983
955
elif from_kind == 'tree-reference':
984
956
if (self.source.get_reference_revision(file_id, from_path)
985
957
!= self.target.get_reference_revision(file_id, to_path)):