~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-26 06:24:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2376.
  • Revision ID: andrew.bennetts@canonical.com-20070326062401-k3nbefzje5332jaf
Deal with review comments from Robert:

  * Add my name to the NEWS file
  * Move the test case to a new module in branch_implementations
  * Remove revision_history cruft from identitymap and test_identitymap
  * Improve some docstrings

Also, this fixes a bug where revision_history was not returning a copy of the
cached data, allowing the cache to be corrupted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
214
214
            if match:
215
215
                return patterns[match.lastindex -1]
216
216
        return None
217
 
 
218
 
 
219
 
class _OrderedGlobster(Globster):
220
 
    """A Globster that keeps pattern order."""
221
 
 
222
 
    def __init__(self, patterns):
223
 
        """Constructor.
224
 
 
225
 
        :param patterns: sequence of glob patterns
226
 
        """
227
 
        # Note: This could be smarter by running like sequences together
228
 
        self._regex_patterns = []
229
 
        for pat in patterns:
230
 
            pat = normalize_pattern(pat)
231
 
            if pat.startswith(u'RE:') or u'/' in pat:
232
 
                self._add_patterns([pat], _sub_fullpath) 
233
 
            elif pat.startswith(u'*.'):
234
 
                self._add_patterns([pat], _sub_extension,
235
 
                    prefix=r'(?:.*/)?(?!.*/)(?:.*\.)')
236
 
            else:
237
 
                self._add_patterns([pat], _sub_basename, 
238
 
                    prefix=r'(?:.*/)?(?!.*/)')
239
 
 
 
217
        
240
218
 
241
219
def normalize_pattern(pattern):
242
220
    """Converts backslashes in path patterns to forward slashes.