Mercurial > hg-stable
changeset 16625:df9df747070d
phases: stop modifying localrepo in readroots()
phasedefaults is also passed explicitely to help the casual reader
understand where it is used without grepping all the sources.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Thu, 10 May 2012 18:52:04 +0200 |
parents | 3f85cef66dcc |
children | 503e674fb545 |
files | mercurial/localrepo.py mercurial/phases.py |
diffstat | 2 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu May 10 18:21:15 2012 +0200 +++ b/mercurial/localrepo.py Thu May 10 18:52:04 2012 +0200 @@ -183,8 +183,8 @@ @storecache('phaseroots') def _phaseroots(self): - self._dirtyphases = False - phaseroots = phases.readroots(self) + phaseroots, self._dirtyphases = phases.readroots( + self, self._phasedefaults) return phaseroots @propertycache
--- a/mercurial/phases.py Thu May 10 18:21:15 2012 +0200 +++ b/mercurial/phases.py Thu May 10 18:52:04 2012 +0200 @@ -124,8 +124,18 @@ updated = True return updated -def readroots(repo): - """Read phase roots from disk""" +def readroots(repo, phasedefaults=None): + """Read phase roots from disk + + phasedefaults is a list of fn(repo, roots) callable, which are + executed if the phase roots file does not exist. When phases are + being initialized on an existing repository, this could be used to + set selected changesets phase to something else than public. + + Return (roots, dirty) where dirty is true if roots differ from + what is being stored. + """ + dirty = False roots = [set() for i in allphases] try: f = repo.sopener('phaseroots') @@ -138,12 +148,13 @@ except IOError, inst: if inst.errno != errno.ENOENT: raise - for f in repo._phasedefaults: - roots = f(repo, roots) - repo._dirtyphases = True + if phasedefaults: + for f in phasedefaults: + roots = f(repo, roots) + dirty = True if _filterunknown(repo.ui, repo.changelog, roots): - repo._dirtyphases = True - return roots + dirty = True + return roots, dirty def writeroots(repo): """Write phase roots from disk"""