diff --git a/hgext/eol.py b/hgext/eol.py --- a/hgext/eol.py +++ b/hgext/eol.py @@ -101,6 +101,7 @@ from mercurial import ( error, extensions, match, + pycompat, util, ) @@ -170,7 +171,7 @@ class eolfile(object): isrepolf = self.cfg.get('repository', 'native') != 'CRLF' self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf' - iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n') + iswdlf = ui.config('eol', 'native', pycompat.oslinesep) in ('LF', '\n') self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf' include = [] diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -42,6 +42,7 @@ if ispy3: fsencode = os.fsencode fsdecode = os.fsdecode # A bytes version of os.name. + oslinesep = os.linesep.encode('ascii') osname = os.name.encode('ascii') ospathsep = os.pathsep.encode('ascii') ossep = os.sep.encode('ascii') @@ -231,6 +232,7 @@ else: strkwargs = identity byteskwargs = identity + oslinesep = os.linesep osname = os.name ospathsep = os.pathsep ossep = os.sep diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1102,7 +1102,7 @@ class ui(object): # When stdin is in binary mode on Windows, it can cause # raw_input() to emit an extra trailing carriage return - if os.linesep == '\r\n' and line and line[-1] == '\r': + if pycompat.oslinesep == '\r\n' and line and line[-1] == '\r': line = line[:-1] return line