ディノ社内のバージョン管理は主にSubversionを利用しています。また、社内の開発環境はWindowsとMacとLinuxが入り乱れています。そんな環境で、一番問題が少なそうなSubversionの設定を考えてみました。現在これを社内標準として運用していますが、今のところ大きな問題は起きていません。
設定内容ですが、auto-propsとglobal-ignoresの設定です。各種ファイルについて、eol-style=nativeやkeywords=Idやsvn:mime-typeなどを設定します。
ちなみに、本設定はsymfonyの公式オススメ設定「Symfony Repository Tips」から大半を流用しています。
設定内容
設定内容はsubversion-config.txtの通りです。同じ内容を以下に貼付けておきます。
#diff-cmd = diff
[miscellany]
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store Thumbs.db
enable-auto-props = yes
[auto-props]
# Scriptish formats
*.bat = svn:eol-style=native; svn:keywords=Id; svn-mine-type=text/plain
*.bsh = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-beanshell
*.cgi = svn:eol-style=native; svn:keywords=Id; svn-mine-type=text/plain
*.cmd = svn:eol-style=native; svn:keywords=Id; svn-mine-type=text/plain
*.js = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/javascript
*.php = svn:eol-style=native; svn:keywords=Id Rev Date; svn:mime-type=text/x-php
*.pl = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-perl; svn:executable
*.pm = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-perl
*.py = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-python; svn:executable
*.sh = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-sh; svn:executable
# Image formats
*.bmp = svn:mime-type=image/bmp
*.gif = svn:mime-type=image/gif
*.ico = svn:mime-type=image/ico
*.jpeg = svn:mime-type=image/jpeg
*.jpg = svn:mime-type=image/jpeg
*.png = svn:mime-type=image/png
*.tif = svn:mime-type=image/tiff
*.tiff = svn:mime-type=image/tiff
# Data formats
*.pdf = svn:mime-type=application/pdf
*.avi = svn:mime-type=video/avi
*.doc = svn:mime-type=application/msword
*.eps = svn:mime-type=application/postscript
*.gz = svn:mime-type=application/gzip
*.mov = svn:mime-type=video/quicktime
*.mp3 = svn:mime-type=audio/mpeg
*.ppt = svn:mime-type=application/vnd.ms-powerpoint
*.ps = svn:mime-type=application/postscript
*.psd = svn:mime-type=application/photoshop
*.rdf = svn:eol-style=native; svn:keywords=Id
*.rss = svn:eol-style=native; svn:keywords=Id
*.rtf = svn:mime-type=text/rtf
*.swf = svn:mime-type=application/x-shockwave-flash
*.tgz = svn:mime-type=application/gzip
*.wav = svn:mime-type=audio/wav
*.xls = svn:mime-type=application/vnd.ms-excel
*.zip = svn:mime-type=application/zip
# Text formats
.htaccess = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.css = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/css
*.dtd = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.html = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/html
*.ini = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.sql = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/x-sql
*.txt = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.xhtml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xhtml+xml
*.xml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xsd = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xsl = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xslt = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xml
*.xul = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/xul
*.yaml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.yml = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
CHANGES = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
COPYING = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
INSTALL = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
Makefile* = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
README = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
TODO = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
# Code formats
*.c = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.cpp = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.h = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
*.java = svn:eol-style=native; svn:keywords=Id; svn:mime-type=text/plain
各種クライアントの設定方法
適切な場所にsubversion-config.txtの内容を貼付ければOKです。
- 本家svnコマンド
- ~/.subversion/configを編集。
- TortoiseSVN
- 「デスクトップを右クリック」 → 「TortoiseSVN」 → 「設定(S)」
- Eclipse(Subversive)
- 「Window」 → 「preferences」 → 「Team」→「SVN」→「Properties Configuration」
Tracの設定
svn:mime-typeを設定すると、svnリポジトリに直接ブラウザからアクセスした際に、ちょっとしたトラブルが発生します。HTTPのContent-typeが svn:mime-typeで設定した内容になってしまうため、ソースコードを見ようとすると「別アプリケーションで開く?それともファイルをセーブする?」などと聞かれてしまいます。少し悲しいですね。
また、trac.iniに下記の設定が無い場合はTracのリポジトリブラウザからも見えないのでかなり悲しい気分になります。trac.iniの設定を徹底しましょう。
enscript_modes = text/x-dylan:dylan:4,text/x-php:php:4
enscript_path = enscript
mime_map = text/x-dylan:dylan,text/x-idl:ice,text/x-ada:ads:adb,text/x-php:php
silvercity_modes = text/x-php:HyperText:4
既存プロジェクトのpropを変更
これまで紹介してきた設定はリポジトリにファイルを新規commitした場合のみ有効です。既存のリポジトリをこの設定に合わせたい場合は、下記のように手動で頑張るしかありません。
$ find . -type f -name \*.php -print0 | xargs -0 svn propset svn:eol-style native
$ find . -type f -name \*.php -print0 | xargs -0 svn propset svn:keywords "Id Rev Date"
$ find . -type f -name \*.php -print0 | xargs -0 svn propset svn:mime-type text/x-php
これは*.phpファイルの例です。他の拡張子のファイルについても同様に頑張る必要があります。
1 response so far ↓
1 links for 2008-10-15 « 個人的な雑記 // 10 月 16, 2008 at 07:00
[...] Subversion設定の標準化 (tags: subversion) [...]
コメントをどうぞ