changeset 90:a5f6194eb05c

[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
author Alain Leufroy <alain.leufroy@logilab.fr>
date Tue, 13 Sep 2011 15:35:49 +0200
parents 757153438e58
children 5b8d08c78854
files hgext/states.py tests/test-states.t
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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