~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: Parth Malwankar
  • Date: 2010-06-30 12:03:30 UTC
  • mto: This revision was merged to the branch mainline in revision 5339.
  • Revision ID: parth.malwankar@gmail.com-20100630120330-uud7s38i8s08izh8
added InvalidPattern error.
This is raised by lazy_regex and Globster on bad regex.

Show diffs side-by-side

added added

removed removed

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