in eden/scm/edenscm/mercurial/exchange.py [0:0]
def _pullbundle2(pullop):
"""pull data using bundle2
For now, the only supported data are changegroup."""
kwargs = {"bundlecaps": caps20to10(pullop.repo)}
# At the moment we don't do stream clones over bundle2. If that is
# implemented then here's where the check for that will go.
streaming = False
# pulling changegroup
pullop.stepsdone.add("changegroup")
kwargs["common"] = pullop.common
kwargs["heads"] = pullop.heads or pullop.rheads
kwargs["cg"] = pullop.fetch
ui = pullop.repo.ui
# if narrow-heads enabled, phases exchange is not needed
if ui.configbool("experimental", "narrow-heads"):
pullop.stepsdone.add("phases")
else:
legacyphase = "phases" in ui.configlist("devel", "legacy.exchange")
hasbinaryphase = "heads" in pullop.remotebundle2caps.get("phases", ())
if not legacyphase and hasbinaryphase:
kwargs["phases"] = True
pullop.stepsdone.add("phases")
bookmarksrequested = False
legacybookmark = "bookmarks" in ui.configlist("devel", "legacy.exchange")
hasbinarybook = "bookmarks" in pullop.remotebundle2caps
if pullop.remotebookmarks is not None:
pullop.stepsdone.add("request-bookmarks")
if (
"request-bookmarks" not in pullop.stepsdone
and pullop.remotebookmarks is None
and not legacybookmark
and hasbinarybook
):
kwargs["bookmarks"] = True
bookmarksrequested = True
if "listkeys" in pullop.remotebundle2caps:
if "phases" not in pullop.stepsdone and pullop.extras.get("phases", True):
kwargs["listkeys"] = ["phases"]
if "request-bookmarks" not in pullop.stepsdone and pullop.extras.get(
"bookmarks", True
):
# make sure to always includes bookmark data when migrating
# `hg incoming --bundle` to using this function.
pullop.stepsdone.add("request-bookmarks")
kwargs.setdefault("listkeys", []).append("bookmarks")
# If this is a full pull / clone and the server supports the clone bundles
# feature, tell the server whether we attempted a clone bundle. The
# presence of this flag indicates the client supports clone bundles. This
# will enable the server to treat clients that support clone bundles
# differently from those that don't.
if (
pullop.remote.capable("clonebundles")
and pullop.heads is None
and list(pullop.common) == [nullid]
):
kwargs["cbattempted"] = pullop.clonebundleattempted
if streaming:
pullop.repo.ui.status(_("streaming all changes\n"))
elif not pullop.fetch:
pullop.repo.ui.status(_("no changes found\n"))
pullop.cgresult = 0
else:
if pullop.heads is None and set(pullop.common).issubset({nullid}):
pullop.repo.ui.status(_("requesting all changes\n"))
_pullbundle2extraprepare(pullop, kwargs)
bundle = pullop.remote.getbundle("pull", **kwargs)
try:
op = bundle2.bundleoperation(
pullop.repo, pullop.gettransaction, extras=pullop.extras
)
op.modes["bookmarks"] = "records"
bundle2.processbundle(pullop.repo, bundle, op=op)
except bundle2.AbortFromPart as exc:
pullop.repo.ui.status(_("remote: abort: %s\n") % exc)
raise error.Abort(_("pull failed on remote"), hint=exc.hint)
except error.BundleValueError as exc:
raise error.Abort(_("missing support for %s") % exc)
if pullop.fetch:
pullop.cgresult = bundle2.combinechangegroupresults(op)
# processing phases change
for namespace, value in op.records["listkeys"]:
if namespace == "phases":
_pullapplyphases(pullop, value)
# processing bookmark update
if bookmarksrequested:
books = {}
for record in op.records["bookmarks"]:
books[record["bookmark"]] = record["node"]
pullop.remotebookmarks = books
else:
for namespace, value in op.records["listkeys"]:
if namespace == "bookmarks":
pullop.remotebookmarks = bookmod.unhexlifybookmarks(value)
# bookmark data were either already there or pulled in the bundle
if pullop.remotebookmarks is not None and pullop.extras.get("bookmarks", True):
_pullbookmarks(pullop)