pull: only prefetch bookmarks when using bundle1

All bundle2 servers now support the 'listkeys' part(1), so we'll
always be able to fetch bookmarks data at the same time as the
changeset. This should be enough to avoid the one race condition that
this bookmark prefetching is trying to work around. It even allows
future server to make sure everything is generated from the same
"transaction" if they become capable of such. The current code was
already overwriting the prefetched value with the one in bundle2
anyway.  Note that this is not preventing all race conditions in
related to bookmark in 'hg pull' it makes nothing better and nothing
worse.

Reducing the number of listkeys calls will reduce the latency on pull.

The pre-fetch is also moved into a discovery step because it seems to belong
there.

(1) Because all servers not speaking 'pushkey' parts are compatible with the
'HG2X' protocol only.
This commit is contained in:
Pierre-Yves David 2015-05-27 04:57:03 -07:00
parent 1cc98f4f80
commit 8305af854f

View File

@ -895,7 +895,6 @@ def pull(repo, remote, heads=None, force=False, bookmarks=()):
" %s") % (', '.join(sorted(missing)))
raise util.Abort(msg)
pullop.remotebookmarks = remote.listkeys('bookmarks')
lock = pullop.repo.lock()
try:
pullop.trmanager = transactionmanager(repo, 'pull', remote.url())
@ -943,6 +942,16 @@ def _pulldiscovery(pullop):
step = pulldiscoverymapping[stepname]
step(pullop)
@pulldiscovery('b1:bookmarks')
def _pullbookmarkbundle1(pullop):
"""fetch bookmark data in bundle1 case
If not using bundle2, we have to fetch bookmarks before changeset
discovery to reduce the chance and impact of race conditions."""
if not _canusebundle2(pullop): # all bundle2 server now support listkeys
pullop.remotebookmarks = pullop.remote.listkeys('bookmarks')
@pulldiscovery('changegroup')
def _pulldiscoverychangegroup(pullop):
"""discovery phase for the pull