changeset 30:ddf24d7eb625

'walkhg' accepts (0|no|false|1|yes|true) as boolean values
author Robin Farine <robin.farine@terminus.org>
date Sun, 17 Dec 2006 12:17:24 +0100
parents 422907bd754f
children bfb2a805b490
files forest.py test-forest
diffstat 2 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/forest.py	Sat Dec 09 13:33:30 2006 +0100
+++ b/forest.py	Sun Dec 17 12:17:24 2006 +0100
@@ -29,11 +29,12 @@
 This extension recognizes the following item in the forest
 configuration section:
 
-walkhg = (0|1)
+walkhg = (0|no|false|1|yes|true)
 
-  Whether repositories under a .hg directory should be skipped (0) or
-  not (1). The default value is 0. Some commands accept the --walkhg
-  command-line option to override the behavior selected by this item.
+  Whether repositories under a .hg directory should be skipped
+  (0|no|false) or not (1|yes|true). The default value is 0. Some
+  commands accept the --walkhg command-line option to override the
+  behavior selected by this item.
 """
 
 import ConfigParser
@@ -60,8 +61,13 @@
     """Generate a lexicographically sorted list of repository roots."""
 
     walkhg = opts['walkhg']
-    if walkhg == 2:
-        walkhg = ui.configbool('forest', 'walkhg', 0)
+    if walkhg == '':
+        walkhg = ui.config('forest', 'walkhg', 'false')
+    try:
+        walkhg = { '0' : False, 'false' : False, 'no' : False,
+                   '1' : True, 'true' : True, 'yes' : True }[walkhg.lower()]
+    except KeyError:
+        raise util.Abort(_("invalid value for 'walkhg': %s" % walkhg))
     dirs = ['.']
     while dirs:
         root = dirs.pop()
@@ -364,8 +370,9 @@
 
 def uisetup(ui):
     global cmdtable
-    walkhgopt = ('', 'walkhg', 2,
-                 _("whether to walk (1) repositories under '.hg' or not (0)"))
+    walkhgopt = ('', 'walkhg', '',
+                 _("whether to walk (1|yes|true) repositories under '.hg' or "
+                   "not (0|no|false)"))
     cmdtable = {
         "fclone" :
             (clone,
--- a/test-forest	Sat Dec 09 13:33:30 2006 +0100
+++ b/test-forest	Sun Dec 17 12:17:24 2006 +0100
@@ -99,6 +99,6 @@
 hg ftrees --cwd walkhg
 hg ftrees --cwd walkhg --walkhg=1
 echo "[forest]" >> walkhg/.hg/hgrc
-echo "walkhg = 1" >> walkhg/.hg/hgrc
+echo "walkhg = Yes" >> walkhg/.hg/hgrc
 hg ftrees --cwd walkhg
-hg ftrees --cwd walkhg --walkhg=0
+hg ftrees --cwd walkhg --walkhg=FALSE