[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
--- 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