##// END OF EJS Templates
patch: construct and parse binary hunks at the same time
Patrick Mezard -
r14384:9d59c596 default
parent child Browse files
Show More
@@ -960,10 +960,11 b' class hunk(object):'
960 960
961 961 class binhunk:
962 962 'A binary patch file. Only understands literals so far.'
963 def __init__(self, gitpatch):
963 def __init__(self, gitpatch, lr):
964 964 self.gitpatch = gitpatch
965 965 self.text = None
966 966 self.hunk = ['GIT binary patch\n']
967 self._read(lr)
967 968
968 969 def createfile(self):
969 970 return self.gitpatch.op == 'ADD'
@@ -977,7 +978,7 b' class binhunk:'
977 978 def new(self):
978 979 return [self.text]
979 980
980 def extract(self, lr):
981 def _read(self, lr):
981 982 line = lr.readline()
982 983 self.hunk.append(line)
983 984 while line and not line.startswith('literal '):
@@ -1135,8 +1136,7 b' def iterhunks(fp):'
1135 1136 or x.startswith('GIT binary patch')):
1136 1137 gp = changed.get(bfile)
1137 1138 if x.startswith('GIT binary patch'):
1138 h = binhunk(gp)
1139 h.extract(lr)
1139 h = binhunk(gp, lr)
1140 1140 afile = 'a/' + afile
1141 1141 bfile = 'b/' + bfile
1142 1142 else:
General Comments 0
You need to be logged in to leave comments. Login now