D5448: pull: update comment and refactor in preparation for next commit

valentin.gatienbaron (Valentin Gatien-Baron) phabricator at mercurial-scm.org
Tue Dec 18 13:58:58 UTC 2018


valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5448

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

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:



To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list