--- a/doc/PLAN Fri Mar 06 13:26:35 2009 +0000
+++ b/doc/PLAN Fri Mar 06 13:30:37 2009 +0000
@@ -9,10 +9,10 @@
- move most of do-refresh-auth into a module
- give that module a hook, and call the hook instead of the exe
- abolish refresh-auth shell script and rename do-refresh-auth to refresh-auth
+- replace env vars with Python globals
Todo:
-- replace env vars with Python globals
- change refresh-auth to refer to hg-ssh directly, abolish hg-ssh-wrapper
- add comment check and -f flag to refresh-auth
- change install script to a Python script, abolishing hginit
--- a/src/hg-ssh Fri Mar 06 13:26:35 2009 +0000
+++ b/src/hg-ssh Fri Mar 06 13:30:37 2009 +0000
@@ -70,8 +70,7 @@
fail("hg-ssh must have exactly one argument (%s)"
% sys.argv)
-remote_user = sys.argv[1]
-os.environ['REMOTE_USER'] = remote_user
+ruleset.rules.set(user = sys.argv[1])
# Use a different hgrc for remote pulls - this way you can set
# up access.py for everything at once without affecting local operations
@@ -86,5 +85,4 @@
if os.path.isfile(f):
ruleset.rules.readfile(f)
-ruleset.rules.set(user = getpath(remote_user))
try_cmd(os.environ.get('SSH_ORIGINAL_COMMAND', '?'))
--- a/src/mercurialserver/ruleset.py Fri Mar 06 13:26:35 2009 +0000
+++ b/src/mercurialserver/ruleset.py Fri Mar 06 13:30:37 2009 +0000
@@ -61,6 +61,9 @@
def set(self, **kw):
self.preset.update(kw)
+ def get(self, k):
+ return self.preset.get(k, None)
+
def matchrule(self, kw):
d = self.preset.copy()
d.update(kw)
--- a/src/mercurialserver/servelog.py Fri Mar 06 13:26:35 2009 +0000
+++ b/src/mercurialserver/servelog.py Fri Mar 06 13:30:37 2009 +0000
@@ -12,8 +12,8 @@
import os
import time
-from mercurialserver import changes
-
+from mercurialserver import ruleset, changes
+
def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
if hooktype == 'changegroup':
op = "push"
@@ -23,7 +23,7 @@
raise mercurial.util.Abort(_('servelog installed as wrong hook type,'
' must be changegroup or outgoing but is %s') % hooktype)
t = time.strftime("%Y-%m-%d_%H:%M:%S", time.gmtime())
- user = os.environ['REMOTE_USER']
+ user = ruleset.rules.get('user')
# FIXME: lock it
log = open(repo.join("serve-log"), "a+")
try: