# HG changeset patch # User Pulkit Goyal # Date 2018-09-17 18:41:34 # Node ID a1942015c10e2c670557705f2f0deabff71b0a2f # Parent dee887072f270624c561093de542e5934fed5dd6 changegroup: add functionality to skip adding changelog data to changegroup In narrow extension, when we have a non-ellipses narrow working copy and we extend it, we pull all the changelog data again and the client tries to reapply all that changelog data. While downloading millions of changeset data is still not very expensive but applying them on the client side is very expensive and takes ~10 minutes. These 10 minutes are added to every `hg tracked --addinclude <>` call and extending a narrow copy becomes very slow. This patch adds a new changelog argument to cgpacker.generate() fn. If the changelog argument is set to False, we won't yield the changelog data. We still have to iterate over the deltas returned by _generatechangelog() because that's a generator and builds the data for clstate variable which is required for calculating manifests and filelogs. Differential Revision: https://phab.mercurial-scm.org/D4638 diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -827,8 +827,11 @@ class cgpacker(object): else: self._verbosenote = lambda s: None - def generate(self, commonrevs, clnodes, fastpathlinkrev, source): - """Yield a sequence of changegroup byte chunks.""" + def generate(self, commonrevs, clnodes, fastpathlinkrev, source, + changelog=True): + """Yield a sequence of changegroup byte chunks. + If changelog is False, changelog data won't be added to changegroup + """ repo = self._repo cl = repo.changelog @@ -838,9 +841,11 @@ class cgpacker(object): clstate, deltas = self._generatechangelog(cl, clnodes) for delta in deltas: - for chunk in _revisiondeltatochunks(delta, self._builddeltaheader): - size += len(chunk) - yield chunk + if changelog: + for chunk in _revisiondeltatochunks(delta, + self._builddeltaheader): + size += len(chunk) + yield chunk close = closechunk() size += len(close)