[PATCH 04 of 11 sparse] sparse: refactor activeprofiles into a generic function (API)

Gregory Szorc gregory.szorc at gmail.com
Tue Jul 11 00:31:47 EDT 2017


On Mon, Jul 10, 2017 at 3:07 PM, Martin von Zweigbergk <
martinvonz at google.com> wrote:

> On Sat, Jul 8, 2017 at 4:28 PM, Gregory Szorc <gregory.szorc at gmail.com>
> wrote:
> > diff --git a/mercurial/sparse.py b/mercurial/sparse.py
> > --- a/mercurial/sparse.py
> > +++ b/mercurial/sparse.py
> > @@ -124,15 +124,26 @@ def patternsforrev(repo, rev):
> >
> >      return includes, excludes, profiles
> >
> > -def activeprofiles(repo):
> > +def activeconfig(repo):
> > +    """Determine the active sparse config rules.
> > +
> > +    Rules are constructed by reading the current sparse config and
> bringing in
> > +    referenced profiles from parents of the working directory.
> > +    """
> >      revs = [repo.changelog.rev(node) for node in
> >              repo.dirstate.parents() if node != nullid]
> >
> > -    profiles = set()
> > +    allincludes = set()
> > +    allexcludes = set()
> > +    allprofiles = set()
> > +
> >      for rev in revs:
> > -        profiles.update(patternsforrev(repo, rev)[2])
> > +        includes, excludes, profiles = patternsforrev(repo, rev)
> > +        allincludes |= includes
> > +        allexcludes |= excludes
> > +        allprofiles |= set(profiles)
>
> Feel like changing parseconfig() to return profiles as set too (in a
> followup)? I couldn't see a reason that it shouldn't be.
>

Since at the end of the day the only things that matter are includes and
excludes (which are sets), I agree that profiles could be a set. I do find
it somewhat odd that the existing code treats them as a list. So I want to
run this by Durham (CCd) in case there is something subtle that wants
profiles to be a list. Any non-determinism issues could be fixed by
throwing a sorted() around profiles traversal, of course.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170710/d69aba9b/attachment.html>


More information about the Mercurial-devel mailing list