##// END OF EJS Templates
Use line length field when extracting git binary patches
Brendan Cully -
r3374:fd43ff3b default
parent child Browse files
Show More
@@ -191,18 +191,22 b' def readgitpatch(patchname):'
191 def dogitpatch(patchname, gitpatches, cwd=None):
191 def dogitpatch(patchname, gitpatches, cwd=None):
192 """Preprocess git patch so that vanilla patch can handle it"""
192 """Preprocess git patch so that vanilla patch can handle it"""
193 def extractbin(fp):
193 def extractbin(fp):
194 line = fp.readline()
194 line = fp.readline().rstrip()
195 while line and not line.startswith('literal '):
195 while line and not line.startswith('literal '):
196 line = fp.readline()
196 line = fp.readline().rstrip()
197 if not line:
197 if not line:
198 return
198 return
199 size = int(line[8:].rstrip())
199 size = int(line[8:])
200 dec = []
200 dec = []
201 line = fp.readline()
201 line = fp.readline().rstrip()
202 while line:
202 while line:
203 line = line[1:-1]
203 l = line[0]
204 dec.append(base85.b85decode(line))
204 if l <= 'Z' and l >= 'A':
205 line = fp.readline()
205 l = ord(l) - ord('A') + 1
206 else:
207 l = ord(l) - ord('a') + 27
208 dec.append(base85.b85decode(line[1:])[:l])
209 line = fp.readline().rstrip()
206 text = zlib.decompress(''.join(dec))
210 text = zlib.decompress(''.join(dec))
207 if len(text) != size:
211 if len(text) != size:
208 raise util.Abort(_('binary patch is %d bytes, not %d') %
212 raise util.Abort(_('binary patch is %d bytes, not %d') %
General Comments 0
You need to be logged in to leave comments. Login now