##// END OF EJS Templates
patch: properly escape \ in string literals...
Gregory Szorc -
r41675:47c92f8e default
parent child Browse files
Show More
@@ -753,7 +753,7 b' class patchfile(object):'
753 for l in x.hunk:
753 for l in x.hunk:
754 lines.append(l)
754 lines.append(l)
755 if l[-1:] != '\n':
755 if l[-1:] != '\n':
756 lines.append("\n\ No newline at end of file\n")
756 lines.append("\n\\ No newline at end of file\n")
757 self.backend.writerej(self.fname, len(self.rej), self.hunks, lines)
757 self.backend.writerej(self.fname, len(self.rej), self.hunks, lines)
758
758
759 def apply(self, h):
759 def apply(self, h):
@@ -1305,7 +1305,7 b' class hunk(object):'
1305 self.hunk.append(u)
1305 self.hunk.append(u)
1306
1306
1307 l = lr.readline()
1307 l = lr.readline()
1308 if l.startswith('\ '):
1308 if l.startswith(br'\ '):
1309 s = self.a[-1][:-1]
1309 s = self.a[-1][:-1]
1310 self.a[-1] = s
1310 self.a[-1] = s
1311 self.hunk[-1] = s
1311 self.hunk[-1] = s
@@ -1323,7 +1323,7 b' class hunk(object):'
1323 hunki = 1
1323 hunki = 1
1324 for x in pycompat.xrange(self.lenb):
1324 for x in pycompat.xrange(self.lenb):
1325 l = lr.readline()
1325 l = lr.readline()
1326 if l.startswith('\ '):
1326 if l.startswith(br'\ '):
1327 # XXX: the only way to hit this is with an invalid line range.
1327 # XXX: the only way to hit this is with an invalid line range.
1328 # The no-eol marker is not counted in the line range, but I
1328 # The no-eol marker is not counted in the line range, but I
1329 # guess there are diff(1) out there which behave differently.
1329 # guess there are diff(1) out there which behave differently.
@@ -1380,7 +1380,7 b' class hunk(object):'
1380
1380
1381 def _fixnewline(self, lr):
1381 def _fixnewline(self, lr):
1382 l = lr.readline()
1382 l = lr.readline()
1383 if l.startswith('\ '):
1383 if l.startswith(br'\ '):
1384 diffhelper.fixnewline(self.hunk, self.a, self.b)
1384 diffhelper.fixnewline(self.hunk, self.a, self.b)
1385 else:
1385 else:
1386 lr.push(l)
1386 lr.push(l)
General Comments 0
You need to be logged in to leave comments. Login now