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

Greg Ward greg-hg at gerg.ca
Wed Jul 22 12:55:17 CDT 2009

On Tue, Jul 21, 2009 at 10:04 PM, Matt Mackall<mpm at selenic.com> wrote:
>> 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.
> Let's use inheritance here?

Sure, could do.  FWIW, this is a pattern I use frequently; I typically
use the same __repr__() implementation, regardless of whether classes
are related or not.  The only problem with my usual __repr__() is that
it requires a separate __str__(); without it, you get infinite
recursion.  Hmmm: that could be fixed with a base class.

OK, I'll send a new patch.


More information about the Mercurial-devel mailing list