Index: cvs.module
===================================================================
--- cvs.module	(revision 533)
+++ cvs.module	(working copy)
@@ -209,6 +209,27 @@
   return $items;
 }
 
+/**
+ * Implementation of hook_apachesolr_update_index.
+ */
+function cvs_apachesolr_update_index(&$document, $node) {
+
+  $interval = 60 * 60 * 24 * 30 * 2; // 2 months
+
+  // Retrieve the number of CVS commits:
+  $commits = db_result(db_query("SELECT COUNT(m.cid) AS count FROM {cvs_files} f INNER JOIN {cvs_messages} m ON f.cid = m.cid WHERE f.nid = %d AND m.created > %d", $node->nid, time() - $interval));
+
+  // Update the Apache Solr field:
+  $document->isfield_commits = $commits;
+
+  // TODO: we need to optimize this query -- it takes up to 0.5 second to 
+  //       complete on the drupal.org database.  Fortunately, it shouldn't
+  //       all that often.
+
+  // TODO: ideally we'd be able to return statistics per branch but that 
+  //       informaiton is not available in the CVS tables.
+}
+
 function cvs_account_tracker_access($account) {
   $result = db_query('SELECT uid, status FROM {cvs_accounts} WHERE uid = %d', $account->uid);
   if ($cvs_account = db_fetch_object($result)) {
