Show More
@@ -353,6 +353,29 b' def encoding(mctx, x):' | |||||
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. | |
@@ -395,6 +418,7 b' symbols = {' | |||||
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, |
@@ -226,3 +226,21 b' Test with a revision' | |||||
226 | b2 |
|
226 | b2 | |
227 | c1 |
|
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