[PATCH 2 of 5 modernize-streamclone] exchange: expose bundle2 capabilities as part of pulloperation
Gregory Szorc
gregory.szorc at gmail.com
Sun Oct 4 15:11:28 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443988384 25200
# Sun Oct 04 12:53:04 2015 -0700
# Node ID bd70e2580060df39691b6e1106914e230efe079e
# Parent 28a2967528155aac6fbabf642061aa3ba1360be0
exchange: expose bundle2 capabilities as part of pulloperation
This adds a cache and makes accessing the capabilities slightly simpler,
as you don't need to directly go through the bundle2 module. This will
also help prevent a function-level import in streamclone.py.
This patch arguably isn't necessary. But I think it makes things
slightly nicer.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -883,8 +883,12 @@ class pulloperation(object):
# We pulled a specific subset
# sync on this subset
return self.heads
+ @util.propertycache
+ def bundle2caps(self):
+ return bundle2.bundle2caps(self.remote)
+
def gettransaction(self):
# deprecated; talk to trmanager directly
return self.trmanager.transaction()
@@ -1007,10 +1011,9 @@ def _pullbookmarkbundle1(pullop):
If not using bundle2, we have to fetch bookmarks before changeset
discovery to reduce the chance and impact of race conditions."""
if pullop.remotebookmarks is not None:
return
- if (_canusebundle2(pullop)
- and 'listkeys' in bundle2.bundle2caps(pullop.remote)):
+ if _canusebundle2(pullop) and 'listkeys' in pullop.bundle2caps:
# all known bundle2 servers now support listkeys, but lets be nice with
# new implementation.
return
pullop.remotebookmarks = pullop.remote.listkeys('bookmarks')
@@ -1057,17 +1060,16 @@ def _pulldiscoverychangegroup(pullop):
def _pullbundle2(pullop):
"""pull data using bundle2
For now, the only supported data are changegroup."""
- remotecaps = bundle2.bundle2caps(pullop.remote)
kwargs = {'bundlecaps': caps20to10(pullop.repo)}
# pulling changegroup
pullop.stepsdone.add('changegroup')
kwargs['common'] = pullop.common
kwargs['heads'] = pullop.heads or pullop.rheads
kwargs['cg'] = pullop.fetch
- if 'listkeys' in remotecaps:
+ if 'listkeys' in pullop.bundle2caps:
kwargs['listkeys'] = ['phase']
if pullop.remotebookmarks is None:
# make sure to always includes bookmark data when migrating
# `hg incoming --bundle` to using this function.
@@ -1078,9 +1080,9 @@ def _pullbundle2(pullop):
else:
if pullop.heads is None and list(pullop.common) == [nullid]:
pullop.repo.ui.status(_("requesting all changes\n"))
if obsolete.isenabled(pullop.repo, obsolete.exchangeopt):
- remoteversions = bundle2.obsmarkersversion(remotecaps)
+ remoteversions = bundle2.obsmarkersversion(pullop.bundle2caps)
if obsolete.commonversion(remoteversions) is not None:
kwargs['obsmarkers'] = True
pullop.stepsdone.add('obsmarkers')
_pullbundle2extraprepare(pullop, kwargs)
More information about the Mercurial-devel
mailing list