Mercurial > hg
comparison mercurial/phases.py @ 44065:ab41dad7345e
phases: make phasecache._phasesets immutable
Previously, some code paths would mutate the cache itself, which
could give weird results if multiple revsets got evaluated through
that path.
Differential Revision: https://phab.mercurial-scm.org/D7854
author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
---|---|
date | Mon, 13 Jan 2020 19:11:44 -0800 |
parents | 8eb3c52337a6 |
children | 9d2b2df2c2ba |
comparison
equal
deleted
inserted
replaced
44064:8eb3c52337a6 | 44065:ab41dad7345e |
---|---|
251 if not phases: | 251 if not phases: |
252 return smartset.fullreposet(repo) | 252 return smartset.fullreposet(repo) |
253 | 253 |
254 # fast path: _phasesets contains the interesting sets, | 254 # fast path: _phasesets contains the interesting sets, |
255 # might only need a union and post-filtering. | 255 # might only need a union and post-filtering. |
256 revsneedscopy = False | |
256 if len(phases) == 1: | 257 if len(phases) == 1: |
257 [p] = phases | 258 [p] = phases |
258 revs = self._phasesets[p] | 259 revs = self._phasesets[p] |
260 revsneedscopy = True # Don't modify _phasesets | |
259 else: | 261 else: |
260 # revs has the revisions in all *other* phases. | 262 # revs has the revisions in all *other* phases. |
261 revs = set.union(*[self._phasesets[p] for p in phases]) | 263 revs = set.union(*[self._phasesets[p] for p in phases]) |
262 | 264 |
263 def _addwdir(wdirsubset, wdirrevs): | 265 def _addwdir(wdirsubset, wdirrevs): |
264 if wdirrev in wdirsubset and repo[None].phase() in phases: | 266 if wdirrev in wdirsubset and repo[None].phase() in phases: |
267 if revsneedscopy: | |
268 wdirrevs = wdirrevs.copy() | |
265 # The working dir would never be in the # cache, but it was in | 269 # The working dir would never be in the # cache, but it was in |
266 # the subset being filtered for its phase (or filtered out, | 270 # the subset being filtered for its phase (or filtered out, |
267 # depending on publicphase), so add it to the output to be | 271 # depending on publicphase), so add it to the output to be |
268 # included (or filtered out). | 272 # included (or filtered out). |
269 wdirrevs.add(wdirrev) | 273 wdirrevs.add(wdirrev) |