Provide additional information via environment to Mercurial hooks
I like to request additional information of heptapod to custom mercurial hooks.
I developed a custom hook to automatically post review request on server-side to Review Board [1]. It can be used with local "hg serve", Kallithea and SCM-Manager. I like to add support for heptapod, too. I added the hook to global "/etc/gitlab/heptapod.hgrc" and the hook was called. Great! But I do not get the authenticated user and a more or less useful repository name (needs to be stripped from HG_PENDING).
So, please add additional information of the authenticated user and the repository group / repository. Kallithea uses json data in KALLITHEA_EXTRAS [2] and SCM-Manager REMOTE_USER and REPO_NAME env variables.
Example of https://repo.domain.de/XYZgroup/ABCrepo
HEPTAPOD_USER=andre
HEPTAPOD_REPOSITORY=XYZgroup/ABCrepo
This is all I get now:
{ 'HG_NODE': '96f4459ab6b8e3c54d6b2395ad2ecb86fe0706a9', 'HG_TXNID': 'TXN:9b4db098081e61229dba6bf22773a5b5b27b4727', 'HG_NODE_LAST': '96f4459ab6b8e3c54d6b2395ad2ecb86fe0706a9', 'SHLVL': '0', 'HG_PENDING': '/var/opt/gitlab/git-data/repositories/XYZgroup/ABCrepo.hg', 'OLDPWD': '/opt/gitlab/sv/hgserve', 'HG_URL': 'remote:http::heptapod-write', 'SERVER_SOFTWARE': 'gunicorn/19.9.0', 'GUNICORN_CMD_ARGS': '--workers=5 --timeout=3600 --max-requests 1000 --max-requests-jitter 100 --worker-tmp-dir /dev/shm', 'HG_SOURCE': 'serve', 'HG_HOOKTYPE': 'pretxnchangegroup', 'PWD': '/var/opt/gitlab/git-data/repositories/XYZgroup/ABCrepo.hg', 'HG_HOOKNAME': 'pretxnchangegroup.rb', 'PATH': '/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin', 'HG': '/opt/gitlab/bin/hg', 'HG_BUNDLE2': '1' }
Of course I can already use this. But the user is always "git". ;-)
I saw that heptapod has multiple "hg serve" daemons. Maybe it is not supported to pass additional env variables to the already running daemons? Any hint that I could try?
[1] https://github.com/misery/ExtendedApproval/blob/master/contrib/mercurial_push.py
[2] https://github.com/misery/ExtendedApproval/blob/master/contrib/mercurial_push.py#L710