##// END OF EJS Templates
phases: store phase values in constant instead of using raw integer...
Pierre-Yves David -
r15818:57241845 default
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7 7
8 8 from node import nullid, nullrev, short, hex
9 9 from i18n import _
10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding
10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
11 11 import match as matchmod
12 12 import os, errno, stat
13 13
@@ -119,13 +119,13 b' class changectx(object):'
119 119 return self._repo.nodebookmarks(self._node)
120 120 def phase(self):
121 121 if self._rev == -1:
122 return 0
122 return phases.public
123 123 if self._rev >= len(self._repo._phaserev):
124 124 # outdated cache
125 125 del self._repo._phaserev
126 126 return self._repo._phaserev[self._rev]
127 127 def mutable(self):
128 return self._repo._phaserev[self._rev] > 0
128 return self._repo._phaserev[self._rev] > phases.public
129 129 def hidden(self):
130 130 return self._rev in self._repo.changelog.hiddenrevs
131 131
@@ -812,7 +812,7 b' class workingctx(changectx):'
812 812 return b
813 813
814 814 def phase(self):
815 phase = 1 # default phase to draft
815 phase = phases.draft # default phase to draft
816 816 for p in self.parents():
817 817 phase = max(phase, p.phase())
818 818 return phase
@@ -181,7 +181,7 b' class localrepository(repo.repository):'
181 181
182 182 @propertycache
183 183 def _phaserev(self):
184 cache = [0] * len(self)
184 cache = [phases.public] * len(self)
185 185 for phase in phases.trackedphases:
186 186 roots = map(self.changelog.rev, self._phaseroots[phase])
187 187 if roots:
@@ -1253,7 +1253,8 b' class localrepository(repo.repository):'
1253 1253 parent2=xp2, pending=p)
1254 1254 self.changelog.finalize(trp)
1255 1255 # set the new commit is proper phase
1256 targetphase = self.ui.configint('phases', 'new-commit', 1)
1256 targetphase = self.ui.configint('phases', 'new-commit',
1257 phases.draft)
1257 1258 if targetphase:
1258 1259 # retract boundary do not alter parent changeset.
1259 1260 # if a parent have higher the resulting phase will
@@ -1554,7 +1555,7 b' class localrepository(repo.repository):'
1554 1555 else:
1555 1556 # Remote is old or publishing all common changesets
1556 1557 # should be seen as public
1557 phases.advanceboundary(self, 0, common + added)
1558 phases.advanceboundary(self, phases.public, common + added)
1558 1559 finally:
1559 1560 lock.release()
1560 1561
@@ -1615,14 +1616,14 b' class localrepository(repo.repository):'
1615 1616 # even when we don't push, exchanging phase data is useful
1616 1617 remotephases = remote.listkeys('phases')
1617 1618 if not remotephases: # old server or public only repo
1618 phases.advanceboundary(self, 0, fut)
1619 phases.advanceboundary(self, phases.public, fut)
1619 1620 # don't push any phase data as there is nothing to push
1620 1621 else:
1621 1622 ana = phases.analyzeremotephases(self, fut, remotephases)
1622 1623 rheads, rroots = ana
1623 1624 ### Apply remote phase on local
1624 1625 if remotephases.get('publishing', False):
1625 phases.advanceboundary(self, 0, fut)
1626 phases.advanceboundary(self, phases.public, fut)
1626 1627 else: # publish = False
1627 1628 for phase, rpheads in enumerate(rheads):
1628 1629 phases.advanceboundary(self, phase, rpheads)
@@ -2057,9 +2058,9 b' class localrepository(repo.repository):'
2057 2058 if publishing and srctype == 'push':
2058 2059 # Old server can not push the boundary themself.
2059 2060 # This clause ensure pushed changeset are alway marked as public
2060 phases.advanceboundary(self, 0, added)
2061 phases.advanceboundary(self, phases.public, added)
2061 2062 elif srctype != 'strip': # strip should not touch boundary at all
2062 phases.retractboundary(self, 1, added)
2063 phases.retractboundary(self, phases.draft, added)
2063 2064
2064 2065 # make changelog see real files again
2065 2066 cl.finalize(trp)
@@ -102,7 +102,7 b' import errno'
102 102 from node import nullid, bin, hex, short
103 103 from i18n import _
104 104
105 allphases = range(3)
105 allphases = public, draft, secret = range(3)
106 106 trackedphases = allphases[1:]
107 107
108 108 def readroots(repo):
@@ -242,7 +242,7 b' def pushphase(repo, nhex, oldphasestr, n'
242 242 def visibleheads(repo):
243 243 """return the set of visible head of this repo"""
244 244 # XXX we want a cache on this
245 sroots = repo._phaseroots[2]
245 sroots = repo._phaseroots[secret]
246 246 if sroots:
247 247 # XXX very slow revset. storing heads or secret "boundary" would help.
248 248 revset = repo.set('heads(not (%ln::))', sroots)
General Comments 0
You need to be logged in to leave comments. Login now