viewvc是一個基于web的CVS、SVN代碼倉庫瀏覽工具。它最早是從cvsweb發(fā)展而來的,cvsweb是用Perl編寫的,viewvc原作者Greg Stein發(fā)現(xiàn)很難在此基礎(chǔ)上擴展新的功能,于是用Python重新實現(xiàn),并命名為viewcvs。后來又加入了對SVN代碼倉庫的支持,為反映這一變化viewcvs重命名為viewvc。viewvc可以以獨立的程序運行(standalone.py),也可以以cgi方式運行于支持CGI的web服務(wù)器,還可以以ASP模式運行于IIS,以mod_python模式運行于Apache。viewvc通過本地文件系統(tǒng)訪問代碼倉庫,所以它必須安裝在運行CVS或SVN代碼倉庫的同一服務(wù)器上。運行viewvc需要很多第三方軟件,具體需要的依賴軟件取決于啟用功能和運行平臺兩大因素。viewvc除了支持CVS代碼倉庫瀏覽功能,還支持 1)SVN代碼倉庫瀏覽功能 2)代碼語法加亮、顏色標(biāo)注 3)CVS代碼修訂歷史圖形顯示 4)CVS代碼代碼提交動作的記錄、查詢 本文以Windows系統(tǒng)下實現(xiàn)上述1,2,3三個功能為例說明viewvc + Apache CGI的安裝配置過程。具體環(huán)境是Windows XP SP2,CVSNT 1)Python 運行時 2)Subversion及Subversion Python綁定 3)Enscript(http://www./people/mtr/genscript/)或者Highlight, code colorizer, 4)CvsGraph 在Windows平臺上,由于viewvc使用了Python的Win32擴展模塊,所以第一項依賴軟件包除了安裝官方發(fā)布的Python外,還需要Python Win32擴展模塊(可從從http://starship./crew/mhammond/win32/下載)。為了省去另行安裝的麻煩,可以使用ActiveState提供的Windows版的ActivePython,它包含了Python Win32擴展模塊,使得安裝更為便捷。第二項依賴軟件包可以從Subversion的官方網(wǎng)站獲取。Enscript和highlight都可以對代碼進(jìn)行語法加亮、顏色標(biāo)注,但由于Enscript相對比較舊,支持的語言相對較少,而且本身又有依賴,所以第三項依賴軟件包采用功能更豐富、開發(fā)相對比較活躍的highlight。 整個安裝配置的過程大致是: 1)獲取viewvc及其依賴的軟件包 2)安裝配置viewvc依賴的軟件包 3)安裝viewvc 4)配置viewvc 5)測試 6)集成到Apache <!--[if !supportLists]-->2. <!--[endif]-->獲取viewvc及其依賴的軟件包
<!--[if !supportLists]-->2.1. <!--[endif]-->獲取viewvc獲取viewvc可以從http://www./download.html下載。目前,viewvc的穩(wěn)定版本是0.94,但該版本對Windows系統(tǒng)的支持有問題,使用它默認(rèn)的安裝方式往往無法成功。而且,功能不及現(xiàn)在1.0-dev版本全面,事實上,很多開源組織(參見http://svn./viewcvs.cgi/vienna-rss/trunk/ 獲得viewvc 1.0-dev版本需要用svn從viewvc的開發(fā)網(wǎng)站http://viewvc. checkout代碼具體命令: svn co http://viewvc./svn/viewvc/trunk/ viewvc-1.0-dev E:\>svn co http://viewvc./svn/viewvc/trunk/ viewvc-1.0-de A viewvc-1.0-dev\www A viewvc-1.0-dev\www\project_tools.html A viewvc-1.0-dev\www\index.html A viewvc-1.0-dev\tparse\tparsemodule.cpp A viewvc-1.0-dev\tparse\INSTALL A viewvc-1.0-dev\tparse\Setup.py A viewvc-1.0-dev\tparse\CHANGES A viewvc-1.0-dev\tparse\tparsemodule.h A viewvc-1.0-dev\tparse\.cvsignore A viewvc-1.0-dev\tparse\README A viewvc-1.0-dev\templates A viewvc-1.0-dev\templates\diff.ezt A viewvc-1.0-dev\templates\docroot ...... A viewvc-1.0-dev\elemx\elx_page.sh A viewvc-1.0-dev\elemx\elx.h A viewvc-1.0-dev\viewcvs.conf.dist 取出修訂版 1278。 賬號可以用guest,密碼可以用guest <!--[if !supportLists]-->2.2. <!--[endif]-->獲取Subversion Python綁定Subversion Python綁定是一些訪問Subversion功能的Python模塊,在Subversion的每個主要版本發(fā)布時都會發(fā)布相應(yīng)的Python綁定。二進(jìn)制文件可以從以下鏈接處獲得http://subversion./servlets/ProjectDocumentList?folderID=91。目前,官方發(fā)布的Subversion <!--[if !supportLists]-->2.3. <!--[endif]-->獲取ActivePython從http://www./Products/ActivePython/處下一個和Subversion Python綁定兼容的版本。 <!--[if !supportLists]-->2.4. <!--[endif]-->獲取CvsGraph為支持CVS代碼修訂歷史圖形顯示功能,viewvc需要CvsGraph <!--[if !supportLists]-->2.5. <!--[endif]-->獲取Highlight為支持代碼語法加亮功能,viewvc需要Highlight, code colorizer, <!--[if !supportLists]-->3. <!--[endif]-->安裝配置viewvc依賴的軟件包
<!--[if !supportLists]-->3.1. <!--[endif]-->安裝Python首先,安裝Python,假定是ActivePython <!--[if !supportLists]-->3.2. <!--[endif]-->安裝Subversion Python綁定然后,解開Subversion Perl綁定壓縮包svn-win32- <!--[if !supportLists]-->3.3. <!--[endif]-->安裝CvsGraph將下載的cvsgraph- <!--[if !supportLists]-->3.4. <!--[endif]-->安裝Highlight將下載的highlight發(fā)行包解壓縮至某個目錄,假定是D:\OSS\highlight- <!--[if !supportLists]-->4. <!--[endif]-->安裝配置viewvc
到viewvc的發(fā)行版目錄下(本例為E:\viewvc-1.0-dev),運行python viewcvs-install E:\viewvc-1.0-dev>python viewcvs-install This is the ViewVC 1.0-dev installer. It will allow you to choose the install path for ViewVC. You will now be asked some installation questions. Defaults are given in square brackets. Just hit [Enter] if a default is okay. Installation path [C:\Program Files\viewvc-1.0-dev]: e:\viewvc2 DESTDIR path (generally, only package maintainers will need to change this) []: Installing ViewVC to: e:\viewvc2 bin/cgi/viewcvs.cgi bin/cgi/query.cgi bin/mod_python/viewcvs.py bin/mod_python/query.py bin/mod_python/handler.py bin/mod_python/.htaccess bin/standalone.py ...... templates\revision.ezt templates\roots.ezt templates\rss.ezt ViewVC File Installation Complete Consult INSTALL for detailed information to finish the installation and configure ViewVC for your system. Overview of remaining steps: 1) Edit the e:\viewvc2\viewcvs.conf file. 2) Configure an existing web server to run (or copy to cgi-bin) e:\viewvc2\bin\cgi\viewcvs.cgi. OR Run the web server that comes with ViewVC at e:\viewvc2\standalone.py. <!--[if !supportLists]-->5. <!--[endif]-->配置viewvc
接下來需要配置viewvc,主要的配置信息有cvs或svn的代碼倉庫的位置,cvsnt或rcs命令的的位置。這些信息在viewvc安裝根目錄下的的viewcvs.conf文件中,該文件采用Windows常見的.ini格式,其中的每一個參數(shù)都有詳盡的解釋。在該文件開頭的注釋部分說明了使viewvc運行起來需要設(shè)定的基本參數(shù),以及源代碼語法加亮,顯示界面客戶化等功能需要設(shè)定的參數(shù)。 <!--[if !supportLists]-->5.1. <!--[endif]-->基本參數(shù)<!--[if !supportLists]-->5.1.1. <!--[endif]-->代碼倉庫位置參數(shù)使viewvc運行起來需要告訴它cvs或svn的代碼倉庫的位置,相關(guān)參數(shù)是cvs_roots,svn_roots,這兩個參數(shù)使用相同的語法:每指定一個代碼倉庫需要給其命名,然后指定代碼倉庫的絕對路徑,兩者用冒號分隔。如果指定多個代碼庫用用逗號分隔每個名稱:路徑字符串。示例如下: cvs_roots = new technology: C:\cvs_repos\new_tech, leyacy_code: C:\cvs_repos\leyacy_code, projectA: C:\cvs_repos\projectA, projectB: C:\cvs_repos\projectB svn_roots = new technology: C:\svn_repos\new_tech, leyacy_code: C:\svn_repos\leyacy_code, productA: C:\svn_repos\productA, productB: C:\svn_repos\productB 如果有多個代碼倉庫需要讓viewvc通過web展示,并且這些代碼倉庫都在同一個目錄下,可以使用參數(shù)root_parents。所以上述配置可以簡寫為: root_parents = C:\svn_repos : svn, C:\cvs_repos : cvs <!--[if !supportLists]-->5.1.2. <!--[endif]-->cvs,svn可以執(zhí)行文件位置viewvc需要使用cvs或svn的可執(zhí)行程序訪問代碼倉庫,某些情況下需要顯示指定這些可執(zhí)行程序的位置。CVS的情況稍微復(fù)雜一些,如果代碼庫是CVSNT的,則應(yīng)當(dāng)使用cvsnt的cvs客戶端可執(zhí)行程序,以增強對CVSNT擴展特性的支持。對于標(biāo)準(zhǔn)安裝的Subversion使用默認(rèn)的設(shè)置即可。相關(guān)參數(shù)有cvsnt_exe_path,svn_path cvsnt_exe_path = C:\Program Files\CVSNT\cvs.exe use_cvsgraph = 1 cvsgraph_path =D:\OSS\cvsgraph # should we use ‘highlight‘ for syntax coloring? # NOTE: use_enscript has to be 0 or enscript will be used instead use_highlight = 1 # # if the highlight program is not on the path, set this value # highlight_path = D:\OSS\highlight- # what coloring style should highlight use? highlight_style = emacs # should we add line numbers? highlight_line_numbers = 1 # convert tabs to ## spaces (use 0 for no conversion) highlight_convert_tabs = 2 <!--[if !supportLists]-->5.2. <!--[endif]-->CVS代碼修訂歷史圖形顯示參數(shù)啟用CVS代碼修訂歷史圖形顯示功能需要將參數(shù)use_cvsgraph設(shè)為1,如果cvsgraph.exe可執(zhí)行文件不在環(huán)境變量Path中,需要cvsgraph_path參數(shù)告訴viewvc cvsgraph.exe的絕對路徑。此外,還可以指定cvsgraph的配置文件。以下是和highlight相關(guān)的配置示例: # # Use CvsGraph. See http://www.akhphd./~bertho/cvsgraph/ for # documentation and download. # use_cvsgraph = 1 # # if the cvsgraph program is not on the path, set this value # cvsgraph_path =D:\OSS\cvsgraph # cvsgraph_path = /usr/local/bin/ # # Location of the customized cvsgraph configuration file. # You will need an absolute pathname here: # cvsgraph_conf = cvsgraph.conf <!--[if !supportLists]-->5.3. <!--[endif]-->代碼語法加亮參數(shù)啟用CVS代碼修訂歷史圖形顯示功能需要將參數(shù)use_highlight設(shè)為1,如果highlight.exe可執(zhí)行文件不在環(huán)境變量Path中,需要highlight_path參數(shù)告訴viewvc highlight.exe的絕對路徑。此外,可以設(shè)定代碼風(fēng)格(highlight_style),tab鍵轉(zhuǎn)換成空格(highlight_convert_tabs)等參數(shù)??蛇x的代碼風(fēng)格可以到highlight安裝目錄下的themes子目錄下查找相應(yīng)style文件名。 D:\OSS\highlight- 驅(qū)動器 D 中的卷是 work 卷的序列號是 D D:\OSS\highlight- 2006-03-10 00:44
2006-03-10 00:44
2005-10-19 20:38 573 acid.style 2005-10-19 20:38 665 berries-dark.style 2005-10-19 20:38 671 berries-light.style 2005-10-19 20:38 664 bipolar.style 2005-10-19 20:38 629 blacknblue.style 2005-10-19 20:38 611 bright.style 2005-10-19 20:38 657 contrast.style 2005-10-19 20:38 521 darkblue.style 2005-10-19 20:38 625 darkness.style 2005-10-19 20:38 626 desert.style 2005-10-19 20:38 643 dull.style 2005-10-19 20:38 626 easter.style 2005-10-19 20:38 495 emacs.style 2005-10-19 20:38 626 golden.style 2005-10-19 20:38 620 greenlcd.style 2005-10-19 20:38 602 ide-anjuta.style 2005-10-19 20:38 454 ide-codewarrior.style 2005-10-19 20:38 609 ide-devcpp.style 2005-10-19 20:38 498 ide-eclipse.style 2005-10-19 20:38 605 ide-kdev.style 2005-10-19 20:38 609 ide-msvcpp.style 2005-10-19 20:38 469 kwrite.style …… 從上面的輸出可知可選的風(fēng)格有acid, berries-dark, berries-light, bipolar,ide-anjuta, ide-codewarrior, ide-devcpp, ide-eclipse, ide-kdev, ide-msvcpp等等。以下是和highlight相關(guān)的配置示例: # should we use ‘highlight‘ for syntax coloring? # NOTE: use_enscript has to be 0 or enscript will be used instead use_highlight = 1 # # if the highlight program is not on the path, set this value # highlight_path = D:\OSS\highlight- # what coloring style should highlight use? highlight_style = emacs # should we add line numbers? highlight_line_numbers = 1 # convert tabs to ## spaces (use 0 for no conversion) highlight_convert_tabs = 2 <!--[if !supportLists]-->5.4. <!--[endif]-->其它參數(shù)通常address參數(shù)需要修改,它是一個給管理員發(fā)郵件的鏈接。 address = Tell SCM master if you have troubles in use viewvc <!--[if !supportLists]-->6. <!--[endif]-->測試配置
配置完成后可以通過運行standalone.py來測試安裝配置是否正確。運行e:\viewvc2\bin\standalone.py E:\viewvc2\bin>standalone.py server ready at http://localhost:7467/viewvc 打開瀏覽器輸入http://localhost:7467/viewvc查看viewvc是否正常運行。 <!--[if !supportLists]-->7. <!--[endif]-->將viewvc和Apache集成
standalone.py啟動的viewvc服務(wù)不夠穩(wěn)定,在生產(chǎn)環(huán)境通產(chǎn)需要和web服務(wù)器集成。viewvc以CGI方式集成到Apache中相當(dāng)簡單。只需要用ScriptAlias指令將viewvc安裝目錄下的bin\cgi子目錄映射到一個URL上去。示例: ScriptAlias /codeview/ "E:/viewvc/bin/cgi/" 重啟Apache,即可通過URL:http://localhost/codeview/viewcvs.cgi訪問所配置的代碼倉庫。 <!--[if !supportLists]-->8. <!--[endif]-->總結(jié)
安裝配置viewvc涉及到眾多依賴軟件和參數(shù),如果以Apache CGI方式運行viewvc同時Apache作為Windows Service運行修改配置后可能需要重啟Windows才能生效。另外,如果viewvc運行不正常,常見的錯誤是CVS,SVN的代碼倉庫位置不正確,或者使用到了highlight,cvsgraph沒有制定正確的路徑。 |
|