# HG changeset patch # User Pulkit Goyal # Date 2018-09-17 12:55:18 # Node ID c73c7653dfb9a2da91442304529fb3998f7cfb0f # Parent 322aaf80acf38c9d77fa5b38f1a0ecb650f20959 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 diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py --- a/hgext/narrow/narrowbundle2.py +++ b/hgext/narrow/narrowbundle2.py @@ -21,6 +21,7 @@ from mercurial import ( error, exchange, extensions, + match as matchmod, narrowspec, repair, repository, @@ -72,6 +73,9 @@ def getbundlechangegrouppart_widen(bundl 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 @@ def getbundlechangegrouppart_widen(bundl # 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) diff --git a/tests/test-narrow-widen-no-ellipsis.t b/tests/test-narrow-widen-no-ellipsis.t --- a/tests/test-narrow-widen-no-ellipsis.t +++ b/tests/test-narrow-widen-no-ellipsis.t @@ -95,7 +95,7 @@ added upstream revisions. 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 @@ widen the narrow spec to include the wid 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 @@ make narrow clone with every third node. 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 @@ Widening that fails can be recovered fro 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