OpenGrok

OpenGrok is a fast and usable source code search and cross reference engine. It helps you search, cross-reference and navigate your source tree. It can understand various program file formats and version control histories.

Perforce History Reader

I have added a Perforce History Reader to OpenGrok 0.6.1 I am going to propose it for inclusion in the mainline distribution(Done).

Configuration

All the P4 configuration (ie: P4CLIENT, P4USER, …) is supposed to be stored in a P4CONFIG file.

If you name it ”.p4config”, it will be automatically excluded by the OpenGrok indexer.

Testing

This guide tells you how to get a Perforce client and server up and running in a matter of minutes. This is a summary of the following official Perforce documentation:

1) We need to dowload the perforce client (P4: Command-Line Client) and server (P4D: Server) for our plaltform. All the most common platforms are supported (Windows, Linux, Macintosh, Solaris, FreeBSD, etc):

For example, in my case (Ubuntu 8.04):

2) Make the programs executable and copy them in the bin directory:

chmod +x p4
sudo mv p4 /usr/local/bin/
chmod +x p4d
sudo mv p4d /usr/local/bin/

Check that the p4 client is correctly installed:

$ p4 -V
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2008 Perforce Software.  All rights reserved.
Rev. P4/LINUX26X86/2008.1/158777 (2008/07/09).

3) P4 needs to know the name of the config file containing the settings of the view on the depot. The name of the configuration file is stored in the environmental variable P4CONFIG. In theory we could choose any name for the configuration file. I have added the most common one to the OpenGrok ignored names: .p4config

Just as a reminder, in Ubuntu you need to append the following line to /etc/profile:

export P4CONFIG=.p4config

4) Before starting the server, we want to install the Perforce sample depot:

In our example we will unzip it in the following directory: /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server

To create the database launch the following command:

cd PerforceSample
p4d -r /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server/PerforceSample -jr /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server/PerforceSample/checkpoint

You will see the message:

Perforce db files in '/home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server/PerforceSample' will be created if missing...
Recovering from /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server/PerforceSample/checkpoint...

Your Perforce database is now installed.

To ensure that the database format is consistent with the Perforce Server version that you are using, issue the following command:

p4d -r /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server/PerforceSample -xu

You will see the message:

2007.3: (re)building haveMap from db.have/db.working.
2007.3: (re)building db.archmap (lazy-copy map) table.
2007.3: removing old db.archive.
2008.1: upgrading db.change.
...upgrades done

5) Start the Perforce Server:

p4d -r /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/server/PerforceSample -p 1492 -d
When the server starts, it displays the message “Perforce Server starting…”. The Perforce Server is now started and listening for client connections on port number 1492.

6) We are now ready to use Perforce Sample Depot! Let's create our first client in: /home/emilmont/Software/opengrok-dev/testdata/repositories/perforce/client Create a file named “.p4config”, with the following content:

P4CLIENT=opengrok_test
P4PORT=localhost:1492

Create the client:

p4 client

This puts you in the editor. Just save and quit—the defaults are fine.

To syncronize your client with the depot:

p4 sync ...

Annotation with revision description

In the “Annotate” view, it would be nice to have a pop-up window with the “revision description text” when you hover a “revision number” .

Basically, this requires to add an HashMap (key:revision, value:description) to the “Annotation” class, this doesn't require big changes on the History Parsers, they can decide to fill or not this new field, if the HashMap is not filled there will be no pop-up window. This usually requires to make two different queries to the depot for each “annotate” request: one for the usual annotation and one to get the filelog.

This “Annotate” view page, will require to include a fixed javascript and the dynamically generated HashMap.

I think this is useful, because when I want to see an annotated source file, I want to know why a line was changed.

NOTE: This feature is currently implemented only for Perforce

Annotation with revision description

Download

Until the code for these features is not included in the mainline distribution, you can download it from here.

java/opengrok.txt · Last modified: 2010/08/12 by emilmont
CC Attribution-Noncommercial-Share Alike 3.0 Unported
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0