py3: replace s[-1] with s.endswith() in eol handling
authorYuya Nishihara <yuya@tcha.org>
Sat, 16 Jun 2018 17:53:51 +0900
changeset 38329 f47608575c10
parent 38328 aa9dd805234d
child 38330 ae3f17a87b28
py3: replace s[-1] with s.endswith() in eol handling
contrib/python3-whitelist
hgext/eol.py
mercurial/patch.py
--- a/contrib/python3-whitelist	Sat Jun 16 17:36:44 2018 +0900
+++ b/contrib/python3-whitelist	Sat Jun 16 17:53:51 2018 +0900
@@ -123,6 +123,7 @@
 test-eol-add.t
 test-eol-clone.t
 test-eol-hook.t
+test-eol-patch.t
 test-eol-tag.t
 test-eol-update.t
 test-excessive-merge.t
@@ -199,6 +200,7 @@
 test-http.t
 test-hybridencode.py
 test-identify.t
+test-import-bypass.t
 test-import-merge.t
 test-import-unknown.t
 test-import.t
--- a/hgext/eol.py	Sat Jun 16 17:36:44 2018 +0900
+++ b/hgext/eol.py	Sat Jun 16 17:53:51 2018 +0900
@@ -142,7 +142,7 @@
     if ui.configbool('eol', 'only-consistent') and inconsistenteol(s):
         return s
     if (ui.configbool('eol', 'fix-trailing-newline')
-        and s and s[-1] != '\n'):
+        and s and not s.endswith('\n')):
         s = s + '\n'
     return util.tolf(s)
 
@@ -153,7 +153,7 @@
     if ui.configbool('eol', 'only-consistent') and inconsistenteol(s):
         return s
     if (ui.configbool('eol', 'fix-trailing-newline')
-        and s and s[-1] != '\n'):
+        and s and not s.endswith('\n')):
         s = s + '\n'
     return util.tocrlf(s)
 
--- a/mercurial/patch.py	Sat Jun 16 17:36:44 2018 +0900
+++ b/mercurial/patch.py	Sat Jun 16 17:53:51 2018 +0900
@@ -707,7 +707,7 @@
         if self.eolmode != 'strict' and eol and eol != '\n':
             rawlines = []
             for l in lines:
-                if l and l[-1] == '\n':
+                if l and l.endswith('\n'):
                     l = l[:-1] + eol
                 rawlines.append(l)
             lines = rawlines