Mercurial > hg-stable
changeset 24444:27e3ba73fbb1
phase: default to C implementation for phase computation
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Fri, 20 Mar 2015 11:14:27 -0700 |
parents | 539b3c7eea44 |
children | c71edbafe603 |
files | mercurial/phases.py mercurial/revlog.py |
diffstat | 2 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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: