Index: versioncontrol_fakevcs.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/versioncontrol/versioncontrol_fakevcs/versioncontrol_fakevcs.module,v retrieving revision 1.37 diff -u -r1.37 versioncontrol_fakevcs.module --- versioncontrol_fakevcs.module 2 Nov 2007 13:39:12 -0000 1.37 +++ versioncontrol_fakevcs.module 7 Dec 2007 17:31:34 -0000 @@ -389,6 +389,63 @@ } /** + * Implementation of [versioncontrol_backend]_get_commit_statistics(): + * Retrieve general statistics about what happened in a single commit. For more granular + * details about what happened in a single commit, use versioncontrol_get_commit_actions. + * + * @param $commit + * The commit to retrieve statistics about + * + * @return + * A structured array containing general statistics about this commit. The array will consist + * of elements with the following keys: + * + * - 'lines_added': Total number of lines added during this commit + * - 'lines_added_squared': Total of (number of lines added per action) squared, during this commit. + * Useful for calculating the standard deviation. + * - 'lines_removed': Total number of lines removed during this commit + * - 'lines_removed_squared': Total of (number of lines removed per action) squared, during this commit. + * Useful for calculating the standard deviation. + * - 'action_count': Total number of actions within this commit + */ +function versioncontrol_fakevcs_get_commit_statistics($commit) { + // Assuming $commit is a single commit array that looks like this: + $commit = array( + // The commit id, a simple running number. Doesn't have any specific + // meaning, but is necessary for indexing and joining tables. + 'commit_id' => 2345, + // The repository that was affected by this commit. + 'repository' => $affected_repository, + // The time when the commit was executed, in Unix timestamp format. + 'date' => time(), + // User id of the committer's Drupal user account. + // 0 if no corresponding account exists. + 'uid' => $user->uid, + // The committer's username known to the repository itself. In most cases + // this will probably be the name of the committer's Unix user account. + 'username' => 'jpetso', + // The deepest-level directory in the repository that is common to + // all the changed items in this commit. + 'directory' => '/', + // The commit message, which is expected to span one or more lines. + 'message' => 'All kinds of demonstrative changes.', + // The revision identifier of the commit, in the VCS's proprietary format - + // running number, SHA-1 hash, or whatever. If there is no single revision + // identifier for the whole commit (which should only be the case for CVS) + // then the value for this key is set to NULL. + 'revision' => '404', // for this commit, let's assume this is an SVN repository + ); + + return array( + 'lines_added' => 75, // 50 from one action, 20 from another, 5 from another + 'lines_added_squared' => 2925, // 50^2 + 20^2 + 5^2 + 'lines_removed' => 21, // 15 from one action, 6 from another + 'lines_removed_squared' => 261, // 15^2 + 6^2 + 'action_count' => 8, + ); +} + +/** * Implementation of [versioncontrol_backend]_get_directory_item(): * Retrieve the item of the deepest-level directory in the repository that is * common to all the changed/branched/tagged items in a commit, branch or