##// END OF EJS Templates
match: remove head and tail args from _globre
Matt Mackall -
r8582:a4c199e1 default
parent child Browse files
Show More
@@ -120,7 +120,7 b' def _patsplit(pat, default):'
120 return pat, val
120 return pat, val
121 return default, pat
121 return default, pat
122
122
123 def _globre(pat, head, tail):
123 def _globre(pat):
124 "convert a glob pattern into a regexp"
124 "convert a glob pattern into a regexp"
125 i, n = 0, len(pat)
125 i, n = 0, len(pat)
126 res = ''
126 res = ''
@@ -170,7 +170,7 b' def _globre(pat, head, tail):'
170 res += re.escape(c)
170 res += re.escape(c)
171 else:
171 else:
172 res += re.escape(c)
172 res += re.escape(c)
173 return head + res + tail
173 return res
174
174
175 def _regex(kind, name, tail):
175 def _regex(kind, name, tail):
176 '''convert a pattern into a regular expression'''
176 '''convert a pattern into a regular expression'''
@@ -181,14 +181,14 b' def _regex(kind, name, tail):'
181 elif kind == 'path':
181 elif kind == 'path':
182 return '^' + re.escape(name) + '(?:/|$)'
182 return '^' + re.escape(name) + '(?:/|$)'
183 elif kind == 'relglob':
183 elif kind == 'relglob':
184 return _globre(name, '(?:|.*/)', tail)
184 return '(?:|.*/)' + _globre(name) + tail
185 elif kind == 'relpath':
185 elif kind == 'relpath':
186 return re.escape(name) + '(?:/|$)'
186 return re.escape(name) + '(?:/|$)'
187 elif kind == 'relre':
187 elif kind == 'relre':
188 if name.startswith('^'):
188 if name.startswith('^'):
189 return name
189 return name
190 return '.*' + name
190 return '.*' + name
191 return _globre(name, '', tail)
191 return _globre(name) + tail
192
192
193 def _buildmatch(pats, tail):
193 def _buildmatch(pats, tail):
194 """build a matching function from a set of patterns"""
194 """build a matching function from a set of patterns"""
General Comments 0
You need to be logged in to leave comments. Login now