Whodo SVN 的 Hooks 脚本会检查新增文件的属性,没有设置 svn:mime-type 和/或 svn:eol-style 属性,禁止提交。
但是每次添加文件后,还要执行类似“svn ps svn:eol-style ...”的命令,实在太繁琐了! 不过幸好,SVN 客户端(命令行或者 TortoiseSVN),支持自动属性的功能。即会为新增文件自动添加属性。
启用和设置自动属性,是在 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
修改 config 配置文件,启用 auto-props:
[miscellany] enable-auto-props = yes
自动属性的设置,是根据文件名来匹配的。修改 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 # 下面的语句有风险,只有用 “群英汇-开源速递” 提供的 Subversion 客户端才可以使用。 # * = svn:eol-style=native
文件添加后,在提交之前,可以通过如下命令查看新增文件的属性:
$ svn proplist -v *
Copyright © 2006 WorldHello 开放文档之源 计划 |