##// END OF EJS Templates
changegroup: avoid large copies...
Matt Mackall -
r5368:61462e7d default
parent child Browse files
Show More
@@ -33,10 +33,9 b' def chunkiter(source):'
33 33 break
34 34 yield c
35 35
36 def genchunk(data):
37 """build a changegroup chunk"""
38 header = struct.pack(">l", len(data)+ 4)
39 return "%s%s" % (header, data)
36 def chunkheader(length):
37 """build a changegroup chunk header"""
38 return struct.pack(">l", length + 4)
40 39
41 40 def closechunk():
42 41 return struct.pack(">l", 0)
@@ -86,7 +85,12 b' def writebundle(cg, filename, bundletype'
86 85 empty = True
87 86 for chunk in chunkiter(cg):
88 87 empty = False
89 fh.write(z.compress(genchunk(chunk)))
88 fh.write(z.compress(chunkheader(len(chunk))))
89 pos = 0
90 while pos < len(chunk):
91 next = pos + 2**20
92 fh.write(z.compress(chunk[pos:next]))
93 pos = next
90 94 fh.write(z.compress(closechunk()))
91 95 fh.write(z.flush())
92 96 cleanup = None
@@ -1720,7 +1720,8 b' class localrepository(repo.repository):'
1720 1720 # If any filenodes are left, generate the group for them,
1721 1721 # otherwise don't bother.
1722 1722 if len(msng_filenode_lst) > 0:
1723 yield changegroup.genchunk(fname)
1723 yield changegroup.chunkheader(len(fname))
1724 yield fname
1724 1725 # Sort the filenodes by their revision #
1725 1726 msng_filenode_lst.sort(cmp_by_rev_func(filerevlog))
1726 1727 # Create a group generator and only pass in a changenode
@@ -1796,7 +1797,8 b' class localrepository(repo.repository):'
1796 1797 nodeiter = gennodelst(filerevlog)
1797 1798 nodeiter = list(nodeiter)
1798 1799 if nodeiter:
1799 yield changegroup.genchunk(fname)
1800 yield changegroup.chunkheader(len(fname))
1801 yield fname
1800 1802 lookup = lookuprevlink_func(filerevlog)
1801 1803 for chnk in filerevlog.group(nodeiter, lookup):
1802 1804 yield chnk
@@ -1094,7 +1094,9 b' class revlog(object):'
1094 1094 meta += mdiff.trivialdiffheader(len(d))
1095 1095 else:
1096 1096 d = self.revdiff(a, b)
1097 yield changegroup.genchunk("%s%s" % (meta, d))
1097 yield changegroup.chunkheader(len(meta) + len(d))
1098 yield meta
1099 yield d
1098 1100
1099 1101 yield changegroup.closechunk()
1100 1102
General Comments 0
You need to be logged in to leave comments. Login now