~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: Kent Gibson
  • Date: 2007-03-02 00:34:38 UTC
  • mto: (2319.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2320.
  • Revision ID: warthog618@gmail.com-20070302003438-c9ju53dq662l0edr
Review fixes for lp86451 patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
 
110
110
 
111
111
def _trailing_backslashes_regex(m):
112
 
    if len(m) %2  != 0:
 
112
    """Check trailing backslashes.
 
113
 
 
114
    Does a head count on trailing backslashes to ensure there isn't an odd
 
115
    one on the end that would escape the brackets we wrap the RE in.
 
116
    """
 
117
    if (len(m) % 2) != 0:
113
118
        warning(u"Regular expressions cannot end with an odd number of '\\'. "
114
119
                "Dropping the final '\\'.")
115
120
        return m[:-1]
211
216
        return None
212
217
        
213
218
 
214
 
_normalize_re = re.compile(ur'\\(?!x\d\d|\d\d\d|u\d\d\d\d)')
215
 
 
216
 
 
217
219
def normalize_pattern(pattern):
218
220
    """Converts backslashes in path patterns to forward slashes.
219
 
     
220
 
    Avoids converting escape backslashes.
 
221
    
 
222
    Doesn't normalize regular expressions - they may contain escapes.
221
223
    """
222
224
    if not pattern.startswith('RE:'):
223
 
        pattern = _normalize_re.sub('/', pattern)
 
225
        pattern = pattern.replace('\\','/')
224
226
    return pattern.rstrip('/')