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