Whodo 维客
Whodo 论坛 问题追踪 版本控制 邮件列表 DocBook 文档 FreeMind 文档 我爱维基百科

SVN

来自 Whodo Wiki (混沌初开)

跳转到: navigation, search

Whodo 的工作流程图:

http://www.worldhello.net/doc/whodo_howto/images/process.png


从中我们可以看出 WHODO 工作流的核心就是 Subversion(简写为 SVN),那么什么是 SVN 呢?

目录

[编辑] 1 SVN 是 CVS 版本控制系统的理想替代者

最好的 SVN 参考书,在这里:Version Control with Subversion

SVN 是什么?一句话 SVN 是版本控制系统:

  • 虽然 Wiki 也包含版本控制系统的功能,不信看看页面历史?
  • 但是 Wiki 的版本控制只针对 Wiki 页面(还有上传文件),不能对其他文件进行版本控制;
  • SVN 版本控制的内容包罗万象,我就连我新居的户型图都放在了版本控制系统中,每有一个想法,就添上一笔;
  • SVN 支持分支,可以实现功能的分支开发与代码合并;
  • ...

[编辑] 2 WHODO SVN 地址

WHODO SVN 的地址是 http://svn.worldhello.net/svn/whodo/ 。Whodo Subversion 版本库目录结构:

  • trunk/doc
    Whodo 文档就提交到这里。要在该目录下创建子目录。 目前除了 /trunk/doc 外,其他目录暂时只读,如果需要修改其他目录,请和管理员联系
  • trunk/includes
    样式表、DocBook 文档有关的图标、图片,FreeMind Flash 有关文件
  • trunk/tools
    DocBook、FreeMind 格式转换的样式表、编译脚本
  • jiangxin.worldhello.net
    一个 DocBook Website 站点示例

[编辑] 3 使用 SVN 客户端软件

且慢,虽然 SVN 的地址看起来就是一个 URL 地址,但 SVN 不是用浏览器来访问的。即使是由于 SVN 的 WebDAV 模块能够支持浏览器的访问,但是浏览器只是访问到最新的版本,功能不及 SVN 客户端的万分之一。

  • 下载 TortoiseSVN
    http://tortoisesvn.sourceforge.net
    TortoiseSVN 是 Windows 上最好的客户端,Windows 上的第一选择。
  • 下载 SVN
    http://subversion.tigris.org
    即使是 Windows,有时候也需要使用命令行(或者是界面操作实在太烦琐);对于在 *nix 上开发,命令行绝对是第一选择;
  • Cygwin
    Windows 环境下,安装 Cygwin,会为命令行如虎添翼,在 Windows 下享受到 Unix 命令行的便利。


[编辑] 4 如何获取 Whodo SVN 用户账号?

只要在 WHODO 网站上注册,自动获得 SVN 只读账号。马上注册...

如果需要提交权限,参见: 成为 WHODO 作者

[编辑] 5 如何更改我的 SVN 账号口令?

访问 http://www.worldhello.net/members/ , 登录后选择"更改口令"。

如果忘记口令,点击这里,输入用户名和注册时留下的邮件地址,新口令会发到您的邮箱。

[编辑] 6 Whodo SVN 注意事项

[编辑] 6.1 我忘记了口令,试过几次后,甚至连整个 http://www.worldhello.net 网站都无法访问了?

WorldHello.net/Ossxp.com 网站,通过技术手段来防范暴力口令破解,以免系统被黑客攻击或者 SVN 账号口令被破解。

当用户连续若干次登录失败后,网站会暂时切断该用户IP地址。在用户看来会有一段时间(5分钟?)无法继续访问网站。


[编辑] 6.2 新增文件的属性设置?

Whodo SVN 的 Hooks 脚本会检查新增文件的属性,没有设置 svn:mime-type 和/或 svn:eol-style 属性,禁止提交。

但是每次添加文件后,还要执行类似“svn ps svn:eol-style ...”的命令,实在太繁琐了!不过幸好,SVN 客户端(命令行或者 TortoiseSVN),支持自动属性的功能。即会为新增文件自动添加属性。

[编辑] 6.2.1 config 配置文件

启用和设置自动属性,是在 config 配置文件中完成的。 config 配置文件的位置:

  • Unix 平台
    全局的配置文件位置为:/etc/subversion/config; 每个用户主目录还有配置文件覆盖全局配置文件的设置:~/.subversion/config;
  • Windows 平台
    注册表中可能包含相应的设置:HKLM\Software\Tigris.org\Subversion\Config,以及 HKCU\Software\Tigris.org\Subversion\Config。 不过文件的优先级更高。全局配置文件:%ALLUSERSPROFILE%\Application Data\Subversion\config,用户个人配置文件:%APPDATA%\Subversion\config

[编辑] 6.2.2 启用 auto-props

修改 config 配置,启用 auto-props:

[miscellany]
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store .cvsignore Thumbs.db CVS
use-commit-times = yes
enable-auto-props = yes

[编辑] 6.2.3 基于文件名的 auto-props 设置

自动属性的设置,是根据文件名来匹配的。修改 config 文件,增添新的配置,如下:

### Section for configuring automatic properties.
[auto-props]
### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match will be applied to the file.
### Note that auto-props functionality must be enabled, which
### is typically done by setting the 'enable-auto-props' option.

##################################################
### Binary files
##################################################
*.bmp	= svn:mime-type=image/bmp
*.gif	= svn:mime-type=image/gif
*.gz	= svn:mime-type=application/x-gzip
*.ico	= svn:mime-type=image/x-icon
*.jar	= svn:mime-type=application/zip
*.jpg	= svn:mime-type=image/jpeg
*.pdf	= svn:mime-type=application/pdf
*.png	= svn:mime-type=image/png
*.ps	= svn:mime-type=application/postscript
*.tif	= svn:mime-type=image/tiff
*.vsd	= svn:mime-type=application/octet-stream
*.zip	= svn:mime-type=application/zip

##################################################
### Text files, OS dependent eol-style
##################################################
*.dsp	= svn:eol-style=CRLF
*.dsw	= svn:eol-style=CRLF

*.mm	= svn:eol-style=LF;svn:mime-type=text/xml
*.sh	= svn:eol-style=LF;svn:executable
Makefile	= svn:eol-style=LF

##################################################
### Text files, eol-style is native
##################################################
*.c		= svn:eol-style=native;svn:mime-type=text/plain
*.cpp	= svn:eol-style=native;svn:mime-type=text/plain
*.css	= svn:eol-style=native;svn:mime-type=text/css
*.diff	= svn:eol-style=native;svn:mime-type=text/plain
*.dsl	= svn:eol-style=native;svn:mime-type=text/sgml
*.dtd	= svn:eol-style=native;svn:mime-type=text/plain
*.ent	= svn:eol-style=native;svn:mime-type=text/plain
*.gml	= svn:eol-style=native;svn:mime-type=text/sgml
*.h		= svn:eol-style=native;svn:mime-type=text/plain
*.htm	= svn:eol-style=native;svn:mime-type=text/html
*.html	= svn:eol-style=native;svn:mime-type=text/html
*.java	= svn:eol-style=native;svn:mime-type=text/plain
*.js	= svn:eol-style=native;svn:mime-type=text/plain
*.mod	= svn:eol-style=native;svn:mime-type=text/plain
*.patch	= svn:eol-style=native;svn:mime-type=text/plain
*.php	= svn:eol-style=native
*.pl	= svn:eol-style=native
*.py	= svn:eol-style=native
*.sgm	= svn:eol-style=native;svn:mime-type=text/sgml
*.sgml	= svn:eol-style=native;svn:mime-type=text/sgml
*.svg	= svn:eol-style=native;svn:mime-type=text/xml
*.txt	= svn:mime-type=text/plain
*.xml	= svn:eol-style=native;svn:mime-type=text/xml
*.xsl	= svn:eol-style=native;svn:mime-type=text/xml
*.xslt	= svn:eol-style=native;svn:mime-type=text/xml
README	= svn:eol-style=native

文件添加后,在提交之前,可以通过如下命令查看新增文件的属性:

$ svn proplist -v *

[编辑] 6.3 对 Commit Log 的检查

目前对 Commit log 的检查只是检查长度要大于 5 个字节,否则会触发 subversion hooks,导致提交被退回。

[编辑] 6.4 文件名命名原则

  • 在 subversion 的 http://svn.worldhello.net/svn/whodo/trunk/doc 路径下创建子目录;
  • 子目录名称使用英文名称,提交文档到此子目录下;
  • DocBook 文档的首页文件名为 index.xml ;
  • FreeMind 文档的文件名和子目录名同名,扩展名为 .mm ;