# HG changeset patch # User Eric Sumner # Date 1418931528 28800 # Node ID b8260abfeb7d3cf39a132d8f32777e51dbd7113f # Parent b9af235810cc9c309a94cdfd9c11c554161a7984 bundlerepo: implement safe phasecache This patch makes bundlerepo use a subclass of phasecache that will allow phase boundaries to be moved around, but will never write them to the underlying repository. diff -r b9af235810cc -r b8260abfeb7d mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Thu Dec 18 11:30:10 2014 -0800 +++ b/mercurial/bundlerepo.py Thu Dec 18 11:38:48 2014 -0800 @@ -15,7 +15,7 @@ from i18n import _ import os, tempfile, shutil import changegroup, util, mdiff, discovery, cmdutil, scmutil, exchange -import localrepo, changelog, manifest, filelog, revlog, error +import localrepo, changelog, manifest, filelog, revlog, error, phases class bundlerevlog(revlog.revlog): def __init__(self, opener, indexfile, bundle, linkmapper): @@ -184,6 +184,23 @@ def canpush(self): return False +class bundlephasecache(phases.phasecache): + def __init__(self, *args, **kwargs): + super(bundlephasecache, self).__init__(*args, **kwargs) + if util.safehasattr(self, 'opener'): + self.opener = scmutil.readonlyvfs(self.opener) + + def write(self): + raise NotImplementedError + + def _write(self, fp): + raise NotImplementedError + + def _updateroots(self, phase, newroots, tr): + self.phaseroots[phase] = newroots + self.invalidate() + self.dirty = True + class bundlerepository(localrepo.localrepository): def __init__(self, ui, path, bundlename): self._tempparent = None @@ -226,6 +243,10 @@ self.bundlefilespos = {} @localrepo.unfilteredpropertycache + def _phasecache(self): + return bundlephasecache(self, self._phasedefaults) + + @localrepo.unfilteredpropertycache def changelog(self): # consume the header if it exists self.bundle.changelogheader() diff -r b9af235810cc -r b8260abfeb7d mercurial/phases.py --- a/mercurial/phases.py Thu Dec 18 11:30:10 2014 -0800 +++ b/mercurial/phases.py Thu Dec 18 11:38:48 2014 -0800 @@ -161,7 +161,7 @@ def copy(self): # Shallow copy meant to ensure isolation in # advance/retractboundary(), nothing more. - ph = phasecache(None, None, _load=False) + ph = self.__class__(None, None, _load=False) ph.phaseroots = self.phaseroots[:] ph.dirty = self.dirty ph.opener = self.opener