obsolete: extract encoding of marker for pushkey from the list key function
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 27 Feb 2014 20:01:28 -0800
changeset 20599 dad29624b056
parent 20598 e57e2da803aa
child 20600 2e68882852ee
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.
mercurial/obsolete.py
--- 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'):