Rename paths.py ot config.py
authorPaul Crowley <paul@lshift.net>
Fri, 13 Nov 2009 12:26:08 +0000
changeset 211 0cd59649772c
parent 208 31e862df1884
child 212 ab5e0e4f5a0c
Rename paths.py ot config.py
src/hg-ssh
src/mercurialserver/config.py
src/mercurialserver/paths.py
src/mercurialserver/refreshauth.py
src/refresh-auth
--- a/src/hg-ssh	Thu Nov 12 11:19:36 2009 +0000
+++ b/src/hg-ssh	Fri Nov 13 12:26:08 2009 +0000
@@ -35,7 +35,7 @@
 
 import sys, os, os.path
 import base64
-from mercurialserver import ruleset, paths
+from mercurialserver import config, ruleset
 
 def fail(message):
     sys.stderr.write("mercurial-server: %s\n" % message)
@@ -71,7 +71,7 @@
     checkParents(repo)
     return repo
 
-paths.setExePath()
+config.setExePath()
 
 if len(sys.argv) == 3 and sys.argv[1] == "--base64":
     ruleset.rules.set(user = base64.b64decode(sys.argv[2]))
@@ -84,11 +84,11 @@
 # Use a different hgrc for remote pulls - this way you can set
 # up access.py for everything at once without affecting local operations
 
-os.environ['HGRCPATH'] = paths.getHgrcPaths()
+os.environ['HGRCPATH'] = config.getHgrcPaths()
 
-os.chdir(paths.getReposPath())
+os.chdir(config.getReposPath())
 
-for f in paths.getAccessPaths():
+for f in config.getAccessPaths():
     if os.path.isfile(f):
         ruleset.rules.readfile(f)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mercurialserver/config.py	Fri Nov 13 12:26:08 2009 +0000
@@ -0,0 +1,47 @@
+# Copyright 2008-2009 LShift Ltd
+
+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]))
+
+def getExePath():
+    return _exePath
+
--- a/src/mercurialserver/paths.py	Thu Nov 12 11:19:36 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-# Copyright 2008-2009 LShift Ltd
-
-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]))
-
-def getExePath():
-    return _exePath
-
--- a/src/mercurialserver/refreshauth.py	Thu Nov 12 11:19:36 2009 +0000
+++ b/src/mercurialserver/refreshauth.py	Fri Nov 13 12:26:08 2009 +0000
@@ -10,13 +10,13 @@
 import os
 import os.path
 import subprocess
-from mercurialserver import paths
+from mercurialserver import config
 
 goodkey = re.compile("[/A-Za-z0-9._-]+$")
 
 def refreshAuth():
     akeyfile = os.path.expanduser("~/.ssh/authorized_keys")
-    wrappercommand = paths.getExePath() + "/hg-ssh"
+    wrappercommand = config.getExePath() + "/hg-ssh"
     prefix='no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command='
 
     if os.path.exists(akeyfile):
@@ -29,7 +29,7 @@
             f.close()
 
     akeys = open(akeyfile + "_new", "w")
-    for keyroot in paths.getKeysPaths():
+    for keyroot in config.getKeysPaths():
         kr = keyroot + "/"
         #print "Processing keyroot", keyroot
         for root, dirs, files in os.walk(keyroot):
--- a/src/refresh-auth	Thu Nov 12 11:19:36 2009 +0000
+++ b/src/refresh-auth	Fri Nov 13 12:26:08 2009 +0000
@@ -8,7 +8,7 @@
 
 import sys
 import os
-from mercurialserver import refreshauth, paths
+from mercurialserver import refreshauth, config
 
 if len(sys.argv) != 1:
     sys.stderr.write("refresh-auth: must be called with no arguments (%s)\n" % sys.argv)
@@ -16,9 +16,9 @@
 
 # To protect the authorized_keys file for innocent users, you have to have
 # a ~/.mercurial-server file to run this.
-if not paths.configExists():
+if not config.configExists():
     print >>sys.stderr, "Must be run as the 'hg' user"
     sys.exit(-1)
 
-paths.setExePath()
+config.setExePath()
 refreshauth.refreshAuth()