##// END OF EJS Templates
changegroup: new bundler API
Benoit Boissinot -
r14143:da635d3c default
parent child Browse files
Show More
@@ -6,7 +6,8 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import util
9 from node import nullrev
10 import mdiff, util
10 import struct, os, bz2, zlib, tempfile
11 import struct, os, bz2, zlib, tempfile
11
12
12 _BUNDLE10_DELTA_HEADER = "20s20s20s20s"
13 _BUNDLE10_DELTA_HEADER = "20s20s20s20s"
@@ -212,16 +213,33 b' def readbundle(fh, fname):'
212 return unbundle10(fh, alg)
213 return unbundle10(fh, alg)
213
214
214 class bundle10(object):
215 class bundle10(object):
216 deltaheader = _BUNDLE10_DELTA_HEADER
215 def __init__(self, lookup):
217 def __init__(self, lookup):
216 self._lookup = lookup
218 self._lookup = lookup
217 def close(self):
219 def close(self):
218 return closechunk()
220 return closechunk()
219 def fileheader(self, fname):
221 def fileheader(self, fname):
220 return chunkheader(len(fname)) + fname
222 return chunkheader(len(fname)) + fname
221 def revchunk(self, revlog, node='', p1='', p2='', prefix='', data=''):
223 def revchunk(self, revlog, rev, prev):
224 node = revlog.node(rev)
225 p1, p2 = revlog.parentrevs(rev)
226 base = prev
227
228 prefix = ''
229 if base == nullrev:
230 delta = revlog.revision(node)
231 prefix = mdiff.trivialdiffheader(len(delta))
232 else:
233 delta = revlog.revdiff(base, rev)
222 linknode = self._lookup(revlog, node)
234 linknode = self._lookup(revlog, node)
223 meta = node + p1 + p2 + linknode + prefix
235 p1n, p2n = revlog.parents(node)
224 l = len(meta) + len(data)
236 basenode = revlog.node(base)
237 meta = self.builddeltaheader(node, p1n, p2n, basenode, linknode)
238 meta += prefix
239 l = len(meta) + len(delta)
225 yield chunkheader(l)
240 yield chunkheader(l)
226 yield meta
241 yield meta
227 yield data
242 yield delta
243 def builddeltaheader(self, node, p1n, p2n, basenode, linknode):
244 # do nothing with basenode, it is implicitly the previous one in HG10
245 return struct.pack(self.deltaheader, node, p1n, p2n, linknode)
@@ -1086,17 +1086,8 b' class revlog(object):'
1086
1086
1087 # build deltas
1087 # build deltas
1088 for r in xrange(len(revs) - 1):
1088 for r in xrange(len(revs) - 1):
1089 a, b = revs[r], revs[r + 1]
1089 prev, curr = revs[r], revs[r + 1]
1090 nb = self.node(b)
1090 for c in bundler.revchunk(self, curr, prev):
1091 p1, p2 = self.parents(nb)
1092 prefix = ''
1093
1094 if a == nullrev:
1095 d = self.revision(nb)
1096 prefix = mdiff.trivialdiffheader(len(d))
1097 else:
1098 d = self.revdiff(a, b)
1099 for c in bundler.revchunk(self, nb, p1, p2, prefix, d):
1100 yield c
1091 yield c
1101
1092
1102 yield bundler.close()
1093 yield bundler.close()
General Comments 0
You need to be logged in to leave comments. Login now