25
25
from bzrlib import (
26
conflicts as _mod_conflicts,
28
29
revision as _mod_revision,
29
conflicts as _mod_conflicts,
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.
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:
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
188
For example, in the tree::
198
The yield order (ignoring root) would be::
199
a, f, a/b, a/d, a/b/c, a/d/e, f/g
184
201
return self.inventory.iter_entries_by_dir(
185
202
specific_file_ids=specific_file_ids)
513
530
raise NotImplementedError(self.walkdirs)
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.
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.
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)
549
for path in path_names:
550
yield searcher.get_items(path)
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])
516
564
class EmptyTree(Tree):