From 55a42b68dbfcd18e697df4cb68db00299e719b4e Mon Sep 17 00:00:00 2001
From: Marco Villegas <marvil07@gmail.com>
Date: Wed, 19 Jan 2011 16:31:16 -0500
Subject: [PATCH] task #1024960 follow-up: Need view for individual commit message.

- Add an argument for filter by repository in the individual_commit_view.
- Modify the link shown on operation date handler.
---
 commitlog/commitlog.module                         |   13 +++--
 .../commitlog_individual_commit.view.php           |   59 +++++++++++++------
 ...versioncontrol_handler_field_operation_date.inc |    4 +-
 3 files changed, 51 insertions(+), 25 deletions(-)

diff --git commitlog/commitlog.module commitlog/commitlog.module
index 614d552..4637fa6 100644
--- commitlog/commitlog.module
+++ commitlog/commitlog.module
@@ -37,10 +37,10 @@ function commitlog_menu() {
     'access arguments' => array($view_access),
     'type' => MENU_SUGGESTED_ITEM,
   );
-  $items['commitlog/commit/%'] = array(
+  $items['commitlog/commit/%/%'] = array(
     'title' => 'Commit',
     'page callback' => 'commitlog_operations_page',
-    'page arguments' => array('commit', 2),
+    'page arguments' => array('commit', 2, 3),
     'access arguments' => array($view_access),
     'type' => MENU_SUGGESTED_ITEM,
   );
@@ -101,8 +101,10 @@ function commitlog_ctools_plugin_directory($module, $plugin) {
  *   What type of commit log listing we're creating.  Supported types are 'author' and 'repository'.
  * @param $argument
  *   The argument with which to filter the view.  This is used as the first argument in the view in question.
+ * @param $argument2
+ *   Another argument to filter the view.  This is used as the second argument in the view in question.
  */
-function commitlog_operations_page($type = NULL, $argument = NULL) {
+function commitlog_operations_page($type = NULL, $argument = NULL, $argument2 = NULL) {
   drupal_add_css(drupal_get_path('module', 'commitlog') . '/commitlog.css', 'module');
 
   $view = '';
@@ -120,9 +122,10 @@ function commitlog_operations_page($type = NULL, $argument = NULL) {
     $set = versioncontrol_get_views_set('repository_commit_view');
     $view = $set->getViewNameByEntity(versioncontrol_repository_load($argument));
   }
-  else if ($type == 'commit' && !is_null($argument)) {
+  else if ($type == 'commit' && !is_null($argument) && !is_null($argument2)) {
     $set = versioncontrol_get_views_set('individual_commit_view');
-    $view = $view = $set->getViewName();
+    $view_name = $set->getViewName();
+    return views_embed_view($view_name, 'default', $argument, $argument2);
   }
   else {
     $set = versioncontrol_get_views_set('global_commit_view');
diff --git commitlog/includes/views/default_views/commitlog_individual_commit.view.php commitlog/includes/views/default_views/commitlog_individual_commit.view.php
index 3cfaa4e..ca2badf 100644
--- commitlog/includes/views/default_views/commitlog_individual_commit.view.php
+++ commitlog/includes/views/default_views/commitlog_individual_commit.view.php
@@ -300,7 +300,7 @@ $handler->override_option('sorts', array(
   ),
 ));
 $handler->override_option('arguments', array(
-  'revision' => array(
+  'repo_id' => array(
     'default_action' => 'not found',
     'style_plugin' => 'default_summary',
     'style_options' => array(),
@@ -312,6 +312,44 @@ $handler->override_option('arguments', array(
     'default_argument' => '',
     'validate_type' => 'none',
     'validate_fail' => 'not found',
+    'break_phrase' => 0,
+    'not' => 0,
+    'id' => 'repo_id',
+    'table' => 'versioncontrol_repositories',
+    'field' => 'repo_id',
+    'validate_user_argument_type' => 'uid',
+    'validate_user_roles' => array(
+      '2' => 0,
+    ),
+    'relationship' => 'none',
+    'default_options_div_prefix' => '',
+    'default_argument_fixed' => '',
+    'default_argument_user' => 0,
+    'default_argument_php' => '',
+    'validate_argument_node_type' => array(
+      'page' => 0,
+      'story' => 0,
+    ),
+    'validate_argument_node_access' => 0,
+    'validate_argument_nid_type' => 'nid',
+    'validate_argument_vocabulary' => array(),
+    'validate_argument_type' => 'tid',
+    'validate_argument_transform' => 0,
+    'validate_user_restrict_roles' => 0,
+    'validate_argument_php' => '',
+  ),
+  'revision' => array(
+    'default_action' => 'not found',
+    'style_plugin' => 'default_summary',
+    'style_options' => array(),
+    'wildcard' => 'all',
+    'wildcard_substitution' => 'All',
+    'title' => 'Revision %1',
+    'breadcrumb' => '',
+    'default_argument_type' => 'fixed',
+    'default_argument' => '',
+    'validate_type' => 'none',
+    'validate_fail' => 'not found',
     'glossary' => 0,
     'limit' => '0',
     'case' => 'none',
@@ -323,12 +361,6 @@ $handler->override_option('arguments', array(
     'validate_user_argument_type' => 'uid',
     'validate_user_roles' => array(
       '2' => 0,
-      '3' => 0,
-      '4' => 0,
-      '5' => 0,
-      '6' => 0,
-      '7' => 0,
-      '8' => 0,
     ),
     'relationship' => 'none',
     'default_options_div_prefix' => '',
@@ -336,23 +368,12 @@ $handler->override_option('arguments', array(
     'default_argument_user' => 0,
     'default_argument_php' => '',
     'validate_argument_node_type' => array(
-      'forum' => 0,
-      'project_project' => 0,
-      'project_release' => 0,
-      'project_issue' => 0,
-      'book' => 0,
       'page' => 0,
       'story' => 0,
     ),
     'validate_argument_node_access' => 0,
     'validate_argument_nid_type' => 'nid',
-    'validate_argument_vocabulary' => array(
-      '1' => 0,
-      '5' => 0,
-      '3' => 0,
-      '2' => 0,
-      '4' => 0,
-    ),
+    'validate_argument_vocabulary' => array(),
     'validate_argument_type' => 'tid',
     'validate_argument_transform' => 0,
     'validate_user_restrict_roles' => 0,
diff --git includes/views/handlers/versioncontrol_handler_field_operation_date.inc includes/views/handlers/versioncontrol_handler_field_operation_date.inc
index 425d391..12da3e8 100644
--- includes/views/handlers/versioncontrol_handler_field_operation_date.inc
+++ includes/views/handlers/versioncontrol_handler_field_operation_date.inc
@@ -8,6 +8,7 @@ class versioncontrol_handler_field_operation_date extends views_handler_field_da
     parent::construct();
     $this->additional_fields['revision'] = 'revision';
     $this->additional_fields['date'] = 'date';
+    $this->additional_fields['repo_id'] = 'repo_id';
   }
 
   function option_definition() {
@@ -40,7 +41,8 @@ class versioncontrol_handler_field_operation_date extends views_handler_field_da
     }
     else {
       $date_field = parent::render($values);
-      return l($date_field, 'commitlog/commit/'. $values->{$this->aliases['revision']});
+      $link = sprintf('commitlog/commit/%d/%s', $values->{$this->aliases['repo_id']}, $values->{$this->aliases['revision']});
+      return l($date_field, $link);
     }
 
   }
-- 
1.7.2.3

