# HG changeset patch # User mpm@selenic.com # Date 1116639072 28800 # Node ID aea6562add6cc7e5311d1c84db506e8cda10ebc7 # Parent 2c80f6f8fc08a6a71b74283a8db4d079652fc3bf Make compression more intelligent: - we don't attempt to compress things under 44 bytes (empirical) - we check whether larger objects actually compress - we tag objects to indicate their compression NUL means uncompressed and starts with NUL x means gzipped and starts with x (handy) u means uncompressed, drop the u diff -r 2c80f6f8fc08 -r aea6562add6c mercurial/revlog.py --- a/mercurial/revlog.py Fri May 20 17:28:09 2005 -0800 +++ b/mercurial/revlog.py Fri May 20 17:31:12 2005 -0800 @@ -16,10 +16,23 @@ def short(node): return hex(node[:4]) def compress(text): - return zlib.compress(text) + if not text: return text + if len(text) < 44: + if text[0] == '\0': return text + return 'u' + text + bin = zlib.compress(text) + if len(bin) > len(text): + if text[0] == '\0': return text + return 'u' + text + return bin def decompress(bin): - return zlib.decompress(bin) + if not bin: return bin + t = bin[0] + if t == '\0': return bin + if t == 'x': return zlib.decompress(bin) + if t == 'u': return bin[1:] + raise "unknown compression type %s" % t def hash(text, p1, p2): l = [p1, p2]