I have an Apache httpd+mod_wsgi+Mercurial setup and I would like to get authenticated user in a hook, specifically pretxnchangegroup
hook. I have read (most likely incorrectly) that os.environ['REMOTE_USER']
should contain that info, but doesn't look like it does.
I currently have an extension, that prints os.environ
to stderr
.
import sys
import os
def pretxnchangegroup_hook(ui, repo, **kwargs):
print >> sys.stderr, 'pretxnchangegroup activated'
print >> sys.stderr, os.environ
def reposetup(ui, repo):
ui.setconfig('hooks', 'incoming.accesscontrol', pretxnchangegroup_hook)
With hg -v push
this code outputs:
remote: calling hook incoming.accesscontrol: <function pretxnchangegroup_hook at 0x7f8310221230>
remote: pretxnchangegroup activated
remote: {'LANG': 'C', 'TERM': 'xterm', 'SHLVL': '2', 'PWD': '/', 'PATH': '/sbin:/usr/sbin:/bin:/usr/bin', '_': '/usr/sbin/httpd'}