/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: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
36
from bzrlib.inventory import InventoryFile
37
37
from bzrlib.inter import InterObject
38
38
from bzrlib.osutils import fingerprint_file
39
 
import bzrlib.revision
40
39
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
41
40
from bzrlib.trace import note
42
41
 
98
97
    def iter_changes(self, from_tree, include_unchanged=False,
99
98
                     specific_files=None, pb=None, extra_trees=None,
100
99
                     require_versioned=True, want_unversioned=False):
 
100
        """See InterTree.iter_changes"""
101
101
        intertree = InterTree.get(from_tree, self)
102
102
        return intertree.iter_changes(include_unchanged, specific_files, pb,
103
103
            extra_trees, require_versioned, want_unversioned=want_unversioned)
222
222
    def path_content_summary(self, path):
223
223
        """Get a summary of the information about path.
224
224
 
 
225
        All the attributes returned are for the canonical form, not the
 
226
        convenient form (if content filters are in use.)
 
227
 
225
228
        :param path: A relative path within the tree.
226
229
        :return: A tuple containing kind, size, exec, sha1-or-link.
227
230
            Kind is always present (see tree.kind()).
228
 
            size is present if kind is file, None otherwise.
 
231
            size is present if kind is file and the size of the 
 
232
                canonical form can be cheaply determined, None otherwise.
229
233
            exec is None unless kind is file and the platform supports the 'x'
230
234
                bit.
231
235
            sha1-or-link is the link target if kind is symlink, or the sha1 if
400
404
            bit_iter = iter(path.split("/"))
401
405
            for elt in bit_iter:
402
406
                lelt = elt.lower()
 
407
                new_path = None
403
408
                for child in self.iter_children(cur_id):
404
409
                    try:
 
410
                        # XXX: it seem like if the child is known to be in the
 
411
                        # tree, we shouldn't need to go from its id back to
 
412
                        # its path -- mbp 2010-02-11
 
413
                        #
 
414
                        # XXX: it seems like we could be more efficient
 
415
                        # by just directly looking up the original name and
 
416
                        # only then searching all children; also by not
 
417
                        # chopping paths so much. -- mbp 2010-02-11
405
418
                        child_base = os.path.basename(self.id2path(child))
406
 
                        if child_base.lower() == lelt:
 
419
                        if (child_base == elt):
 
420
                            # if we found an exact match, we can stop now; if
 
421
                            # we found an approximate match we need to keep
 
422
                            # searching because there might be an exact match
 
423
                            # later.  
407
424
                            cur_id = child
408
 
                            cur_path = osutils.pathjoin(cur_path, child_base)
 
425
                            new_path = osutils.pathjoin(cur_path, child_base)
409
426
                            break
 
427
                        elif child_base.lower() == lelt:
 
428
                            cur_id = child
 
429
                            new_path = osutils.pathjoin(cur_path, child_base)
410
430
                    except NoSuchId:
411
431
                        # before a change is committed we can see this error...
412
432
                        continue
 
433
                if new_path:
 
434
                    cur_path = new_path
413
435
                else:
414
436
                    # got to the end of this directory and no entries matched.
415
437
                    # Return what matched so far, plus the rest as specified.
693
715
                for path in path_names:
694
716
                    yield searcher.get_items(path)
695
717
 
696
 
    @needs_read_lock
697
718
    def _get_rules_searcher(self, default_searcher):
698
719
        """Get the RulesSearcher for this tree given the default one."""
699
720
        searcher = default_searcher
848
869
    will pass through to InterTree as appropriate.
849
870
    """
850
871
 
 
872
    # Formats that will be used to test this InterTree. If both are
 
873
    # None, this InterTree will not be tested (e.g. because a complex
 
874
    # setup is required)
 
875
    _matching_from_tree_format = None
 
876
    _matching_to_tree_format = None
 
877
 
851
878
    _optimisers = []
852
879
 
853
880
    def _changes_from_entries(self, source_entry, target_entry,
950
977
            a PathsNotVersionedError will be thrown.
951
978
        :param want_unversioned: Scan for unversioned paths.
952
979
        """
953
 
        # NB: show_status depends on being able to pass in non-versioned files
954
 
        # and report them as unknown
955
980
        trees = (self.source,)
956
981
        if extra_trees is not None:
957
982
            trees = trees + tuple(extra_trees)