See comment in http://hgbook.red-bean.com/read/behind-the-scenes.html
attached to para beginning "If the connection is over HTTP"
Reproduced below for convenience.
19:05 < mpm> bzip2 is used to build bundles.
19:05 < mpm> But zlib is used over http.
19:06 < faheem_> mpm: bryan's book talks about bzip2 over http
19:06 < faheem_> unless i am misunderstanding
19:08 < mpm> Pretty sure he's mistaken.
19:09 < mpm> hgweb uses zlib to balance bandwidth and cpu usage. bz2 is too expensive.
19:10 < faheem_> mpm: he has - "If the connection is over HTTP, Mercurial recompresses the entire stream of data using a compression algorithm that gives a better compression ratio (the Burrows-Wheeler algorithm from the widely used bzip2 compression package)."
19:10 < faheem_> if this is wrong, i can add a comment
19:10 < mpm> Yeah, that's wrong.
19:10 < mpm> It decompresses a bunch of separately compressed zlib pieces and recompresses them as a single zlib stream.
19:11 < mpm> (see mercurial/hgweb/protocol.py:changegroup)
19:11 < mpm> That results in substantially better overall compression but still minimal CPU usage.
< mpm> bzip -is- used by bundles.