[PATCH] context: use common __repr__() implementation for all classes

Nicolas Dumazet nicdumz at gmail.com
Tue Jul 21 20:59:50 CDT 2009


2009/7/22 Greg Ward <greg-hg at gerg.ca>:
> context: use common __repr__() implementation for all classes.
>
> Before this, subclasses used their parent's __repr__(), which had
> hardcoded class names.  That made repr() of a workingctx object
> indistinguishable from repr() of a changectx.

That looks fine for me.

[...]

>
> +# common implementation of __repr__()
> +def __repr__(self):
> +    return "<%s %s>" % (self.__class__.__name__, str(self))
> +

I'm just not really sure if we do need to name that common method "__repr__".

[...]

> +    __repr__ = __repr__
> +

That resulting stance looks a bit awkward to me, I would rather read a
"__repr__ = commonrepr"

-- 
Nicolas Dumazet — NicDumZ [ nɪk.d̪ymz ]



More information about the Mercurial-devel mailing list