infinitepush: only warn about mutation server support if entries are to be sent

Summary:
In the Mononoke integration tests (which are .t tests), we've started seeing
this waring show up.

We probably shouldn't have mutation enabled for most of those tests anyway
(save for the tests that actually exercise mutation), so I'm turning that off.
That said, we'd still see the warning. So, this diff refactors mutation a
little bit to only warn if we do have something to send to the server.

Reviewed By: ikostia

Differential Revision: D22016685

fbshipit-source-id: e9e8dbcc44a0fa048dca3ca7ce0961631058a2d6
This commit is contained in:
Thomas Orozco 2020-06-12 04:14:13 -07:00 committed by Facebook GitHub Bot
parent d03da109c7
commit cb64897c70
2 changed files with 26 additions and 16 deletions

View File

@ -124,18 +124,20 @@ def getscratchbranchparts(
) )
if mutation.enabled(repo): if mutation.enabled(repo):
if constants.scratchmutationparttype not in bundle2.bundle2caps(peer): entries = mutation.entriesforbundle(repo, outgoing.missing)
repo.ui.warn( if entries:
_("no server support for %r - skipping\n") if constants.scratchmutationparttype not in bundle2.bundle2caps(peer):
% constants.scratchmutationparttype repo.ui.warn(
) _("no server support for %r - skipping\n")
else: % constants.scratchmutationparttype
parts.append( )
bundle2.bundlepart( else:
constants.scratchmutationparttype, parts.append(
data=mutation.bundle(repo, outgoing.missing), bundle2.bundlepart(
constants.scratchmutationparttype,
data=mutation.bundleentries(entries),
)
) )
)
try: try:
treemod = extensions.find("treemanifest") treemod = extensions.find("treemanifest")

View File

@ -659,11 +659,8 @@ def unbundle(repo, bundledata):
recordentries(repo, entries, skipexisting=True) recordentries(repo, entries, skipexisting=True)
def bundle(repo, nodes): def entriesforbundle(repo, nodes):
"""Generate bundled mutation data for bundling alongside the given nodes. """Generate mutation entries for the given nodes
This consists of mutation entries for all predecessors of the given nodes,
including the nodes themselves.
""" """
nodes = set(nodes) nodes = set(nodes)
remaining = set(nodes) remaining = set(nodes)
@ -682,9 +679,20 @@ def bundle(repo, nodes):
if nextnode not in seen: if nextnode not in seen:
remaining.add(nextnode) remaining.add(nextnode)
return entries
def bundleentries(entries):
return mutationstore.bundle(entries) return mutationstore.bundle(entries)
def bundle(repo, nodes):
"""Generate bundled mutation data for bundling alongside the given nodes.
"""
entries = entriesforbundle(repo, nodes)
return bundleentries(entries)
def convertfromobsmarkers(repo): def convertfromobsmarkers(repo):
"""Convert obsmarkers into mutation records.""" """Convert obsmarkers into mutation records."""
obsmarkers = repo.obsstore._all obsmarkers = repo.obsstore._all