Mercurial > public > mercurial-scm > hg
comparison mercurial/fileset.py @ 14684:87b9d6a7d807
fileset: add encoding() predicate
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 18 Jun 2011 16:53:49 -0500 |
parents | 281102f37b24 |
children | 394121d9f4fc |
comparison
equal
deleted
inserted
replaced
14683:281102f37b24 | 14684:87b9d6a7d807 |
---|---|
311 else: | 311 else: |
312 raise error.ParseError(_("couldn't parse size"), expr) | 312 raise error.ParseError(_("couldn't parse size"), expr) |
313 | 313 |
314 return [f for f in mctx.subset if m(mctx.ctx[f].size())] | 314 return [f for f in mctx.subset if m(mctx.ctx[f].size())] |
315 | 315 |
316 def encoding(mctx, x): | |
317 """``encoding(name)`` | |
318 File can be successfully decoded with the given character | |
319 encoding. May not be useful for encodings other than ASCII and | |
320 UTF-8. | |
321 """ | |
322 | |
323 enc = getstring(x, _("encoding requires an encoding name")) | |
324 | |
325 s = [] | |
326 for f in mctx.subset: | |
327 d = mctx.ctx[f].data() | |
328 try: | |
329 d.decode(enc) | |
330 except LookupError: | |
331 raise util.Abort(_("unknown encoding '%s'") % enc) | |
332 except UnicodeDecodeError: | |
333 continue | |
334 s.append(f) | |
335 | |
336 return s | |
337 | |
316 symbols = { | 338 symbols = { |
317 'added': added, | 339 'added': added, |
318 'binary': binary, | 340 'binary': binary, |
319 'clean': clean, | 341 'clean': clean, |
320 'deleted': deleted, | 342 'deleted': deleted, |
343 'encoding': encoding, | |
321 'exec': exec_, | 344 'exec': exec_, |
322 'grep': grep, | 345 'grep': grep, |
323 'ignored': ignored, | 346 'ignored': ignored, |
324 'hgignore': hgignore, | 347 'hgignore': hgignore, |
325 'modified': modified, | 348 'modified': modified, |