[PATCH evolve-ext-V5] evolve: add new methods _evolvestatewrite, _evolvestateread, _evolvestatedelete

Yuya Nishihara yuya at tcha.org
Wed Jan 27 09:07:44 CST 2016


On Tue, 26 Jan 2016 15:43:07 -0800, Shusen LIU wrote:
> # HG changeset patch
> # User Shusen LIU <liushusen at fb.com>
> # Date 1453329104 28800
> #      Wed Jan 20 14:31:44 2016 -0800
> # Node ID c82a0edf16d90727e307e2c4b17bd1202e414fb7
> # Parent  ea7523380efa894213582ca1600dc472baa7b25e
> evolve: add new methods _evolvestatewrite, _evolvestateread, _evolvestatedelete

> +def _fm0evolvestateread(repo):
> +    serialized_data = repo.vfs.read('evolvestate').split('\n')[1]
> +    data = dict([(str(k), str(v))
> +                 for k,v in json.loads(serialized_data).iteritems()])
> +    return data
> +
> +def _fm0evolvestatewrite(repo, data):
> +    serialized_data = json.dumps(data)
> +    repo.vfs.write('evolvestate',
> +                   '\n'.join([str(_fm0evolvestateversion), serialized_data]))

I'm not sure this is the case, but JSON is really bad at handling non-UTF-8
string such as a file name. If 'evolvestate' is not intended to be read by
other tools, JSON won't be a good choice.


More information about the Mercurial-devel mailing list