##// END OF EJS Templates
Fix hg unbundle chunking performance bug
Eric Hopper -
r1374:c3654cfa default
parent child Browse files
Show More
@@ -1681,22 +1681,14 b' def unbundle(ui, repo, fname):'
1681 if f.read(4) != "HG10":
1681 if f.read(4) != "HG10":
1682 raise util.Abort("%s: not a Mercurial bundle file" % fname)
1682 raise util.Abort("%s: not a Mercurial bundle file" % fname)
1683
1683
1684 class bzread:
1684 def bzgenerator(f):
1685 def __init__(self, f):
1685 zd = bz2.BZ2Decompressor()
1686 self.zd = bz2.BZ2Decompressor()
1686 for chunk in f:
1687 self.f = f
1687 yield zd.decompress(chunk)
1688 self.buf = ""
1688 yield zd.flush()
1689 def read(self, l):
1690 while l > len(self.buf):
1691 r = self.f.read(4096)
1692 if r:
1693 self.buf += self.zd.decompress(r)
1694 else:
1695 break
1696 d, self.buf = self.buf[:l], self.buf[l:]
1697 return d
1698
1689
1699 repo.addchangegroup(bzread(f))
1690 bzgen = bzgenerator(util.filechunkiter(f, 4096))
1691 repo.addchangegroup(util.chunkbuffer(bzgen))
1700
1692
1701 def undo(ui, repo):
1693 def undo(ui, repo):
1702 """undo the last commit or pull
1694 """undo the last commit or pull
General Comments 0
You need to be logged in to leave comments. Login now