Added invalid-value checking to becommands/set.py.
authorW. Trevor King <wking@drexel.edu>
Tue, 25 Nov 2008 01:55:24 +0000 (20:55 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 25 Nov 2008 01:55:24 +0000 (20:55 -0500)
Kindof a cludgy check, but there's currently no simpler way to find
valid entries for a given setting name (that I can think of).

becommands/set.py

index 287ceb4cef34a3c6df3f12627a7cffbdc08395e1..0085f0fc11bd0ab2903882e7523cedf8b2f391dc 100644 (file)
@@ -46,7 +46,17 @@ def execute(args):
         print bd.settings.get(args[0])
     else:
         if args[1] != "none":
+            old_setting = bd.settings[args[0]]
             bd.settings[args[0]] = args[1]
+            
+            # attempt to get the new value
+            bd.save()
+            try:
+                bd.load()
+            except bugdir.InvalidValue, e:
+                bd.settings[args[0]] = old_setting
+                bd.save()
+                raise cmdutil.UserError(e)
         else:
             del bd.settings[args[0]]
         bd.save()