viewvc是一個(gè)基于web的CVS、SVN代碼倉(cāng)庫(kù)瀏覽工具。它最早是從cvsweb發(fā)展而來(lái)的,cvsweb是用Perl編寫(xiě)的,viewvc原作者Greg Stein發(fā)現(xiàn)很難在此基礎(chǔ)上擴(kuò)展新的功能,于是用Python重新實(shí)現(xiàn),并命名為viewcvs。后來(lái)又加入了對(duì)SVN代碼倉(cāng)庫(kù)的支持,為反映這一變化viewcvs重命名為viewvc。viewvc可以以獨(dú)立的程序運(yùn)行(standalone.py),也可以以cgi方式運(yùn)行于支持CGI的web服務(wù)器,還可以以ASP模式運(yùn)行于IIS,以mod_python模式運(yùn)行于Apache。viewvc通過(guò)本地文件系統(tǒng)訪問(wèn)代碼倉(cāng)庫(kù),所以它必須安裝在運(yùn)行CVS或SVN代碼倉(cāng)庫(kù)的同一服務(wù)器上。運(yùn)行viewvc需要很多第三方軟件,具體需要的依賴軟件取決于啟用功能和運(yùn)行平臺(tái)兩大因素。viewvc除了支持CVS代碼倉(cāng)庫(kù)瀏覽功能,還支持 1)SVN代碼倉(cāng)庫(kù)瀏覽功能 2)代碼語(yǔ)法加亮、顏色標(biāo)注 3)CVS代碼修訂歷史圖形顯示 4)CVS代碼代碼提交動(dòng)作的記錄、查詢 本文以Windows系統(tǒng)下實(shí)現(xiàn)上述1,2,3三個(gè)功能為例說(shuō)明viewvc + Apache CGI的安裝配置過(guò)程。具體環(huán)境是Windows XP SP2,CVSNT 1)Python 運(yùn)行時(shí) 2)Subversion及Subversion Python綁定 3)Enscript(http://www./people/mtr/genscript/)或者Highlight, code colorizer, 4)CvsGraph 在Windows平臺(tái)上,由于viewvc使用了Python的Win32擴(kuò)展模塊,所以第一項(xiàng)依賴軟件包除了安裝官方發(fā)布的Python外,還需要Python Win32擴(kuò)展模塊(可從從http://starship./crew/mhammond/win32/下載)。為了省去另行安裝的麻煩,可以使用ActiveState提供的Windows版的ActivePython,它包含了Python Win32擴(kuò)展模塊,使得安裝更為便捷。第二項(xiàng)依賴軟件包可以從Subversion的官方網(wǎng)站獲取。Enscript和highlight都可以對(duì)代碼進(jìn)行語(yǔ)法加亮、顏色標(biāo)注,但由于Enscript相對(duì)比較舊,支持的語(yǔ)言相對(duì)較少,而且本身又有依賴,所以第三項(xiàng)依賴軟件包采用功能更豐富、開(kāi)發(fā)相對(duì)比較活躍的highlight。 整個(gè)安裝配置的過(guò)程大致是: 1)獲取viewvc及其依賴的軟件包 2)安裝配置viewvc依賴的軟件包 3)安裝viewvc 4)配置viewvc 5)測(cè)試 6)集成到Apache <!--[if !supportLists]-->2. <!--[endif]-->獲取viewvc及其依賴的軟件包
<!--[if !supportLists]-->2.1. <!--[endif]-->獲取viewvc獲取viewvc可以從http://www./download.html下載。目前,viewvc的穩(wěn)定版本是0.94,但該版本對(duì)Windows系統(tǒng)的支持有問(wèn)題,使用它默認(rèn)的安裝方式往往無(wú)法成功。而且,功能不及現(xiàn)在1.0-dev版本全面,事實(shí)上,很多開(kāi)源組織(參見(jiàn)http://svn./viewcvs.cgi/vienna-rss/trunk/ 獲得viewvc 1.0-dev版本需要用svn從viewvc的開(kāi)發(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。 賬號(hào)可以用guest,密碼可以用guest <!--[if !supportLists]-->2.2. <!--[endif]-->獲取Subversion Python綁定Subversion Python綁定是一些訪問(wèn)Subversion功能的Python模塊,在Subversion的每個(gè)主要版本發(fā)布時(shí)都會(huì)發(fā)布相應(yīng)的Python綁定。二進(jìn)制文件可以從以下鏈接處獲得http://subversion./servlets/ProjectDocumentList?folderID=91。目前,官方發(fā)布的Subversion <!--[if !supportLists]-->2.3. <!--[endif]-->獲取ActivePython從http://www./Products/ActivePython/處下一個(gè)和Subversion Python綁定兼容的版本。 <!--[if !supportLists]-->2.4. <!--[endif]-->獲取CvsGraph為支持CVS代碼修訂歷史圖形顯示功能,viewvc需要CvsGraph <!--[if !supportLists]-->2.5. <!--[endif]-->獲取Highlight為支持代碼語(yǔ)法加亮功能,viewvc需要Highlight, code colorizer, <!--[if !supportLists]-->3. <!--[endif]-->安裝配置viewvc依賴的軟件包
<!--[if !supportLists]-->3.1. <!--[endif]-->安裝Python首先,安裝Python,假定是ActivePython <!--[if !supportLists]-->3.2. <!--[endif]-->安裝Subversion Python綁定然后,解開(kāi)Subversion Perl綁定壓縮包svn-win32- <!--[if !supportLists]-->3.3. <!--[endif]-->安裝CvsGraph將下載的cvsgraph- <!--[if !supportLists]-->3.4. <!--[endif]-->安裝Highlight將下載的highlight發(fā)行包解壓縮至某個(gè)目錄,假定是D:\OSS\highlight- <!--[if !supportLists]-->4. <!--[endif]-->安裝配置viewvc
到viewvc的發(fā)行版目錄下(本例為E:\viewvc-1.0-dev),運(yùn)行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
接下來(lái)需要配置viewvc,主要的配置信息有cvs或svn的代碼倉(cāng)庫(kù)的位置,cvsnt或rcs命令的的位置。這些信息在viewvc安裝根目錄下的的viewcvs.conf文件中,該文件采用Windows常見(jiàn)的.ini格式,其中的每一個(gè)參數(shù)都有詳盡的解釋。在該文件開(kāi)頭的注釋部分說(shuō)明了使viewvc運(yùn)行起來(lái)需要設(shè)定的基本參數(shù),以及源代碼語(yǔ)法加亮,顯示界面客戶化等功能需要設(shè)定的參數(shù)。 <!--[if !supportLists]-->5.1. <!--[endif]-->基本參數(shù)<!--[if !supportLists]-->5.1.1. <!--[endif]-->代碼倉(cāng)庫(kù)位置參數(shù)使viewvc運(yùn)行起來(lái)需要告訴它cvs或svn的代碼倉(cāng)庫(kù)的位置,相關(guān)參數(shù)是cvs_roots,svn_roots,這兩個(gè)參數(shù)使用相同的語(yǔ)法:每指定一個(gè)代碼倉(cāng)庫(kù)需要給其命名,然后指定代碼倉(cāng)庫(kù)的絕對(duì)路徑,兩者用冒號(hào)分隔。如果指定多個(gè)代碼庫(kù)用用逗號(hào)分隔每個(gè)名稱:路徑字符串。示例如下: 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 如果有多個(gè)代碼倉(cāng)庫(kù)需要讓viewvc通過(guò)web展示,并且這些代碼倉(cāng)庫(kù)都在同一個(gè)目錄下,可以使用參數(shù)root_parents。所以上述配置可以簡(jiǎn)寫(xiě)為: root_parents = C:\svn_repos : svn, C:\cvs_repos : cvs <!--[if !supportLists]-->5.1.2. <!--[endif]-->cvs,svn可以執(zhí)行文件位置viewvc需要使用cvs或svn的可執(zhí)行程序訪問(wèn)代碼倉(cāng)庫(kù),某些情況下需要顯示指定這些可執(zhí)行程序的位置。CVS的情況稍微復(fù)雜一些,如果代碼庫(kù)是CVSNT的,則應(yīng)當(dāng)使用cvsnt的cvs客戶端可執(zhí)行程序,以增強(qiáng)對(duì)CVSNT擴(kuò)展特性的支持。對(duì)于標(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的絕對(duì)路徑。此外,還可以指定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]-->代碼語(yǔ)法加亮參數(shù)啟用CVS代碼修訂歷史圖形顯示功能需要將參數(shù)use_highlight設(shè)為1,如果highlight.exe可執(zhí)行文件不在環(huán)境變量Path中,需要highlight_path參數(shù)告訴viewvc highlight.exe的絕對(duì)路徑。此外,可以設(shè)定代碼風(fēng)格(highlight_style),tab鍵轉(zhuǎn)換成空格(highlight_convert_tabs)等參數(shù)。可選的代碼風(fēng)格可以到highlight安裝目錄下的themes子目錄下查找相應(yīng)style文件名。 D:\OSS\highlight- 驅(qū)動(dòng)器 D 中的卷是 work 卷的序列號(hào)是 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ù)需要修改,它是一個(gè)給管理員發(fā)郵件的鏈接。 address = Tell SCM master if you have troubles in use viewvc <!--[if !supportLists]-->6. <!--[endif]-->測(cè)試配置
配置完成后可以通過(guò)運(yùn)行standalone.py來(lái)測(cè)試安裝配置是否正確。運(yùn)行e:\viewvc2\bin\standalone.py E:\viewvc2\bin>standalone.py server ready at http://localhost:7467/viewvc 打開(kāi)瀏覽器輸入http://localhost:7467/viewvc查看viewvc是否正常運(yùn)行。 <!--[if !supportLists]-->7. <!--[endif]-->將viewvc和Apache集成
standalone.py啟動(dòng)的viewvc服務(wù)不夠穩(wěn)定,在生產(chǎn)環(huán)境通產(chǎn)需要和web服務(wù)器集成。viewvc以CGI方式集成到Apache中相當(dāng)簡(jiǎn)單。只需要用ScriptAlias指令將viewvc安裝目錄下的bin\cgi子目錄映射到一個(gè)URL上去。示例: ScriptAlias /codeview/ "E:/viewvc/bin/cgi/" 重啟Apache,即可通過(guò)URL:http://localhost/codeview/viewcvs.cgi訪問(wèn)所配置的代碼倉(cāng)庫(kù)。 <!--[if !supportLists]-->8. <!--[endif]-->總結(jié)
安裝配置viewvc涉及到眾多依賴軟件和參數(shù),如果以Apache CGI方式運(yùn)行viewvc同時(shí)Apache作為Windows Service運(yùn)行修改配置后可能需要重啟Windows才能生效。另外,如果viewvc運(yùn)行不正常,常見(jiàn)的錯(cuò)誤是CVS,SVN的代碼倉(cāng)庫(kù)位置不正確,或者使用到了highlight,cvsgraph沒(méi)有制定正確的路徑。 |
|
來(lái)自: ekylin > 《軟件技術(shù)》