changeset 1462:12a8d772fa32

Optimizing manifest reads in changegroupsubset by using deltas.
author Eric Hopper <hopper@omnifarious.org>
date Mon, 10 Oct 2005 08:36:29 -0700
parents 02099220ad49
children 26e73acc0cdf
files mercurial/localrepo.py
diffstat 1 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Oct 07 19:51:09 2005 -0700
+++ b/mercurial/localrepo.py	Mon Oct 10 08:36:29 2005 -0700
@@ -963,14 +963,30 @@
             return msng_mnfst_set[mnfstnode]
 
         def filenode_collector(changedfiles):
+            next_rev = [0]
             def collect_msng_filenodes(mnfstnode):
-                m = mnfst.read(mnfstnode)
-                for f in changedfiles:
-                    fnode = m.get(f, None)
-                    if fnode is not None:
-                        clnode = msng_mnfst_set[mnfstnode]
-                        ndset = msng_filenode_set.setdefault(f, {})
-                        ndset.setdefault(fnode, clnode)
+                r = mnfst.rev(mnfstnode)
+                if r == next_rev[0]:
+                    # If the last rev we looked at was the one just previous,
+                    # we only need to see a diff.
+                    delta = mdiff.patchtext(mnfst.delta(mnfstnode))
+                    for dline in delta.splitlines():
+                        f, fnode = dline.split('\0')
+                        fnode = bin(fnode[:40])
+                        f = changedfiles.get(f, None)
+                        if f is not None:
+                            clnode = msng_mnfst_set[mnfstnode]
+                            ndset = msng_filenode_set.setdefault(f, {})
+                            ndset.setdefault(fnode, clnode)
+                else:
+                    m = mnfst.read(mnfstnode)
+                    for f in changedfiles:
+                        fnode = m.get(f, None)
+                        if fnode is not None:
+                            clnode = msng_mnfst_set[mnfstnode]
+                            ndset = msng_filenode_set.setdefault(f, {})
+                            ndset.setdefault(fnode, clnode)
+                next_rev[0] = r + 1
             return collect_msng_filenodes
 
         def prune_filenodes(f, filerevlog):
@@ -997,14 +1013,14 @@
             prune_manifests()
             msng_mnfst_lst = msng_mnfst_set.keys()
             msng_mnfst_lst.sort(cmp_by_rev_func(mnfst))
-            changedfiles = changedfiles.keys()
-            changedfiles.sort()
             group = mnfst.group(msng_mnfst_lst, lookup_manifest_link,
                                 filenode_collector(changedfiles))
             for chnk in group:
                 yield chnk
             msng_mnfst_lst = None
             msng_mnfst_set.clear()
+            changedfiles = changedfiles.keys()
+            changedfiles.sort()
             for fname in changedfiles:
                 filerevlog = self.file(fname)
                 prune_filenodes(fname, filerevlog)