星期五, 11月 24, 2006

Subversion同時使用兩個Repository

Subversion應該沒有支援Dual Repository的機制,由於平時偷懶把自己寫的幾支程式都放在同一個Repository,需要分享時就很麻煩。原本想利用Apache的虛擬目錄 Alias 的方式達成,但目前看來不可行;再使用mod_proxy的方式也有權限問題,無法達成目標。

所以我利用 Subversion 1.3版開始非正式支援SVN_ASP_DOT_NET_HACK變數,就可以在同一個目錄下有兩個不同的Repository。
The "_svn" hack is now officially supported: since some versions of ASP.NET don't allow directories beginning with dot (e.g., ".svn", the standard Subversion working copy administrative directory), the svn command line client and svnversion now treat the environment variable SVN_ASP_DOT_NET_HACK specially on Windows. If this variable is set (to any value), they will use "_svn" instead of ".svn". We recommend that all Subversion clients running on Windows take advantage of this behaviour. Note that once the environment variable is set, working copies with standard ".svn" directories will stop working, and will need to be re-checked-out to get "_svn" instead.
雖然麻煩一點,但就是在命令列切換:
C:\MyAp>set SVN_ASP_DOT_NET_HACK=1
C:\MyAp>svn commit
C:\MyAp>set SVN_ASP_DOT_NET_HACK=
C:\MyAp>svn commit
或者做成批次檔切換變數。

請注意:此特性只有在Win32平台有效,在source如main.c有特別定義:
#if defined(WIN32) || defined(__CYGWIN__)
/* Set the working copy administrative directory name. */
if (getenv("SVN_ASP_DOT_NET_HACK"))
{
err = svn_wc_set_adm_dir("_svn", pool);
if (err)
return svn_cmdline_handle_exit_error(err, pool, "svn: ");
}
#endif
所以若要在其他平台有此功能,必須修改source code再自行編譯。剛才確認在1.4.2版共11個檔案要修改。

沒有留言: