changeset 20599:dad29624b056

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 27 Feb 2014 20:01:28 -0800
parents e57e2da803aa
children 2e68882852ee
files mercurial/obsolete.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Wed Feb 19 13:46:49 2014 -0800
+++ b/mercurial/obsolete.py	Thu Feb 27 20:01:28 2014 -0800
@@ -352,14 +352,15 @@
 # - 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 is base86 encoded
+    - splitted in chunks 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 = []
@@ -372,6 +373,12 @@
         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'):