# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2017-03-26 15:22:51 # Node ID 6c80f985a13c6fb438a7c8abb9c8c8142844a8b9 # Parent bbf7a29dcf9b3c1c8ce285f5fae64027206739dc diff: slice over bytes to make sure conditions work normally Both of this are part of generating `hg diff` on python 3. diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -229,7 +229,7 @@ def unidiff(a, ad, b, bd, fn1, fn2, opts 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 --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -737,7 +737,7 @@ class patchfile(object): 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)