[PATCH 11 of 25 RFC] phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld
boris.feld at octobus.net
Thu Jun 7 10:11:10 EDT 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1528215367 -7200
# Tue Jun 05 18:16:07 2018 +0200
# Node ID 76416e99327fc44f049546ad6a39609d9d606081
# Parent 7fa3408f83ef1a04e2d23ab6f8498833b450e589
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 76416e99327f
phase: use `trackedphases` in `_getphaserevsnative`
Instead of manually listing secret and draft, simply use the `trackedphases`
constant. The constant is already used by `_getphaserevsnative`.
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -272,19 +272,16 @@ class phasecache(object):
repo = repo.unfiltered()
cl = repo.changelog
self._phasesets = [set() for phase in allphases]
- roots = pycompat.maplist(cl.rev, self.phaseroots[secret])
- if roots:
- ps = set(cl.descendants(roots))
- for root in roots:
- ps.add(root)
- self._phasesets[secret] = ps
- roots = pycompat.maplist(cl.rev, self.phaseroots[draft])
- if roots:
- ps = set(cl.descendants(roots))
- for root in roots:
- ps.add(root)
- ps.difference_update(self._phasesets[secret])
- self._phasesets[draft] = ps
+ lowerroots = set()
+ for phase in reversed(trackedphases):
+ roots = pycompat.maplist(cl.rev, self.phaseroots[phase])
+ if roots:
+ ps = set(cl.descendants(roots))
+ for root in roots:
+ ps.add(root)
+ ps.difference_update(lowerroots)
+ lowerroots.update(ps)
+ self._phasesets[phase] = ps
self._loadedrevslen = len(cl)
def loadphaserevs(self, repo):
More information about the Mercurial-devel
mailing list