Mercurial 不使用changenotify 发送电子邮件

发布于 2024-12-03 14:27:23 字数 2860 浏览 0 评论 0原文

我设置了一个 http 中央 Mercurial 存储库,并尝试在每次推送时发送电子邮件。我按照 Mercurial 页面和 http://morecode.wordpress.com/2007/08/03/setting-up-mercurial-to-e-mail-on-a-commit/

推送工作正常,但我根本没有看到任何通知消息。请帮我。

我的客户端存储库文件夹中的 .hg/hgrc 看起来像这样

[extensions]
hgext.notify= 

[hooks]
changegroup.notify = python:hgext.notify.hook

[email]
from = [email protected]

[smtp]
host = smtp.gmail.com
username = [email protected]
password = ohyea
port = 587
tls = true

[web]
baseurl = http://1.1.1.1/repo_name

[notify]
sources = serve push pull bundle

# set this to False when you're ready for mail to start sending
test = False

config = /home/myhome/something/subscription.conf

template = \ndetails:   {baseurl}{webroot}/rev/{node|short}\nchangeset:{rev}:node|short}\nuser:      {author}\ndate:      {date|date}\ndescription:\n{desc}\n

maxdiff = 300

我的 /home/myhome/something/subscription.conf 看起来像

[reposubs]
# key is glob pattern, value is comma-separated list of subscriber emails
* = [email protected]

我保存的,我的结果如下所示,如果您注意到我根本没有看到任何通知消息

pushing to http://1.1.1.1/repo_name
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 7376 changes to 7376 files

[更新:]

我发现我的系统中没有 hgext 文件夹。所以我手动下载了与我的 hg 版本匹配的源代码并更新了我的 hgrc,如下所示,但它仍然不起作用。请提供任何帮助。

[extensions]
notify= /path/to/notify.py

[更新 2:]

谢谢 Ry4an - 我尝试过,仍然没有运气。

在我的网络服务器中

/var/www 和 /var/www/hg 下 我创建了 .hgrc 文件,只是不确定哪一个是我的 webroot,所以我在两个地方都做了内容,

[trusted]
users=user_name

这个用户名是我尝试推送到存储库的客户端中的用户名。

客户端上

在我的存储库的 .hg/hgrc 中的

[trusted]
users=user_name

,我添加了受信任的部分上述过程没有帮助

我的客户端上的第二种方法

在我的存储库的 .hg 下,我做了

chown www-data:www-data hgrc

,当我尝试推送时,我在推送时收到了一些消息说

sending capabilities command
capabilities: changegroupsubset stream lookup pushkey unbundle=HG10GZ,HG10BZ,HG10UN branchmap
sending heads command
searching for changes
common changesets up to 6ef19c49143a
sending branchmap command
ignoring untrusted configuration option hooks.changegroup.notify = python:hgext.notify.hook

在第一种方法中不会出现此忽略命令,只有在我更改 hgrc 的所有权后,才会弹出此命令。

I set up a http central Mercurial repository and try to send emails on every push. I follow instructions from mercurial page and from http://morecode.wordpress.com/2007/08/03/setting-up-mercurial-to-e-mail-on-a-commit/.

Push works fine, but I don't see any notify message at all. Please help me.

My .hg/hgrc in my repository folder of my client looks like this

[extensions]
hgext.notify= 

[hooks]
changegroup.notify = python:hgext.notify.hook

[email]
from = [email protected]

[smtp]
host = smtp.gmail.com
username = [email protected]
password = ohyea
port = 587
tls = true

[web]
baseurl = http://1.1.1.1/repo_name

[notify]
sources = serve push pull bundle

# set this to False when you're ready for mail to start sending
test = False

config = /home/myhome/something/subscription.conf

template = \ndetails:   {baseurl}{webroot}/rev/{node|short}\nchangeset:{rev}:node|short}\nuser:      {author}\ndate:      {date|date}\ndescription:\n{desc}\n

maxdiff = 300

My /home/myhome/something/subscription.conf looks like

[reposubs]
# key is glob pattern, value is comma-separated list of subscriber emails
* = [email protected]

I save and my result looks like below, if you notice I don't see any notify message at all

pushing to http://1.1.1.1/repo_name
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 7376 changes to 7376 files

[Update:]

I found that there was no hgext folder in my system. So I manually downloaded the source matching my hg version and updated my hgrc as below, and still it does not work. Any help please.

[extensions]
notify= /path/to/notify.py

[Update 2:]

Thanks Ry4an - I tried it, still no luck.

In my webserver

Under /var/www and /var/www/hg
I created .hgrc files, just not sure which one is my webroot, so I did at both places with contents

[trusted]
users=user_name

this user name is the username in my client from where I'm trying to push to the repo.

on my client

in the .hg/hgrc of my repo, I added trusted section

[trusted]
users=user_name

The above procedure did not help

Second approach

on my client,

under my repo's .hg, I did

chown www-data:www-data hgrc

and when I tried to push I got some message while pushing saying

sending capabilities command
capabilities: changegroupsubset stream lookup pushkey unbundle=HG10GZ,HG10BZ,HG10UN branchmap
sending heads command
searching for changes
common changesets up to 6ef19c49143a
sending branchmap command
ignoring untrusted configuration option hooks.changegroup.notify = python:hgext.notify.hook

This ignoring command does not appear during the first approach, only after I change the ownership of hgrc, this pops up.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风吹雨成花 2024-12-10 14:27:23

这可能是一个信任问题,但让我们先解决一些其他问题:

A) 将扩展负载切换为:

[extensions]
notify=

hgext 部分不再需要,但不会造成伤害。在未来更新的情况下,提供扩展的完整路径会更加脆弱。原始的 notify= 语法对于 Mercurial 附带的扩展来说已经足够了,并且 notification 总是如此。

B) 将 test = false 切换为 test = true 它将帮助您调试它——它将电子邮件发送到 Stdout,这很方便。

好了,这两个都完成了,让我们看看信任。 Mercurial 的信任系统是围绕这样的理念构建的:并非任何人都应该能够让您运行代码。想象一下,如果您的存储库的 .hg/hgrc 文件中有这样一个部分:

[hooks]
pre-push = rm -rf ~

当我推送到它时,它会删除我的主目录。那会让我很烦的。为了避免这种情况发生,Mercurial 只会加载/运行它信任的 hgrc 文件,并且您可以通过 您的 hgrc 中的 [trusted] 部分告诉它信任什么。当您通过 ssh 推送时,您实际上正在登录到远程计算机,并且您自己的 ~/.hgrc 可能会说明您愿意执行的其他 hgrc 文件。

不过 HTTP 很特殊。即使您可能正在进行身份验证,您也可能没有像您自己一样在远程系统上运行 Mercurial。可能是一些非用户用户,例如 www-datawwwapachenoone,具体取决于如何您的网络服务器已配置,因此...您需要使该存储库的 .hg/hgrc' 由网络服务器用户信任的用户(或组)拥有(或组拥有)。要实现这一点,您可以chwown.hg/hgrc文件传递给 Web 服务器用户,或者找到 Web 服务器的主目录(通常/var/ www) 并在其中创建一个.hgrc文件,其中包含一个[trusted]块,表示 Web 服务器用户信任拥有该文件的任何人repo 的 .hg/hgrc` 文件。

如果我对发生的事情的判断是正确的,那么你的网络服务器的错误日志中就会出现明显的迹象,你会在其中看到很多消息,例如“不信任某个用户拥有的 /path/to/repo/.hg/hgrc”。

TL;DR: 确保您的 Web 服务器用户信任(在 hgrc 意义上)指定挂钩的 .hg/hgrc 的所有者。

It's likely a trust issue, but let's hit a few other things first:

A) Switch the extension load to:

[extensions]
notify=

The hgext part is no longer necessary, but doesn't hurt. Giving the full path to the extension is more fragile in the case of future updates. The raw notify= syntax is sufficient for extensions that come with Mercurial and notify always does.

B) Switch the test = false to test = true it will help you debug this -- it sends the email to Stdout, which is handy.

Okay, those two done, let's look at trust. Mercurial's trust system is built around the idea that not just anyone should be able to get you to run code. Imagine if your repo's .hg/hgrc file had a section in it like:

[hooks]
pre-push = rm -rf ~

When I pushed to it it would delete my home directory. That would bum me out. To avoid that happening Mercurial will only load/run hgrc files that it trusts, and you tell it what to trust with [trusted] sections in your hgrc. When you're pushing over ssh you're effectively logging into the remote machine and it's your own ~/.hgrc that probably states what other hgrc files you're willing to execute.

HTTP is special though. Even though you may be authenticating you're probably not running Mercurial on the remote system as yourself. It's probably some some non-user user like www-data, www, apache, or noone depending on how your web server is configured, so... you need to make that repo's .hg/hgrc' owned (or group-owned) by an user (or group) that the webserver user trusts. To achieve that you can eitherchwownthe.hg/hgrcfile over to the web server user, or find the web server's home directory (often/var/www) and create a.hgrcfile in there with a[trusted]block saying that the web server user trusts whomever it is that owns the repo's.hg/hgrc` file.

If I'm right about what's going on the tell tale sign would be in your webserver's errors log where you'd see a lot of messages like "Not trusting /path/to/repo/.hg/hgrc owned by someuser".

TL;DR: Make sure your web server user trusts (in the hgrc sense) the owner of the .hg/hgrc that's specifying the hook.

为人所爱 2024-12-10 14:27:23

当与 Exchange Server 通信时,这对我有用:

[hostfingerprints]
<my exchange FQDN> = 2a:f3:89:69:13:b2:1e:3a:c2:fe:f9:7f:de:b3:39:e7:82:8e:99:93

[extensions]
notify =

[hooks]
changegroup.notify = python:hgext.notify.hook

[email]
from = Mercurial Notification <noreply@mydomain>

[smtp]
host = <exchange FQDN>
tls = true

[notify]
sources = serve push pull bundle
test = False
maxdiff = 300

[reposubs]
* = Cameron Rich <[email protected]>

将以上内容放入存储库的 hgrc 文件中。

例如 C:\repositories\test.hg\hgrc

This worked for me when communicating with an Exchange Server:

[hostfingerprints]
<my exchange FQDN> = 2a:f3:89:69:13:b2:1e:3a:c2:fe:f9:7f:de:b3:39:e7:82:8e:99:93

[extensions]
notify =

[hooks]
changegroup.notify = python:hgext.notify.hook

[email]
from = Mercurial Notification <noreply@mydomain>

[smtp]
host = <exchange FQDN>
tls = true

[notify]
sources = serve push pull bundle
test = False
maxdiff = 300

[reposubs]
* = Cameron Rich <[email protected]>

Put the above in the hgrc file in your repository.

e.g. C:\repositories\test.hg\hgrc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文