changeset 31775:8181f378b073

pycompat: provide bytes os.linesep
author Yuya Nishihara <yuya@tcha.org>
date Wed, 29 Mar 2017 21:23:28 +0900
parents 7d2cbe11ae48
children fe9b33bcec6a
files hgext/eol.py mercurial/pycompat.py mercurial/ui.py
diffstat 3 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/eol.py	Wed Mar 29 21:13:55 2017 +0900
+++ b/hgext/eol.py	Wed Mar 29 21:23:28 2017 +0900
@@ -101,6 +101,7 @@
     error,
     extensions,
     match,
+    pycompat,
     util,
 )
 
@@ -170,7 +171,7 @@
 
         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 = []
--- a/mercurial/pycompat.py	Wed Mar 29 21:13:55 2017 +0900
+++ b/mercurial/pycompat.py	Wed Mar 29 21:23:28 2017 +0900
@@ -42,6 +42,7 @@
     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 @@
     strkwargs = identity
     byteskwargs = identity
 
+    oslinesep = os.linesep
     osname = os.name
     ospathsep = os.pathsep
     ossep = os.sep
--- a/mercurial/ui.py	Wed Mar 29 21:13:55 2017 +0900
+++ b/mercurial/ui.py	Wed Mar 29 21:23:28 2017 +0900
@@ -1102,7 +1102,7 @@
 
         # 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