##// END OF EJS Templates
unbundler: separate delta and header parsing...
Benoit Boissinot -
r14144:3c3c53d8 default
parent child Browse files
Show More
@@ -34,7 +34,7 b' class bundlerevlog(revlog.revlog):'
34 34 n = len(self)
35 35 chain = None
36 36 while 1:
37 chunkdata = bundle.parsechunk(chain)
37 chunkdata = bundle.deltachunk(chain)
38 38 if not chunkdata:
39 39 break
40 40 node = chunkdata['node']
@@ -197,6 +197,8 b' class bundlerepository(localrepo.localre'
197 197
198 198 @util.propertycache
199 199 def changelog(self):
200 # consume the header if it exists
201 self.bundle.changelogheader()
200 202 c = bundlechangelog(self.sopener, self.bundle)
201 203 self.manstart = self.bundle.tell()
202 204 return c
@@ -204,6 +206,8 b' class bundlerepository(localrepo.localre'
204 206 @util.propertycache
205 207 def manifest(self):
206 208 self.bundle.seek(self.manstart)
209 # consume the header if it exists
210 self.bundle.manifestheader()
207 211 m = bundlemanifest(self.sopener, self.bundle, self.changelog.rev)
208 212 self.filestart = self.bundle.tell()
209 213 return m
@@ -225,12 +229,13 b' class bundlerepository(localrepo.localre'
225 229 if not self.bundlefilespos:
226 230 self.bundle.seek(self.filestart)
227 231 while 1:
228 chunk = self.bundle.chunk()
229 if not chunk:
232 chunkdata = self.bundle.filelogheader()
233 if not chunkdata:
230 234 break
231 self.bundlefilespos[chunk] = self.bundle.tell()
235 fname = chunkdata['filename']
236 self.bundlefilespos[fname] = self.bundle.tell()
232 237 while 1:
233 c = self.bundle.chunk()
238 c = self.bundle.deltachunk(None)
234 239 if not c:
235 240 break
236 241
@@ -159,10 +159,21 b' class unbundle10(object):'
159 159 self.callback()
160 160 return l - 4
161 161
162 def chunk(self):
163 """return the next chunk from changegroup 'source' as a string"""
162 def changelogheader(self):
163 """v10 does not have a changelog header chunk"""
164 return {}
165
166 def manifestheader(self):
167 """v10 does not have a manifest header chunk"""
168 return {}
169
170 def filelogheader(self):
171 """return the header of the filelogs chunk, v10 only has the filename"""
164 172 l = self.chunklength()
165 return readexactly(self._stream, l)
173 if not l:
174 return {}
175 fname = readexactly(self._stream, l)
176 return dict(filename=fname)
166 177
167 178 def _deltaheader(self, headertuple, prevnode):
168 179 node, p1, p2, cs = headertuple
@@ -172,7 +183,7 b' class unbundle10(object):'
172 183 deltabase = prevnode
173 184 return node, p1, p2, deltabase, cs
174 185
175 def parsechunk(self, prevnode):
186 def deltachunk(self, prevnode):
176 187 l = self.chunklength()
177 188 if not l:
178 189 return {}
@@ -1220,7 +1220,7 b' def debugbundle(ui, bundlepath, all=None'
1220 1220 ui.write("\n%s\n" % named)
1221 1221 chain = None
1222 1222 while 1:
1223 chunkdata = gen.parsechunk(chain)
1223 chunkdata = gen.deltachunk(chain)
1224 1224 if not chunkdata:
1225 1225 break
1226 1226 node = chunkdata['node']
@@ -1234,17 +1234,21 b' def debugbundle(ui, bundlepath, all=None'
1234 1234 hex(cs), hex(deltabase), len(delta)))
1235 1235 chain = node
1236 1236
1237 chunkdata = gen.changelogheader()
1237 1238 showchunks("changelog")
1239 chunkdata = gen.manifestheader()
1238 1240 showchunks("manifest")
1239 1241 while 1:
1240 fname = gen.chunk()
1241 if not fname:
1242 chunkdata = gen.filelogheader()
1243 if not chunkdata:
1242 1244 break
1245 fname = chunkdata['filename']
1243 1246 showchunks(fname)
1244 1247 else:
1248 chunkdata = gen.changelogheader()
1245 1249 chain = None
1246 1250 while 1:
1247 chunkdata = gen.parsechunk(chain)
1251 chunkdata = gen.deltachunk(chain)
1248 1252 if not chunkdata:
1249 1253 break
1250 1254 node = chunkdata['node']
@@ -1712,6 +1712,7 b' class localrepository(repo.repository):'
1712 1712 pr = prog()
1713 1713 source.callback = pr
1714 1714
1715 source.changelogheader()
1715 1716 if (cl.addgroup(source, csmap, trp) is None
1716 1717 and not emptyok):
1717 1718 raise util.Abort(_("received changelog group is empty"))
@@ -1731,6 +1732,7 b' class localrepository(repo.repository):'
1731 1732 # if the result of the merge of 1 and 2 is the same in 3 and 4,
1732 1733 # no new manifest will be created and the manifest group will
1733 1734 # be empty during the pull
1735 source.manifestheader()
1734 1736 self.manifest.addgroup(source, revmap, trp)
1735 1737 self.ui.progress(_('manifests'), None)
1736 1738
@@ -1752,9 +1754,10 b' class localrepository(repo.repository):'
1752 1754 source.callback = None
1753 1755
1754 1756 while 1:
1755 f = source.chunk()
1756 if not f:
1757 chunkdata = source.filelogheader()
1758 if not chunkdata:
1757 1759 break
1760 f = chunkdata["filename"]
1758 1761 self.ui.debug("adding %s revisions\n" % f)
1759 1762 pr()
1760 1763 fl = self.file(f)
@@ -1122,7 +1122,7 b' class revlog(object):'
1122 1122 # loop through our set of deltas
1123 1123 chain = None
1124 1124 while 1:
1125 chunkdata = bundle.parsechunk(chain)
1125 chunkdata = bundle.deltachunk(chain)
1126 1126 if not chunkdata:
1127 1127 break
1128 1128 node = chunkdata['node']
General Comments 0
You need to be logged in to leave comments. Login now