Mercurial > hg
diff mercurial/bundlerepo.py @ 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 | 510cafe72004 |
children | e7fcf58acd71 |
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()