##// END OF EJS Templates
patch: pass linereader to binaryhunk.extract() instead of wrapped fp...
Patrick Mezard -
r7153:353141d7 default
parent child Browse files
Show More
@@ -669,17 +669,17 b' class binhunk:'
669 def new(self):
669 def new(self):
670 return [self.text]
670 return [self.text]
671
671
672 def extract(self, fp):
672 def extract(self, lr):
673 line = fp.readline()
673 line = lr.readline()
674 self.hunk.append(line)
674 self.hunk.append(line)
675 while line and not line.startswith('literal '):
675 while line and not line.startswith('literal '):
676 line = fp.readline()
676 line = lr.readline()
677 self.hunk.append(line)
677 self.hunk.append(line)
678 if not line:
678 if not line:
679 raise PatchError(_('could not extract binary patch'))
679 raise PatchError(_('could not extract binary patch'))
680 size = int(line[8:].rstrip())
680 size = int(line[8:].rstrip())
681 dec = []
681 dec = []
682 line = fp.readline()
682 line = lr.readline()
683 self.hunk.append(line)
683 self.hunk.append(line)
684 while len(line) > 1:
684 while len(line) > 1:
685 l = line[0]
685 l = line[0]
@@ -688,7 +688,7 b' class binhunk:'
688 else:
688 else:
689 l = ord(l) - ord('a') + 27
689 l = ord(l) - ord('a') + 27
690 dec.append(base85.b85decode(line[1:-1])[:l])
690 dec.append(base85.b85decode(line[1:-1])[:l])
691 line = fp.readline()
691 line = lr.readline()
692 self.hunk.append(line)
692 self.hunk.append(line)
693 text = zlib.decompress(''.join(dec))
693 text = zlib.decompress(''.join(dec))
694 if len(text) != size:
694 if len(text) != size:
@@ -806,7 +806,7 b' def scangitpatch(lr, firstline):'
806 gitlr.push(firstline)
806 gitlr.push(firstline)
807 (dopatch, gitpatches) = readgitpatch(gitlr)
807 (dopatch, gitpatches) = readgitpatch(gitlr)
808 fp.seek(pos)
808 fp.seek(pos)
809 return fp, dopatch, gitpatches
809 return dopatch, gitpatches
810
810
811 def iterhunks(ui, fp, sourcefile=None):
811 def iterhunks(ui, fp, sourcefile=None):
812 """Read a patch and yield the following events:
812 """Read a patch and yield the following events:
@@ -871,7 +871,7 b' def iterhunks(ui, fp, sourcefile=None):'
871 if emitfile:
871 if emitfile:
872 emitfile = False
872 emitfile = False
873 yield 'file', (afile, bfile, current_hunk)
873 yield 'file', (afile, bfile, current_hunk)
874 current_hunk.extract(fp)
874 current_hunk.extract(lr)
875 elif x.startswith('diff --git'):
875 elif x.startswith('diff --git'):
876 # check for git diff, scanning the whole patch file if needed
876 # check for git diff, scanning the whole patch file if needed
877 m = gitre.match(x)
877 m = gitre.match(x)
@@ -879,7 +879,7 b' def iterhunks(ui, fp, sourcefile=None):'
879 afile, bfile = m.group(1, 2)
879 afile, bfile = m.group(1, 2)
880 if not git:
880 if not git:
881 git = True
881 git = True
882 fp, dopatch, gitpatches = scangitpatch(lr, x)
882 dopatch, gitpatches = scangitpatch(lr, x)
883 yield 'git', gitpatches
883 yield 'git', gitpatches
884 for gp in gitpatches:
884 for gp in gitpatches:
885 changed[gp.path] = gp
885 changed[gp.path] = gp
General Comments 0
You need to be logged in to leave comments. Login now