changeset 39681:c73c7653dfb9

narrow: use diffmatcher to send only new filelogs in non-ellipses widening Before this patch, when we widen a non-ellipses narrow clone, we downloads all the filelogs matching the resulting new matcher. This is same as the ellipses case but can be improved because, we don't pull new csets in non-ellipses cases, we can only download the new added files instead of downloading all the files which matches the new matcher. So, we only download files which matches the new matcher but does not matches the old matcher. There exists a match.differencematcher() which is used here. This will lead to significant amount of speedup in extending a non-ellipses narrow copy on large repos because we will download and process only the new required filelogs. The tests changes demonstrate that we are downloading now less files. Thanks to Augie for pointing that functionality of differencematcher exists in core. Differential Revision: https://phab.mercurial-scm.org/D4614
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 17 Sep 2018 15:55:18 +0300
parents 322aaf80acf3
children b77f2ea51da5
files hgext/narrow/narrowbundle2.py tests/test-narrow-widen-no-ellipsis.t
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py	Mon Sep 17 15:27:39 2018 +0300
+++ b/hgext/narrow/narrowbundle2.py	Mon Sep 17 15:55:18 2018 +0300
@@ -21,6 +21,7 @@
     error,
     exchange,
     extensions,
+    match as matchmod,
     narrowspec,
     repair,
     repository,
@@ -72,6 +73,9 @@
     newmatch = narrowspec.match(repo.root, include=include, exclude=exclude)
     oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
     oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
+    oldmatch = narrowspec.match(repo.root, include=oldinclude,
+                                exclude=oldexclude)
+    diffmatch = matchmod.differencematcher(newmatch, oldmatch)
     common = set(common or [nullid])
 
     if (oldinclude != include or oldexclude != exclude):
@@ -84,7 +88,7 @@
             # XXX: we should only send the filelogs (and treemanifest). user
             # already has the changelog and manifest
             packer = changegroup.getbundler(version, repo,
-                                            filematcher=newmatch,
+                                            filematcher=diffmatch,
                                             fullnodes=commonnodes)
             cgdata = packer.generate(set([nullid]), list(commonnodes), False,
                     source)
--- a/tests/test-narrow-widen-no-ellipsis.t	Mon Sep 17 15:27:39 2018 +0300
+++ b/tests/test-narrow-widen-no-ellipsis.t	Mon Sep 17 15:55:18 2018 +0300
@@ -95,7 +95,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 0 changesets with 1 changes to 2 files
+  added 0 changesets with 1 changes to 1 files
   3 local changesets published
   $ hg tracked
   I path:inside
@@ -154,7 +154,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 0 changesets with 1 changes to 3 files
+  added 0 changesets with 1 changes to 1 files
   5 local changesets published
   $ hg tracked
   I path:inside
@@ -259,7 +259,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 0 changesets with 1 changes to 5 files
+  added 0 changesets with 1 changes to 1 files
   11 local changesets published
   $ hg tracked
   I path:d0
@@ -351,7 +351,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 0 changesets with 1 changes to 2 files
+  added 0 changesets with 1 changes to 1 files
   11 local changesets published
   $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n"
   11: local