# HG changeset patch # User Laurent Charignon # Date 1426875267 25200 # Node ID 27e3ba73fbb18096cf8d0463ae1dd2d23b77f506 # Parent 539b3c7eea4410b4da099e42d118464c43c8f842 phase: default to C implementation for phase computation diff -r 539b3c7eea44 -r 27e3ba73fbb1 mercurial/phases.py --- a/mercurial/phases.py Tue Mar 24 11:00:09 2015 -0700 +++ b/mercurial/phases.py Fri Mar 20 11:14:27 2015 -0700 @@ -172,19 +172,29 @@ for a in 'phaseroots dirty opener _phaserevs'.split(): setattr(self, a, getattr(phcache, a)) + def getphaserevsnative(self, repo): + repo = repo.unfiltered() + nativeroots = [] + for phase in trackedphases: + nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase])) + return repo.changelog.computephases(nativeroots) + def getphaserevs(self, repo): if self._phaserevs is None: - repo = repo.unfiltered() - revs = [public] * len(repo.changelog) - self._phaserevs = revs - self._populatephaseroots(repo) - for phase in trackedphases: - roots = 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 + try: + self._phaserevs = self.getphaserevsnative(repo) + except AttributeError: + repo = repo.unfiltered() + revs = [public] * len(repo.changelog) + self._phaserevs = revs + self._populatephaseroots(repo) + for phase in trackedphases: + roots = 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 return self._phaserevs def invalidate(self): diff -r 539b3c7eea44 -r 27e3ba73fbb1 mercurial/revlog.py --- a/mercurial/revlog.py Tue Mar 24 11:00:09 2015 -0700 +++ b/mercurial/revlog.py Fri Mar 20 11:14:27 2015 -0700 @@ -724,6 +724,9 @@ except AttributeError: return self._headrevs() + def computephases(self, roots): + return self.index.computephases(roots) + def _headrevs(self): count = len(self) if not count: