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

login
register
mail settings
Submitter Pulkit Goyal
Date March 29, 2017, 7:46 p.m.
Message ID <08aeba5bc7c623a700ee.1490816767@pulkit-goyal>
Download mbox | patch
Permalink /patch/19827/
State Accepted
Headers show

Comments

Pulkit Goyal - March 29, 2017, 7:46 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@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.
Yuya Nishihara - March 30, 2017, 2:16 p.m.
On Thu, 30 Mar 2017 01:16:07 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@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

Queued, thanks.

Patch

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)