Patchset page alows viewing a single commit.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 3 Feb 2009 06:13:04 +0000 (23:13 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 3 Feb 2009 06:55:59 +0000 (23:55 -0700)
chora/docs/CHANGES
chora/patchsets.php
chora/templates/patchsets/header.inc
framework/Vcs/lib/Horde/Vcs.php
framework/Vcs/lib/Horde/Vcs/Cvs.php
framework/Vcs/lib/Horde/Vcs/Git.php

index fe37b9a..562d264 100644 (file)
@@ -2,6 +2,7 @@
 v3.0-git
 --------
 
+[mms] Patchset page supports viewing a single patchset.
 [mms] Add configuration option to disable caching.
 [mms] Move log entries in annotate screen to an AJAX request.
 [mms] Add support for git repositories.
index 0bc40c7..d8454f3 100644 (file)
@@ -25,8 +25,13 @@ if (!$VC->isFile($fullname)) {
     Chora::fatal(sprintf(_("%s: no such file or directory"), $where), '404 Not Found');
 }
 
+$ps_opts = array();
+if ($ps_id = Util::getFormData('ps')) {
+    $ps_opts['range'] = array($ps_id);
+}
+
 try {
-    $ps = $VC->getPatchsetObject($where);
+    $ps = $VC->getPatchsetObject($where, $ps_opts);
     $patchsets = $ps->getPatchsets();
 } catch (Horde_Vcs_Exception $e) {
     Chora::fatal($e);
@@ -37,7 +42,14 @@ $extraLink = Chora::getFileViews($where, 'patchsets');
 
 Horde::addScriptFile('prototype.js', 'horde', true);
 Horde::addScriptFile('tables.js', 'horde', true);
-Horde::addScriptFile('QuickFinder.js', 'horde', true);
+
+// JS search not needed if showing a single patchset
+if ($ps_id) {
+    $full_ps_link = Horde::link(Chora::url('patchsets', $where)) . _("View All Patchsets for File") . '</a>';
+} else {
+    Horde::addScriptFile('QuickFinder.js', 'horde', true);
+}
+
 require CHORA_TEMPLATES . '/common-header.inc';
 require CHORA_TEMPLATES . '/menu.inc';
 require CHORA_TEMPLATES . '/headerbar.inc';
index a040d0a..e9a8c78 100644 (file)
@@ -1,8 +1,12 @@
 <table class="options" cellspacing="0">
  <tr>
   <td>
+<?php if ($ps_id): ?>
+   <?php echo $full_ps_link ?>
+<?php else: ?>
    <?php echo _("Search Patchsets:") ?>
    <input type="text" for="patchsets_body" size="20" />
+<?php endif; ?>
   </td>
  </tr>
 </table>
index c3d7705..829d808 100644 (file)
@@ -536,11 +536,12 @@ class Horde_Vcs
     /**
      * TODO
      */
-    public function getPatchsetObject($filename)
+    public function getPatchsetObject($filename, $opts = array())
     {
         $class = 'Horde_Vcs_Patchset_' . $this->_driver;
 
-        $cacheId = implode('|', array($class, $this->sourceroot(), $filename, $this->_cacheVersion));
+        ksort($opts);
+        $cacheId = implode('|', array($class, $this->sourceroot(), $filename, serialize($opts), $this->_cacheVersion));
 
         if (!empty($this->_cache)) {
             // TODO: Can't use filemtime() - Git bare repos contain no files
@@ -550,7 +551,7 @@ class Horde_Vcs
             }
         }
 
-        $ob = new $class($this, $filename);
+        $ob = new $class($this, $filename, $opts);
 
         if (!empty($this->_cache)) {
             $this->_cache->set($cacheId, serialize($ob));
@@ -1175,8 +1176,13 @@ abstract class Horde_Vcs_Patchset
      *
      * @param Horde_Vcs $rep  A Horde_Vcs repository object.
      * @param string $file    The filename to create patchsets for.
+     * @param array $opts     Additional options:
+     * <pre>
+     * 'range' - (array) The patchsets to process.
+     *           DEFAULT: None (all patchsets are processed).
+     * </pre>
      */
-    abstract public function __construct($rep, $file);
+    abstract public function __construct($rep, $file, $opts = array());
 
     /**
      * TODO
index 43c4e87..8a824dc 100644 (file)
@@ -663,10 +663,15 @@ class Horde_Vcs_Patchset_Cvs extends Horde_Vcs_Patchset
      *
      * @param Horde_Vcs $rep  A Horde_Vcs repository object.
      * @param string $file    The filename to create a patchset for.
+     * @param array $opts     Additional options.
+     * <pre>
+     * 'range' - (array) The patchsets to process.
+     *           DEFAULT: None (all patchsets are processed).
+     * </pre>
      *
      * @throws Horde_Vcs_Exception
      */
-    public function __construct($rep, $file)
+    public function __construct($rep, $file, $opts = array())
     {
         $file = $rep->sourceroot() . '/' . $file;
 
@@ -681,8 +686,12 @@ class Horde_Vcs_Patchset_Cvs extends Horde_Vcs_Patchset
             'HOME=' . escapeshellarg($cvsps_home) . ' ' :
             '';
 
+        $rangecmd = empty($opts['range'])
+            ? ''
+            : ' -s ' . escapeshellarg(implode(',', $opts['range']));
+
         $ret_array = array();
-        $cmd = $HOME . escapeshellcmd($rep->getPath('cvsps')) . ' -u --cvs-direct --root ' . escapeshellarg($rep->sourceroot()) . ' -f ' . escapeshellarg(basename($file)) . ' ' . escapeshellarg(dirname($file));
+        $cmd = $HOME . escapeshellcmd($rep->getPath('cvsps')) . $rangecmd . ' -u --cvs-direct --root ' . escapeshellarg($rep->sourceroot()) . ' -f ' . escapeshellarg(basename($file)) . ' ' . escapeshellarg(dirname($file));
         exec($cmd, $ret_array, $retval);
         if ($retval) {
             throw new Horde_Vcs_Exception('Failed to spawn cvsps to retrieve patchset information.');
index d918149..f8742a5 100644 (file)
@@ -593,12 +593,27 @@ class Horde_Vcs_Patchset_Git extends Horde_Vcs_Patchset
      *
      * @param Horde_Vcs $rep  A Horde_Vcs repository object.
      * @param string $file    The filename to create patchsets for.
+     * @param array $opts     Additional options.
+     * <pre>
+     * 'range' - (array) The patchsets to process.
+     *           DEFAULT: None (all patchsets are processed).
+     * </pre>
      */
-    public function __construct($rep, $file)
+    public function __construct($rep, $file, $opts = array())
     {
         $fileOb = $rep->getFileObject($file);
+        $revs = array();
+
+        if (empty($opts['range'])) {
+            $revs = $fileOb->queryLogs();
+        } else {
+            foreach ($opts['range'] as $val) {
+                $revs[$val] = $fileOb->queryLogs($val);
+            }
+        }
 
-        foreach ($fileOb->queryLogs() as $rev => $log) {
+        reset($revs);
+        while(list($rev, $log) = each($revs)) {
             $this->_patchsets[$rev] = array(
                 'date' => $log->queryDate(),
                 'author' => $log->queryAuthor(),