diff --git a/remotefilelog/shallowbundle.py b/remotefilelog/shallowbundle.py --- a/remotefilelog/shallowbundle.py +++ b/remotefilelog/shallowbundle.py @@ -44,6 +44,17 @@ 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 @@ 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 @@ 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 --- a/tests/test-treemanifest-server.t +++ b/tests/test-treemanifest-server.t @@ -120,10 +120,7 @@ [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 --- a/tests/test-treemanifest-treeonly.t +++ b/tests/test-treemanifest-treeonly.t @@ -94,7 +94,6 @@ $ 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 --- a/treemanifest/__init__.py +++ b/treemanifest/__init__.py @@ -56,12 +56,6 @@ 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 @@ # 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':