Show More
@@ -353,6 +353,29 b' def encoding(mctx, x):' | |||
|
353 | 353 | |
|
354 | 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 | 379 | def copied(mctx, x): |
|
357 | 380 | """``copied()`` |
|
358 | 381 | File that is recorded as being copied. |
@@ -395,6 +418,7 b' symbols = {' | |||
|
395 | 418 | 'copied': copied, |
|
396 | 419 | 'deleted': deleted, |
|
397 | 420 | 'encoding': encoding, |
|
421 | 'eol': eol, | |
|
398 | 422 | 'exec': exec_, |
|
399 | 423 | 'grep': grep, |
|
400 | 424 | 'ignored': ignored, |
@@ -226,3 +226,21 b' Test with a revision' | |||
|
226 | 226 | b2 |
|
227 | 227 | c1 |
|
228 | 228 | |
|
229 | >>> open('dos', 'wb').write("dos\r\n") | |
|
230 | >>> open('mixed', 'wb').write("dos\r\nunix\n") | |
|
231 | >>> open('mac', 'wb').write("mac\r") | |
|
232 | $ hg add dos mixed mac | |
|
233 | ||
|
234 | $ fileset 'eol(dos)' | |
|
235 | dos | |
|
236 | mixed | |
|
237 | $ fileset 'eol(unix)' | |
|
238 | .hgsub | |
|
239 | .hgsubstate | |
|
240 | a1 | |
|
241 | b1 | |
|
242 | b2 | |
|
243 | c1 | |
|
244 | mixed | |
|
245 | $ fileset 'eol(mac)' | |
|
246 | mac |
General Comments 0
You need to be logged in to leave comments.
Login now