Commits

Pierre-Yves David  committed c9da156

add a states command

The command list enabled state and allow to enable, disable state.

test have been update to use it.

  • Participants
  • Parent commits b372166
  • Branches default

Comments (0)

Files changed (4)

 # 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):

File tests/test-draft.t

   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
   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
   3:73585b17392a
 
 turn draft on again (repo side)
-  $ echo draft > .hg/states/Enabled
+  $ hg states draft
 
 test incoming and pull
 
 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
   $ "$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"

File tests/test-ready.t

 
   $ hg init alpha
   $ cd alpha
-  $ mkdir .hg/states
-  $ echo ready > .hg/states/Enabled
+  $ hg states ready
   $ mkcommit z
   $ mkcommit a
   $ mkcommit b
   $ 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

File tests/test-states.t

+
+  $ 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
+