This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new!

Feature: Tools & Utilities

Browse all your source code revisions with ViewVC

By David Pendell on December 02, 2008 (8:00:00 PM)

Share    Print    Comments   

For programmers on big projects, a version control system for managing source code is vital, but working on files in a large project from one of these programs' command-line interfaces is cumbersome. Worse, the results of the commands lack highlighting to show the differences between files and revisions. ViewVC is a handy browser-based code viewer that allows users to browse a source code tree managed by either CVS or Subversion, look at changes, compare revisions at the file or line level, and perform other operations -- just about anything except allow users to check out or commit files.

You can install ViewVC from a repository in Ubuntu, Gentoo, Fedora, and other distributions. If there is not a package available for your distro you can download the source code. You'll also need to install Apache2, Subversion or CVS, lib-apache2-mod-python, GNU diff, MySQL and for those using CVS, CvsGraph.

In Ubuntu, ViewVC is installed in /usr/lib/viewvc/ and the main executable is in /usr/lib/cgi-bin/. In order to make Apache recognize ViewVC, you must add the following line to /etc/apache2/httpd.conf:

ScriptAlias /viewvc/ /usr/lib/cgi-bin/

You must also edit /etc/viewvc/viewvc.conf and change the following lines by adding the highlighted information:

svn_roots = svnroot: /path/to/svn/repository #for Subversion cvs_roots = cvs: /home/cvsroot #for CVS address = &lt a href="" &gt youremail at yourservice dot com &lt /a &gt

Note: svnroot: and cvs: in the above lines will be the repository names as far as ViewVC is concerned, and they can be whatever you want. Unless you are going to use both Subversion and CVS, comment out the line for the service that you are not using with a #.

Finally, run the command sudo /etc/init.d/apache2 restart to restart Apache. You should then be ready to browse through your source code. Note: Due to differences in terminology, I will be referring to tag/branches from CVS as revisions for the sake of brevity.

Browsing the repo

To begin browsing the repo that you configured above, open a Web browser and type enter http://localhost/viewvc/viewvc.cgi. You will see a very basic page that contains one of two Web links: cvs and svnroot. Click on the service you are using to display a summary of your project. The revision information will reflect what Subversion or CVS reports, including the age, author, and last log entry. A link that allows you download the entire project appears on every page that has a directory on it, along with a link to download source code that is just in the current directory. At the bottom of every page is a link for help on the repository Web server. At the top you'll see a link to the project path that you are viewing and a dropdown box that allows you to switch between repositories -- even when one repository is managed by CVS and another by Subversion.

Click on the project link. Once you have opened the page that has the repository, the links will follow the directory structure of the versioning system that you are using. For instance, Subversion generally has a directory called "trunk" that comes before the project directory. Once you're at the root directory of your project, you should see information about files, directories, revision numbers, ages, authors, and log entries that reflect the way Subversion and CVS handle the files in question. If you click on a file that shows several revisions, you'll bring up a log of its revisions. You can then view, download, annotate, or compare revisions. Click on the view link to see a complete view of the file at a given revision, or Download to download it. Annotate will show the entire file along with the changes made at each revision. Select For Diffs will cause the page to refresh with the selected revision number in the first field at the bottom of the page. The options for difference highlighting are Colored Diff, which shows only the snippets of code that have changed in any of several styles; Long Colored Diff, which shows the entire file with changes highlighted; Unidiff, which shows a listing of the changes in a Patch-compatible format; Context Diff, which shows another patch file, this time with context information shown; and Side by Side, which shows the revisions side by side.

In the colored diff selections you will see numbered links that show changes in the revisions, along with the author who made the changes and links to each revision. There are also links to the Parent Directory, the Revision Log for this file, and a link that will allow the user to download a Patch file for this particular revision.

On the file's revision log page, another link lets users jump directly to a colored diff page for each revision. The link shows a description of what the shortcut will show, and whether it is one of the previous revisions or the revision that you "select[ed] for diffs." Also on this page is a field that allow the user to select a revision to make it "sticky" so that this and other pages that show revisions, such as the index of the project, will only show up to the revision selected. This is useful for working with views that default to a particular revision.

If you are engaged in a project with lots of revisions, the command-line tools in both Subversion or CVS can be annoying and time-consuming to work with. ViewVC streamlines the process of source code browsing and highlighting. While not a replacement for command-line utilities, the ability to browse source code repositories is a real boon to developers, team leads, and managers. ViewVC provides a fast and easy way to browse source code and differences between revisions.

David Pendell has been working with computers for the last 23 years in a variety of capacities, including for programming and audio and video processing. He has been using Linux since Red Hat 5.1 and has used a variety of distros.

Share    Print    Comments   


on Browse all your source code revisions with ViewVC

Note: Comments are owned by the poster. We are not responsible for their content.

Try Sventon

Posted by: Anonymous [ip:] on December 02, 2008 09:53 PM
The requirement of having a database is somewhat of a downside for these browsing applications. All the revisions and source are already in the repository, why do we need yet another storage mechanism to track them? I would suggest that ViewVC, while useful, can be replaced by Sventon.


Re: Try Sventon

Posted by: Anonymous [ip:] on December 03, 2008 06:59 AM
Actually, you don't need a database for ViewVC; I've never had one connected to it, and I've been using ViewVC for about three years now.

However, if you add the database support, ViewVC will store every commit into a database much like the one used by Bonsai over at the Bugzilla project. The main advantage of this is that you can do queries by project a lot more easily... and ViewVC will provide RSS feeds based on the database queries, so others can easily watch the updates.


Browse all your source code revisions with ViewVC

Posted by: Anonymous [ip:] on December 02, 2008 11:20 PM
Why using a server if you can get all the project history local?
Just clone the svn repo with git-svn and you have a _really_ sophisticated source browser with all tools coming with git.

mercurial or e.g bzr might do just as good, though don't know about their importer quality.


Browse all your source code revisions with ViewVC

Posted by: Anonymous [ip:] on December 03, 2008 12:09 PM
ViewVC should add a security layer so that the CVS can be viewed by authorised users.

Doesn't SVN provide http based code browsing by default?


Change all your source code with Fram

Posted by: Anonymous [ip:] on December 03, 2008 10:55 PM
If all bugs are shallow given enough eyeballs, why not let people who spot them fix them in their browser right away? With Fram you can write both the explanation and the code at the same time in a regular Mediawiki article and then extract the code as needed. Just like Wikipedia. It's a promising concept, yet needs some more work to be really usable - take a look at



Re: Change all your source code with Fram

Posted by: Anonymous [ip:] on December 03, 2008 11:01 PM
Sorry, the link above became broken - try



Posted by: Anonymous [ip:] on December 04, 2008 08:13 PM

[Modified by: Nathan Willis on December 04, 2008 05:57 PM]


Posted by: Anonymous [ip:] on December 05, 2008 12:28 AM

[Modified by: Nathan Willis on December 05, 2008 08:49 AM]


Browse all your source code revisions with ViewVC

Posted by: Anonymous [ip:] on December 20, 2008 11:22 PM
ViewVC looks a but un-polished, we have been using websvn and finding it quite nice


This story has been archived. Comments can no longer be posted.

Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya