/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: Canonical.com Patch Queue Manager
  • Date: 2008-07-02 02:04:17 UTC
  • mfrom: (3515.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080702020417-2gnc111mzyl1xusr
Rule-based preferences (Ian Clatworthy)

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
512
513
        """
513
514
        raise NotImplementedError(self.walkdirs)
514
515
 
 
516
    def iter_search_rules(self, path_names, pref_names=None,
 
517
        _default_searcher=rules._per_user_searcher):
 
518
        """Find the preferences for filenames in a tree.
 
519
 
 
520
        :param path_names: an iterable of paths to find attributes for.
 
521
          Paths are given relative to the root of the tree.
 
522
        :param pref_names: the list of preferences to lookup - None for all
 
523
        :param _default_searcher: private parameter to assist testing - don't use
 
524
        :return: an iterator of tuple sequences, one per path-name.
 
525
          See _RulesSearcher.get_items for details on the tuple sequence.
 
526
        """
 
527
        searcher = self._get_rules_searcher(_default_searcher)
 
528
        if searcher is not None:
 
529
            if pref_names is not None:
 
530
                for path in path_names:
 
531
                    yield searcher.get_selected_items(path, pref_names)
 
532
            else:
 
533
                for path in path_names:
 
534
                    yield searcher.get_items(path)
 
535
 
 
536
    @needs_read_lock
 
537
    def _get_rules_searcher(self, default_searcher):
 
538
        """Get the RulesSearcher for this tree given the default one."""
 
539
        searcher = default_searcher
 
540
        file_id = self.path2id(rules.RULES_TREE_FILENAME)
 
541
        if file_id is not None:
 
542
            ini_file = self.get_file(file_id)
 
543
            searcher = rules._StackedRulesSearcher(
 
544
                [rules._IniBasedRulesSearcher(ini_file), default_searcher])
 
545
        return searcher
 
546
 
515
547
 
516
548
class EmptyTree(Tree):
517
549