[PATCH py3 V2] diff: slice over bytes to make sure conditions work normally

Pulkit Goyal 7895pulkit at gmail.com
Wed Mar 29 19:46:07 UTC 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1490541771 -19800
#      Sun Mar 26 20:52:51 2017 +0530
# Node ID 08aeba5bc7c623a700eea9011e0d904e3732134a
# Parent  331cc4433efe0d897bb16ad4ff08a3fbe850869b
diff: slice over bytes to make sure conditions work normally

Both of this are part of generating `hg diff` on python 3.

diff -r 331cc4433efe -r 08aeba5bc7c6 mercurial/mdiff.py
--- a/mercurial/mdiff.py	Tue Mar 28 08:40:12 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
 
diff -r 331cc4433efe -r 08aeba5bc7c6 mercurial/patch.py
--- a/mercurial/patch.py	Tue Mar 28 08:40:12 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)
 


More information about the Mercurial-devel mailing list