diff mercurial/match.py @ 14248:25c68ac247c1

match: make 'listfile:' split on LF and CRLF We want util.readfile() to operate in binary mode, so EOLs have to be handled correctly depending on the platform. It seems both easier and more convenient to treat LF and CRLF the same way on all platforms.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 07 May 2011 21:12:30 +0200
parents 135e244776f0
children 1c151b963254
line wrap: on
line diff
--- a/mercurial/match.py	Sat May 07 17:25:12 2011 +0200
+++ b/mercurial/match.py	Sat May 07 21:12:30 2011 +0200
@@ -273,9 +273,12 @@
         elif kind in ('relglob', 'path'):
             name = util.normpath(name)
         elif kind in ('listfile', 'listfile0'):
-            delimiter = kind == 'listfile0' and '\0' or '\n'
             try:
-                files = util.readfile(name).split(delimiter)
+                files = util.readfile(name)
+                if kind == 'listfile0':
+                    files = files.split('\0')
+                else:
+                    files = files.splitlines()
                 files = [f for f in files if f]
             except EnvironmentError:
                 raise util.Abort(_("unable to read file list (%s)") % name)