changeset 31777:6a5b69b0abec

util: add helper to convert between LF and native EOL See the next patch for why.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 29 Mar 2017 21:40:15 +0900
parents fe9b33bcec6a
children ac69675fff1c
files mercurial/util.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Wed Mar 29 21:28:54 2017 +0900
+++ b/mercurial/util.py	Wed Mar 29 21:40:15 2017 +0900
@@ -2211,6 +2211,13 @@
 def tocrlf(s):
     return _eolre.sub('\r\n', s)
 
+if pycompat.oslinesep == '\r\n':
+    tonativeeol = tocrlf
+    fromnativeeol = tolf
+else:
+    tonativeeol = pycompat.identity
+    fromnativeeol = pycompat.identity
+
 def escapestr(s):
     # call underlying function of s.encode('string_escape') directly for
     # Python 3 compatibility