D1606: phases: drop the list with phase of each rev, always comput phase sets

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Fri Dec 8 09:54:21 EST 2017


yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Queued, thanks. Can you send follow-up patches to address trivial issues?

INLINE COMMENTS

> revlog.c:692
>  	for (i = 0; i < len; i++) {
>  		PyObject *phaseval;
>  

Removed unused variable in flight.

> phases.py:205
>              self.phaseroots, self.dirty = _readroots(repo, phasedefaults)
> -            self._phaserevs = None
> +            self._phasemaxrev = nullrev
>              self._phasesets = None

Nit: this isn't the "max" revision, but the size. Perhaps the initial
value should be 0.

> phases.py:236
> +                return smartset.fullreposet(repo)
> +            return smartset.fullreposet(repo).filter(lambda r: r not in revs)
>  

Nit: could be written as `fullrepoest(repo) - baseset(revs)`.

> phases.py:264
>          repo = repo.unfiltered()
> -        revs = [public] * len(repo.changelog)
> -        self._phaserevs = revs
> -        self._populatephaseroots(repo)
> -        for phase in trackedphases:
> -            roots = list(map(repo.changelog.rev, self.phaseroots[phase]))
> -            if roots:
> -                for rev in roots:
> -                    revs[rev] = phase
> -                for rev in repo.changelog.descendants(roots):
> -                    revs[rev] = phase
> +        cl = repo.changelog
> +        self._phasesets = [set() for phase in allphases]

Nice, no dependency on repo. As a follow-up, maybe we
can extract a pure function as truly drop-in replacement for
the native function.

> phases.py:266
> +        self._phasesets = [set() for phase in allphases]
> +        roots = map(cl.rev, self.phaseroots[secret])
> +        if roots:

s/map/pycompat.maplist/ for Python 3 compatibility. Fixed in flight.

> phases.py:295
>      def phase(self, repo, rev):
>          # We need a repo argument here to be able to build _phaserevs
>          # if necessary. The repository instance is not stored in

s/_phaserevs/_phasesets/. Fixed in flight.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1606

To: joerg.sonnenberger, #hg-reviewers, quark, yuja
Cc: yuja, durin42, quark, mercurial-devel


More information about the Mercurial-devel mailing list