--- a/src/mercurialserver/paths.py Fri Oct 30 16:55:07 2009 +0000
+++ b/src/mercurialserver/paths.py Mon Nov 09 12:15:09 2009 +0000
@@ -1,10 +1,43 @@
# Copyright 2008-2009 LShift Ltd
-# Crude but it will do
-
import sys
import os.path
+import mercurial.config
+globalconfig = None
+
+def _getConf():
+ global globalconfig
+ if globalconfig is None:
+ globalconfig = mercurial.config.config()
+ globalconfig.read(os.path.expanduser("~/.mercurial-server"))
+ return globalconfig
+
+def configExists():
+ try:
+ _getConf()
+ return True
+ except:
+ return False
+
+def _getPath(name):
+ return os.path.expanduser(_getConf()["paths"][name])
+
+def _getPaths(name):
+ return [os.path.expanduser(p)
+ for p in _getConf()["paths"][name].split(":")]
+
+
+def getExePath(): return _getPath("exe")
+def getReposPath(): return _getPath("repos")
+
+def getKeysPaths(): return _getPaths("keys")
+def getAccessPaths(): return _getPaths("access")
+
+# This goes into an env var, so pass it on verbatim.
+def getHgrcPaths(): return _getConf()["paths"]["hgrc"]
+
+# Work out where we are, don't use config.
def setExePath():
global _exePath
_exePath = os.path.dirname(os.path.abspath(sys.argv[0]))
@@ -12,5 +45,3 @@
def getExePath():
return _exePath
-def getEtcPath():
- return "/etc/mercurial-server"