~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-06 06:48:25 UTC
  • mfrom: (4070.8.6 debug-config)
  • Revision ID: pqm@pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
(mbp) debug_flags configuration option

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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,
28
27
    delta,
29
 
    filters,
30
28
    osutils,
31
29
    revision as _mod_revision,
32
30
    rules,
97
95
            want_unversioned=want_unversioned,
98
96
            )
99
97
 
 
98
    @symbol_versioning.deprecated_method(symbol_versioning.one_three)
 
99
    def _iter_changes(self, *args, **kwargs):
 
100
        return self.iter_changes(*args, **kwargs)
 
101
 
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
546
548
 
 
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
 
547
555
    def lock_read(self):
548
556
        pass
549
557
 
619
627
    def supports_content_filtering(self):
620
628
        return False
621
629
 
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
 
 
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.
905
876
            output. An unversioned file is defined as one with (False, False)
906
877
            for the versioned pair.
907
878
        """
 
879
        result = []
908
880
        lookup_trees = [self.source]
909
881
        if extra_trees:
910
882
             lookup_trees.extend(extra_trees)
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)):