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.
--- 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'):