Description | This patch adds support to pocess daily updates from a Perforce server.
Once P4Web has been selected as the viewer tool (TODO: CDash should decouple the viewer from the VCS type, as one might want to use FishEye to browse Perforce), CDash daily updates will be fetched from the P4 Repository with a list of committers and their E-Mails. The configuration required in the [Project Settings|Repository] window is:
- Repository: The command line necessary to get to the server, connect and pass a valid client name: Example: -u username -c cdash_client -H p4server -p 1888
- Branch: The path specification to get access to the perforce branch. It's usually the client name: //cdash_client/...
This patch uses the P4 executable, which needs to be installed on the server, to access the repository. In config.php (or config.local.php) there is now the variable $CDASH_P4_COMMAND that points to the location of the p4 executable (if it's not on the system path). |
Attached Files | 0002-Daily-Updates-for-Perforce.patch [^] (5,120 bytes) 2013-10-28 17:15 [Show Content] [Hide Content]From 6febabff2480a264f7e504244c25f85334e9fcc0 Mon Sep 17 00:00:00 2001
From: Pedro Navarro <pnavarro@netflix.com>
Date: Thu, 24 Oct 2013 18:08:48 -0700
Subject: [PATCH 2/2] The Daily Updates page now queries Perforce repositories
---
cdash/config.php | 2 ++
cdash/dailyupdates.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+)
diff --git a/cdash/config.php b/cdash/config.php
index 44fde60..28046b6 100644
--- a/cdash/config.php
+++ b/cdash/config.php
@@ -136,6 +136,8 @@ $CDASH_MANAGE_CLIENTS = '0';
$CDASH_GIT_COMMAND = 'git';
// The default git directory where the bare repositories should be created
$CDASH_DEFAULT_GIT_DIRECTORY = 'git';
+// Define the p4 command
+$CDASH_P4_COMMAND = 'p4';
// Number of seconds to allow processing a single submission before resetting
$CDASH_SUBMISSION_PROCESSING_TIME_LIMIT = '450';
// Number of times to attempt processing a single submission before giving up
diff --git a/cdash/dailyupdates.php b/cdash/dailyupdates.php
index ea498ec..ef539c8 100644
--- a/cdash/dailyupdates.php
+++ b/cdash/dailyupdates.php
@@ -289,6 +289,93 @@ function get_cvs_repository_commits($cvsroot, $dates)
return $commits;
} // end get_cvs_repository_commits
+/** Get the Perforce repository commits */
+function get_p4_repository_commits($root, $branch, $dates)
+{
+ include('cdash/config.php');
+ $commits = array();
+ $users = array();
+
+ // Add the command line specified by the user in the "Repository" field
+ // of the project settings "Repository" tab and set the message language
+ // to be English
+ $p4command = $CDASH_P4_COMMAND." ".$root." -L en";
+
+ // Perforce needs the dates separated with / and not with -
+ $fromtime = str_replace("-", "/", gmdate(FMT_DATETIMESTD, $dates['nightly-1']+1));
+ $totime = str_replace("-", "/", gmdate(FMT_DATETIMESTD, $dates['nightly-0']));
+
+ // "Branch" is the file spec for the root directory of the P4 client
+ // Example: //depot/myproject/...
+ $raw_output = `$p4command changes $branch@"$fromtime","$totime" 2>&1`;
+ $lines = explode("\n", $raw_output);
+
+ // Enumerate the changelists between the two given dates and p4 describe
+ // them to get a list of files commited
+ foreach($lines as $line)
+ {
+ if(preg_match("/^Change ([0-9]+) on/", $line, $matches))
+ {
+ $raw_output = `$p4command describe -s $matches[1]`;
+ $describe_lines = explode("\n", $raw_output);
+
+ $commit = array();
+ $comment = "";
+
+ // Parse the changelist description and add each file modified to the
+ // commits list
+ foreach($describe_lines as $dline)
+ {
+ // Commit header
+ if(preg_match("/^Change ([0-9]+) by (.+)@(.+) on (.*)$/", $dline, $matches))
+ {
+ $commit['revision'] = $matches[1];
+ $commit['priorrevision'] = '';
+ $commit['comment'] = '';
+ $commit['time'] = gmdate(FMT_DATETIME,strtotime($matches[4]));
+
+ $user = $matches[2];
+ if(isset($users[$user]) && $users[$user] != '')
+ {
+ $commit['author'] = $users[$user]['name'];
+ $commit['email'] = $users[$user]['email'];
+ }
+ else
+ {
+ $raw_output = `$p4command users -m 1 $user`;
+ if(preg_match("/^(.+) <(.*)> \((.*)\) accessed (.*)$/", $raw_output, $matches))
+ {
+ $newuser = array();
+ $newuser['username'] = $matches[1];
+ $newuser['email'] = $matches[2];
+ $newuser['name'] = $matches[3];
+ $newuser['time'] = $matches[4];
+ $users[$user] = $newuser;
+
+ $commit['author'] = $newuser['name'];
+ $commit['email'] = $newuser['email'];
+ }
+ }
+ }
+ // File specification
+ else if(preg_match("/^\\.\\.\\. (.*)#[0-9]+ ([^ ]+)$/", $dline, $matches))
+ {
+ $commit['filename'] = $matches[1];
+ $commit['directory'] = remove_directory_from_filename($commit['filename']);
+ $commits[$directory."/".$filename.";".$commit['revision']] = $commit;
+ }
+ // Anything else that begins with a tab is a comment line
+ else if(strlen($dline)>0 && $dline[0] == "\t")
+ {
+ $commit['comment' ] = $commit['comment'].trim(substr($dline, 1))."\n";
+ }
+ }
+ }
+ }
+
+ return $commits;
+}
+
/** Get the GIT repository commits */
function get_git_repository_commits($gitroot, $dates, $branch, $previousrevision)
{
@@ -666,6 +753,11 @@ function get_repository_commits($projectid, $dates)
{
$new_commits = get_bzr_repository_commits($root, $dates);
}
+ else if($cvsviewer == "p4web")
+ {
+ $branch = $repositories_array["branch"];
+ $new_commits = get_p4_repository_commits($root, $branch, $dates);
+ }
else if($cvsviewer == "gitweb" || $cvsviewer == "gitorious" || $cvsviewer == "github")
{
$branch = $repositories_array["branch"];
--
1.7.10.4
|