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