changeset 12:6312fc525a54

rename state related attributes frozen is now published public is now ready
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 25 May 2011 02:04:12 +0200
parents 47ba990eff0e
children e95e8cf7988f
files states.py tests/test-draft.t tests/test-private.t
diffstat 3 files changed, 234 insertions(+), 230 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-draft.t	Wed May 25 02:04:12 2011 +0200
@@ -0,0 +1,209 @@
+  $ cat >> $HGRCPATH <<EOF
+  > [web]
+  > push_ssl = false
+  > allow_push = *
+  > [extensions]
+  > EOF
+  $ echo "states=$(echo $(dirname $TESTDIR))/states.py" >> $HGRCPATH
+
+  $ hg init local
+  $ hg init remote1
+  $ hg init remote2
+  $ cd local
+  $ echo "celestine" > babar
+  $ hg add babar
+  $ hg ci -m "add babar"
+  $ echo "la veille dame" > babar
+  $ hg ci -m "add dame"
+  $ hg log --template='{rev}:{node|short}: {state}\n'
+  1:710fe444b3b0: published
+  0:5caa672bac26: published
+  $ hg out  ../remote1 --template='{rev}:{node|short}\n'
+  comparing with ../remote1
+  searching for changes
+  0:5caa672bac26
+  1:710fe444b3b0
+  $ hg push ../remote1
+  pushing to ../remote1
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  $ hg setstate published 1 # until we fix push
+  $ echo "tree" >> savanna
+  $ hg add savanna
+  $ hg ci -m "terrain"
+  $ echo "flore" >> babar
+  $ hg ci -m "children"
+  $ hg log --template='{rev}:{node|short}: {state}\n'
+  3:73585b17392a: published
+  2:3c8695235a32: published
+  1:710fe444b3b0: published
+  0:5caa672bac26: published
+
+turn draft on (repo side)
+  $ cat > .hg/hgrc << EOF
+  > [states]
+  > draft=yes
+  > EOF
+  $ hg log --template='{rev}:{node|short}: {state}\n'
+  3:73585b17392a: draft
+  2:3c8695235a32: draft
+  1:710fe444b3b0: published
+  0:5caa672bac26: published
+
+test outgoing and push
+  $ hg out  ../remote1 --template='{rev}:{node|short}\n'
+  comparing with ../remote1
+  searching for changes
+  no changes found
+  [1]
+  $ hg push  ../remote1
+  pushing to ../remote1
+  searching for changes
+  no changes found
+
+  $ hg out  ../remote2 --template='{rev}:{node|short}\n'
+  comparing with ../remote2
+  searching for changes
+  0:5caa672bac26
+  1:710fe444b3b0
+  $ hg push  ../remote2
+  pushing to ../remote2
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+
+turn draft off again (repo side)
+  $ sed -i 's/^draft=.*$/draft=no/' .hg/hgrc
+  $ hg log --template='{rev}:{node|short}: {state}\n'
+  3:73585b17392a: published
+  2:3c8695235a32: published
+  1:710fe444b3b0: published
+  0:5caa672bac26: published
+  $ hg out  ../remote1 --template='{rev}:{node|short}\n'
+  comparing with ../remote1
+  searching for changes
+  2:3c8695235a32
+  3:73585b17392a
+
+turn draft on again (repo side)
+  $ sed -i 's/^draft=.*$/draft=yes/' .hg/hgrc
+
+test incoming and pull
+
+  $ hg init ../other1
+  $ cd ../other1
+  $ hg incoming ../local --template='{rev}:{node|short}\n'
+  comparing with ../local
+  0:5caa672bac26
+  1:710fe444b3b0
+  $ hg pull  ../local
+  pulling from ../local
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  (run 'hg update' to get a working copy)
+  $ hg log --template='{rev}:{node|short}\n'
+  1:710fe444b3b0
+  0:5caa672bac26
+  $ cd ..
+  $ hg clone local other2
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg -R other2 log --template='{rev}:{node|short}\n'
+  1:710fe444b3b0
+  0:5caa672bac26
+
+test on http
+
+  $ hg -R local serve -p $HGPORT -d --pid-file=local.pid
+  $ cat local.pid >> "$DAEMON_PIDS"
+  $ hg clone http://localhost:$HGPORT/ fromhttp
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg -R fromhttp log --template='{rev}:{node|short}\n'
+  1:710fe444b3b0
+  0:5caa672bac26
+
+  $ hg init fromhttp2
+  $ cd fromhttp2
+  $ hg inc http://localhost:$HGPORT/ --template='{rev}:{node|short}\n'
+  comparing with http://localhost:$HGPORT/
+  0:5caa672bac26
+  1:710fe444b3b0
+  $ hg pull http://localhost:$HGPORT/
+  pulling from http://localhost:$HGPORT/
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  (run 'hg update' to get a working copy)
+  $ hg log --template='{rev}:{node|short}\n'
+  1:710fe444b3b0
+  0:5caa672bac26
+  $ hg inc http://localhost:$HGPORT/ --template='{rev}:{node|short}\n'
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  [1]
+
+turn draft off again (repo side)
+  $ cd ..
+  $ "$TESTDIR/killdaemons.py"
+  $ sed -i 's/^draft=.*$/draft=off/' ./local/.hg/hgrc
+  $ hg -R local serve -p $HGPORT -d --pid-file=local.pid
+  $ cat local.pid >> "$DAEMON_PIDS"
+  $ cd fromhttp2
+
+  $ hg inc http://localhost:$HGPORT/ --template='{rev}:{node|short}\n'
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  2:3c8695235a32
+  3:73585b17392a
+  $ hg pull http://localhost:$HGPORT/
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+  (run 'hg update' to get a working copy)
+  $ cd ..
+  $ "$TESTDIR/killdaemons.py"
+
+turn draft on again (repo side)
+  $ sed -i 's/^draft=.*$/draft=on/' local/.hg/hgrc
+  $ hg init httpto
+  $ hg -R httpto serve -p $HGPORT -d --pid-file=remote.pid
+  $ cat remote.pid >> "$DAEMON_PIDS"
+  $ cd local
+  $ hg out http://localhost:$HGPORT/  --template='{rev}:{node|short}\n'
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  0:5caa672bac26
+  1:710fe444b3b0
+  $ hg push http://localhost:$HGPORT/
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 2 changesets with 2 changes to 1 files
+  $ "$TESTDIR/killdaemons.py"
--- a/tests/test-private.t	Wed May 25 01:50:23 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-  $ cat >> $HGRCPATH <<EOF
-  > [web]
-  > push_ssl = false
-  > allow_push = *
-  > [extensions]
-  > EOF
-  $ echo "states=$(echo $(dirname $TESTDIR))/states.py" >> $HGRCPATH
-
-  $ hg init local
-  $ hg init remote1
-  $ hg init remote2
-  $ cd local
-  $ echo "celestine" > babar
-  $ hg add babar
-  $ hg ci -m "add babar"
-  $ echo "la veille dame" > babar
-  $ hg ci -m "add dame"
-  $ hg log --template='{rev}:{node|short}: {state}\n'
-  1:710fe444b3b0: published
-  0:5caa672bac26: published
-  $ hg out  ../remote1 --template='{rev}:{node|short}\n'
-  comparing with ../remote1
-  searching for changes
-  0:5caa672bac26
-  1:710fe444b3b0
-  $ hg push ../remote1
-  pushing to ../remote1
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 1 files
-  $ hg setstate published 1 # until we fix push
-  $ echo "tree" >> savanna
-  $ hg add savanna
-  $ hg ci -m "terrain"
-  $ echo "flore" >> babar
-  $ hg ci -m "children"
-  $ hg log --template='{rev}:{node|short}: {state}\n'
-  3:73585b17392a: published
-  2:3c8695235a32: published
-  1:710fe444b3b0: published
-  0:5caa672bac26: published
-
-turn private on (repo side)
-  $ cat > .hg/hgrc << EOF
-  > [states]
-  > private=yes
-  > EOF
-  $ hg log --template='{rev}:{node|short}: {state}\n'
-  3:73585b17392a: draft
-  2:3c8695235a32: draft
-  1:710fe444b3b0: published
-  0:5caa672bac26: published
-
-test outgoing and push
-  $ hg out  ../remote1 --template='{rev}:{node|short}\n'
-  comparing with ../remote1
-  searching for changes
-  no changes found
-  [1]
-  $ hg push  ../remote1
-  pushing to ../remote1
-  searching for changes
-  no changes found
-
-  $ hg out  ../remote2 --template='{rev}:{node|short}\n'
-  comparing with ../remote2
-  searching for changes
-  0:5caa672bac26
-  1:710fe444b3b0
-  $ hg push  ../remote2
-  pushing to ../remote2
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 1 files
-
-turn private off again (repo side)
-  $ sed -i 's/^private=.*$/private=no/' .hg/hgrc
-  $ hg log --template='{rev}:{node|short}: {state}\n'
-  3:73585b17392a: published
-  2:3c8695235a32: published
-  1:710fe444b3b0: published
-  0:5caa672bac26: published
-  $ hg out  ../remote1 --template='{rev}:{node|short}\n'
-  comparing with ../remote1
-  searching for changes
-  2:3c8695235a32
-  3:73585b17392a
-
-turn private on again (repo side)
-  $ sed -i 's/^private=.*$/private=yes/' .hg/hgrc
-
-test incoming and pull
-
-  $ hg init ../other1
-  $ cd ../other1
-  $ hg incoming ../local --template='{rev}:{node|short}\n'
-  comparing with ../local
-  0:5caa672bac26
-  1:710fe444b3b0
-  $ hg pull  ../local
-  pulling from ../local
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 1 files
-  (run 'hg update' to get a working copy)
-  $ hg log --template='{rev}:{node|short}\n'
-  1:710fe444b3b0
-  0:5caa672bac26
-  $ cd ..
-  $ hg clone local other2
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 1 files
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg -R other2 log --template='{rev}:{node|short}\n'
-  1:710fe444b3b0
-  0:5caa672bac26
-
-test on http
-
-  $ hg -R local serve -p $HGPORT -d --pid-file=local.pid
-  $ cat local.pid >> "$DAEMON_PIDS"
-  $ hg clone http://localhost:$HGPORT/ fromhttp
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 1 files
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg -R fromhttp log --template='{rev}:{node|short}\n'
-  1:710fe444b3b0
-  0:5caa672bac26
-
-  $ hg init fromhttp2
-  $ cd fromhttp2
-  $ hg inc http://localhost:$HGPORT/ --template='{rev}:{node|short}\n'
-  comparing with http://localhost:$HGPORT/
-  0:5caa672bac26
-  1:710fe444b3b0
-  $ hg pull http://localhost:$HGPORT/
-  pulling from http://localhost:$HGPORT/
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 1 files
-  (run 'hg update' to get a working copy)
-  $ hg log --template='{rev}:{node|short}\n'
-  1:710fe444b3b0
-  0:5caa672bac26
-  $ hg inc http://localhost:$HGPORT/ --template='{rev}:{node|short}\n'
-  comparing with http://localhost:$HGPORT/
-  searching for changes
-  no changes found
-  [1]
-
-turn private off again (repo side)
-  $ cd ..
-  $ "$TESTDIR/killdaemons.py"
-  $ sed -i 's/^private=.*$/private=off/' ./local/.hg/hgrc
-  $ hg -R local serve -p $HGPORT -d --pid-file=local.pid
-  $ cat local.pid >> "$DAEMON_PIDS"
-  $ cd fromhttp2
-
-  $ hg inc http://localhost:$HGPORT/ --template='{rev}:{node|short}\n'
-  comparing with http://localhost:$HGPORT/
-  searching for changes
-  2:3c8695235a32
-  3:73585b17392a
-  $ hg pull http://localhost:$HGPORT/
-  pulling from http://localhost:$HGPORT/
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 2 files
-  (run 'hg update' to get a working copy)
-  $ cd ..
-  $ "$TESTDIR/killdaemons.py"
-
-turn private on again (repo side)
-  $ sed -i 's/^private=.*$/private=on/' local/.hg/hgrc
-  $ hg init httpto
-  $ hg -R httpto serve -p $HGPORT -d --pid-file=remote.pid
-  $ cat remote.pid >> "$DAEMON_PIDS"
-  $ cd local
-  $ hg out http://localhost:$HGPORT/  --template='{rev}:{node|short}\n'
-  comparing with http://localhost:$HGPORT/
-  searching for changes
-  0:5caa672bac26
-  1:710fe444b3b0
-  $ hg push http://localhost:$HGPORT/
-  pushing to http://localhost:$HGPORT/
-  searching for changes
-  remote: adding changesets
-  remote: adding manifests
-  remote: adding file changes
-  remote: added 2 changesets with 2 changes to 1 files
-  $ "$TESTDIR/killdaemons.py"