# HG changeset patch
# User Stanislau Hlebik <st...@fb.com>
# Date 1479807361 28800
#      Tue Nov 22 01:36:01 2016 -0800
# Node ID be39a83d5cb8c60e9b9a2a1b58b4b0dde833c77b
# Parent  b08e4f9ed873bb9b6bd8e170401a150f9b094bfd
pull: use `bookmarks` bundle2 part

Apply changes from `bookmarks` part.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1330,9 +1330,13 @@
     kwargs['cg'] = pullop.fetch
     if 'listkeys' in pullop.remotebundle2caps:
         kwargs['listkeys'] = ['phases']
-        if pullop.remotebookmarks is None:
-            # make sure to always includes bookmark data when migrating
-            # `hg incoming --bundle` to using this function.
+
+    if pullop.remotebookmarks is None:
+        # make sure to always includes bookmark data when migrating
+        # `hg incoming --bundle` to using this function.
+        if 'bookmarks' in pullop.remotebundle2caps:
+            kwargs['bookmarks'] = True
+        elif 'listkeys' in pullop.remotebundle2caps:
             kwargs['listkeys'].append('bookmarks')
 
     # If this is a full pull / clone and the server supports the clone bundles
@@ -1360,10 +1364,23 @@
     _pullbundle2extraprepare(pullop, kwargs)
     bundle = pullop.remote.getbundle('pull', **kwargs)
     try:
-        op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
+        bundleopbehavior = {
+            'processbookmarksmode': 'diverge',
+            'explicitbookmarks': pullop.explicitbookmarks,
+            'remotepath': pullop.remote.url(),
+        }
+        bundleop = bundle2.bundleoperation(pullop.repo, pullop.gettransaction,
+                                           behavior=bundleopbehavior)
+        op = bundle2.processbundle(pullop.repo, bundle,
+                                   pullop.gettransaction, op=bundleop)
     except error.BundleValueError as exc:
         raise error.Abort(_('missing support for %s') % exc)
 
+    # `bookmarks` part was in bundle and it was applied to the repo. No need to
+    # apply bookmarks one more time
+    if 'bookmarks' in kwargs and kwargs['bookmarks']:
+        pullop.stepsdone.add('bookmarks')
+
     if pullop.fetch:
         results = [cg['return'] for cg in op.records['changegroup']]
         pullop.cgresult = changegroup.combineresults(results)
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to