Patchwork [4,of,9,RFC] obsolete: add binary version of listmarkers (API)

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 14, 2016, 9:10 p.m.
Message ID <67501b93c9875cc6cdef.1471209003@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16283/
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 1471206127 25200
#      Sun Aug 14 13:22:07 2016 -0700
# Node ID 67501b93c9875cc6cdef0e77d2d148a14a5d60a8
# Parent  cab15fd54ee60cc067920454544586cc4aa03d8e
obsolete: add binary version of listmarkers (API)

Continuing our work to implement binary/raw versions of listkeys
functions.

We had to update a caller in exchange.py because we stopped returning
base85 encoded data from obsolete._pushkeyescape.
Pierre-Yves David - Aug. 16, 2016, 11:59 p.m.
On 08/14/2016 11:10 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1471206127 25200
> #      Sun Aug 14 13:22:07 2016 -0700
> # Node ID 67501b93c9875cc6cdef0e77d2d148a14a5d60a8
> # Parent  cab15fd54ee60cc067920454544586cc4aa03d8e
> obsolete: add binary version of listmarkers (API)
>
> Continuing our work to implement binary/raw versions of listkeys
> functions.
>
> We had to update a caller in exchange.py because we stopped returning
> base85 encoded data from obsolete._pushkeyescape.

We already have binary listing of obsolescence markers with bundle2. I 
don't think we need this changeset.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1014,16 +1014,17 @@  def _pushobsolete(pushop):
     pushop.stepsdone.add('obsmarkers')
     if pushop.outobsmarkers:
         pushop.ui.debug('try to push obsolete markers to remote\n')
         rslts = []
         remotedata = obsolete._pushkeyescape(sorted(pushop.outobsmarkers))
         for key in sorted(remotedata, reverse=True):
             # reverse sort to ensure we end with dump0
             data = remotedata[key]
+            data = base85.b85encode(data)
             rslts.append(remote.pushkey('obsolete', key, '', data))
         if [r for r in rslts if not r]:
             msg = _('failed to push some obsolete markers!\n')
             repo.ui.warn(msg)
 
 def _pushbookmark(pushop):
     """Update bookmark position on remote"""
     if pushop.cgresult == 0 or 'bookmarks' in pushop.stepsdone:
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -722,39 +722,44 @@  def commonversion(versions):
 # you have to take in account:
 # - the version header
 # - the base85 encoding
 _maxpayload = 5300
 
 def _pushkeyescape(markers):
     """encode markers into a dict suitable for pushkey exchange
 
-    - binary data is base85 encoded
     - split in chunks smaller than 5300 bytes"""
     keys = {}
     parts = []
     currentlen = _maxpayload * 2  # ensure we create a new part
     for marker in markers:
         nextdata = _fm0encodeonemarker(marker)
         if (len(nextdata) + currentlen > _maxpayload):
             currentpart = []
             currentlen = 0
             parts.append(currentpart)
         currentpart.append(nextdata)
         currentlen += len(nextdata)
     for idx, part in enumerate(reversed(parts)):
         data = ''.join([_pack('>B', _fm0version)] + part)
-        keys['dump%i' % idx] = base85.b85encode(data)
+        keys['dump%i' % idx] = data
     return keys
 
+def listmarkersraw(repo):
+    if not repo.obsstore:
+        return {}
+    return _pushkeyescape(sorted(repo.obsstore))
+
 def listmarkers(repo):
     """List markers over pushkey"""
-    if not repo.obsstore:
-        return {}
-    return _pushkeyescape(sorted(repo.obsstore))
+    d = {}
+    for k, v in listmarkersraw(repo).iteritems():
+        d[k] = base85.b85encode(v)
+    return d
 
 def pushmarker(repo, key, old, new):
     """Push markers over pushkey"""
     if not key.startswith('dump'):
         repo.ui.warn(_('unknown key: %r') % key)
         return 0
     if old:
         repo.ui.warn(_('unexpected old value for %r') % key)