Patchwork [V2,(typo,fix)] obsolete: extract encoding of marker for pushkey from the list key function

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 28, 2014, 6:17 p.m.
Message ID <fd6b1e810bd74484f67f.1393611457@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3807/
State Accepted
Commit dad29624b05663f7e785e333ad48d5a530dd5b37
Headers show

Comments

Pierre-Yves David - Feb. 28, 2014, 6:17 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1393560088 28800
#      Thu Feb 27 20:01:28 2014 -0800
# Node ID fd6b1e810bd74484f67f4669ad02531463ec4936
# 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.
Augie Fackler - Feb. 28, 2014, 7:51 p.m.
queued, thanks

On Feb 28, 2014, at 1:17 PM, pierre-yves.david@ens-lyon.org wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1393560088 28800
> #      Thu Feb 27 20:01:28 2014 -0800
> # Node ID fd6b1e810bd74484f67f4669ad02531463ec4936
> # 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 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 = []
>             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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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 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 = []
             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