hg: fix sending trees from the server to non-tree clients

Summary:
Previously we were trying to send trees to all clients during an
infinitepull, even ones that didn't support treemanifest. This caused
infinitepulls that required rebundling to fail for non-tree clients.

The fix is to just not send them unless the client is advertising the
capability.

Reviewed By: phillco

Differential Revision: D7432374

fbshipit-source-id: 1fae14a158ef56fe39439a718b1b98928f4e07b0
This commit is contained in:
Durham Goode 2018-03-28 13:38:33 -07:00 committed by Saurabh Singh
parent 78965e53ca
commit f5b8d91797
3 changed files with 27 additions and 2 deletions

View File

@ -529,9 +529,21 @@ def _rebundle(bundlerepo, bundleroots, unknownhead, cgversion, bundlecaps):
except KeyError:
pass
else:
# This parsing should be refactored to be shared with
# exchange.getbundlechunks. But I'll do that in a separate diff.
if bundlecaps is None:
bundlecaps = set()
b2caps = {}
for bcaps in bundlecaps:
if bcaps.startswith('bundle2='):
blob = util.urlreq.unquote(bcaps[len('bundle2='):])
b2caps.update(bundle2.decodecaps(blob))
missing = outgoing.missing
if remotefilelog.shallowbundle.cansendtrees(bundlerepo, missing,
source='infinitepushpull'):
source='infinitepushpull',
bundlecaps=bundlecaps,
b2caps=b2caps):
treepart = treemod.createtreepackpart(bundlerepo, outgoing,
treemod.TREEGROUP_PARTTYPE2)
parts.append(treepart)

View File

@ -509,7 +509,8 @@ def cansendtrees(repo, nodes, source=None, bundlecaps=None, b2caps=None):
prefetch = AllTrees
if repo.svfs.treemanifestserver:
if source == 'infinitepushpull':
if (source == 'infinitepushpull' and
'True' in b2caps.get('treemanifest', [])):
result = AllTrees
else:
result = NoTrees

View File

@ -272,6 +272,18 @@ Pull a normal scratch branch into a treeonly client
$ cd ..
Pull a normal scratch branch into a normal client with rebundling where the
server has treemanifest enabled.
$ cd normal-client
$ hg pull -r 42ec76eb772a --config extensions.treemanifest=! --config fastmanifest.usetree=False
pulling from ssh://user@dummy/master
no changes found
adding changesets
adding manifests
adding file changes
added 0 changesets with 1 changes to 1 files
$ cd ..
Verify its not on the server
$ cd master
$ hg log -G