Index: versioncontrol.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/versioncontrol/versioncontrol.module,v
retrieving revision 1.206
diff -u -p -r1.206 versioncontrol.module
--- versioncontrol.module	18 Feb 2011 00:45:52 -0000	1.206
+++ versioncontrol.module	19 Feb 2011 07:30:21 -0000
@@ -132,6 +132,15 @@ function versioncontrol_theme() {
     'arguments' => array('places', 'results'),
     'file' => 'includes/versioncontrol_theme.inc'
   );
+  $theme['versioncontrol_revision_items'] = array(
+    'arguments' => array('values' => NULL),
+    'file' => 'includes/versioncontrol_theme.inc',
+    'template' => 'versioncontrol_revision_items',
+  );
+  $theme['versioncontrol_revision_items_summary'] = array(
+    'arguments' => array('values' => NULL),
+    'file' => 'includes/versioncontrol_theme.inc',
+  );
   return $theme;
 }
 
Index: versioncontrol_revision_items.tpl.php
===================================================================
RCS file: versioncontrol_revision_items.tpl.php
diff -N versioncontrol_revision_items.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ versioncontrol_revision_items.tpl.php	19 Feb 2011 07:30:21 -0000
@@ -0,0 +1,14 @@
+<div class="views-row views-row-<?php print $values['counter']; ?> views-row-<?php print $values['stripe']; ?>">
+
+  <div class="views-field-path">
+                <span class="field-content"><?php print $values['path']; ?></span>
+  </div>
+
+  <div class="views-field-changed-lines">
+                <span class="field-content"><?php print $values['lines_changed']; ?></span>
+  </div>
+
+  <div class="views-field-visual-diffstat">
+                <span class="field-content"><?php print $values['diffstat']; ?></span>
+  </div>
+</div>
Index: includes/versioncontrol_theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/versioncontrol/includes/versioncontrol_theme.inc,v
retrieving revision 1.3
diff -u -p -r1.3 versioncontrol_theme.inc
--- includes/versioncontrol_theme.inc	18 Feb 2011 00:45:52 -0000	1.3
+++ includes/versioncontrol_theme.inc	19 Feb 2011 07:30:21 -0000
@@ -26,3 +26,16 @@ function theme_versioncontrol_diffstat($
   }
   return '<span class="versioncontrol-diffstat clear-block">'. $output .'</span>';
 }
+
+function versioncontrol_preprocess_versioncontrol_revision_items($vars) {
+}
+
+function theme_versioncontrol_revision_items_summary($rows) {
+  $output = '';
+  foreach ($rows as $index => $row) {
+    $row['counter'] = $index + 1;
+    $row['stripe'] = ($row['counter'] % 2) ? 'odd' : 'even';
+    $output .= theme('versioncontrol_revision_items', $row);
+  }
+  return $output;
+}
Index: includes/views/versioncontrol.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/versioncontrol/includes/views/versioncontrol.views.inc,v
retrieving revision 1.30
diff -u -p -r1.30 versioncontrol.views.inc
--- includes/views/versioncontrol.views.inc	18 Feb 2011 23:56:38 -0000	1.30
+++ includes/views/versioncontrol.views.inc	19 Feb 2011 07:30:21 -0000
@@ -287,6 +287,14 @@ function versioncontrol_views_data() {
     ),
   );
 
+  $data['versioncontrol_operations']['versioncontrol_handler_field_item_revision_summary'] = array(
+    'field' => array(
+      'title' => t('Item revisions summary'),
+      'help' => t('Summary of all item revisions corresponding to the operation.'),
+      'handler' => 'versioncontrol_handler_field_item_revision_summary',
+    ),
+  );
+
   $data['versioncontrol_operations']['revision'] = array(
     'title'    => t('Revision'),
     'help'     => t('The Operation Revision Identifier'),
@@ -366,6 +374,8 @@ function versioncontrol_views_data() {
       'type' => 'LEFT',
     ),
   );
+
+
   $data['users']['table']['join']['versioncontrol_operations'] = array(
     'left_field' => 'author_uid',
       'field'      => 'uid',
@@ -629,6 +639,9 @@ function versioncontrol_views_handlers()
       'versioncontrol_handler_field_operation_labels' => array(
         'parent' => 'views_handler_field',
       ),
+      'versioncontrol_handler_field_item_revision_summary' => array(
+        'parent' => 'views_handler_field',
+      ),
       // filter handlers
       'versioncontrol_handler_filter_operation_type' => array(
         'parent' => 'views_handler_filter_in_operator',
Index: includes/views/handlers/versioncontrol_handler_field_item_revision_path.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/versioncontrol/includes/views/handlers/versioncontrol_handler_field_item_revision_path.inc,v
retrieving revision 1.2
diff -u -p -r1.2 versioncontrol_handler_field_item_revision_path.inc
--- includes/views/handlers/versioncontrol_handler_field_item_revision_path.inc	19 Feb 2011 00:22:13 -0000	1.2
+++ includes/views/handlers/versioncontrol_handler_field_item_revision_path.inc	19 Feb 2011 07:30:21 -0000
@@ -78,7 +78,7 @@ class versioncontrol_handler_field_item_
         $link = $url_handler->getItemViewUrl($item_revision);
     }
     if (!empty($link)) {
-      return l(check_plain($path), $link);
+      return l($path, $link);
     }
     return check_plain($path);
   }
Index: includes/views/handlers/versioncontrol_handler_field_item_revision_summary.inc
===================================================================
RCS file: includes/views/handlers/versioncontrol_handler_field_item_revision_summary.inc
diff -N includes/views/handlers/versioncontrol_handler_field_item_revision_summary.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/views/handlers/versioncontrol_handler_field_item_revision_summary.inc	19 Feb 2011 07:30:21 -0000
@@ -0,0 +1,139 @@
+<?php
+// $Id$
+class versioncontrol_handler_field_item_revision_summary extends views_handler_field {
+  public $backends = NULL;
+  public $repos = array();
+  public $itemRevisions = array();
+  public $ops = array();
+
+  function construct() {
+    parent::construct();
+    $this->backends = versioncontrol_get_backends();
+
+    $this->additional_fields['repo_id'] = 'repo_id';
+    $this->additional_fields['vc_op_id'] = 'vc_op_id';
+    $this->additional_fields['vcs'] = array('table' => 'versioncontrol_repositories', 'field' => 'vcs');
+  }
+
+  /**
+   * Get a repository of the @param $vcs type.
+   */
+  function getRepository($vcs, $repo_id) {
+    if (!isset($this->repos[$repo_id])) {
+      $this->repos[$repo_id] = $this->backends[$vcs]->loadEntity('repo', array($repo_id));
+    }
+    return $this->repos[$repo_id];
+  }
+
+  /**
+   * Get an item revision.
+   */
+  function getItemRevision($vcs, $item_revision_id) {
+    if (!isset($this->itemRevisions[$item_revision_id])) {
+      $this->itemRevisions[$item_revision_id] = $this->backends[$vcs]->loadEntity('item', array($item_revision_id));
+    }
+    return $this->itemRevisions[$item_revision_id];
+  }
+
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $form['link_type'] = array(
+      '#type' => 'radios',
+      '#title' => t('Where to link at the repository browser'),
+      '#default_value' => $this->options['link_type'],
+      '#options' => array(
+        'view' => t('Item content'),
+        'log' => t('Item log history'),
+      ),
+    );
+    $form['places'] = array(
+      '#type' => 'select',
+      '#title' => t('Select how many places should be displayed'),
+      '#options' => array(3 => 3, 5 => 5, 7 => 7, 9 => 9),
+      '#default_value' => $this->options['places'],
+    );
+  }
+
+  function pre_render($values) {
+    $repo_ids = array();
+    $op_ids = array();
+    $vcs_backends = array();
+    // Get all the IDs that we care about.
+    foreach ($values as $result) {
+      $vcs = $result->{$this->aliases['vcs']};
+      $vcs_backends[] = $vcs;
+
+      $op_ids[$vcs][] = $result->{$this->aliases['vc_op_id']};
+      $repo_ids[$vcs][] = $result->{$this->aliases['repo_id']};
+      $this->ops[$result->{$this->aliases['vc_op_id']}] = array();
+    }
+    // Load all repos
+    foreach ($vcs_backends as $vcs) {
+      $this->itemRevisions += $this->backends[$vcs]->loadEntities('item', array(), array('vc_op_id' => $op_ids[$vcs]));
+      $this->repos += $this->backends[$vcs]->loadEntities('repo', $repo_ids[$vcs]);
+    }
+
+    // Map itemRevisions to operations
+    foreach ($this->itemRevisions as $item_revision_id => $item_revision) {
+      $this->ops[$item_revision->vc_op_id][$item_revision_id] = $item_revision;
+    }
+  }
+
+  function render($values) {
+    $rows = array();
+
+    // Get all the items that match this op
+    $item_revisions = $this->ops[$values->{$this->aliases['vc_op_id']}];
+    foreach ($item_revisions as $item_revision) {
+      // Get the path and link
+      $repo = $this->repos[$item_revision->repo_id];
+      $url_handler = $repo->getUrlHandler();
+      $link_type = !empty($this->options['link_type']) ? $this->options['link_type'] : 'view';
+      switch ($link_type) {
+        case 'log':
+          $link = $url_handler->getItemLogViewUrl($item_revision);
+        case 'view':
+        default:
+          $link = $url_handler->getItemViewUrl($item_revision);
+      }
+      if (!empty($link)) {
+        $path = l($item_revision->path, $link);
+      }
+      else {
+        $path = check_plain($item_revision->path);
+      }
+
+      // Get addition/deletions
+      $additions = format_plural($item_revision->line_changes_added, '1 addition', '@count additions');
+      $removals = format_plural($item_revision->line_changes_removed, '1 deletion', '@count deletions');
+      $lines_changed =  t('!addition & !removal', array('!addition' => $additions, '!removal' => $removals));
+
+      // Get the diffstat
+      module_load_include('inc', 'versioncontrol', 'includes/views/handlers/versioncontrol_handler_field_item_revision_visual_diffstat');
+      $diffstat_handler = new versioncontrol_handler_field_item_revision_visual_diffstat;
+      $diffstat_handler->options['places'] = $this->options['places'];
+      $diffstat_handler->aliases['line_changes_added'] = 'added';
+      $diffstat_handler->aliases['line_changes_removed'] = 'removed';
+
+      $diffstat_values = new stdClass;
+      $diffstat_values->added = $item_revision->line_changes_added;
+      $diffstat_values->removed = $item_revision->line_changes_removed;
+
+      $diffstat = $diffstat_handler->render($diffstat_values);
+
+      $rows[] = array(
+        'path' => $path,
+        'lines_changed' => $lines_changed,
+        'diffstat' => $diffstat,
+      );
+
+    }
+
+    return theme('versioncontrol_revision_items_summary', $rows);
+  }
+}
