Patchwork [9,of,9,RFC] exchange: call listkeys2 to fetch obsolescence data if available

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 14, 2016, 9:10 p.m.
Message ID <f878f764517369b28d0d.1471209008@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16288/
State Changes Requested
Headers show

Comments

Gregory Szorc - Aug. 14, 2016, 9:10 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1471208941 25200
#      Sun Aug 14 14:09:01 2016 -0700
# Node ID f878f764517369b28d0dfd9bd9fb14514dc44862
# Parent  d2870bcbc43041909e9f637b294cb889f7ed4933
exchange: call listkeys2 to fetch obsolescence data if available
Pierre-Yves David - Aug. 17, 2016, 12:06 a.m.
On 08/14/2016 11:10 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1471208941 25200
> #      Sun Aug 14 14:09:01 2016 -0700
> # Node ID f878f764517369b28d0dfd9bd9fb14514dc44862
> # Parent  d2870bcbc43041909e9f637b294cb889f7ed4933
> exchange: call listkeys2 to fetch obsolescence data if available

If mercurial is recent enough to have the new listkey, it also recent 
enough to have bundle2 and the obsmarkers will already be send in binary 
as a dedicated parts.

(cf reply to previous email in the series about this)

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1454,23 +1454,30 @@  def _pullobsolete(pullop):
 
     Exists mostly to allow overriding for experimentation purpose"""
     if 'obsmarkers' in pullop.stepsdone:
         return
     pullop.stepsdone.add('obsmarkers')
     tr = None
     if obsolete.isenabled(pullop.repo, obsolete.exchangeopt):
         pullop.repo.ui.debug('fetching remote obsolete markers\n')
-        remoteobs = pullop.remote.listkeys('obsolete')
+        raw = pullop.remote.capable('listkeys2')
+        if raw:
+            fn = pullop.remote.listkeys2
+        else:
+            fn = pullop.remote.listkeys
+        remoteobs = fn('obsolete')
         if 'dump0' in remoteobs:
             tr = pullop.gettransaction()
             markers = []
             for key in sorted(remoteobs, reverse=True):
                 if key.startswith('dump'):
-                    data = base85.b85decode(remoteobs[key])
+                    data = remoteobs[key]
+                    if not raw:
+                        data = base85.b85decode(data)
                     version, newmarks = obsolete._readmarkers(data)
                     markers += newmarks
             if markers:
                 pullop.repo.obsstore.add(tr, markers)
             pullop.repo.invalidatevolatilesets()
     return tr
 
 def caps20to10(repo):