Patchwork [8,of,9,V6] pull: use `bookmarks` bundle2 part

login
register
mail settings
Submitter Stanislau Hlebik
Date Oct. 11, 2016, 4:25 p.m.
Message ID <445790ea847e83d17836.1476203150@dev1918.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17031/
State Changes Requested
Delegated to: Pierre-Yves David
Headers show

Comments

Stanislau Hlebik - Oct. 11, 2016, 4:25 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1476195835 25200
#      Tue Oct 11 07:23:55 2016 -0700
# Node ID 445790ea847e83d178368f148c302df8fca66e03
# Parent  48e5db9c751c1eca19019bbc24de43f7cb3368e7
pull: use `bookmarks` bundle2 part

Apply changes from `bookmarks` part.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1322,9 +1322,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
@@ -1352,10 +1356,20 @@ 
     _pullbundle2extraprepare(pullop, kwargs)
     bundle = pullop.remote.getbundle('pull', **kwargs)
     try:
-        op = bundle2.processbundle(pullop.repo, bundle, pullop.gettransaction)
+        op = bundle2.bundleoperation(pullop.repo, pullop.gettransaction,
+                                     processbookmarksmode='diverge',
+                                     explicitbookmarks=pullop.explicitbookmarks,
+                                     remotepath=pullop.remote.url())
+        op = bundle2.processbundle(pullop.repo, bundle,
+                                   pullop.gettransaction, op=op)
     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)
@@ -1752,7 +1766,8 @@ 
                     gettransaction()
 
                 op = bundle2.bundleoperation(repo, gettransaction,
-                                             captureoutput=captureoutput)
+                                             captureoutput=captureoutput,
+                                             processbookmarksmode='apply')
                 try:
                     op = bundle2.processbundle(repo, cg, op=op)
                 finally: