treemanifest: remove sendflat config

Previously the sendflat config decided if we should send flat manifests or not.
To reduce the number of config permutations we have to handle, let's change the
code to always send the flat manifests, if it exists.

Differential Revision: https://phab.mercurial-scm.org/D1266
This commit is contained in:
Durham Goode 2017-11-01 17:10:05 -07:00
parent df82fc6557
commit 2f95e6e9ca
4 changed files with 15 additions and 18 deletions

View File

@ -44,6 +44,17 @@ def shallowgroup(cls, self, nodelist, rlog, lookup, units=None, reorder=None):
yield self.close() yield self.close()
def _cansendflat(repo, mfnodes):
if not util.safehasattr(repo.manifestlog, '_revlog'):
return False
revlog = repo.manifestlog._revlog
for mfnode in mfnodes:
if mfnode not in revlog.nodemap:
return False
return True
@shallowutil.interposeclass(changegroup, 'cg1packer') @shallowutil.interposeclass(changegroup, 'cg1packer')
class shallowcg1packer(changegroup.cg1packer): class shallowcg1packer(changegroup.cg1packer):
def generate(self, commonrevs, clnodes, fastpathlinkrev, source): def generate(self, commonrevs, clnodes, fastpathlinkrev, source):
@ -73,9 +84,7 @@ class shallowcg1packer(changegroup.cg1packer):
core generatemanifests method, whose length depends on the core generatemanifests method, whose length depends on the
version of core Hg. version of core Hg.
""" """
sendflat = self._repo.ui.configbool('treemanifest', 'sendflat', if _cansendflat(self._repo, mfs.keys()):
True)
if sendflat:
# In this code path, generating the manifests populates fnodes for # In this code path, generating the manifests populates fnodes for
# us. # us.
chunks = super(shallowcg1packer, self).generatemanifests( chunks = super(shallowcg1packer, self).generatemanifests(
@ -241,12 +250,10 @@ if util.safehasattr(changegroup, 'cg3packer'):
for chunk in chunks: for chunk in chunks:
yield chunk yield chunk
sendflat = self._repo.ui.configbool('treemanifest', 'sendflat',
True)
# If we're not sending flat manifests, then the subclass # If we're not sending flat manifests, then the subclass
# generatemanifests call did not add the appropriate closing chunk # generatemanifests call did not add the appropriate closing chunk
# for a changegroup3. # for a changegroup3.
if not sendflat: if not _cansendflat(self._repo, mfs.keys()):
yield self._manifestsdone() yield self._manifestsdone()
# Unused except in older versions of Mercurial # Unused except in older versions of Mercurial

View File

@ -120,10 +120,7 @@ Test pushing flat and tree
[255] [255]
Test pushing only trees with commit hooks Test pushing only trees with commit hooks
$ cat >> .hg/hgrc <<EOF TODO: change this to create a treeonly commit and try to push it
> [treemanifest]
> sendflat=False
> EOF
$ hg push --to mybook $ hg push --to mybook
pushing to ssh://user@dummy/master pushing to ssh://user@dummy/master
searching for changes searching for changes

View File

@ -94,7 +94,6 @@ Transition to tree-only client
$ cat >> .hg/hgrc <<EOF $ cat >> .hg/hgrc <<EOF
> [treemanifest] > [treemanifest]
> treeonly=True > treeonly=True
> sendflat=False
> EOF > EOF
Make a local tree-only draft commit Make a local tree-only draft commit

View File

@ -56,12 +56,6 @@ default values are 0 and len(changelog) - 1, respectively.
repackstartrev = 0 repackstartrev = 0
repackendrev = 1000 repackendrev = 1000
Setting `treemanifest.sendflat` to False will stop flat manifests from being
sent as part of changegroups during push. It defaults to True.
[treemanifest]
sendflat = True
Setting `treemanifest.treeonly` to True will force all manifest reads to use the Setting `treemanifest.treeonly` to True will force all manifest reads to use the
tree format. This is useful in the final stages of a migration to treemanifest tree format. This is useful in the final stages of a migration to treemanifest
to prevent accesses of flat manifests. to prevent accesses of flat manifests.
@ -1050,7 +1044,7 @@ def _registerbundle2parts():
# Treemanifest servers don't accept tree directly. They must go through # Treemanifest servers don't accept tree directly. They must go through
# pushrebase, which uses it's own part type and handler. # pushrebase, which uses it's own part type and handler.
if op.repo.svfs.treemanifestserver: if repo.svfs.treemanifestserver:
return return
if part.params.get('cache', 'False') == 'True': if part.params.get('cache', 'False') == 'True':