util: add helper to convert between LF and native EOL
See the next patch for why.
--- 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