/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Robert Collins
  • Date: 2009-05-23 20:57:12 UTC
  • mfrom: (4371 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4441.
  • Revision ID: robertc@robertcollins.net-20090523205712-lcwbfqk6vwavinuv
MergeĀ .dev.

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
 
        _default_searcher=rules._per_user_searcher):
 
660
        _default_searcher=None):
632
661
        """Find the preferences for filenames in a tree.
633
662
 
634
663
        :param path_names: an iterable of paths to find attributes for.
638
667
        :return: an iterator of tuple sequences, one per path-name.
639
668
          See _RulesSearcher.get_items for details on the tuple sequence.
640
669
        """
 
670
        if _default_searcher is None:
 
671
            _default_searcher = rules._per_user_searcher
641
672
        searcher = self._get_rules_searcher(_default_searcher)
642
673
        if searcher is not None:
643
674
            if pref_names is not None:
876
907
            output. An unversioned file is defined as one with (False, False)
877
908
            for the versioned pair.
878
909
        """
879
 
        result = []
880
910
        lookup_trees = [self.source]
881
911
        if extra_trees:
882
912
             lookup_trees.extend(extra_trees)
941
971
            if kind[0] != kind[1]:
942
972
                changed_content = True
943
973
            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) !=
 
974
                if (self.source.get_file_sha1(file_id, from_path, from_stat) !=
949
975
                    self.target.get_file_sha1(file_id, to_path, to_stat)):
950
976
                    changed_content = True
951
977
            elif from_kind == 'symlink':
952
978
                if (self.source.get_symlink_target(file_id) !=
953
979
                    self.target.get_symlink_target(file_id)):
954
980
                    changed_content = True
 
981
                # XXX: Yes, the indentation below is wrong. But fixing it broke
 
982
                # test_merge.TestMergerEntriesLCAOnDisk.
 
983
                # test_nested_tree_subtree_renamed_and_modified. We'll wait for
 
984
                # the fix from bzr.dev -- vila 2009026
955
985
                elif from_kind == 'tree-reference':
956
986
                    if (self.source.get_reference_revision(file_id, from_path)
957
987
                        != self.target.get_reference_revision(file_id, to_path)):