##// END OF EJS Templates
diffhelper: rename module to avoid conflicts with ancient C module (issue5846)...
Yuya Nishihara -
r37821:72f6498c stable
parent child Browse files
Show More
@@ -1,4 +1,4 b''
1 # diffhelpers.py - helper routines for patch
1 # diffhelper.py - helper routines for patch
2 #
2 #
3 # Copyright 2009 Matt Mackall <mpm@selenic.com> and others
3 # Copyright 2009 Matt Mackall <mpm@selenic.com> and others
4 #
4 #
@@ -28,7 +28,7 b' from .node import ('
28 )
28 )
29 from . import (
29 from . import (
30 copies,
30 copies,
31 diffhelpers,
31 diffhelper,
32 encoding,
32 encoding,
33 error,
33 error,
34 mail,
34 mail,
@@ -800,7 +800,7 b' class patchfile(object):'
800 # if there's skew we want to emit the "(offset %d lines)" even
800 # if there's skew we want to emit the "(offset %d lines)" even
801 # when the hunk cleanly applies at start + skew, so skip the
801 # when the hunk cleanly applies at start + skew, so skip the
802 # fast case code
802 # fast case code
803 if self.skew == 0 and diffhelpers.testhunk(old, self.lines, oldstart):
803 if self.skew == 0 and diffhelper.testhunk(old, self.lines, oldstart):
804 if self.remove:
804 if self.remove:
805 self.backend.unlink(self.fname)
805 self.backend.unlink(self.fname)
806 else:
806 else:
@@ -827,7 +827,7 b' class patchfile(object):'
827 cand = [oldstart]
827 cand = [oldstart]
828
828
829 for l in cand:
829 for l in cand:
830 if not old or diffhelpers.testhunk(old, self.lines, l):
830 if not old or diffhelper.testhunk(old, self.lines, l):
831 self.lines[l : l + len(old)] = new
831 self.lines[l : l + len(old)] = new
832 self.offset += len(new) - len(old)
832 self.offset += len(new) - len(old)
833 self.skew = l - orig_start
833 self.skew = l - orig_start
@@ -1259,8 +1259,8 b' class hunk(object):'
1259 self.starta = int(self.starta)
1259 self.starta = int(self.starta)
1260 self.startb = int(self.startb)
1260 self.startb = int(self.startb)
1261 try:
1261 try:
1262 diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb,
1262 diffhelper.addlines(lr, self.hunk, self.lena, self.lenb,
1263 self.a, self.b)
1263 self.a, self.b)
1264 except error.ParseError as e:
1264 except error.ParseError as e:
1265 raise PatchError(_("bad hunk #%d: %s") % (self.number, e))
1265 raise PatchError(_("bad hunk #%d: %s") % (self.number, e))
1266 # if we hit eof before finishing out the hunk, the last line will
1266 # if we hit eof before finishing out the hunk, the last line will
@@ -1379,7 +1379,7 b' class hunk(object):'
1379 def _fixnewline(self, lr):
1379 def _fixnewline(self, lr):
1380 l = lr.readline()
1380 l = lr.readline()
1381 if l.startswith('\ '):
1381 if l.startswith('\ '):
1382 diffhelpers.fixnewline(self.hunk, self.a, self.b)
1382 diffhelper.fixnewline(self.hunk, self.a, self.b)
1383 else:
1383 else:
1384 lr.push(l)
1384 lr.push(l)
1385
1385
General Comments 0
You need to be logged in to leave comments. Login now