[PATCH 5 of 8] pager: use super class's _runpager if possible

Yuya Nishihara yuya at tcha.org
Tue Jan 10 09:44:36 EST 2017


On Tue, 10 Jan 2017 07:30:22 +0800, Jun Wu wrote:
> Excerpts from Jun Wu's message of 2017-01-10 07:12:25 +0800:
> > # HG changeset patch
> > # User Jun Wu <quark at fb.com>
> > # Date 1484002766 -28800
> > #      Tue Jan 10 06:59:26 2017 +0800
> > # Node ID 24ebef0f19843c6b1b8fbf32d99a7e8dba2fb734
> > # Parent  483eabc8ccbbdfabed7f0f0abd74fb131adcd3c3
> > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 24ebef0f1984
> > pager: use super class's _runpager if possible
> > 
> > The ui class is currently pagerui(chgui(ui)), so chgui's _runpager will be
> > overrided by pagerui. Detect it and use chgui's _runpager, in pager.py.
> > 
> > In the future, when pager is moved to core, pagerui will no longer exist and
> > ui.py has _runpager implemented directly, and we can just call ui._runpager
> > without any check.
> > 
> > diff --git a/hgext/pager.py b/hgext/pager.py
> > --- a/hgext/pager.py
> > +++ b/hgext/pager.py
> > @@ -121,5 +121,6 @@ def uisetup(ui):
> >      class pagerui(ui.__class__):
> >          def _runpager(self, pagercmd):
> > -            _runpager(self, pagercmd)
> > +            runpager = getattr(super(pagerui, self), '_runpager', _runpager)
> 
> I realized that this is wrong (super(...) is not a class but an instance).
> Fortunately it seems that this patch could be just dropped without affecting
> correctness because how chg works currently.

Dropped this. Maybe we can simply skip the pagerui wrapping if ui has
_runpager.


More information about the Mercurial-devel mailing list