--- a/states.py Wed May 25 01:50:23 2011 +0200
+++ b/states.py Wed May 25 02:04:12 2011 +0200
@@ -78,11 +78,11 @@
else:
return 'heads'
-STDRAFT = state('draft', _NOSHARE | _MUTABLE)
-STREADY = state('ready', _MUTABLE, next=STDRAFT)
-STPUBLISHED = state('published', next=STREADY)
+ST2 = state('draft', _NOSHARE | _MUTABLE)
+ST1 = state('ready', _MUTABLE, next=ST2)
+ST0 = state('published', next=ST1)
-STATES = (STPUBLISHED, STREADY, STDRAFT)
+STATES = (ST0, ST1, ST2)
# util function
#############################
@@ -116,8 +116,7 @@
#############################
def cmdsetstate(ui, repo, statename, *changesets):
- """turn private changesets into public ones"""
- #assert repo.ui.configbool('private', 'enable', False)
+ """change changeset state"""
for state in STATES: # few states
if state.name == statename:
break
@@ -154,7 +153,7 @@
# Write protocols
####################
def heads(repo, proto):
- h = repo._publicheads
+ h = repo._readyheads
return wireproto.encodelist(h) + "\n"
def _reducehead(wirerepo, heads):
@@ -174,26 +173,27 @@
def nodestate(self, node):
rev = self.changelog.rev(node)
- for head in self._publicheads:
+ for head in self._readyheads:
revhead = self.changelog.rev(head)
if self.changelog.descendant(revhead, rev):
return STATES[2]
- for head in self._frozenheads:
+ for head in self._publishedheads:
revhead = self.changelog.rev(head)
if self.changelog.descendant(revhead, rev):
return STATES[1]
return STATES[0]
+
@property
- def _publicheads(self):
- if self.ui.configbool('states', 'private', False):
- return self._statesheads[STREADY]
+ def _readyheads(self):
+ if self.ui.configbool('states', ST1.next.name, False):
+ return self._statesheads[ST1]
return self.heads()
@property
- def _frozenheads(self):
- if self.ui.configbool('states', 'liquid', False):
- return self._statesheads[STPUBLISHED]
+ def _publishedheads(self):
+ if self.ui.configbool('states', ST0.next.name, False):
+ return self._statesheads[ST0]
return self.heads()
@util.propertycache
@@ -214,8 +214,10 @@
return heads
def _readstatesheads(self):
statesheads = {}
- statesheads[STPUBLISHED] = self._readheadsfile('frozenheads')
- statesheads[STREADY] = self._readheadsfile('publicheads')
+ for state in STATES:
+ if state.trackheads:
+ filename = 'states/%s-heads' % state.name
+ statesheads[state] = self._readheadsfile(filename)
return statesheads
def _writeheadsfile(self, filename, heads):
@@ -229,8 +231,10 @@
def _writestateshead(self):
# transaction!
- self._writeheadsfile('frozenheads', self._statesheads[STPUBLISHED])
- self._writeheadsfile('publicheads', self._statesheads[STREADY])
+ for state in STATES:
+ if state.trackheads:
+ filename = 'states/%s-heads' % state.name
+ self._writeheadsfile(filename, self._statesheads[state])
def setstate(self, state, nodes):
"""freeze targets changeset and it's ancestors.
@@ -254,7 +258,7 @@
for candidate in candidates:
rev = self.changelog.rev(candidate)
ok = True
- for h in self._publicheads:
+ for h in self._readyheads:
revh = self.changelog.rev(h)
if self.changelog.descendant(revh, rev):
ok = False
@@ -264,7 +268,7 @@
return sorted(selected)
def cancopy(self):
- return o_cancopy() and (self._publicheads == self.heads())
+ return o_cancopy() and (self._readyheads == self.heads())
repo.__class__ = statefulrepo