changeset 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 f5d2720f3bea
files mercurial/phases.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/phases.py	Mon Jan 13 19:06:36 2020 -0800
+++ b/mercurial/phases.py	Mon Jan 13 19:11:44 2020 -0800
@@ -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