Mercurial > public > mercurial-scm > hg-stable
diff mercurial/phases.py @ 39326:7775c1fb8fa0
phases: enforce internal phase support
We should not use the internal phase for repository without the requirement.
Otherwise, older clients could have a look at the repository and see the
internal changesets.
For now, we introduce a low-level Programming error, more UI friendly error
will be introduced later.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 29 May 2018 18:13:19 +0200 |
parents | 06c976acc581 |
children | 49c7b701fdc2 |
line wrap: on
line diff
--- a/mercurial/phases.py Thu May 24 09:59:10 2018 +0200 +++ b/mercurial/phases.py Tue May 29 18:13:19 2018 +0200 @@ -140,6 +140,10 @@ remotehiddenphases = tuple(allphases[2:]) localhiddenphases = tuple(p for p in allphases if p & HIDEABLE_FLAG) +def supportinternal(repo): + """True if the internal phase can be used on a repository""" + return 'internal-phase' in repo.requirements + def _readroots(repo, phasedefaults=None): """Read phase roots from disk @@ -442,6 +446,9 @@ def _retractboundary(self, repo, tr, targetphase, nodes): # Be careful to preserve shallow-copied values: do not update # phaseroots values, replace them. + if targetphase == internal and not supportinternal(repo): + msg = 'this repository does not support the internal phase' + raise error.ProgrammingError(msg) repo = repo.unfiltered() currentroots = self.phaseroots[targetphase]