comparison hgext/narrow/narrowbundle2.py @ 39665: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 ce20caecacbd
children f1844a10ee19
comparison
equal deleted inserted replaced
39664:322aaf80acf3 39665:c73c7653dfb9
19 bundle2, 19 bundle2,
20 changegroup, 20 changegroup,
21 error, 21 error,
22 exchange, 22 exchange,
23 extensions, 23 extensions,
24 match as matchmod,
24 narrowspec, 25 narrowspec,
25 repair, 26 repair,
26 repository, 27 repository,
27 util, 28 util,
28 wireprototypes, 29 wireprototypes,
70 include = sorted(filter(bool, kwargs.get(r'includepats', []))) 71 include = sorted(filter(bool, kwargs.get(r'includepats', [])))
71 exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) 72 exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
72 newmatch = narrowspec.match(repo.root, include=include, exclude=exclude) 73 newmatch = narrowspec.match(repo.root, include=include, exclude=exclude)
73 oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', []))) 74 oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
74 oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', []))) 75 oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
76 oldmatch = narrowspec.match(repo.root, include=oldinclude,
77 exclude=oldexclude)
78 diffmatch = matchmod.differencematcher(newmatch, oldmatch)
75 common = set(common or [nullid]) 79 common = set(common or [nullid])
76 80
77 if (oldinclude != include or oldexclude != exclude): 81 if (oldinclude != include or oldexclude != exclude):
78 common = repo.revs("::%ln", common) 82 common = repo.revs("::%ln", common)
79 commonnodes = set() 83 commonnodes = set()
82 commonnodes.add(cl.node(c)) 86 commonnodes.add(cl.node(c))
83 if commonnodes: 87 if commonnodes:
84 # XXX: we should only send the filelogs (and treemanifest). user 88 # XXX: we should only send the filelogs (and treemanifest). user
85 # already has the changelog and manifest 89 # already has the changelog and manifest
86 packer = changegroup.getbundler(version, repo, 90 packer = changegroup.getbundler(version, repo,
87 filematcher=newmatch, 91 filematcher=diffmatch,
88 fullnodes=commonnodes) 92 fullnodes=commonnodes)
89 cgdata = packer.generate(set([nullid]), list(commonnodes), False, 93 cgdata = packer.generate(set([nullid]), list(commonnodes), False,
90 source) 94 source)
91 95
92 part = bundler.newpart('changegroup', data=cgdata) 96 part = bundler.newpart('changegroup', data=cgdata)