diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -753,7 +753,7 @@ for l in x.hunk: lines.append(l) if l[-1:] != '\n': - lines.append("\n\ No newline at end of file\n") + lines.append("\n\\ No newline at end of file\n") self.backend.writerej(self.fname, len(self.rej), self.hunks, lines) def apply(self, h): @@ -1305,7 +1305,7 @@ self.hunk.append(u) l = lr.readline() - if l.startswith('\ '): + if l.startswith(br'\ '): s = self.a[-1][:-1] self.a[-1] = s self.hunk[-1] = s @@ -1323,7 +1323,7 @@ hunki = 1 for x in pycompat.xrange(self.lenb): l = lr.readline() - if l.startswith('\ '): + if l.startswith(br'\ '): # XXX: the only way to hit this is with an invalid line range. # The no-eol marker is not counted in the line range, but I # guess there are diff(1) out there which behave differently. @@ -1380,7 +1380,7 @@ def _fixnewline(self, lr): l = lr.readline() - if l.startswith('\ '): + if l.startswith(br'\ '): diffhelper.fixnewline(self.hunk, self.a, self.b) else: lr.push(l)