[states] do not activate deactivated state with ``hg states --off <state>``
authorAlain Leufroy <alain.leufroy@logilab.fr>
Tue, 13 Sep 2011 15:35:49 +0200
changeset 90 a5f6194eb05c
parent 89 757153438e58
child 91 5b8d08c78854
[states] do not activate deactivated state with ``hg states --off <state>`` previously: $ hg init alpha $ cd alpha $ hg states --off draft $ hg states published draft now: $ hg init alpha $ cd alpha $ hg states --off draft $ hg states published
hgext/states.py
tests/test-states.t
--- a/hgext/states.py	Mon Sep 19 18:27:30 2011 +0200
+++ b/hgext/states.py	Tue Sep 13 15:35:49 2011 +0200
@@ -517,8 +517,13 @@
             else:
                 ui.write_err(_('no state named %s\n') % state_name)
                 return 1
-            if off and st in repo._enabledstates:
-                repo._enabledstates.remove(st)
+            if off:
+                if st in repo._enabledstates:
+                    repo._enabledstates.remove(st)
+                else:
+                    ui.write_err(_('state %s already deactivated\n') %
+                                 state_name)
+
             else:
                 repo._enabledstates.add(st)
         repo._writeenabledstates()
--- a/tests/test-states.t	Mon Sep 19 18:27:30 2011 +0200
+++ b/tests/test-states.t	Tue Sep 13 15:35:49 2011 +0200
@@ -35,3 +35,9 @@
   $ hg -R ../other states
   published
 
+do nothing if state already deactivated
+  $ hg states --off draft
+  state draft already deactivated
+  $ hg states
+  published
+  ready