~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/rules.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-20 03:21:36 UTC
  • mfrom: (3946.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090120032136-alahvfk4g7y8iczn
Multi-glob rules (Marius Kruger)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from bzrlib import (
23
23
    config,
 
24
    commands,
24
25
    errors,
25
26
    globbing,
26
27
    osutils,
73
74
        options = {'encoding': 'utf-8'}
74
75
        self._cfg = configobj.ConfigObj(inifile, options=options)
75
76
        sections = self._cfg.keys()
76
 
        patterns = [s[FILE_PREFS_PREFIX_LEN:] for s in sections
77
 
            if s.startswith(FILE_PREFS_PREFIX)]
 
77
        patterns = []
 
78
        self.pattern_to_section = {}
 
79
        for s in sections:
 
80
            if s.startswith(FILE_PREFS_PREFIX):
 
81
                file_patterns = commands.shlex_split_unicode(
 
82
                    s[FILE_PREFS_PREFIX_LEN:])
 
83
                patterns.extend(file_patterns)
 
84
                for fp in file_patterns:
 
85
                    self.pattern_to_section[fp] = s
78
86
        if len(patterns) < len(sections):
79
87
            unknowns = [s for s in sections
80
88
                if not s.startswith(FILE_PREFS_PREFIX)]
92
100
        if pat is None:
93
101
            return ()
94
102
        else:
95
 
            all = self._cfg[FILE_PREFS_PREFIX + pat]
 
103
            all = self._cfg[self.pattern_to_section[pat]]
96
104
            return tuple(all.items())
97
105
 
98
106
    def get_selected_items(self, path, names):
103
111
        if pat is None:
104
112
            return ()
105
113
        else:
106
 
            all = self._cfg[FILE_PREFS_PREFIX + pat]
 
114
            all = self._cfg[self.pattern_to_section[pat]]
107
115
            return tuple((k, all.get(k)) for k in names)
108
116
 
109
117