[issue625] hg push fails when running a hook in a hgweb.cgi-based repository
Joel Rosdahl
mercurial-bugs at selenic.com
Tue Jul 10 10:43:12 CDT 2007
New submission from Joel Rosdahl <joel at rosdahl.net>:
hg push fails with
abort: 'http://hg.example.com/repo/' does not appear to be an hg repository!
when running a changegroup hook in a hgweb.cgi-based repository.
Here is a shell script that reproduces the error (edit the three
variables at the top first):
######################################################################
#! /bin/sh
# Where put the repository in the file system.
repo_dir=/path/to/repo
# URL that maps to the repository at $repo_dir. The web server must be
# set up to allow executing $repo_url/index.cgi.
repo_url=http://url/to/repo
# Where to find the template hgweb.cgi script.
hgweb_cgi=/path/to/hgweb.cgi
# ---------------------------------------------
hg init $repo_dir
sed 's|/path/to/repo|.|' $hgweb_cgi >$repo_dir/index.cgi
chmod +x $repo_dir/index.cgi
cat <<EOF >$repo_dir/.hg/hgrc
[web]
allow_push = *
push_ssl = false
[hooks]
changegroup = foo
EOF
hg clone $repo_dir $repo_dir-clone
touch $repo_dir-clone/f
hg -R $repo_dir-clone ci -A -m x
hg -R $repo_dir-clone push $repo_url
######################################################################
The problems seems to be that mercurial.hook._exthook runs
r = util.system(cmd, environ=env, cwd=repo.root)
and mercurial.util.system runs
if 'HG' not in os.environ:
os.environ['HG'] = _hgexecutable
and os.environ.__setitem__ runs
putenv(key, item)
which complains about item (i.e., the value of _hgexecutable) being
None instead of a string. I guess this is because
mercurial.util.set_hgexecutable is never called in the hgweb.cgi case.
My work-around is to set os.environ["HG"] in index.cgi.
(Tested with hg version f48290864625 and Python 2.3.5.)
----------
messages: 3479
nosy: jrosdahl
priority: bug
status: unread
title: hg push fails when running a hook in a hgweb.cgi-based repository
topic: hgweb
____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue625>
____________________________________________________
More information about the Mercurial-devel
mailing list