/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

Merge in the BranchBuilder updates, which brings in a newer bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import bzrlib
25
25
from bzrlib import (
 
26
    conflicts as _mod_conflicts,
26
27
    delta,
27
28
    osutils,
28
29
    revision as _mod_revision,
29
 
    conflicts as _mod_conflicts,
 
30
    rules,
30
31
    symbol_versioning,
31
32
    )
32
33
from bzrlib.decorators import needs_read_lock
176
177
    def iter_entries_by_dir(self, specific_file_ids=None):
177
178
        """Walk the tree in 'by_dir' order.
178
179
 
179
 
        This will yield each entry in the tree as a (path, entry) tuple. The
180
 
        order that they are yielded is: the contents of a directory are 
181
 
        preceeded by the parent of a directory, and all the contents of a 
182
 
        directory are grouped together.
 
180
        This will yield each entry in the tree as a (path, entry) tuple.
 
181
        The order that they are yielded is:
 
182
 
 
183
        Directories are walked in a depth-first lexicographical order,
 
184
        however, whenever a directory is reached, all of its direct child
 
185
        nodes are yielded in  lexicographical order before yielding the
 
186
        grandchildren.
 
187
 
 
188
        For example, in the tree::
 
189
 
 
190
           a/
 
191
             b/
 
192
               c
 
193
             d/
 
194
               e
 
195
           f/
 
196
             g
 
197
 
 
198
        The yield order (ignoring root) would be::
 
199
          a, f, a/b, a/d, a/b/c, a/d/e, f/g
183
200
        """
184
201
        return self.inventory.iter_entries_by_dir(
185
202
            specific_file_ids=specific_file_ids)
512
529
        """
513
530
        raise NotImplementedError(self.walkdirs)
514
531
 
 
532
    def iter_search_rules(self, path_names, pref_names=None,
 
533
        _default_searcher=rules._per_user_searcher):
 
534
        """Find the preferences for filenames in a tree.
 
535
 
 
536
        :param path_names: an iterable of paths to find attributes for.
 
537
          Paths are given relative to the root of the tree.
 
538
        :param pref_names: the list of preferences to lookup - None for all
 
539
        :param _default_searcher: private parameter to assist testing - don't use
 
540
        :return: an iterator of tuple sequences, one per path-name.
 
541
          See _RulesSearcher.get_items for details on the tuple sequence.
 
542
        """
 
543
        searcher = self._get_rules_searcher(_default_searcher)
 
544
        if searcher is not None:
 
545
            if pref_names is not None:
 
546
                for path in path_names:
 
547
                    yield searcher.get_selected_items(path, pref_names)
 
548
            else:
 
549
                for path in path_names:
 
550
                    yield searcher.get_items(path)
 
551
 
 
552
    @needs_read_lock
 
553
    def _get_rules_searcher(self, default_searcher):
 
554
        """Get the RulesSearcher for this tree given the default one."""
 
555
        searcher = default_searcher
 
556
        file_id = self.path2id(rules.RULES_TREE_FILENAME)
 
557
        if file_id is not None:
 
558
            ini_file = self.get_file(file_id)
 
559
            searcher = rules._StackedRulesSearcher(
 
560
                [rules._IniBasedRulesSearcher(ini_file), default_searcher])
 
561
        return searcher
 
562
 
515
563
 
516
564
class EmptyTree(Tree):
517
565