From patchwork Tue Jan 14 03:18:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7854: phases: make phasecache._phasesets immutable From: phabricator X-Patchwork-Id: 44301 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 14 Jan 2020 03:18:14 +0000 rdamazio created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Previously, some code paths would mutate the cache itself, which could give weird results if multiple revsets got evaluated through that path. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D7854 AFFECTED FILES mercurial/phases.py CHANGE DETAILS To: rdamazio, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -253,15 +253,19 @@ # fast path: _phasesets contains the interesting sets, # might only need a union and post-filtering. + revsneedscopy = False if len(phases) == 1: [p] = phases revs = self._phasesets[p] + revsneedscopy = True # Don't modify _phasesets else: # revs has the revisions in all *other* phases. revs = set.union(*[self._phasesets[p] for p in phases]) def _addwdir(wdirsubset, wdirrevs): if wdirrev in wdirsubset and repo[None].phase() in phases: + if revsneedscopy: + wdirrevs = wdirrevs.copy() # The working dir would never be in the # cache, but it was in # the subset being filtered for its phase (or filtered out, # depending on publicphase), so add it to the output to be