The Subversion (SVN) sensor collects information about each revision of a file maintained in a SVN repository. The SVN sensor represents this information using the Commit sensor data type, documented in Section 25.7, “Commit”. This sensor can track file rename.
The SVN Server sensor requires Java 1.5.0 or later, Ant 1.6.5 or later, and Subversion 1.2.1 or later. It also requires an SVN URL for connection purposes. The http:, https:, and svn: protocols are supported, but the file: protocol is not. This sensor has been tested only with Subversion 1.2.1 using the svn: protocol on Windows XP. Please let us know if this sensor fails under different conditions.
Follow the instructions in Chapter 2, Client-side configuration: Tool sensor installation to set your Hackystat host and user key.
In the HackyInstaller main window, select the SVN sensor and press "Configure Selected Sensor". Figure 26.56, “ Subversion sensor installer configuration window ” shows what the configuration window should look like after the path to Ant is set, the sensor is enabled, and the "Install" button has been pressed to install the sensor.
This sensor supports the following properties and paths:
Enable SVN Sensor: This property controls whether the sensor is active or not. If not checked, the sensor will not collect or send data even if installed.
Ant home directory: This path specifies the top-level directory for Ant. The SVN sensor requires the placement of a sensor executable into Ant's lib/ directory.
Use HackyInstaller to configure the usermaps.xml file, as documented in Section 2.7, “Sensors for multi-user tools and the usermaps.xml file”.
![]() | Note |
|---|---|
The tool name in the usermaps.xml file must be "SVN". You can also specify a default user. The default user will be used if no username is present on the commit (i.e. the SVN server allows anonymous commit) or the user Hackystat account is not found through usermaps.xml. | |
The SVN sensor is written as an Ant task. Example 26.70, “Invoking the SVN sensor with ANT” illustrates an example Ant target. Section 4.15, “Measurement: Version control commits with Subversion” provides an example use of the Subversion sensor with a sample Java system called StackyHack.
Example 26.70. Invoking the SVN sensor with ANT
<target name="run">
<taskdef name="svn-sensor" classname="org.hackystat.sensor.svn.SvnSensorAntTask" />
<svn-sensor repositoryName="Local"
repositoryUrl="svn://localhost:9999/test"
userName="myUserName"
password="myPassword"
fileNamePrefix="c:/svn/project"
defaultHackystatAccountKey="defaultUserKey"
verbose="true"
fromDate="2006-01-01"
toDate="2006-05-01"
fromEmail="joe@foo.com"
toEmail="joe@foo.com"
smtpServer="smtp.foo.com"
debug="true" />
</target>
As illustrated above, the sensor accepts a variety of attributes. Below is a table describing the valid attributes.
Table 26.14. Subversion Sensor Ant Task Attributes
| Attribute | Description | Required? |
|---|---|---|
| repositoryName | SVN repository name. | Required |
| repositoryUrl | The url to the svn repository. HTTP|HTTPS|SVN protocols are supported. File protocol is not supported. | Required |
| userName | The user name to gain read access, if the SVN repository does not allow anonymous access. | Optional |
| password | The password corresponds to the user name. This attribute is ignored if userName is not set. | Optional |
| fileNamePrefix | The sensor can only retrieve the file name relative to SVN repository root. However Hackystat analysis requires fully qualified file name. The attribute allows you to specify a path to be prepended to the SVN relative file name. | Optional. |
| defaultHackystatAccountKey | For each revision, the sensor finds out the hackystat account associated with the committer, and send metrics to that account. The mapping is defined in a xml map file. Refer to "hackyKernel/sensor/usermap" package for detailed information. If the sensor cannot determine the associated Hackystat account, and if this attribute is specified, then the metrics will be sent to the default Hackystat account. In other words, if you want all commit information sent to one single account, don't define any mapping and use this attribute. | Optional. Default is no default Hackystat account. |
| verbose | If set to true, information about each file being process will be output. | Optional. Default is false. |
| fromDate | The date from which to record commit information. It must be in yyyy-MM-dd format. | Optional. If set, ToDate must also be set. If not set, only previous day's commit information if recorded. |
| toDate | The date to which to record commit information. It must be in yyyy-MM-dd format. | Optional. If set, FromDate must also be set. If not set, only previous day's commit information if recorded. |
| fromEmail | The email account of the person who would be listed in the From: field if the sensor malfunctions and an email notification is generated by the sensor. | Optional, but fromEmail, toEmail, smtpServer must be used together. |
| toEmail | The To: field of the alert message generated if the sensor malfunctions. | Optional, but fromEmail, toEmail, smtpServer must be used together. |
| smtpServer | The SMTP server used to send out alert message if the sensor malfunctions. | Optional, but fromEmail, toEmail, smtpServer must be used together. |
| debug | If set to true, information about all captured commit metrics is written to console. Note that metrics will NOT be sent to Hackystat server if debug=true. | Optional. Default is false. |
By setting up the usermaps.xml file, the SVN sensor can send SVN sensor data to the Hackystat accounts associated with a set of users. This SVN data will contain a fully qualified file name that starts with the fileNamePrefix. In the above example invocation of the SVN sensor listed above, the fileNamePrefix is "c:\svn\project".
In order for this SVN data to be associated with a Hackystat project, each user's Workspace Root must be set correctly for the SVN data. In most cases, this means that each user must login to the Hackystat server, go to the Preferences page, and use the Workspace Roots command to add the fileNamePrefix value as one of their workspace roots. (This prefix value will not appear in the set of possible Workspace Roots until after some SVN data has been sent to the user's account.) For more details on Workspace Roots, see Section 3.3, “Overview of Workspaces, WorkspaceFiles, and Workspace Roots”.
The typical way to invoke the Subversion sensor is to use an operating system facility to run your script once a day at a convenient time, and configure the sensor to capture the previous day's commits. In Unix, the facility is called "cron", in Windows, the facility is called "Scheduled Tasks" and is found in the Control Panel. Each day when it runs, it will process all commit data from the previous day. Thus, you will need to wait a day to see commit data show up in your Hackystat analyses.
The sensor can also be configured to capture commit information between any arbitrary period by specifying 'fromDate' and 'toDate' attributes. This is useful when you want to recover historical commit records. The sensor is written in such a way that it is safe to run multiple times for the same period. There will be no duplicated commit records.
The first step in troubleshooting your sensor installation is to verify that your Hackystat host and key settings are valid and that you can contact the Hackystat server, as described in Section 2.4, “HackyInstaller GUI: Setting and verifying the Hackystat host and user key”
The SVN sensor will cache data locally if it cannot find the user associated with an account and no default user is supplied. If you are obtaining the error message that the data is cached locally, be sure that you are supply a default user (the defaultHackystatAccountKey).
The SVN sensor writes out a file called SVN.0.log to the .hackystat/logs directory that can be useful in debugging your installation. Under normal conditions, this file should look similar to Example 26.71, “Log file for SVN sensor”.
Example 26.71. Log file for SVN sensor
Hackystat Version: 6.4.204 (February 4 2005 14:59:29) SensorShell started at: 03/22/2005 10:12:50 Type 'help' for a list of commands. Host: http://HACKY_SERVER/ is available and key is valid. Defined shell command: Dependency Defined shell command: Issue Defined shell command: Perf Defined shell command: FileMetric Defined shell command: ReviewIssue Defined shell command: Activity Defined shell command: Cli Defined shell command: ReviewActivity Defined shell command: Coverage Defined shell command: UnitTest Defined shell command: BuffTrans Defined shell command: Commit Defined shell command: Build AutoSend not enabled. Checking for offline data to recover. No offline data found. #> Commit [setTool, Subversion] setTool OK #> Commit [add, 1111416141824, /SixthAnalysis/build.xml, todd, http://REPOSITORYURL, NA, 32, 0, 0, 0, New build file to be used as part of main build] Commit add OK (1 total)
If none of the above troubleshooting activities solves your problem, then you should send an email to your Hackystat Administrator to request help. Please include in your email the following information:
The output from 'java -version'.
The output from 'java -jar sensorshell.jar -verify'.
The contents of your sensor.properties file.
The contents of the Subversion.0.log file.
A description of the problem you are having.
To disable SVN sensor data collection temporarily, invoke HackyInstaller, bring up the SVN configuration window, and uncheck the "Enable SVN sensor" property, and apply the setting. To permanently uninstall the SVN sensor, bring up the SVN configuration window, press the "Uninstall" button, and remove the SVN sensor targets from your Ant build.xml files.