changegroup hook Linux httpd cgi
Simon King
simon at simonking.org.uk
Wed Feb 22 15:45:35 UTC 2017
Mercurial will search the PATH for the hook script, so you ought to be able
to get rid of the "./" if you add the directory containing the script to
the PATH. You could do that in your Apache configuration, or in the cgi
script. The cgi version would look something like:
import os
os.environ['PATH'] = os.environ['PATH'] + ':/path/to/hook-script-directory'
Simon
On Wed, Feb 22, 2017 at 3:25 PM, Jérôme Godbout <jerome at bodycad.com> wrote:
> Seem like the hgrc is executed, but it cannot find the command:
>
> *hg push --debug*
> *...*
> *remote: /bin/sh: **refresh_repos*
> *: command not found*
> *remote: warning: changegroup.refresh_repos hook exited with status 127*
> *...*
>
> So under Linux I have to put
> *changegroup.refresh_redmine = ./refresh_redmine*
> but under Windows (the dot make the command fail)
> *changegroup.refresh_redmine = refresh_redmine*
>
> Maybe I should put 2 hook and let the non right platform one failed and
> put a warning or put the script into available path under Linux somewhere
> into /usr/bin maybe, but that's sad since this is part of the repos hook.
>
> Thanks, for the help, good to known that the --debug flag give server side
> error/warnings too.
>
> On Tue, Feb 21, 2017 at 11:50 AM, Simon King <simon at simonking.org.uk>
> wrote:
>
>> If those permissions are accurate, I don't think adding a [trusted]
>> section would make any difference.
>>
>> Do you have any evidence that the .hg/hgrc file is being read at all? You
>> could try adding something like this:
>>
>> [hooks]
>> pretxnchangegroup.abort = false
>>
>> With that in place, pushing to the repository should fail. If it
>> succeeds, the hgrc file is being ignored.
>>
>> Either way, the output from "hg push --debug" might be useful.
>>
>> Simon
>>
>>
>> On Tue, Feb 21, 2017 at 3:23 PM, Jérôme Godbout <jerome at bodycad.com>
>> wrote:
>>
>>> httpd run as apache user
>>>
>>> ls -l /mnt/hg/.hg
>>> -rwxrwxrwx. 1 apache apache 239 Jan 18 12:26 hgrc
>>>
>>> ls -l /mnt/hg
>>> -rwxrwxrwx. 1 apache apache 169 Feb 20 13:37 refresh_repos
>>>
>>> The error log have nothing into it that (both error_log and the vhost
>>> error log).
>>>
>>> Should I add the following somewhere (hgweb.config, hgrc) ?
>>>
>>> [trusted]users = apache
>>>
>>> On Tue, Feb 21, 2017 at 5:54 AM, Simon King <simon at simonking.org.uk>
>>> wrote:
>>>
>>>> On Mon, Feb 20, 2017 at 7:55 PM, Jérôme Godbout <jerome at bodycad.com>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>> I'm trying to have a repos on a mount drive that is used by multiple
>>>>> VM under different OS (Windows, Linux). This save a lot of disk space and
>>>>> the lock is just fine for that use case.
>>>>>
>>>>> I was trying to add a hook that could be execute cross platform. In my
>>>>> *.hg/hgrc* I added this:
>>>>>
>>>>> *[hooks]*
>>>>> *changegroup.refresh_repos = refresh_repos*
>>>>>
>>>>> In my root repos directory I made a *refresh_repos.cmd* file and a *refresh_repos
>>>>> *shell script. Both script execute into command line just fine. The
>>>>> Windows mount seem to perform the hook properly and the refresh is perform
>>>>> after a push to the drive localy. But the Linux machine that do the httpd
>>>>> cgi hgserve doesn't seem to perform the hook properly.
>>>>>
>>>>> I was wondering if the entry into the hgrc for Linux should be made
>>>>> differently (path wise *./resfresh_repos*) ?
>>>>>
>>>>> Or does the hgserve perform the hgrc hook at all? Do I have to add the
>>>>> hook inside the *hgserve.config* used by cgi script?
>>>>>
>>>>> Inside the .cgi script
>>>>> *from mercurial import demandimport; demandimport.enable()*
>>>>> *from mercurial.hgweb import hgweb, wsgicgi*
>>>>> *application = hgweb("**hgserve.config"**)*
>>>>> *wsgicgi.launch(application)*
>>>>>
>>>>>
>>>>> Is there any permission involved here? does the file need a special
>>>>> permission inside Apache ? pushing/pulling to that drive work just fine and
>>>>> the script file have the apache:apache with rx permission. Is apache aware
>>>>> that the python script access a file outside and block it?
>>>>>
>>>>>
>>>> Are there any messages from mercurial in the Apache error log? One
>>>> possible problem is the ownership of the hgrc file. If the cgi script runs
>>>> as apache:apache, then the hgrc file must usually also be owned by the same
>>>> user. See https://www.mercurial-scm.org/wiki/Trust for details.
>>>>
>>>> Hope that helps,
>>>>
>>>> Simon
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20170222/86db270b/attachment-0002.html>
More information about the Mercurial
mailing list