[PATCH 02 of 10 shelve-ext] shelve: add an ability to write json to a new type of shelve files

Yuya Nishihara yuya at tcha.org
Fri Dec 2 08:25:50 EST 2016


On Tue, 29 Nov 2016 15:55:06 +0000, Jun Wu wrote:
> Excerpts from Kostia Balytskyi's message of 2016-11-29 07:22:56 -0800:
> > # HG changeset patch
> > # User Kostia Balytskyi <ikostia at fb.com>
> > # Date 1480426193 28800
> > #      Tue Nov 29 05:29:53 2016 -0800
> > # Node ID 37119e028c699d9fabd220086e08c754827e709f
> > # Parent  f6f0ab3f7b0ea0e05cfdcd7afd4994ea21988fd9
> > shelve: add an ability to write json to a new type of shelve files
> > 
> > Obsolescense-based shelve only needs metadata stored in .hg/shelved
> > and I think that this metadata should be stored in json for
> > potential extensibility purposes. JSON is not critical here, but
> > I want to avoid storing it in an unstructured text file where
> > order of lines determines their semantical meanings (as now
> > happens in .hg/shelvedstate. .hg/rebasestate and I suspect other
> > state files as well).
> > 
> > If we want, we can refactor it to something else later.
> > 
> > diff --git a/hgext/shelve.py b/hgext/shelve.py
> > --- a/hgext/shelve.py
> > +++ b/hgext/shelve.py
> > @@ -25,6 +25,7 @@ from __future__ import absolute_import
> >  import collections
> >  import errno
> >  import itertools
> > +import json
> 
> I think we avoid using "import json" for some reason (encoding?). There is
> no "import json" in the code base yet.

Yeah, JSON is troublesome because every string must be a valid unicode. If
all strings are known to be ascii or utf-8 for instance, we could use JSON,
but we still have to convert unicode objects back to str.


More information about the Mercurial-devel mailing list