~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: Parth Malwankar
  • Date: 2010-07-19 14:25:37 UTC
  • mto: (5050.3.15 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: parth.malwankar@gmail.com-20100719142537-djnb98492yri3k92
_add_patterns is now done in a specific order in Globster

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
    TYPE_FULLPATH = 1
183
183
    TYPE_BASENAME = 2
184
184
    TYPE_EXTENSION = 3
 
185
    # We want to _add_patterns in a specific order (as per type_list below)
 
186
    # starting with the shortest and going to the longest.
 
187
    # As some Python version don't support ordered dicts the list below is
 
188
    # used to select inputs for _add_pattern in a specific order.
 
189
    type_list = [ TYPE_EXTENSION, TYPE_BASENAME, TYPE_FULLPATH ]
 
190
 
185
191
 
186
192
    translators = {
187
193
        TYPE_FULLPATH : _sub_fullpath,
207
213
        for pat in patterns:
208
214
            pat = normalize_pattern(pat)
209
215
            pattern_lists[Globster.identify(pat)].append(pat)
210
 
        for pattern_type, patterns in pattern_lists.iteritems():
211
 
            self._add_patterns(patterns,
212
 
                Globster.translators[pattern_type],
213
 
                Globster.prefixes[pattern_type])
 
216
        for t in Globster.type_list:
 
217
            self._add_patterns(pattern_lists[t], Globster.translators[t],
 
218
                Globster.prefixes[t])
214
219
 
215
220
    def _add_patterns(self, patterns, translator, prefix=''):
216
221
        while patterns: