diff mercurial/patch.py @ 45154:10f48720ef95

diff: move no-eol text constant to a common location Differential Revision: https://phab.mercurial-scm.org/D8763
author Rodrigo Damazio Bovendorp <rdamazio@google.com>
date Fri, 17 Jul 2020 03:53:19 -0700
parents 20a65e397943
children 210f9b8d7bbd ac362d5a7893
line wrap: on
line diff
--- a/mercurial/patch.py	Fri Jul 17 02:31:42 2020 -0700
+++ b/mercurial/patch.py	Fri Jul 17 03:53:19 2020 -0700
@@ -785,7 +785,7 @@
             for l in x.hunk:
                 lines.append(l)
                 if l[-1:] != b'\n':
-                    lines.append(b"\n\\ No newline at end of file\n")
+                    lines.append(b'\n' + diffhelper.MISSING_NEWLINE_MARKER)
         self.backend.writerej(self.fname, len(self.rej), self.hunks, lines)
 
     def apply(self, h):
@@ -1069,7 +1069,7 @@
 
     def write(self, fp):
         delta = len(self.before) + len(self.after)
-        if self.after and self.after[-1] == b'\\ No newline at end of file\n':
+        if self.after and self.after[-1] == diffhelper.MISSING_NEWLINE_MARKER:
             delta -= 1
         fromlen = delta + self.removed
         tolen = delta + self.added