##// 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 class binhunk:
961 class binhunk:
962 'A binary patch file. Only understands literals so far.'
962 'A binary patch file. Only understands literals so far.'
963 def __init__(self, gitpatch):
963 def __init__(self, gitpatch, lr):
964 self.gitpatch = gitpatch
964 self.gitpatch = gitpatch
965 self.text = None
965 self.text = None
966 self.hunk = ['GIT binary patch\n']
966 self.hunk = ['GIT binary patch\n']
967 self._read(lr)
967
968
968 def createfile(self):
969 def createfile(self):
969 return self.gitpatch.op == 'ADD'
970 return self.gitpatch.op == 'ADD'
@@ -977,7 +978,7 b' class binhunk:'
977 def new(self):
978 def new(self):
978 return [self.text]
979 return [self.text]
979
980
980 def extract(self, lr):
981 def _read(self, lr):
981 line = lr.readline()
982 line = lr.readline()
982 self.hunk.append(line)
983 self.hunk.append(line)
983 while line and not line.startswith('literal '):
984 while line and not line.startswith('literal '):
@@ -1135,8 +1136,7 b' def iterhunks(fp):'
1135 or x.startswith('GIT binary patch')):
1136 or x.startswith('GIT binary patch')):
1136 gp = changed.get(bfile)
1137 gp = changed.get(bfile)
1137 if x.startswith('GIT binary patch'):
1138 if x.startswith('GIT binary patch'):
1138 h = binhunk(gp)
1139 h = binhunk(gp, lr)
1139 h.extract(lr)
1140 afile = 'a/' + afile
1140 afile = 'a/' + afile
1141 bfile = 'b/' + bfile
1141 bfile = 'b/' + bfile
1142 else:
1142 else:
General Comments 0
You need to be logged in to leave comments. Login now