Mercurial > hg
changeset 23631:b8260abfeb7d
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.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Thu, 18 Dec 2014 11:38:48 -0800 |
parents | b9af235810cc |
children | e7fcf58acd71 |
files | mercurial/bundlerepo.py mercurial/phases.py |
diffstat | 2 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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