[PATCH 4 of 6] pull: skip pulling remote bookmarks with bundle2 if a value already exist

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jun 5 00:20:01 CDT 2015

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1433222989 25200
#      Mon Jun 01 22:29:49 2015 -0700
# Node ID 631215946aa71e9feae366e603d17e4d92dea048
# Parent  cc46b372650d7984942aee75d8d371a59507b511
pull: skip pulling remote bookmarks with bundle2 if a value already exist

For efficiency and consistency purpose, remote bookmarks, retrieved at the time
the pull command code is doing lookup, will be reused during the core pull

A second step toward this is to avoid requesting bookmark information in
the bundle 2 if we already have them locally.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1004,11 +1004,15 @@ def _pullbundle2(pullop):
     kwargs['common'] = pullop.common
     kwargs['heads'] = pullop.heads or pullop.rheads
     kwargs['cg'] = pullop.fetch
     if 'listkeys' in remotecaps:
-        kwargs['listkeys'] = ['phase', 'bookmarks']
+        kwargs['listkeys'] = ['phase']
+        if pullop.remotebookmarks is None:
+            # make sure to always includes bookmarks data when migrating
+            # `hg incoming --bundle` to using this function.
+            kwargs['listkeys'].append('bookmarks')
     if not pullop.fetch:
         pullop.repo.ui.status(_("no changes found\n"))
         pullop.cgresult = 0
         if pullop.heads is None and list(pullop.common) == [nullid]:
@@ -1036,11 +1040,14 @@ def _pullbundle2(pullop):
     # processing bookmark update
     for namespace, value in op.records['listkeys']:
         if namespace == 'bookmarks':
             pullop.remotebookmarks = value
-            _pullbookmarks(pullop)
+    # bookmark data were either already there or pulled in the bundle
+    if pullop.remotebookmarks is not None:
+        _pullbookmarks(pullop)
 def _pullbundle2extraprepare(pullop, kwargs):
     """hook function so that extensions can extend the getbundle call"""

More information about the Mercurial-devel mailing list