##// END OF EJS Templates
bundle: get rid of chunkiter
Matt Mackall -
r12335:e21fe9c5 default
parent child Browse files
Show More
@@ -117,7 +117,7 b' def writerevs(ui, r1, r2, order, tr):'
117 117
118 118 try:
119 119 group = util.chunkbuffer(r1.group(order, lookup, progress))
120 r2.addgroup(group.chunks(), unlookup, tr)
120 r2.addgroup(group, unlookup, tr)
121 121 finally:
122 122 ui.progress(_('writing'), None)
123 123
@@ -33,7 +33,10 b' class bundlerevlog(revlog.revlog):'
33 33 self.bundle = bundle
34 34 self.basemap = {}
35 35 def chunkpositer():
36 for chunk in bundle.chunks():
36 while 1:
37 chunk = bundle.chunk()
38 if not chunk:
39 break
37 40 pos = bundle.tell()
38 41 yield chunk, pos - len(chunk)
39 42 n = len(self)
@@ -230,8 +233,10 b' class bundlerepository(localrepo.localre'
230 233 if not chunk:
231 234 break
232 235 self.bundlefilespos[chunk] = self.bundle.tell()
233 for c in self.bundle.chunks():
234 pass
236 while 1:
237 c = self.bundle.chunk()
238 if not c:
239 break
235 240
236 241 if f[0] == '/':
237 242 f = f[1:]
@@ -24,17 +24,6 b' def getchunk(source):'
24 24 % (len(d), l - 4))
25 25 return d
26 26
27 def chunkiter(source, progress=None):
28 """iterate through the chunks in source, yielding a sequence of chunks
29 (strings)"""
30 while 1:
31 c = getchunk(source)
32 if not c:
33 break
34 elif progress is not None:
35 progress()
36 yield c
37
38 27 def chunkheader(length):
39 28 """return a changegroup chunk header (string)"""
40 29 return struct.pack(">l", length + 4)
@@ -94,15 +83,18 b' def writebundle(cg, filename, bundletype'
94 83 # parse the changegroup data, otherwise we will block
95 84 # in case of sshrepo because we don't know the end of the stream
96 85
97 # an empty chunkiter is the end of the changegroup
98 # a changegroup has at least 2 chunkiters (changelog and manifest).
99 # after that, an empty chunkiter is the end of the changegroup
86 # an empty chunkgroup is the end of the changegroup
87 # a changegroup has at least 2 chunkgroups (changelog and manifest).
88 # after that, an empty chunkgroup is the end of the changegroup
100 89 empty = False
101 90 count = 0
102 91 while not empty or count <= 2:
103 92 empty = True
104 93 count += 1
105 for chunk in chunkiter(cg):
94 while 1:
95 chunk = getchunk(cg)
96 if not chunk:
97 break
106 98 empty = False
107 99 fh.write(z.compress(chunkheader(len(chunk))))
108 100 pos = 0
@@ -171,13 +163,6 b' class unbundle10(object):'
171 163 % (len(d), l))
172 164 return d
173 165
174 def chunks(self):
175 while 1:
176 c = self.chunk()
177 if not c:
178 break
179 yield c
180
181 166 class headerlessfixup(object):
182 167 def __init__(self, fh, h):
183 168 self._h = h
@@ -1676,7 +1676,7 b' class localrepository(repo.repository):'
1676 1676 pr = prog()
1677 1677 source.callback = pr
1678 1678
1679 if (cl.addgroup(source.chunks(), csmap, trp) is None
1679 if (cl.addgroup(source, csmap, trp) is None
1680 1680 and not emptyok):
1681 1681 raise util.Abort(_("received changelog group is empty"))
1682 1682 clend = len(cl)
@@ -1695,7 +1695,7 b' class localrepository(repo.repository):'
1695 1695 # if the result of the merge of 1 and 2 is the same in 3 and 4,
1696 1696 # no new manifest will be created and the manifest group will
1697 1697 # be empty during the pull
1698 self.manifest.addgroup(source.chunks(), revmap, trp)
1698 self.manifest.addgroup(source, revmap, trp)
1699 1699 self.ui.progress(_('manifests'), None)
1700 1700
1701 1701 needfiles = {}
@@ -1723,7 +1723,7 b' class localrepository(repo.repository):'
1723 1723 pr()
1724 1724 fl = self.file(f)
1725 1725 o = len(fl)
1726 if fl.addgroup(source.chunks(), revmap, trp) is None:
1726 if fl.addgroup(source, revmap, trp) is None:
1727 1727 raise util.Abort(_("received file revlog group is empty"))
1728 1728 revisions += len(fl) - o
1729 1729 files += 1
@@ -1269,7 +1269,7 b' class revlog(object):'
1269 1269
1270 1270 yield changegroup.closechunk()
1271 1271
1272 def addgroup(self, revs, linkmapper, transaction):
1272 def addgroup(self, bundle, linkmapper, transaction):
1273 1273 """
1274 1274 add a delta group
1275 1275
@@ -1301,7 +1301,10 b' class revlog(object):'
1301 1301 try:
1302 1302 # loop through our set of deltas
1303 1303 chain = None
1304 for chunk in revs:
1304 while 1:
1305 chunk = bundle.chunk()
1306 if not chunk:
1307 break
1305 1308 node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80])
1306 1309 link = linkmapper(cs)
1307 1310 if (node in self.nodemap and
General Comments 0
You need to be logged in to leave comments. Login now