+++ includes/VersioncontrolBackend.php
@@ -44,7 +44,20 @@ abstract class VersioncontrolBackend {
 
   public $classesControllers = array();
 
-  public $controllers = array();
+  /**
+   * An array of the default views for use in the Versioncontorl API interfaces.
+   */
+  public $views = array();
+
+  /**
+   * An array of the update methods available for this backend.
+   *
+   * Currently the keys must pertain to the value of the constants used by the backend.
+   * This undermines the whole purpose of using constants so this should be reworked.
+   *
+   * TODO: Make this not use constants at all?
+   */
+  public $update_methods = array();
 
   public function __construct() {
     // Add defaults to $this->classes
@@ -66,6 +79,16 @@ abstract class VersioncontrolBackend {
       'branch'    => 'VersioncontrolBranch',
       'tag'       => 'VersioncontrolTag',
     );
+    $this->views += array(
+      'repositories' => 'versioncontrol_repositories',
+      'global commit view' => 'versioncontrol_global_commits',
+      'repository commits' => 'versioncontrol_repository_commits',
+      'user commit view' => 'versioncontrol_user_commits',
+    );
+    $this->update_methods += array(
+      0 => t('Automatic log retrieval.'),
+      1 => t('Use external script to insert data.'),
+    );
   }
 
   /**
@@ -135,4 +158,23 @@ abstract class VersioncontrolBackend {
    *   The type of entity being loaded.
    */
   public function augmentEntitySelectQuery($query, $entity_type) {}
+
+  /**
+   * Retrieves the appropriate views module view for this backend.
+   *
+   * Versioncontrol allows backends to customize the views used for the admin
+   * interface.  This method gets the appopriate one for this backend.
+   *
+   * @param $type
+   *   The type of view we are returning (eg. Repositories) 
+   *
+   * @return
+   *   The name of the view to be used.
+   */
+  public function getViewName($type) {
+    if (isset($this->views[$type])) {
+      return $this->views[$type];
+    }
+    return FALSE;
+  }
 }
diff --git includes/views/handlers/versioncontrol_handler_field_repository_actions.inc includes/views/handlers/versioncontrol_handler_field_repository_actions.inc
new file mode 100644
index 0000000..b92c8ef
--- /dev/null
+++ includes/views/handlers/versioncontrol_handler_field_repository_actions.inc
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+
+/**
+ * Views Field handler to provide repository action links.
+ */
+class versioncontrol_handler_field_repository_actions extends views_handler_field {
+
+  /**
+   * Called to add the field to a query.
+   */
+  function query() {
+    $this->ensure_my_table();
+    // Force views to load the repo_id field when this field is added so that
+    // we can appropriately build our links.
+    $this->field_alias = $this->query->add_field($this->table_alias, 'repo_id');
+    $this->add_additional_fields();
+  }
+
+  function render($values) {
+    $links = array(
+      array(
+        'title' => t('Edit'),
+        'href' => 'admin/project/versioncontrol-repositories/edit/'. $values->{$this->field_alias},
+      ),
+      array(
+        'title' => t('Delete'),
+        'href' => 'admin/project/versioncontrol-repositories/delete/'. $values->{$this->field_alias},
+      ),
+    );
+    return theme('links', $links);
+  }
+}
diff --git includes/views/handlers/versioncontrol_handler_field_repository_update_method.inc includes/views/handlers/versioncontrol_handler_field_repository_update_method.inc
index 788d1a1..65dcbf4 100755
--- includes/views/handlers/versioncontrol_handler_field_repository_update_method.inc
+++ includes/views/handlers/versioncontrol_handler_field_repository_update_method.inc
@@ -7,12 +7,20 @@
  */
 class versioncontrol_handler_field_repository_update_method extends views_handler_field {
 
-  function render($values) {
-    $data = unserialize($values->{$this->field_alias});
-    $data_holder = 
-    $data->
+  /**
+   * Called to add the field to a query.
+   */
+  function query() {
+    $this->ensure_my_table();
+    $this->field_alias = $this->query->add_field($this->table_alias, 'update_method');
+    $this->backend_alias = $this->query->add_field($this->table_alias, 'vcs');
+    $this->repo_id_alias = $this->query->add_field($this->table_alias, 'repo_id');
+    $this->add_additional_fields();
+  }
 
-    
-    return $types[$type];
+  function render($values) {
+    $update_methods = versioncontrol_get_backends($values->{$this->backend_alias})->update_methods;
+    // TODO: Add fetch now link!
+    return check_plain($update_methods[$values->{$this->field_alias}]);
   }
 }
diff --git includes/views/versioncontrol.views.inc includes/views/versioncontrol.views.inc
index 8e59460..f1da1d1 100755
--- includes/views/versioncontrol.views.inc
+++ includes/views/versioncontrol.views.inc
@@ -76,6 +76,23 @@ function versioncontrol_views_data() {
       'handler' => 'views_handler_argument_string',
     ),
   );
+  $data['versioncontrol_repositories']['update_method'] = array(
+    'title' => t("Update method"),
+    'help' => t("The method by which this repository will be updated."),
+    'field' => array(
+      'handler' => 'versioncontrol_handler_field_repository_update_method',
+      'click sortable' => TRUE,
+    ),
+  );
+
+  $data['versioncontrol_repositories']['actions'] = array(
+    'title' => t("Actions"),
+    'help' => t("Actions that can be performed on a repository."),
+    'field' => array(
+      'handler' => 'versioncontrol_handler_field_repository_actions',
+      'click sortable' => TRUE,
+    ),
+  );
   $data['versioncontrol_repositories']['root'] = array(
     'title' => t("Root Path"),
     'help' => t("The root path to the repository"),
@@ -90,6 +107,20 @@ function versioncontrol_views_data() {
       'handler' => 'views_handler_filter',
     ),
   );
+  $data['versioncontrol_repositories']['updated'] = array(
+    'title' => t("Last Updated"),
+    'help' => t("The last time the repository was updated."),
+    'field' => array(
+      'handler' => 'views_handler_field_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_date',
+    ),
+  );
   $data['versioncontrol_repositories']['table']['join'] = array(
     'versioncontrol_operations' => array(
       'left_field' => 'repo_id',
@@ -528,6 +559,12 @@ function versioncontrol_views_handlers() {
     ),
     'handlers' => array(
       // field handlers
+      'versioncontrol_handler_field_repository_update_method' => array(
+        'parent' => 'views_handler_field',
+      ),
+      'versioncontrol_handler_field_repository_actions' => array(
+        'parent' => 'views_handler_field',
+      ),
       'versioncontrol_handler_field_operation_type' => array(
         'parent' => 'views_handler_field',
       ),
diff --git includes/views/versioncontrol.views_default.inc includes/views/versioncontrol.views_default.inc
new file mode 100644
index 0000000..22d53ef
--- /dev/null
+++ includes/views/versioncontrol.views_default.inc
@@ -0,0 +1,296 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_views_default_views().
+ */
+function versioncontrol_views_default_views() {
+  /*
+   * View 'versioncontrol_repositories'
+   */
+  $view = new view;
+  $view->name = 'versioncontrol_repositories';
+  $view->description = 'VersionControl Repositories';
+  $view->tag = 'VersionControl';
+  $view->view_php = '';
+  $view->base_table = 'versioncontrol_repositories';
+  $view->is_cacheable = FALSE;
+  $view->api_version = 2;
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+  $handler = $view->new_display('default', 'Defaults', 'default');
+  $handler->override_option('fields', array(
+    'repo_id' => array(
+      'label' => 'Repository ID',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'set_precision' => FALSE,
+      'precision' => 0,
+      'decimal' => '.',
+      'separator' => ',',
+      'prefix' => '',
+      'suffix' => '',
+      'exclude' => 1,
+      'id' => 'repo_id',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'repo_id',
+      'relationship' => 'none',
+    ),
+    'name' => array(
+      'label' => 'Name',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'exclude' => 0,
+      'id' => 'name',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'name',
+      'relationship' => 'none',
+    ),
+    'vcs' => array(
+      'label' => 'Backend Type',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'exclude' => 0,
+      'id' => 'vcs',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'vcs',
+      'relationship' => 'none',
+    ),
+    'root' => array(
+      'label' => 'Root',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'exclude' => 0,
+      'id' => 'root',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'root',
+      'relationship' => 'none',
+    ),
+    'update_method' => array(
+      'label' => 'Update method',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'exclude' => 0,
+      'id' => 'update_method',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'update_method',
+      'relationship' => 'none',
+    ),
+    'actions' => array(
+      'label' => 'Actions',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'target' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'empty' => '',
+      'hide_empty' => 0,
+      'empty_zero' => 0,
+      'exclude' => 0,
+      'id' => 'actions',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'actions',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('arguments', array(
+    'vcs' => array(
+      'default_action' => 'ignore',
+      'style_plugin' => 'default_summary',
+      'style_options' => array(),
+      'wildcard' => 'all',
+      'wildcard_substitution' => 'All',
+      'title' => '',
+      'breadcrumb' => '',
+      'default_argument_type' => 'fixed',
+      'default_argument' => '',
+      'validate_type' => 'none',
+      'validate_fail' => 'not found',
+      'glossary' => 0,
+      'limit' => '0',
+      'case' => 'none',
+      'path_case' => 'none',
+      'transform_dash' => 0,
+      'id' => 'vcs',
+      'table' => 'versioncontrol_repositories',
+      'field' => 'vcs',
+      'validate_user_argument_type' => 'uid',
+      'validate_user_roles' => array(
+        '2' => 0,
+      ),
+      'relationship' => 'none',
+      'default_options_div_prefix' => '',
+      'default_argument_user' => 0,
+      'default_argument_fixed' => '',
+      'arbitrary_data' => '',
+      'default_argument_php' => '',
+      'validate_argument_node_type' => array(
+        'project_project' => 0,
+        'project_release' => 0,
+        'company' => 0,
+        'page' => 0,
+        'person' => 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_project_term_argument_type' => 'tid',
+      'validate_argument_project_term_argument_action_top_without' => 'pass',
+      'validate_argument_project_term_argument_action_top_with' => 'pass',
+      'validate_argument_project_term_argument_action_child' => 'pass',
+      'validate_argument_php' => '',
+    ),
+  ));
+  $handler->override_option('access', array(
+    'type' => 'perm',
+    'perm' => 'administer version control systems',
+  ));
+  $handler->override_option('cache', array(
+    'type' => 'none',
+  ));
+  $handler->override_option('use_ajax', TRUE);
+  $handler->override_option('items_per_page', 15);
+  $handler->override_option('use_pager', 'mini');
+  $handler->override_option('style_plugin', 'table');
+  $handler->override_option('style_options', array(
+    'grouping' => '',
+    'override' => 1,
+    'sticky' => 1,
+    'order' => 'asc',
+    'columns' => array(
+      'vcs' => 'vcs',
+      'repo_id' => 'repo_id',
+      'name' => 'name',
+    ),
+    'info' => array(
+      'vcs' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'repo_id' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+      'name' => array(
+        'sortable' => 1,
+        'separator' => '',
+      ),
+    ),
+    'default' => '-1',
+  ));
+  $views[$view->name] = $view;
+
+  return $views;
+}
+
index 9d471ad..93753f5 100644
---versioncontrol.admin.inc
+++ versioncontrol.admin.inc
@@ -549,71 +549,13 @@ function versioncontrol_admin_account_export_display_form(&$form_state, $reposit
 function versioncontrol_admin_repository_list(&$form_state) {
   $form = array();
   $backends = versioncontrol_get_backends();
-  $repositories = versioncontrol_repository_load_multiple(FALSE);
-
-  if (empty($repositories)) {
-    $form['empty'] = array(
-      '#value' => '<p>'. t('No repositories are currently known. Please add one or more repositories in order to be able to use version control features on the site.') .'</p>'
-    );
-    return $form;
-  }
-
-  // The header may be modified separately for each VCS,
-  // so this is only a template and still missing the Actions column.
-  $header_template = array(t('Name'), t('Root'));
-
-  // Sort repositories by backend.
-  $repositories_by_backend = array();
-  foreach ($repositories as $repo_id => $repository) {
-    if (!isset($repositories_by_backend[$repository['vcs']])) {
-      $repositories_by_backend[$repository['vcs']] = array();
-    }
-    $repositories_by_backend[$repository['vcs']][$repo_id] = $repository;
-  }
-
-  // Construct the form elements for each VCS separately.
-  foreach ($repositories_by_backend as $vcs => $vcs_repositories) {
-    $header = $header_template;
-    $title = t('@vcs repositories', array('@vcs' => $backends[$vcs]->name));
+  foreach ($backends as $backend) {
+    $title = t('@vcs repositories', array('@vcs' => $backend->name));
     $form[$vcs] = array(
       '#value' => '<h4>'. $title .'</h4>',
     );
-
-    // Add the standard items of each repository - name and root - to the rows.
-    $rows_by_repo_id = array();
-    foreach ($vcs_repositories as $repo_id => $repository) {
-      $rows_by_repo_id[$repo_id] = array(
-        'name' => check_plain($repository['name']),
-        'root' => check_plain($repository['root']),
-      );
-    }
-    // Provide a possibility for backends and other modules to modify the list.
-    // TODO replace with drupal_alter()
-    foreach (module_implements('versioncontrol_alter_repository_list') as $module) {
-      $function = $module .'_versioncontrol_alter_repository_list';
-      $function($vcs, $vcs_repositories, $header, $rows_by_repo_id);
-    }
-    // Add the Actions column as final column, after all the other ones
-    $header[] = array('data' => t('Actions'), 'colspan' => 2);
-    foreach ($rows_by_repo_id as $repo_id => $row) {
-      $links = array(
-        array(
-          'title' => t('Edit'),
-          'href' => 'admin/project/versioncontrol-repositories/edit/'. $repo_id,
-        ),
-        array(
-          'title' => t('Delete'),
-          'href' => 'admin/project/versioncontrol-repositories/delete/'. $repo_id,
-        ),
-      );
-      $rows_by_repo_id[$repo_id]['links'] = theme('links', $links);
-    }
-    // We don't want the repository ids in the final $rows array.
-    $rows = array_values($rows_by_repo_id);
-
-    // The finished table for the currently processed VCS.
-    $form[$vcs]['list'] = array(
-      '#value' => theme('table', $header, $rows) .'<br/>'
+    $form[$vcs . '_repositories'] = array(
+      '#value' => views_embed_view($backend->getViewName('repositories'), 'default', $backend->name),
     );
   }
   return $form;
---versioncontrol.install
+++ versioncontrol.install	2 Nov 2010 04:18:29 -0000
@@ -171,6 +171,18 @@ function versioncontrol_schema() {
         'not null' => TRUE,
         'default' => 0,
       ),
+      'updated' => array(
+        'description' => 'The Unix timestamp when this repository was last updated.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0
+      ),
+      'update_method' => array(
+        'description' => 'The method that this repository will use to update the operations table.  This should correspond to constants provided by the backend provider.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 1
+      ),
       'data' => array(
         'description' => 'A serialized array of additional per-label data.',
         'type' => 'text',
@@ -662,3 +674,34 @@ function versioncontrol_update_6301() {
   db_add_field($ret, 'versioncontrol_labels', 'data', $data_spec);
   return $ret;
 }
+
+/**
+ * Add the 'updated', 'updated_method' and 'locked' columns.
+ *
+ * These fields were previously stored as members of a serialized array stored
+ * in the data column but this could be problematic for views integration and
+ * the operations that we need to perform across large numbers of repositories.
+ *
+ * @return array
+ */
+function versioncontrol_update_6302() {
+  $ret = array();
+  $fields = array(
+    'updated' => array(
+      'description' => 'The Unix timestamp when this repository was last updated.',
+      'type' => 'int',
+      'not null' => TRUE,
+      'default' => 0
+    ),
+    'update_method' => array(
+      'description' => 'The method that this repository will use to update the operations table.  This should correspond to constants provided by the backend provider.',
+      'type' => 'int',
+      'not null' => TRUE,
+      'default' => 1
+    ),
+  );
+  foreach  ($fields as $field_name => $data_spec) {
+    db_add_field($ret, 'versioncontrol_repositories', $field_name, $data_spec);
+  }
+  return $ret;
+}
Index: includes/VersioncontrolRepository.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/versioncontrol/includes/VersioncontrolRepository.php,v
retrieving revision 1.10
diff -u -p -r1.10 VersioncontrolRepository.php
--- includes/VersioncontrolRepository.php	27 Oct 2010 15:48:43 -0000	1.10
+++ includes/VersioncontrolRepository.php	2 Nov 2010 04:18:29 -0000
@@ -52,6 +52,22 @@ abstract class VersioncontrolRepository 
   public $authorization_method = 'versioncontrol_admin';
 
   /**
+   * The method that this repository will use to update the operations table.
+   *
+   * This should correspond to constants provided by the backend provider.
+   *
+   * @var    integer
+   */
+  public $update_method = 0;
+
+  /**
+   * The Unix timestamp when this repository was last updated.
+   *
+   * @var    integer
+   */
+  public $updated = 0;
+
+  /**
    * An array of additional per-repository settings, mostly populated by
    * third-party modules. It is serialized on DB.
    */
