Use ConfigParser istead of mercurial.config
authorPaul Crowley <paul@lshift.net>
Fri, 13 Nov 2009 14:42:46 +0000
changeset 215 584df0f2e5c7
parent 214 7374d0147875
child 216 0122df83ebd0
Use ConfigParser istead of mercurial.config
src/hg-ssh
src/mercurialserver/config.py
--- a/src/hg-ssh	Fri Nov 13 14:33:52 2009 +0000
+++ b/src/hg-ssh	Fri Nov 13 14:42:46 2009 +0000
@@ -77,7 +77,7 @@
     fail("hg-ssh wrongly called, is authorized_keys corrupt? (%s)" 
         % sys.argv)
 
-for k,v in config.getEnv().iteritems():
+for k,v in config.getEnv():
     os.environ[k] = v
 
 os.chdir(config.getReposPath())
--- a/src/mercurialserver/config.py	Fri Nov 13 14:33:52 2009 +0000
+++ b/src/mercurialserver/config.py	Fri Nov 13 14:42:46 2009 +0000
@@ -2,14 +2,14 @@
 
 import sys
 import os.path
-import mercurial.config
+import ConfigParser
 
 globalconfig = None
 
 def _getConf():
     global globalconfig
     if globalconfig is None:
-        globalconfig = mercurial.config.config()
+        globalconfig = ConfigParser.RawConfigParser()
         globalconfig.read(os.path.expanduser("~/.mercurial-server"))
     return globalconfig
 
@@ -21,11 +21,11 @@
         return False
 
 def _getPath(name):
-    return os.path.expanduser(_getConf()["paths"][name])
+    return os.path.expanduser(_getConf().get("paths", name))
 
 def _getPaths(name): 
     return [os.path.expanduser(p)
-        for p in _getConf()["paths"][name].split(":")]
+        for p in _getConf().get("paths", name).split(":")]
 
 def getReposPath(): return _getPath("repos")
 def getAuthorizedKeysPath(): return _getPath("authorized_keys")
@@ -33,7 +33,7 @@
 def getKeysPaths(): return _getPaths("keys")
 def getAccessPaths(): return _getPaths("access")
 
-def getEnv(): return _getConf()["env"]
+def getEnv(): return _getConf().items("env")
 
 # Work out where we are, don't use config.
 def setExePath():