Almost everyone who works with version control systems (VCS) feels the need, sooner or later, for a graphical interface, because sometimes a GUI makes your life easier. ViewVC is a full-featured browser interface that's portable as can be, given the design choice (web-based) and the programming language (Python). It was originally created for CVS users and later extended to support Subversion as well.
You need to install ViewVC on a server on your network. My choice for the server is a x86_64 machine running CentOS 6.2, which will host both the web server and read-only copies of one CVS and one Subversion repository, since ViewVC needs physical access to repositories. I will presume that you already have the operating system installed. To install the Apache web server, just run yum install httpd as root.
yum install httpd
Before configuring the ViewVC web interface, you need the CVS and Subversion repositories in place. Let's suppose you want to work on porting some feature from FreeBSD and NetBSD to Linux. The former uses Subversion for anonymous access to its source code, while the latter uses CVS. Let's make sure we have all the packages in place:
What's in a Name?ViewVC was initially called ViewCVS, but when it was expanded to support Subversion, the developers changed the name.
yum install cvs subversion viewvc
Alternatively, you can install ViewVC from source. After unpacking the tarball, run the viewvc-install script, which asks where you want to install the application. After I chose /usr/local/viewvc-1.1.13, which is the same version and place CentOS uses when you get ViewVC via the RPMForge repository, the script did the rest of the job. You can put the files anywhere, but unless you have a good reason to change, stay with the default, /usr/local.
Next, you can check out the FreeBSD source tree with the command svn co svn://svn.freebsd.org/base/stable/9 /usr/src. Since we are doing this just to have access to the source code, not for actually compiling the system, I suggest changing the destination directory from /usr/src to a location in your home directory.
svn co svn://svn.freebsd.org/base/stable/9 /usr/src
Once FreeBSD is ready, it's NetBSD's turn. Again, create a directory inside your $HOME and check out to there:
cvs -email@example.com:/cvsroot -r netbsd-5 co src # after you changed to the destination directory
Now we're ready to configure ViewVC. If you installed it from the package CentOS provides, you can find the ViewVC files by typing rpm -ql viewvc | less at a terminal. Regardless of the files' location, you should have the source code downloaded and unpacked somewhere convenient so you can have access to the installation documentation, especially since the CentOS RPM doesn't seem to offer any man or info pages. One particular document you should read is the INSTALL file, which, besides installation instructions, offers useful tips and troubleshooting info.
rpm -ql viewvc | less
Make sure you also have installed the rcs and diffutils RPMs. You also need Python, but since yum is Python-based, you presumably already have Python installed even on the most minimal of installations. Optionally, you might want to install MySQL for creating a database of available commits, and Enscript for nice, colorized output of your code. If you choose not to use Apache as a web server, make sure your web server of choice supports CGI.
In ViewVC's bin/ directory, find the executable Python script named standalone.py, which you can run to do some preliminary testing:
cd /usr/local/viewvc-1.1.13 # change this to reflect your location./bin/standalone.py -r /home/user/mycvsrepository # same as above
The link to the standalone test web server will be given to you after the script starts. Pay attention, however: In 1.1.13 the port it runs on is 49152, but the documentation says the port is 7467.
Now you can configure ViewVC and the web server, in that order. I used /usr/local/ (the default) for ViewVC and Apache as the web server, so all ViewVC file locations and web server config options below are oriented around those two variables.
Edit /usr/local/viewvc-1.1.13/viewvc.conf to modify a few items. It is a well-commented file, so you will not feel lost. The main variables that have to be edited, and sometimes uncommented, are the ones that tell ViewVC about the locations of the files it needs for CVS, Subversion, RCS, and so on. For instance:
# BASIC CONFIGURATION## For correct operation, you will probably need to change the following# configuration variables:## cvs_roots (for CVS)# svn_roots (for Subversion)# root_parents (for CVS or Subversion)# default_root# rcs_path or cvsnt_exe_path# mime_types_file
The first two variables, the ones ending in _roots, point ViewVC toward the CVS and Subversion repositories, which in our case are /home/user/netbsd and /home/user/freebsd. Adjust to taste, of course. root_parents only makes sense if, unlike our case, you have more than one repository contained in a directory; for example, if the netbsd/ directory contained the system sources and the pkgsrc tree, which allows NetBSD users to install third-party software from source. This option refers to multiple containers, which helps you not have to add or take away entries from *_roots. default_root makes sense only if root_parents is uncommented. For example, if
root_parents = /home/user/svnrepos : svn /home/user/cvsrepos : cvs
then default_root can be svn or cvs, depending on your choice.
rcs_path needs to be uncommented only if the RCS executable is not in /usr/bin. Since we're using CentOS and installed rcs from a package, the executable is there, so this option remains commented. The same applies to other _path variables: Leave them commented if the executables they refer to are in /usr/bin. The last variable, mime_types_file, has a default value that makes sense on systems where you install from source. If you did, uncomment it and set the value that makes sense on your system. I recommend you take a look inside /etc first if you installed from packages.
Depending on how you want to use ViewVC, you might want to change the address variable, which points to the contact information for the repositories maintainer. You can also configure the database back end, should you need it. Make sure you have MySQL up and running with basic access set up, then search the viewvc.conf file for the [cvsdb] section. Make sure it reads enabled = 1 and configure the data for the database, such as host, user, port, and password.
enabled = 1
All that's left now is configuring Apache to support CGI and to follow symlinks. The latter part is optional if you want to create a symbolic link from ViewVC's installation directory to a location Apache is configured to know about for CGI scripts. The documentation (check the "APACHE CONFIGURATION" section) offers more than one method of letting Apache know about scripts; I prefer the first. Find the configuration file for Apache (on CentOS 6 it's /etc/httpd/conf/httpd.conf) and insert the following in the section where you see other ScriptAlias directives:
ScriptAlias /viewvc /usr/local/viewvc-1.1.13/bin/cgi/viewvc.cgi
If you need other CGI acripts from ViewVC, just add other lines similar to the one above.
Now you're finally all set up. Point your browser to http://webservers.addr.ess/viewvc to take advantage of the example above. You'll find using ViewVC is simple. The application offers colorized output, panes, side-by-side differences, and much more.
Since ViewVC's purpose in life is to show you the files from a CVS or SVN repository in a web browser via a web server, you might wonder: What if your repository contains HTML files? Those HTML files will be accesible under ViewVC just as if they were part of your website, with links and references, making your site writable by anyone with commit access to the repositories. The workaround suggested by the developers involves adding two lines of code to lib/viewvc.py that will return a "403 Forbidden" error when someone tries to open files in checkout mode:
def view_checkout(request):>> raise debug.ViewVCException('Checkout view is disabled',>> '403 Forbidden') path, rev = _orig_path(request) fp, revision = request.repos.openfile(path, rev)
Fortunately, this seems to be a problem only to versions prior to 1.1.13; from that version on, blocking write access is the default behavior.
ViewVC makes for a nice small to medium-size development environment for work on projects more oriented toward reading and viewing than editing, or even for a single developer. It provides a good way to compare source code, be it revisions of the same code or different implementations.
Allowed tags: <a> link, <b> bold, <i> italics