[PATCH 1 of 3 V3] hg: make repository take filtername argument to avoid useless filtering

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Jan 9 08:49:00 CST 2016


At Fri, 8 Jan 2016 13:15:39 +0000,
Pierre-Yves David wrote:
> 
> On 01/07/2016 01:09 AM, FUJIWARA Katsunori wrote:
> > At Wed, 6 Jan 2016 00:57:02 +0900,
> > Yuya Nishihara wrote:
> >>
> >> On Sun, 03 Jan 2016 20:03:45 +0900, FUJIWARA Katsunori wrote:
> >>> # HG changeset patch
> >>> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> >>> # Date 1451818994 -32400
> >>> #      Sun Jan 03 20:03:14 2016 +0900
> >>> # Node ID 85def1110482e9f731e56da12d0c6b624f4d8a45
> >>> # Parent  b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a
> >>> hg: make repository take filtername argument to avoid useless filtering
> >>>
> >>> If user of 'repository()' wants non-"visible" view (or unfiltered
> >>> repository), filtering for "visible" view itself is meaningless.
> >>>
> >>> diff --git a/mercurial/hg.py b/mercurial/hg.py
> >>> --- a/mercurial/hg.py
> >>> +++ b/mercurial/hg.py
> >>> @@ -155,14 +155,16 @@ def _peerorrepo(ui, path, create=False):
> >>>               f(ui, obj)
> >>>       return obj
> >>>
> >>> -def repository(ui, path='', create=False):
> >>> +def repository(ui, path='', create=False, filtername='visible'):
> >>>       """return a repository object for the specified path"""
> >>>       peer = _peerorrepo(ui, path, create)
> >>>       repo = peer.local()
> >>>       if not repo:
> >>>           raise error.Abort(_("repository '%s' is not local") %
> >>>                            (path or peer.url()))
> >>> -    return repo.filtered('visible')
> >>> +    if not filtername:
> >>> +        return repo.unfiltered()
> >>> +    return repo.filtered(filtername)
> >>
> >> The first two look good to me, but I hesitated to push them because
> >> hg.repository() is very basic interface and I'm not sure if we want the
> >> filtername argument there.
> >
> >  From the point of view of resource efficiency, meaningless filtering
> > in hg.repository() should be avoided, IMHO.
> >
> > But on the other hand, it is also reasonable that you hesitate
> > changing very basic interface hg.repository().
> 
> If I remember correctly, the filtering does not make much except 
> creating the proxy class. All computation of what is actually filtered 
> should not happen until the first repo.changelog access.

Yes, construction of repoview object itself is very cheap.

I changed hg.repository() just because I don't have any strong opinion
if someone asked me why hg.repository() still returns useless repoview
object in such case.

> Is there something else going one?
> 
> -- 
> Pierre-Yves David
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list