[PATCH 2 of 2] revlog: linearize created changegroups in generaldelta revlogs

Sune Foldager cryo at cyanite.org
Tue May 17 15:36:40 CDT 2011


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1305664425 -7200
# Node ID aeaa52ba0e2394fe337e2444ed3bc4b0bc5e0933
# Parent  d29b9d6e76eca602c879a76427fec813929335d1
revlog: linearize created changegroups in generaldelta revlogs

This greatly improves the speed of the bundling process, and reduces the
bundle size considerably in general. If the repository is already ordered,
this has little effect on both time and bundle size.

For non-generaldelta clients, the reduced bundle size translates to a greatly
reduced repository size, similar to shrinking the revlogs. For generaldelta
clients the difference is minor.

diff -r d29b9d6e76ec -r aeaa52ba0e23 mercurial/revlog.py
--- a/mercurial/revlog.py	Tue May 17 22:33:39 2011 +0200
+++ b/mercurial/revlog.py	Tue May 17 22:33:45 2011 +0200
@@ -14,7 +14,7 @@
 # import stuff from node for others to import from revlog
 from node import bin, hex, nullid, nullrev, short #@UnusedImport
 from i18n import _
-import ancestor, mdiff, parsers, error, util
+import ancestor, mdiff, parsers, error, util, dagutil
 import struct, zlib, errno
 
 _pack = struct.pack
@@ -1098,7 +1098,14 @@
         changegroup starts with a full revision.
         """
 
-        revs = sorted([self.rev(n) for n in nodelist])
+        # for generaldelta revlogs, we linearize the revs; this will both be
+        # much quicker and generate a much smaller bundle
+        if self._generaldelta:
+            dag = dagutil.revlogdag(self)
+            revs = set(self.rev(n) for n in nodelist)
+            revs = dag.linearize(revs)
+        else:
+            revs = sorted([self.rev(n) for n in nodelist])
 
         # if we don't have any revisions touched by these changesets, bail
         if not revs:


More information about the Mercurial-devel mailing list