mercurial/util.py
changeset 31776 fe9b33bcec6a
parent 31720 dea2a17cbfd0
child 31777 6a5b69b0abec
--- a/mercurial/util.py	Wed Mar 29 21:23:28 2017 +0900
+++ b/mercurial/util.py	Wed Mar 29 21:28:54 2017 +0900
@@ -2200,6 +2200,17 @@
     (1, 1, _('%.0f bytes')),
     )
 
+# Matches a single EOL which can either be a CRLF where repeated CR
+# are removed or a LF. We do not care about old Macintosh files, so a
+# stray CR is an error.
+_eolre = remod.compile(br'\r*\n')
+
+def tolf(s):
+    return _eolre.sub('\n', s)
+
+def tocrlf(s):
+    return _eolre.sub('\r\n', s)
+
 def escapestr(s):
     # call underlying function of s.encode('string_escape') directly for
     # Python 3 compatibility