diff: slice over bytes to make sure conditions work normally
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 26 Mar 2017 20:52:51 +0530
changeset 31715 6c80f985a13c
parent 31714 bbf7a29dcf9b
child 31716 439a387ca6f1
diff: slice over bytes to make sure conditions work normally Both of this are part of generating `hg diff` on python 3.
mercurial/mdiff.py
mercurial/patch.py
--- a/mercurial/mdiff.py	Wed Mar 29 20:19:26 2017 -0700
+++ b/mercurial/mdiff.py	Sun Mar 26 20:52:51 2017 +0530
@@ -229,7 +229,7 @@
 
     def checknonewline(lines):
         for text in lines:
-            if text[-1] != '\n':
+            if text[-1:] != '\n':
                 text += "\n\ No newline at end of file\n"
             yield text
 
--- a/mercurial/patch.py	Wed Mar 29 20:19:26 2017 -0700
+++ b/mercurial/patch.py	Sun Mar 26 20:52:51 2017 +0530
@@ -737,7 +737,7 @@
         for x in self.rej:
             for l in x.hunk:
                 lines.append(l)
-                if l[-1] != '\n':
+                if l[-1:] != '\n':
                     lines.append("\n\ No newline at end of file\n")
         self.backend.writerej(self.fname, len(self.rej), self.hunks, lines)