D4886: changegroup: add a parts argument to cgpacker.generate()
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Fri Oct 5 15:40:54 UTC 2018
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This patch removes the changelog argument added to cgpacker.generate() few weeks
ago and add a parts argument which will be a tuple of parts to be included into
the changegroup.
The changelog argument was used to determine that whether we need to add
changelog data to the changegroup or not. In upcoming patches, I will need same
functionality for manifests where I just want to send the dirlogs for extending
a narrow clone. Instead of adding a new argument for each possible thing, let's
add one argument specifying things we want to generate.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4886
AFFECTED FILES
hgext/narrow/narrowbundle2.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/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -77,8 +77,10 @@
packer = changegroup.getbundler(cgversion, repo,
filematcher=diffmatcher,
fullnodes=commonnodes)
+ # XXX: we should also prevent manifests
+ reqparts = ('manifest', 'dirlogs', 'filelog')
cgdata = packer.generate(set([nullid]), list(commonnodes), False,
- 'narrow_widen', changelog=False)
+ 'narrow_widen', parts=reqparts)
return cgdata
To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list