[PATCH 4 of 5] phases: stop modifying localrepo in readroots()
Patrick Mezard
patrick at mezard.eu
Thu May 10 12:05:15 CDT 2012
# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1336668724 -7200
# Node ID c2ac2df839ad1eac79c152fa58c2fb2bd3f4f9c5
# Parent 9321e1adec84760ea47e2eaf841460744a9c2ca3
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.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -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"""
More information about the Mercurial-devel
mailing list