##// END OF EJS Templates
fileset: move helper functions to top
Yuya Nishihara -
r38617:d046bf37 default
parent child Browse files
Show More
@@ -126,6 +126,19 b' def getpattern(x, allkinds, err):'
126 return _getkindpat(x[1], x[2], allkinds, err)
126 return _getkindpat(x[1], x[2], allkinds, err)
127 return getstring(x, err)
127 return getstring(x, err)
128
128
129 def getlist(x):
130 if not x:
131 return []
132 if x[0] == 'list':
133 return getlist(x[1]) + [x[2]]
134 return [x]
135
136 def getargs(x, min, max, err):
137 l = getlist(x)
138 if len(l) < min or len(l) > max:
139 raise error.ParseError(err)
140 return l
141
129 def getset(mctx, x):
142 def getset(mctx, x):
130 if not x:
143 if not x:
131 raise error.ParseError(_("missing argument"))
144 raise error.ParseError(_("missing argument"))
@@ -164,6 +177,21 b' def listset(mctx, a, b):'
164 raise error.ParseError(_("can't use a list in this context"),
177 raise error.ParseError(_("can't use a list in this context"),
165 hint=_('see hg help "filesets.x or y"'))
178 hint=_('see hg help "filesets.x or y"'))
166
179
180 def func(mctx, a, b):
181 funcname = getsymbol(a)
182 if funcname in symbols:
183 enabled = mctx._existingenabled
184 mctx._existingenabled = funcname in _existingcallers
185 try:
186 return symbols[funcname](mctx, b)
187 finally:
188 mctx._existingenabled = enabled
189
190 keep = lambda fn: getattr(fn, '__doc__', None) is not None
191
192 syms = [s for (s, fn) in symbols.items() if keep(fn)]
193 raise error.UnknownIdentifier(funcname, syms)
194
167 # symbols are callable like:
195 # symbols are callable like:
168 # fun(mctx, x)
196 # fun(mctx, x)
169 # with:
197 # with:
@@ -253,34 +281,6 b' def clean(mctx, x):'
253 s = set(mctx.status().clean)
281 s = set(mctx.status().clean)
254 return [f for f in mctx.subset if f in s]
282 return [f for f in mctx.subset if f in s]
255
283
256 def func(mctx, a, b):
257 funcname = getsymbol(a)
258 if funcname in symbols:
259 enabled = mctx._existingenabled
260 mctx._existingenabled = funcname in _existingcallers
261 try:
262 return symbols[funcname](mctx, b)
263 finally:
264 mctx._existingenabled = enabled
265
266 keep = lambda fn: getattr(fn, '__doc__', None) is not None
267
268 syms = [s for (s, fn) in symbols.items() if keep(fn)]
269 raise error.UnknownIdentifier(funcname, syms)
270
271 def getlist(x):
272 if not x:
273 return []
274 if x[0] == 'list':
275 return getlist(x[1]) + [x[2]]
276 return [x]
277
278 def getargs(x, min, max, err):
279 l = getlist(x)
280 if len(l) < min or len(l) > max:
281 raise error.ParseError(err)
282 return l
283
284 @predicate('binary()', callexisting=True)
284 @predicate('binary()', callexisting=True)
285 def binary(mctx, x):
285 def binary(mctx, x):
286 """File that appears to be binary (contains NUL bytes).
286 """File that appears to be binary (contains NUL bytes).
General Comments 0
You need to be logged in to leave comments. Login now