comparison mercurial/patch.py @ 16567:aef3d0d4631c

patch: clarify binary hunk parsing loop
author Patrick Mezard <patrick@mezard.eu>
date Sun, 29 Apr 2012 11:19:51 +0200
parents ed6a74312176
children ea7bf1d49bce
comparison
equal deleted inserted replaced
16566:ae6dddffe4f1 16567:aef3d0d4631c
1038 def getline(lr, hunk): 1038 def getline(lr, hunk):
1039 l = lr.readline() 1039 l = lr.readline()
1040 hunk.append(l) 1040 hunk.append(l)
1041 return l.rstrip('\r\n') 1041 return l.rstrip('\r\n')
1042 1042
1043 line = getline(lr, self.hunk) 1043 while True:
1044 while line and not line.startswith('literal '):
1045 line = getline(lr, self.hunk) 1044 line = getline(lr, self.hunk)
1046 if not line: 1045 if not line:
1047 raise PatchError(_('could not extract "%s" binary data') 1046 raise PatchError(_('could not extract "%s" binary data')
1048 % self._fname) 1047 % self._fname)
1048 if line.startswith('literal '):
1049 break
1049 size = int(line[8:].rstrip()) 1050 size = int(line[8:].rstrip())
1050 dec = [] 1051 dec = []
1051 line = getline(lr, self.hunk) 1052 line = getline(lr, self.hunk)
1052 while len(line) > 1: 1053 while len(line) > 1:
1053 l = line[0] 1054 l = line[0]