[PATCH 1 of 2 STABLE V2] convert: move recode() from convcmd to common

Yuya Nishihara yuya at tcha.org
Mon Nov 27 07:10:22 EST 2017


On Sun, 26 Nov 2017 20:38:55 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1511745478 18000
> #      Sun Nov 26 20:17:58 2017 -0500
> # Branch stable
> # Node ID 7208fc36b7765c36d31d0ccddb7087081617208c
> # Parent  02845f7441aff30bc01975a5881cabfa922c12d4
> convert: move recode() from convcmd to common
> 
> The next patch will need 'orig_encoding' in the p4 module, but importing convcmd
> there creates an import cycle.
> 
> diff --git a/hgext/convert/common.py b/hgext/convert/common.py
> --- a/hgext/convert/common.py
> +++ b/hgext/convert/common.py
> @@ -37,6 +37,14 @@
>      s = base64.decodestring(s)
>      return pickle.loads(s)
>  
> +orig_encoding = 'ascii'
> +
> +def recode(s):
> +    if isinstance(s, unicode):
> +        return s.encode(orig_encoding, 'replace')
> +    else:
> +        return s.decode('utf-8').encode(orig_encoding, 'replace')

We can't simply move these because orig_encoding is updated by
convcmd.convert(). Perhaps we can partly backout 0d5a1175d0f9 for stable.


More information about the Mercurial-devel mailing list