之前翻譯過一系列文章,探討水銀的使用方法。
進來由于工作原因,使用了 bitbucket代碼托管網站。這個網站是為數不多的支持水銀的代碼托管網站之一。經過嘗試,感覺真心不錯。里面有這么一個Service功能,可以添加各種各樣的服務。其中有一個服務,叫做Email。這個服務可以在有人給這個倉庫push代碼的時候,發送郵件給這個倉庫的訂閱者。
這的確是一個比較使用的功能。大家也不可能實時關注倉庫的動態,能夠有這種通知來提醒大家是再好不過了。那么,如果不用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<zhongcheng0519@163.com>
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。