diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4414,23 +4414,24 @@ revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) - pullopargs = {} + @util.cachefunc + def remotebookmarks(): + # The list of bookmark used here is the same used to actually + # update the bookmark names, to avoid the race from issue 4689. + remotebookmarks = other.listkeys('bookmarks') + remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks) + pullopargs['remotebookmarks'] = remotebookmarks + return remotebookmarks + if opts.get('bookmark'): if not revs: revs = [] - # The list of bookmark used here is not the one used to actually - # update the bookmark name. This can result in the revision pulled - # not ending up with the name of the bookmark because of a race - # condition on the server. (See issue 4689 for details) - remotebookmarks = other.listkeys('bookmarks') - remotebookmarks = bookmarks.unhexlifybookmarks(remotebookmarks) - pullopargs['remotebookmarks'] = remotebookmarks for b in opts['bookmark']: b = repo._bookmarks.expandname(b) - if b not in remotebookmarks: + if b not in remotebookmarks(): raise error.Abort(_('remote bookmark %s not found!') % b) - revs.append(hex(remotebookmarks[b])) + revs.append(hex(remotebookmarks()[b])) if revs: try: