[PATCH] obsolete: extract encoding of marker for pushkey from the list key function

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Thu Feb 27 22:17:16 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1393560088 28800
#      Thu Feb 27 20:01:28 2014 -0800
# Node ID c15a6fc0f9e646e9f4d98088458b6f00a892c875
# Parent  710c2755e66a1322d78911a18362636b3b0ead2c
obsolete: extract encoding of marker for pushkey from the list key function

We now have a function taking a list and marker and returning an encoded
version. This will allow obsolescence marker exchange experimentation to easily
pushkey-encode markers to be pushed after selection.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -350,18 +350,19 @@ def _encodeonemarker(marker):
 # you have to take in account:
 # - the version header
 # - the base85 encoding
 _maxpayload = 5300
 
-def listmarkers(repo):
-    """List markers over pushkey"""
-    if not repo.obsstore:
-        return {}
+def _pushkeyescape(markers):
+    """encode markers into a dict suitable for pushkey exchange
+
+    - binary data are base86 encoded
+    - splited in chunk less than 5300 bytes"""
     keys = {}
     parts = []
     currentlen = _maxpayload * 2  # ensure we create a new part
-    for marker in  repo.obsstore:
+    for marker in markers:
         nextdata = _encodeonemarker(marker)
         if (len(nextdata) + currentlen > _maxpayload):
             currentpart = []
             currentlen = 0
             parts.append(currentpart)
@@ -370,10 +371,16 @@ def listmarkers(repo):
     for idx, part in enumerate(reversed(parts)):
         data = ''.join([_pack('>B', _fmversion)] + part)
         keys['dump%i' % idx] = base85.b85encode(data)
     return keys
 
+def listmarkers(repo):
+    """List markers over pushkey"""
+    if not repo.obsstore:
+        return {}
+    return _pushkeyescape(repo.obsstore)
+
 def pushmarker(repo, key, old, new):
     """Push markers over pushkey"""
     if not key.startswith('dump'):
         repo.ui.warn(_('unknown key: %r') % key)
         return 0


More information about the Mercurial-devel mailing list