changeset 960:abfb5cc97fcd

Add ui.setconfig overlay This can simplify option passing
author mpm@selenic.com
date Fri, 19 Aug 2005 21:25:25 -0800
parents 0aaeee519c66
children 3e11d5038649
files mercurial/ui.py
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Fri Aug 19 18:56:20 2005 -0800
+++ b/mercurial/ui.py	Fri Aug 19 21:25:25 2005 -0800
@@ -12,6 +12,7 @@
 class ui:
     def __init__(self, verbose=False, debug=False, quiet=False,
                  interactive=True):
+        self.overlay = {}
         self.cdata = ConfigParser.SafeConfigParser()
         self.cdata.read([os.path.normpath(hgrc) for hgrc in
                          "/etc/mercurial/hgrc", os.path.expanduser("~/.hgrc")])
@@ -29,14 +30,21 @@
     def readconfig(self, fp):
         self.cdata.readfp(fp)
 
-    def config(self, section, val, default=None):
-        if self.cdata.has_option(section, val):
-            return self.cdata.get(section, val)
+    def setconfig(self, section, name, val):
+        self.overlay[(section, name)] = val
+
+    def config(self, section, name, default=None):
+        if self.overlay.has_key((section, name)):
+            return self.overlay[(section, name)]
+        if self.cdata.has_option(section, name):
+            return self.cdata.get(section, name)
         return default
 
-    def configbool(self, section, val, default=False):
-        if self.cdata.has_option(section, val):
-            return self.cdata.getboolean(section, val)
+    def configbool(self, section, name, default=False):
+        if self.overlay.has_key((section, name)):
+            return self.overlay[(section, name)]
+        if self.cdata.has_option(section, name):
+            return self.cdata.getboolean(section, name)
         return default
 
     def configitems(self, section):