Patchwork bundle2: pull bookmark the old way if no bundle2 liskeys support (issue4701)

login
register
mail settings
Submitter Pierre-Yves David
Date June 8, 2015, 8:46 p.m.
Message ID <ffe937d583d702dae10a.1433796396@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9558/
State Accepted
Headers show

Comments

Pierre-Yves David - June 8, 2015, 8:46 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1433795558 25200
#      Mon Jun 08 13:32:38 2015 -0700
# Node ID ffe937d583d702dae10af83989695def011a6297
# Parent  6fabde6ef4453ee6c2aa964184f6cf2c54483621
bundle2: pull bookmark the old way if no bundle2 liskeys support (issue4701)

All known servers implementation have listkeys support with bundle2, but people
in the process of implementing new server may not. Let's be nice with them.
Martin von Zweigbergk - June 8, 2015, 10:55 p.m.
This seems to fix our problem, thanks! Pushed to the clowncopter.

On Mon, Jun 8, 2015 at 1:47 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1433795558 25200
> #      Mon Jun 08 13:32:38 2015 -0700
> # Node ID ffe937d583d702dae10af83989695def011a6297
> # Parent  6fabde6ef4453ee6c2aa964184f6cf2c54483621
> bundle2: pull bookmark the old way if no bundle2 liskeys support
> (issue4701)
>
> All known servers implementation have listkeys support with bundle2, but
> people
> in the process of implementing new server may not. Let's be nice with them.
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -953,12 +953,16 @@ def _pullbookmarkbundle1(pullop):
>
>      If not using bundle2, we have to fetch bookmarks before changeset
>      discovery to reduce the chance and impact of race conditions."""
>      if pullop.remotebookmarks is not None:
>          return
> -    if not _canusebundle2(pullop): # all bundle2 server now support
> listkeys
> -        pullop.remotebookmarks = pullop.remote.listkeys('bookmarks')
> +    if (_canusebundle2(pullop)
> +            and 'listkeys' in bundle2.bundle2caps(pullop.remote)):
> +        # all known bundle2 server now support listkeys, but lets be nice
> with
> +        # new implementation.
> +        return
> +    pullop.remotebookmarks = pullop.remote.listkeys('bookmarks')
>
>
>  @pulldiscovery('changegroup')
>  def _pulldiscoverychangegroup(pullop):
>      """discovery phase for the pull
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -953,12 +953,16 @@  def _pullbookmarkbundle1(pullop):
 
     If not using bundle2, we have to fetch bookmarks before changeset
     discovery to reduce the chance and impact of race conditions."""
     if pullop.remotebookmarks is not None:
         return
-    if not _canusebundle2(pullop): # all bundle2 server now support listkeys
-        pullop.remotebookmarks = pullop.remote.listkeys('bookmarks')
+    if (_canusebundle2(pullop)
+            and 'listkeys' in bundle2.bundle2caps(pullop.remote)):
+        # all known bundle2 server now support listkeys, but lets be nice with
+        # new implementation.
+        return
+    pullop.remotebookmarks = pullop.remote.listkeys('bookmarks')
 
 
 @pulldiscovery('changegroup')
 def _pulldiscoverychangegroup(pullop):
     """discovery phase for the pull