comparison mercurial/fileset.py @ 18842:3ce3f2b059a1

filesets: add eol predicate
author Matt Mackall <mpm@selenic.com>
date Fri, 29 Mar 2013 16:48:32 -0700
parents 6252b4f1c4b4
children 1d08df65cd3c
comparison
equal deleted inserted replaced
18841:e978fb3038e0 18842:3ce3f2b059a1
351 continue 351 continue
352 s.append(f) 352 s.append(f)
353 353
354 return s 354 return s
355 355
356 def eol(mctx, x):
357 """``eol(style)``
358 File contains newlines of the given style (dos, unix, mac). Binary
359 files are excluded, files with mixed line endings match multiple
360 styles.
361 """
362
363 # i18n: "encoding" is a keyword
364 enc = getstring(x, _("encoding requires an encoding name"))
365
366 s = []
367 for f in mctx.existing():
368 d = mctx.ctx[f].data()
369 if util.binary(d):
370 continue
371 if (enc == 'dos' or enc == 'win') and '\r\n' in d:
372 s.append(f)
373 elif enc == 'unix' and re.search('(?<!\r)\n', d):
374 s.append(f)
375 elif enc == 'mac' and re.search('\r(?!\n)', d):
376 s.append(f)
377 return s
378
356 def copied(mctx, x): 379 def copied(mctx, x):
357 """``copied()`` 380 """``copied()``
358 File that is recorded as being copied. 381 File that is recorded as being copied.
359 """ 382 """
360 # i18n: "copied" is a keyword 383 # i18n: "copied" is a keyword
393 'binary': binary, 416 'binary': binary,
394 'clean': clean, 417 'clean': clean,
395 'copied': copied, 418 'copied': copied,
396 'deleted': deleted, 419 'deleted': deleted,
397 'encoding': encoding, 420 'encoding': encoding,
421 'eol': eol,
398 'exec': exec_, 422 'exec': exec_,
399 'grep': grep, 423 'grep': grep,
400 'ignored': ignored, 424 'ignored': ignored,
401 'hgignore': hgignore, 425 'hgignore': hgignore,
402 'modified': modified, 426 'modified': modified,