Mercurial hook not executing properly

后端 未结 9 1374
北恋
北恋 2020-12-30 12:02

This should be a very simple thing to have run, but for some reason it won\'t work with my Mercurial repository. All I want is for the remote repo to automatically run

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 12:44

    Well, after going through the same steps of frustration as Marc W did a while ago, I finally found the solution to the problem, at least when remote serving is done with the hgwebdir WSGI script.

    I found out that when using this kind of remote push via HTTP or HTTPS, Mercurial simply ignores everything you write into the .hg/hgrc file or your repository. However, entering the hook in the hgwebdir config does the trick.

    So if the bottom line in your hgwebdir.wsgi script is something like

    application = hgwebdir('hgweb.config')
    

    the [hooks] config section needs to go into the mentioned hgweb.config.

    One drawback is that these hooks are executed for every repository listed in the [paths] section of that config. Even though HG offers another WSGI-capable function (hgweb instead of hgwebdir) to serve only a single repository, that one doesn't seem to support any hooks (neither does it have any config). This can, however, be circumvented by using a hgwebdir as described above and having some Apache RewriteRule map everything into the desired subdirectory. This one works for me:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/reponame
    RewriteRule ^(.*)$ reponame/$2 [QSA]
    

    Have fun using your remote hooks over HTTP :D

提交回复
热议问题