Mercurial > hg
comparison mercurial/phases.py @ 25190:22438cfd11b5
phases: add set per phase in C phase computation
To speed up the computation of draft(), secret(), divergent(), obsolete() and
unstable() we need to have a fast way of getting the list of revisions that
are in draft(), secret() or the union of both: not public().
This patch extends the work on phase computation in C and make the phase
computation code also return a list of set for each non public phase.
Using these sets we can quickly obtain all the revisions of a given phase.
We do not return a set for the public phase as we expect it to be roughly the
size of the repo. Also, it can be computed easily by substracting the entries in the
non public phases from all the revs in the repo.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 01 Apr 2015 11:17:17 -0700 |
parents | 2a73829ebe17 |
children | 262e6ad93885 |
comparison
equal
deleted
inserted
replaced
25189:1c8c33eaea0a | 25190:22438cfd11b5 |
---|---|
153 def __init__(self, repo, phasedefaults, _load=True): | 153 def __init__(self, repo, phasedefaults, _load=True): |
154 if _load: | 154 if _load: |
155 # Cheap trick to allow shallow-copy without copy module | 155 # Cheap trick to allow shallow-copy without copy module |
156 self.phaseroots, self.dirty = _readroots(repo, phasedefaults) | 156 self.phaseroots, self.dirty = _readroots(repo, phasedefaults) |
157 self._phaserevs = None | 157 self._phaserevs = None |
158 self._phasesets = None | |
158 self.filterunknown(repo) | 159 self.filterunknown(repo) |
159 self.opener = repo.svfs | 160 self.opener = repo.svfs |
160 | 161 |
161 def copy(self): | 162 def copy(self): |
162 # Shallow copy meant to ensure isolation in | 163 # Shallow copy meant to ensure isolation in |
175 def _getphaserevsnative(self, repo): | 176 def _getphaserevsnative(self, repo): |
176 repo = repo.unfiltered() | 177 repo = repo.unfiltered() |
177 nativeroots = [] | 178 nativeroots = [] |
178 for phase in trackedphases: | 179 for phase in trackedphases: |
179 nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase])) | 180 nativeroots.append(map(repo.changelog.rev, self.phaseroots[phase])) |
180 return repo.changelog.computephases(nativeroots) | 181 return repo.changelog.computephasesmapsets(nativeroots) |
181 | 182 |
182 def _computephaserevspure(self, repo): | 183 def _computephaserevspure(self, repo): |
183 repo = repo.unfiltered() | 184 repo = repo.unfiltered() |
184 revs = [public] * len(repo.changelog) | 185 revs = [public] * len(repo.changelog) |
185 self._phaserevs = revs | 186 self._phaserevs = revs |
197 try: | 198 try: |
198 if repo.ui.configbool('experimental', | 199 if repo.ui.configbool('experimental', |
199 'nativephaseskillswitch'): | 200 'nativephaseskillswitch'): |
200 self._computephaserevspure(repo) | 201 self._computephaserevspure(repo) |
201 else: | 202 else: |
202 self._phaserevs = self._getphaserevsnative(repo) | 203 res = self._getphaserevsnative(repo) |
204 self._phaserevs, self._phasesets = res | |
203 except AttributeError: | 205 except AttributeError: |
204 self._computephaserevspure(repo) | 206 self._computephaserevspure(repo) |
205 return self._phaserevs | 207 return self._phaserevs |
206 | 208 |
207 def invalidate(self): | 209 def invalidate(self): |