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