Mercurial > hg-stable
changeset 41548:47c92f8ed128
patch: properly escape \ in string literals
Python 3.8 will emit a SyntaxWarning for str/bytes with invalid
escapes. This commit addresses 4 occurrences where we had a bare
\ in a str/bytes.
Differential Revision: https://phab.mercurial-scm.org/D5818
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 04 Feb 2019 08:59:11 -0800 |
parents | 0f64091cc851 |
children | 7a90ff8cd14c |
files | mercurial/patch.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Mon Feb 04 09:07:00 2019 -0800 +++ b/mercurial/patch.py Mon Feb 04 08:59:11 2019 -0800 @@ -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)