~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

MergeĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tree classes, representing directory at point in time.
18
18
"""
24
24
import bzrlib
25
25
from bzrlib import (
26
26
    conflicts as _mod_conflicts,
 
27
    debug,
27
28
    delta,
 
29
    filters,
28
30
    osutils,
29
31
    revision as _mod_revision,
30
32
    rules,
95
97
            want_unversioned=want_unversioned,
96
98
            )
97
99
 
98
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_three)
99
 
    def _iter_changes(self, *args, **kwargs):
100
 
        return self.iter_changes(*args, **kwargs)
101
 
 
102
100
    def iter_changes(self, from_tree, include_unchanged=False,
103
101
                     specific_files=None, pb=None, extra_trees=None,
104
102
                     require_versioned=True, want_unversioned=False):
546
544
        for child in getattr(entry, 'children', {}).itervalues():
547
545
            yield child.file_id
548
546
 
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."""
552
 
        import sys
553
 
        sys.stdout.write(self.get_file_text(file_id))
554
 
 
555
547
    def lock_read(self):
556
548
        pass
557
549
 
627
619
    def supports_content_filtering(self):
628
620
        return False
629
621
 
 
622
    def _content_filter_stack(self, path=None, file_id=None):
 
623
        """The stack of content filters for a path if filtering is supported.
 
624
 
 
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.
 
628
 
 
629
        :param path: path relative to the root of the tree
 
630
            or None if unknown
 
631
        :param file_id: file_id or None if unknown
 
632
        :return: the list of filters - [] if there are none
 
633
        """
 
634
        filter_pref_names = filters._get_registered_names()
 
635
        if len(filter_pref_names) == 0:
 
636
            return []
 
637
        if path is None:
 
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))
 
643
        return stk
 
644
 
 
645
    def _content_filter_stack_provider(self):
 
646
        """A function that returns a stack of ContentFilters.
 
647
 
 
648
        The function takes a path (relative to the top of the tree) and a
 
649
        file-id as parameters.
 
650
 
 
651
        :return: None if content filtering is not supported by this tree.
 
652
        """
 
653
        if self.supports_content_filtering():
 
654
            return lambda path, file_id: \
 
655
                    self._content_filter_stack(path, file_id)
 
656
        else:
 
657
            return None
 
658
 
630
659
    def iter_search_rules(self, path_names, pref_names=None,
631
660
        _default_searcher=rules._per_user_searcher):
632
661
        """Find the preferences for filenames in a tree.
941
970
            if kind[0] != kind[1]:
942
971
                changed_content = True
943
972
            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) !=
 
973
                if (self.source.get_file_sha1(file_id, from_path, from_stat) !=
949
974
                    self.target.get_file_sha1(file_id, to_path, to_stat)):
950
975
                    changed_content = True
951
976
            elif from_kind == 'symlink':