[PATCH 1 of 3] committablectx: override __int__ to return integer next to tip
Yuya Nishihara
yuya at tcha.org
Wed Apr 15 12:24:27 UTC 2015
On Tue, 14 Apr 2015 14:52:03 -0400, Matt Mackall wrote:
> On Sat, 2015-04-11 at 12:56 +0900, Yuya Nishihara wrote:
> > On Fri, 10 Apr 2015 15:08:40 -0500, Matt Mackall wrote:
> > > On Fri, 2015-04-10 at 23:54 +0900, Yuya Nishihara wrote:
> > > > # HG changeset patch
> > > > # User Yuya Nishihara <yuya at tcha.org>
> > > > # Date 1428154731 -32400
> > > > # Sat Apr 04 22:38:51 2015 +0900
> > > > # Node ID 7b7efec2eafba7dde274316eb3c18a98ec6528b1
> > > > # Parent e0e28e910fa3797fd0aa4f818e9b33c5bcbf0e53
> > > > committablectx: override __int__ to return integer next to tip
> > >
> > > Postscript: I see that normal contexts already have __int__.. which may
> > > be a mistake. Do we use it anywhere?
> >
> > Yes.
> >
> > % grep ctx **/*.py | grep 'int(\|%d' | grep -v 'rev()' | grep -v 'repo\.\(set\|revs\)'
> > ...
> > mercurial/cmdutil.py: repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
> > mercurial/cmdutil.py: repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
> > mercurial/commands.py: ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
> > mercurial/templatekw.py: childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()]
>
> Running the test suite without __int__ spotted a couple more. But I
> still think we should move away from it and not add it to workingctxs.
Agreed. Actually I don't like int(ctx) or str(ctx) because they're too magical.
I'll send V2 after 3.4.
Regards,
More information about the Mercurial-devel
mailing list