diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -7,7 +7,7 @@ from node import nullid, nullrev, short, hex from i18n import _ -import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding +import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases import match as matchmod import os, errno, stat @@ -119,13 +119,13 @@ class changectx(object): return self._repo.nodebookmarks(self._node) def phase(self): if self._rev == -1: - return 0 + return phases.public if self._rev >= len(self._repo._phaserev): # outdated cache del self._repo._phaserev return self._repo._phaserev[self._rev] def mutable(self): - return self._repo._phaserev[self._rev] > 0 + return self._repo._phaserev[self._rev] > phases.public def hidden(self): return self._rev in self._repo.changelog.hiddenrevs @@ -812,7 +812,7 @@ class workingctx(changectx): return b def phase(self): - phase = 1 # default phase to draft + phase = phases.draft # default phase to draft for p in self.parents(): phase = max(phase, p.phase()) return phase diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -181,7 +181,7 @@ class localrepository(repo.repository): @propertycache def _phaserev(self): - cache = [0] * len(self) + cache = [phases.public] * len(self) for phase in phases.trackedphases: roots = map(self.changelog.rev, self._phaseroots[phase]) if roots: @@ -1253,7 +1253,8 @@ class localrepository(repo.repository): parent2=xp2, pending=p) self.changelog.finalize(trp) # set the new commit is proper phase - targetphase = self.ui.configint('phases', 'new-commit', 1) + targetphase = self.ui.configint('phases', 'new-commit', + phases.draft) if targetphase: # retract boundary do not alter parent changeset. # if a parent have higher the resulting phase will @@ -1554,7 +1555,7 @@ class localrepository(repo.repository): else: # Remote is old or publishing all common changesets # should be seen as public - phases.advanceboundary(self, 0, common + added) + phases.advanceboundary(self, phases.public, common + added) finally: lock.release() @@ -1615,14 +1616,14 @@ class localrepository(repo.repository): # even when we don't push, exchanging phase data is useful remotephases = remote.listkeys('phases') if not remotephases: # old server or public only repo - phases.advanceboundary(self, 0, fut) + phases.advanceboundary(self, phases.public, fut) # don't push any phase data as there is nothing to push else: ana = phases.analyzeremotephases(self, fut, remotephases) rheads, rroots = ana ### Apply remote phase on local if remotephases.get('publishing', False): - phases.advanceboundary(self, 0, fut) + phases.advanceboundary(self, phases.public, fut) else: # publish = False for phase, rpheads in enumerate(rheads): phases.advanceboundary(self, phase, rpheads) @@ -2057,9 +2058,9 @@ class localrepository(repo.repository): if publishing and srctype == 'push': # Old server can not push the boundary themself. # This clause ensure pushed changeset are alway marked as public - phases.advanceboundary(self, 0, added) + phases.advanceboundary(self, phases.public, added) elif srctype != 'strip': # strip should not touch boundary at all - phases.retractboundary(self, 1, added) + phases.retractboundary(self, phases.draft, added) # make changelog see real files again cl.finalize(trp) diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -102,7 +102,7 @@ import errno from node import nullid, bin, hex, short from i18n import _ -allphases = range(3) +allphases = public, draft, secret = range(3) trackedphases = allphases[1:] def readroots(repo): @@ -242,7 +242,7 @@ def pushphase(repo, nhex, oldphasestr, n def visibleheads(repo): """return the set of visible head of this repo""" # XXX we want a cache on this - sroots = repo._phaseroots[2] + sroots = repo._phaseroots[secret] if sroots: # XXX very slow revset. storing heads or secret "boundary" would help. revset = repo.set('heads(not (%ln::))', sroots)