From 2f95e6e9ca374826f3cd88599dc0ebc6ca9341dd Mon Sep 17 00:00:00 2001 From: Durham Goode Date: Wed, 1 Nov 2017 17:10:05 -0700 Subject: [PATCH] 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 --- remotefilelog/shallowbundle.py | 19 +++++++++++++------ tests/test-treemanifest-server.t | 5 +---- tests/test-treemanifest-treeonly.t | 1 - treemanifest/__init__.py | 8 +------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/remotefilelog/shallowbundle.py b/remotefilelog/shallowbundle.py index 0d3c2993e1..17c679a7cc 100644 --- a/remotefilelog/shallowbundle.py +++ b/remotefilelog/shallowbundle.py @@ -44,6 +44,17 @@ def shallowgroup(cls, self, nodelist, rlog, lookup, units=None, reorder=None): 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') class shallowcg1packer(changegroup.cg1packer): def generate(self, commonrevs, clnodes, fastpathlinkrev, source): @@ -73,9 +84,7 @@ class shallowcg1packer(changegroup.cg1packer): core generatemanifests method, whose length depends on the version of core Hg. """ - sendflat = self._repo.ui.configbool('treemanifest', 'sendflat', - True) - if sendflat: + if _cansendflat(self._repo, mfs.keys()): # In this code path, generating the manifests populates fnodes for # us. chunks = super(shallowcg1packer, self).generatemanifests( @@ -241,12 +250,10 @@ if util.safehasattr(changegroup, 'cg3packer'): for chunk in chunks: yield chunk - sendflat = self._repo.ui.configbool('treemanifest', 'sendflat', - True) # If we're not sending flat manifests, then the subclass # generatemanifests call did not add the appropriate closing chunk # for a changegroup3. - if not sendflat: + if not _cansendflat(self._repo, mfs.keys()): yield self._manifestsdone() # Unused except in older versions of Mercurial diff --git a/tests/test-treemanifest-server.t b/tests/test-treemanifest-server.t index c3d6d0ca4c..8160916ece 100644 --- a/tests/test-treemanifest-server.t +++ b/tests/test-treemanifest-server.t @@ -120,10 +120,7 @@ Test pushing flat and tree [255] Test pushing only trees with commit hooks - $ cat >> .hg/hgrc < [treemanifest] - > sendflat=False - > EOF +TODO: change this to create a treeonly commit and try to push it $ hg push --to mybook pushing to ssh://user@dummy/master searching for changes diff --git a/tests/test-treemanifest-treeonly.t b/tests/test-treemanifest-treeonly.t index 796d3a5d2c..b2e9984ed1 100644 --- a/tests/test-treemanifest-treeonly.t +++ b/tests/test-treemanifest-treeonly.t @@ -94,7 +94,6 @@ Transition to tree-only client $ cat >> .hg/hgrc < [treemanifest] > treeonly=True - > sendflat=False > EOF Make a local tree-only draft commit diff --git a/treemanifest/__init__.py b/treemanifest/__init__.py index b0de8cea77..1aa9227183 100644 --- a/treemanifest/__init__.py +++ b/treemanifest/__init__.py @@ -56,12 +56,6 @@ default values are 0 and len(changelog) - 1, respectively. repackstartrev = 0 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 tree format. This is useful in the final stages of a migration to treemanifest to prevent accesses of flat manifests. @@ -1050,7 +1044,7 @@ def _registerbundle2parts(): # Treemanifest servers don't accept tree directly. They must go through # pushrebase, which uses it's own part type and handler. - if op.repo.svfs.treemanifestserver: + if repo.svfs.treemanifestserver: return if part.params.get('cache', 'False') == 'True':