changegroup: add functionality to skip adding changelog data to changegroup
authorPulkit Goyal <pulkit@yandex-team.ru>
Mon, 17 Sep 2018 21:41:34 +0300
changeset 39672 a1942015c10e
parent 39671 dee887072f27
child 39673 f1844a10ee19
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
mercurial/changegroup.py
--- a/mercurial/changegroup.py	Tue Sep 18 10:46:19 2018 -0700
+++ b/mercurial/changegroup.py	Mon Sep 17 21:41:34 2018 +0300
@@ -827,8 +827,11 @@
         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 @@
 
         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)