~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: Martin Pool
  • Date: 2010-07-15 09:47:16 UTC
  • mfrom: (5345 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5346.
  • Revision ID: mbp@canonical.com-20100715094716-sljdg6go0d12xi79
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import re
24
24
 
 
25
from bzrlib import errors
25
26
from bzrlib.trace import (
26
 
    warning
 
27
    mutter,
 
28
    warning,
27
29
    )
28
30
 
29
31
 
209
211
 
210
212
        :return A matching pattern or None if there is no matching pattern.
211
213
        """
212
 
        for regex, patterns in self._regex_patterns:
213
 
            match = regex.match(filename)
214
 
            if match:
215
 
                return patterns[match.lastindex -1]
 
214
        try:
 
215
            for regex, patterns in self._regex_patterns:
 
216
                match = regex.match(filename)
 
217
                if match:
 
218
                    return patterns[match.lastindex -1]
 
219
        except errors.InvalidPattern, e:
 
220
            # We can't show the default e.msg to the user as thats for
 
221
            # the combined pattern we sent to regex. Instead we indicate to
 
222
            # the user that an ignore file needs fixing.
 
223
            mutter('Invalid pattern found in regex: %s.', e.msg)
 
224
            e.msg = "File ~/.bazaar/ignore or .bzrignore contains errors."
 
225
            raise e
216
226
        return None
217
227
 
218
228
class ExceptionGlobster(object):