pycompat: provide bytes os.linesep
authorYuya Nishihara <yuya@tcha.org>
Wed, 29 Mar 2017 21:23:28 +0900
changeset 31775 8181f378b073
parent 31774 7d2cbe11ae48
child 31776 fe9b33bcec6a
pycompat: provide bytes os.linesep
hgext/eol.py
mercurial/pycompat.py
mercurial/ui.py
--- 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