D4886: changegroup: add a parts argument to cgpacker.generate()

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Fri Oct 5 13:40:25 EDT 2018


pulkit updated this revision to Diff 11705.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4886?vs=11699&id=11705

REVISION DETAIL
  https://phab.mercurial-scm.org/D4886

AFFECTED FILES
  mercurial/bundle2.py
  mercurial/changegroup.py

CHANGE DETAILS

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -788,20 +788,29 @@
             self._verbosenote = lambda s: None
 
     def generate(self, commonrevs, clnodes, fastpathlinkrev, source,
-                 changelog=True):
+                 parts=None):
         """Yield a sequence of changegroup byte chunks.
-        If changelog is False, changelog data won't be added to changegroup
+
+        parts is a tuple of things which should be generated in the changegroup.
+        Possible values of tuple are 'changelog', 'manifest', 'dirlogs' and
+        'filelogs'
+        callers can pass a tuple omitting some part which they don't want in the
+        changegroup. For ex. widening with narrow passes parts as
+        ('dirlogs', 'filelogs')
         """
 
+        if parts is None:
+            parts = ('changelog', 'manifest', 'dirlogs', 'filelog')
+
         repo = self._repo
         cl = repo.changelog
 
         self._verbosenote(_('uncompressed size of bundle content:\n'))
         size = 0
 
         clstate, deltas = self._generatechangelog(cl, clnodes)
         for delta in deltas:
-            if changelog:
+            if 'changelog' in parts:
                 for chunk in _revisiondeltatochunks(delta,
                                                     self._builddeltaheader):
                     size += len(chunk)
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -2291,8 +2291,9 @@
         packer = changegroup.getbundler(cgversion, repo,
                                         filematcher=diffmatcher,
                                         fullnodes=commonnodes)
+        reqparts = ('manifest', 'dirlogs', 'filelog')
         cgdata = packer.generate(set([nodemod.nullid]), list(commonnodes),
-                                 False, 'narrow_widen', changelog=False)
+                                 False, 'narrow_widen', parts=reqparts)
 
         part = bundler.newpart('changegroup', data=cgdata)
         part.addparam('version', cgversion)



To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list