add a states command
The command list enabled state and allow to enable, disable state.
test have been update to use it.
--- a/states.py Fri Jul 01 17:03:49 2011 +0200
+++ b/states.py Fri Jul 01 17:20:45 2011 +0200
@@ -119,7 +119,30 @@
# New commands
#############################
-cmdtable = {}
+
+def cmdstates(ui, repo, *states, **opt):
+ """show enabled states"""
+ if not states:
+ for st in sorted(repo._enabledstates):
+ ui.write('%s\n' % st)
+ else:
+ off = opt.get('off', False)
+ for state_name in states:
+ for st in STATES:
+ if st.name == state_name:
+ break
+ else:
+ ui.write_err(_('no state named %s\n') % state_name)
+ return 1
+ if off and st in repo._enabledstates:
+ repo._enabledstates.remove(st)
+ else:
+ repo._enabledstates.add(st)
+ repo._writeenabledstates()
+ return 0
+
+cmdtable = {'states': (cmdstates, [ ('', 'off', False, _('desactivate the state') )], '<state>')}
+#cmdtable = {'states': (cmdstates, [], '<state>')}
def makecmd(state):
def cmdmoveheads(ui, repo, *changesets):
--- a/tests/test-draft.t Fri Jul 01 17:03:49 2011 +0200
+++ b/tests/test-draft.t Fri Jul 01 17:20:45 2011 +0200
@@ -42,7 +42,7 @@
0:5caa672bac26: published
turn draft on (repo side)
- $ echo draft > .hg/states/Enabled
+ $ hg states draft
$ hg log --template='{rev}:{node|short}: {state}\n'
3:73585b17392a: draft
2:3c8695235a32: draft
@@ -74,7 +74,7 @@
added 2 changesets with 2 changes to 1 files
turn draft off again (repo side)
- $ sed -i 's/draft//' .hg/states/Enabled
+ $ hg states --off draft
$ hg log --template='{rev}:{node|short}: {state}\n'
3:73585b17392a: published
2:3c8695235a32: published
@@ -87,7 +87,7 @@
3:73585b17392a
turn draft on again (repo side)
- $ echo draft > .hg/states/Enabled
+ $ hg states draft
test incoming and pull
@@ -163,7 +163,7 @@
turn draft off again (repo side)
$ cd ..
$ "$TESTDIR/killdaemons.py"
- $ sed -i 's/draft//' ./local/.hg/states/Enabled
+ $ hg -R local states --off draft
$ hg -R local serve -p $HGPORT -d --pid-file=local.pid
$ cat local.pid >> "$DAEMON_PIDS"
$ cd fromhttp2
@@ -185,7 +185,7 @@
$ "$TESTDIR/killdaemons.py"
turn draft on again (repo side)
- $ echo draft > ./local/.hg/states/Enabled
+ $ hg -R local states draft
$ hg init httpto
$ hg -R httpto serve -p $HGPORT -d --pid-file=remote.pid
$ cat remote.pid >> "$DAEMON_PIDS"
--- a/tests/test-ready.t Fri Jul 01 17:03:49 2011 +0200
+++ b/tests/test-ready.t Fri Jul 01 17:20:45 2011 +0200
@@ -14,8 +14,7 @@
$ hg init alpha
$ cd alpha
- $ mkdir .hg/states
- $ echo ready > .hg/states/Enabled
+ $ hg states ready
$ mkcommit z
$ mkcommit a
$ mkcommit b
@@ -69,8 +68,7 @@
$ cd ..
$ hg init beta
$ cd beta
- $ mkdir .hg/states
- $ echo ready > .hg/states/Enabled
+ $ hg states ready
$ hg pull ../alpha --update
pulling from ../alpha
requesting all changes
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-states.t Fri Jul 01 17:20:45 2011 +0200
@@ -0,0 +1,31 @@
+
+ $ cat >> $HGRCPATH <<EOF
+ > [web]
+ > push_ssl = false
+ > allow_push = *
+ > [extensions]
+ > EOF
+ $ echo "states=$(echo $(dirname $TESTDIR))/states.py" >> $HGRCPATH
+
+ $ hg init local
+ $ hg init other
+ $ cd local
+ $ hg states --traceback -v
+ $ hg states draft
+ $ hg states
+ draft
+ $ hg states ready
+ $ hg states
+ ready
+ draft
+ $ hg states --off draft
+ $ hg states
+ ready
+ $ hg states babar
+ no state named babar
+ [1]
+ $ echo 'babar' >> .hg/states/Enabled
+ $ hg states
+ ready
+ $ hg -R ../other states
+