水银小技巧-向服务器推送时给群组成员发送邮件

之前翻译过一系列文章,探讨水银的使用方法。

进来由于工作原因,使用了 bitbucket代码托管网站。这个网站是为数不多的支持水银的代码托管网站之一。经过尝试,感觉真心不错。里面有这么一个Service功能,可以添加各种各样的服务。其中有一个服务,叫做Email。这个服务可以在有人给这个仓库push代码的时候,发送邮件给这个仓库的订阅者。

水银小技巧-向服务器推送时给群组成员发送邮件_第1张图片

这的确是一个比较使用的功能。大家也不可能实时关注仓库的动态,能够有这种通知来提醒大家是再好不过了。那么,如果不用bitbucket的话,可不可以也有这个功能呢?通过尝试,发现这个功能可以有。

我在Windows 7和Ubuntu上都尝试了这个功能,其实实现起来是一模一样的。我们要做的,只是编辑一个文件。这个文件是你仓库下的.hg下的hgrc文件。当然,这也不是我发明的,网上有教程,只是一开始我摸索了好久都没成功,后来也是糊里糊涂地就搞定了。

[extensions]
notify=

[hooks]
# Enable either changegroup or incoming or outgoing.
# changegroup will send one email for all incoming changesets,
# whereas incoming sends one email per incoming changeset.
# Note: Configuring both is possible, but probably not
#       what you want, you'll get one email for the group
#       and one for each changeset in the group.
# outgoing will send one email for all outgoing changesets
changegroup.notify = python:hgext.notify.hook
#incoming.notify = python:hgext.notify.hook
#outgoing.notify = python:hgext.notify.hook
[email]
from = ZhongCheng
method = smtp

[smtp]
host = smtp.163.com
# Optional options:
username = *******@163.com
password = *******
port = 25
# tls = smtps
tls = none
# local_hostname = me.example.com

# the baseurl is used for constructing hgweb-URLs for the mails
# It can be a dummy value if your repo isn't
# available via http
[web]
baseurl = http://hgserver/hg

[notify]
# Space separated list of change sources. Notifications are sent only
# if it includes the incoming or outgoing changes source. Incoming
# sources can be ``serve`` for changes coming from http or ssh,
# ``pull`` for pulled changes, ``unbundle`` for changes added by
# :hg:`unbundle` or ``push`` for changes being pushed
# locally. Outgoing sources are the same except for ``unbundle`` which
# is replaced by ``bundle``. Default: serve.
sources = serve push unbundle

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

# While the subscription information can be included in this file,
#   (in which case, set: config =)
# having it in a separate file allows for it to be version controlled
# and for the option of having subscribers maintain it themselves.
# config = 

[reposubs]
# key is glob pattern, value is comma-separated list of subscriber emails
* = *******@163.com,*******@163.com,**********@qq.com

# You can override the changeset template here, if you want.
# If it doesn't start with \n it may confuse the email parser.
# here's an example that makes the changeset template look more like hg log:
template =
  details:   {baseurl}/{webroot}/rev/{node|short}
  branches:  {branches}
  changeset: {rev}:{node|short}
  user:      {author}
  date:      {date|date}
  description:
  {desc}\n

# max lines of diffs to include (0=none, -1=all)
maxdiff = 300

# if you want to use a shorter repo-name, you can strip off components at the beginning.
# For example to strip off /usr/local/hg/repos from /usr/local/hg/repos/code use
# strip = 5

我这里使用的是163的smtp服务器,当然,技术好的可以自己搭一个。另外,qq的smtp服务器貌似不太好用,Gmail的smtp的端口号是587。

你可能感兴趣的:(水银小技巧-向服务器推送时给群组成员发送邮件)