freebad6.2 安装Subversion(svn)

SVN] 自动 commit 通知 ---- mailer.conf  

2008-07-10 15:16:46|  分类: scm_svn |字号 订阅

以 FreeBSD 6.2 为例。注意,此 mailer.conf 是 svn 自己的。而 FreeBSD 也有个 mailer.conf,参见 man mailer.conf。


Quick Install
(1) 安装 swig (ports/devel/swig13)

(2) 安装 svn,在 configure 时,会自动找系统是否安装了 swig,因此 swig 要放在前面
    cd ports/devel/subversion
    make install

(3) 安装 swig-py,请阅读 ports/devel/subversion/work/subversion-1.6.2/subversion/bindings/swig/INSTALL
    cd ports/devel/subversion/work/subversion-1.6.2
    gmake swig-py
    gmake check-swig-py
    gmake install-swig-py DESTDIR=/usr/local/svn-python
    echo /usr/local/svn-python > /usr/local/lib/python2.5/site-packages/subversion.pth

(4) 假设建立好的仓库在 /home/svnrepos
    cd /home/svnrepos/hooks
    cp post-commit.tmpl post-commit
    chmod +x post-commit

    修改 post-commit 中最下面的几行命令为:
    PATH=/usr/bin:/usr/local/bin; export PATH
    /usr/local/share/subversion/hook-scripts/mailer/mailer.py commit "$REPOS" "$REV"

    cp /usr/local/share/subversion/hook-scripts/mailer/mailer.conf /home/svnrepos/conf/
    修改 /home/svnrepos/conf/mailer.conf:
      Uncomment the line
        #mail_command = /usr/sbin/sendmail
      and change the line
        to_addr = invalid@example.com
      to
        to_addr = <your e-mail address> <hobbes' e-mail address> <susie's e-mail address>


配置 mailer.conf
假设svn目录结构为:
REPOS/
    program/client/      客户端代码
    program/server/    服务端代码
    design/                   策划文档
那么我们可以配置:
[server]
for_paths = /program/server
to_addr = server programmers' email
commit_subject_prefix = [server]

[client]
for_paths = /program/client
to_addr = client programmers' email
commit_subject_prefix = [client]

[design]
for_paths = /design
to_addr = designers' email
commit_subject_prefix = [design]


FAQ
<1> Warning: 'post-commit' hook failed with error output:
Traceback (most recent call last):
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 1307, in ?
    sys.argv[3:3+expected_args])
  File "/var/lib/python-support/python2.4/svn/core.py", line 217, in run_app
    return apply(func, (_core.application_pool,) + args, kw)
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 77, in main
    messenger.generate()
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 369, in generate
    self.output.finish()
  File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 275, in finish
    self.pipe.tochild.close()
IOError: [Errno 32] Broken pipe
这个错误 ... 因为你没装 sendmail,嘿嘿。

<2> 都设置好了,还是没收到信。测试下:
------------------------------
imp ort subprocess, sys
cmd  = ['/usr/sbin/sendmail', '-f', 'a@b.com', 'your_email']
pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE, close_fds = True)
pipe.stdin.write(r'Subject: abc\n\ngood')
pipe.stdin.close()
pipe.wait()
------------------------------
看看是否正常工作了。还有留意发件人地址,有些邮件服务器会检查发件人是否合法的,sendmail
正常工作,但邮件服务器把你发出去的邮件丢弃了。

<3> 中文显示问题
mailer.py 中,邮件的编码,默认用了 utf-8,svn log 也用了 utf-8 编码,而假设我们项目代码的注释用了 gbk。则需要修改下 mailer.py 文件。比如统一转换为 gbk 编码:
  # 修改邮件头
  hdrs = 'From: %s\n'    \
     ...
     'Content-Type: text/plain; charset=gbk\n' \
     ...

  # 修改log编码
  mylog = repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or '',
  log = (mylog[0].decode('utf-8').encode('gbk'), )
  da ta = _da ta(
    log=log,
    ...
  )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值