[PATCH 1 of 3] upgrade: introduce a 'formatvariant' class

Yuya Nishihara yuya at tcha.org
Sun Apr 16 09:06:34 EDT 2017


On Thu, 13 Apr 2017 01:12:14 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1491860083 -7200
> #      Mon Apr 10 23:34:43 2017 +0200
> # Node ID b42c1f35aedd153c77741d54dac50aa6d3ea43e2
> # Parent  3c77f03f16b386940c60af36d6a3ad83bee37ad4
> # EXP-Topic upgraderepo
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r b42c1f35aedd
> upgrade: introduce a 'formatvariant' class

The code looks generally good, but I'll wait for some comments from Greg.
A couple of nits inline.

> --- a/mercurial/upgrade.py
> +++ b/mercurial/upgrade.py
> @@ -120,6 +120,23 @@ class improvement(object):
>      upgrademessage
>         Message intended for humans explaining what an upgrade addressing this
>         issue will do. Should be worded in the future tense.
> +    """
> +    def __init__(self, name, type, description, upgrademessage):
> +        self.name = name
> +        self.type = type
> +        self.description = description
> +        self.upgrademessage = upgrademessage
> +
> +    def __eq__(self, other):
> +        if not isinstance(other, improvement):
> +            # This is what python tell use to do
> +            return NotImplemented
> +        return self.name == other.name

This isn't a bug introduced by this patch, but __ne__ and __hash__ should
also be defined.

> +    def __init__(self, name, description, upgrademessage, fromdefault,
> +                 fromconfig):
> +        super(formatvariant, self).__init__(name, 'deficiency', description,
> +                                            upgrademessage)

Better to use the "deficiency" constant, but I don't care much since __init__
will be removed by the next patch.


More information about the Mercurial-devel mailing list