Split single and multiple patchset views. Don't show individual files in multiple...
authorChuck Hagenbuch <chuck@horde.org>
Wed, 24 Nov 2010 05:01:11 +0000 (00:01 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Wed, 24 Nov 2010 05:01:11 +0000 (00:01 -0500)
chora/.htaccess
chora/commit.php [new file with mode: 0644]
chora/patchsets.php
chora/templates/patchsets/header_table.inc
chora/templates/patchsets/ps.inc
chora/templates/patchsets/ps_single.inc

index 7e738d7..f4a4cc1 100644 (file)
@@ -2,10 +2,16 @@ Allow from all
 <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteRule   ^([a-z]+).php/(.*)$ $1.php?f=$2 [QSA,L]
+
     RewriteCond   %{REQUEST_FILENAME} !-d
     RewriteCond   %{REQUEST_FILENAME} !-f
     RewriteRule   ^browse/(.*)$ browsedir.php?f=$1 [QSA]
+
+    RewriteCond   %{REQUEST_FILENAME} !-d
+    RewriteCond   %{REQUEST_FILENAME} !-f
     RewriteRule   ^([a-z-\/]+)/-/browse/(.*)$ browsedir.php?f=$2&rt=$1 [QSA]
-    RewriteRule   ^commits/(.*)$ patchsets.php?ps=$1 [QSA]
-    RewriteRule   ^([a-z-\/]+)/-/commits/(.*)$ patchsets.php?ps=$2&rt=$1 [QSA]
+
+    RewriteCond   %{REQUEST_FILENAME} !-d
+    RewriteCond   %{REQUEST_FILENAME} !-f
+    RewriteRule   ^([a-z-\/]+)/-/commit/(.*)$ commit.php?commit=$2&rt=$1 [QSA]
 </IfModule>
diff --git a/chora/commit.php b/chora/commit.php
new file mode 100644 (file)
index 0000000..ad64786
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+/**
+ * Commit view
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Anil Madhavapeddy <anil@recoil.org>
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package Chora
+ */
+
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('chora');
+
+// Exit if patchset feature is not available.
+if (!$GLOBALS['VC']->hasFeature('patchsets')) {
+    Chora::url('browsedir', $where)->redirect();
+}
+
+$commit_id = Horde_Util::getFormData('commit');
+$title = sprintf(_("Commit %s"), $commit_id);
+
+try {
+    $ps = $VC->getPatchsetObject(array('range' => array($commit_id)));
+    $patchsets = $ps->getPatchsets();
+} catch (Horde_Vcs_Exception $e) {
+    Chora::fatal($e);
+}
+
+if (empty($patchsets)) {
+    Chora::fatal(_("Commit Not Found"), '404 Not Found');
+}
+
+$extraLink = Chora::getFileViews($where, 'patchsets');
+
+Horde::addScriptFile('tables.js', 'horde');
+require CHORA_TEMPLATES . '/common-header.inc';
+require CHORA_TEMPLATES . '/menu.inc';
+require CHORA_TEMPLATES . '/headerbar.inc';
+
+$diff_img = Horde::img('diff.png', _("Diff"));
+
+$files = $tags = array();
+
+reset($patchsets);
+$patchset = current($patchsets);
+foreach ($patchset['members'] as $member) {
+    $file = array();
+
+    $file['file'] = Chora::url('co', $member['file'])->link()
+        . htmlspecialchars($member['file']) . '</a>';
+
+    if ($member['status'] == Horde_Vcs_Patchset::ADDED) {
+        $file['from'] = '<ins>' . _("New File") . '</ins>';
+        $file['diff'] = '';
+    } else {
+        $file['from'] = Chora::url('co', $member['file'], array('r' => $member['from']))
+            ->link(array('title' => $member['from']))
+            . htmlspecialchars($VC->abbrev($member['from'])) . '</a>';
+        $file['diff'] = Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to']))
+            ->link(array('title' => _("Diff")))
+            . ' ' . $diff_img . '</a>';
+    }
+
+    if ($member['status'] == Horde_Vcs_Patchset::DELETED) {
+        $file['to'] = '<del>' . _("Deleted") . '</del>';
+        $file['diff'] = '';
+    } else {
+        $file['to'] = Chora::url('co', $member['file'], array('r' => $member['to']))
+            ->link(array('title' => $member['to']))
+            . htmlspecialchars($VC->abbrev($member['to'])) . '</a>';
+    }
+
+    if (isset($member['added'])) {
+        $file['added'] = $member['added'];
+        $file['deleted'] = $member['deleted'];
+    }
+
+    $files[] = $file;
+}
+
+$commitDate = Chora::formatDate($patchset['date']);
+$readableDate = Chora::readableTime($patchset['date'], true);
+$author = Chora::showAuthorName($patchset['author'], true);
+$logMessage = Chora::formatLogMessage($patchset['log']);
+
+if (!empty($patchset['branch'])) {
+    $tags = $patchset['branch'];
+}
+
+if (!empty($patchset['tag'])) {
+    $tags = array_merge($tags, $patchset['tag']);
+}
+
+require CHORA_TEMPLATES . '/patchsets/ps_single.inc';
+require $registry->get('templates', 'horde') . '/common-footer.inc';
index c5c4035..1093bf1 100644 (file)
@@ -22,15 +22,10 @@ if (!$GLOBALS['VC']->hasFeature('patchsets')) {
 }
 
 $ps_opts = array();
-if ($ps_id = Horde_Util::getFormData('ps')) {
-    $ps_opts['range'] = array($ps_id);
-    $title = sprintf(_("Patchset %s"), $ps_id);
-}
-
 if ($where) {
     $ps_opts['file'] = $where;
     if (!isset($title)) {
-        $title = sprintf(_("Patchsets for %s"), $where);
+        $title = sprintf(_("Commits to %s"), $where);
     }
 }
 
@@ -42,71 +37,28 @@ try {
 }
 
 if (empty($patchsets)) {
-    Chora::fatal(_("Patchset Not Found"), '400 Bad Request');
+    Chora::fatal(_("Commit Not Found"), '404 Not Found');
 }
 
 $extraLink = Chora::getFileViews($where, 'patchsets');
 
 Horde::addScriptFile('tables.js', 'horde');
-
-// JS search not needed if showing a single patchset
-if ($ps_id) {
-    Horde::addScriptFile('quickfinder.js', 'horde');
-}
-
+Horde::addScriptFile('quickfinder.js', 'horde');
 require CHORA_TEMPLATES . '/common-header.inc';
 require CHORA_TEMPLATES . '/menu.inc';
 require CHORA_TEMPLATES . '/headerbar.inc';
-require CHORA_TEMPLATES . '/patchsets/header.inc';
-if (!$ps_id) {
-    require CHORA_TEMPLATES . '/patchsets/header_table.inc';
-}
+require CHORA_TEMPLATES . '/patchsets/header_table.inc';
 
 $diff_img = Horde::img('diff.png', _("Diff"));
 
 reset($patchsets);
 while (list($id, $patchset) = each($patchsets)) {
     $patchset_link = Chora::url('patchsets', $where, array('ps' => $id))
-        ->link(array('title' => sprintf("Patchset for %s", $id)))
+        ->link(array('title' => sprintf("Commits to %s", $id)))
         . htmlspecialchars($VC->abbrev($id)) . '</a>';
 
     $files = $tags = array();
 
-    foreach ($patchset['members'] as $member) {
-        $file = array();
-
-        $file['file'] = Chora::url('co', $member['file'])->link()
-            . htmlspecialchars($member['file']) . '</a>';
-
-        if ($member['status'] == Horde_Vcs_Patchset::ADDED) {
-            $file['from'] = '<ins>' . _("New File") . '</ins>';
-            $file['diff'] = '';
-        } else {
-            $file['from'] = Chora::url('co', $member['file'], array('r' => $member['from']))
-                ->link(array('title' => $member['from']))
-                . htmlspecialchars($VC->abbrev($member['from'])) . '</a>';
-            $file['diff'] = Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to']))
-                ->link(array('title' => _("Diff")))
-                . ' ' . $diff_img . '</a>';
-        }
-
-        if ($member['status'] == Horde_Vcs_Patchset::DELETED) {
-            $file['to'] = '<del>' . _("Deleted") . '</del>';
-            $file['diff'] = '';
-        } else {
-            $file['to'] = Chora::url('co', $member['file'], array('r' => $member['to']))
-                ->link(array('title' => $member['to']))
-                . htmlspecialchars($VC->abbrev($member['to'])) . '</a>';
-        }
-
-        if (isset($member['added'])) {
-            $file['added'] = $member['added'];
-            $file['deleted'] = $member['deleted'];
-        }
-
-        $files[] = $file;
-    }
-
     $commitDate = Chora::formatDate($patchset['date']);
     $readableDate = Chora::readableTime($patchset['date'], true);
     $author = Chora::showAuthorName($patchset['author'], true);
@@ -120,14 +72,8 @@ while (list($id, $patchset) = each($patchsets)) {
         $tags = array_merge($tags, $patchset['tag']);
     }
 
-    if ($ps_id) {
-        require CHORA_TEMPLATES . '/patchsets/ps_single.inc';
-    } else {
-        require CHORA_TEMPLATES . '/patchsets/ps.inc';
-    }
+    require CHORA_TEMPLATES . '/patchsets/ps.inc';
 }
 
-if (!$ps_id) {
-    require CHORA_TEMPLATES . '/patchsets/footer.inc';
-}
+require CHORA_TEMPLATES . '/patchsets/footer.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index fbba0e1..20bff4d 100644 (file)
@@ -1,11 +1,17 @@
+<div class="options">
+ <span>
+  <?php echo _("Search Commits:") ?>
+  <input type="text" for="patchsets_body" size="20" />
+ </span>
+</div>
+
 <table class="revlog striped sortable" id="patchsets" cellspacing="0">
 <thead>
  <tr class="item leftAlign">
-  <th><?php echo _("Patchset") ?></th>
+  <th><?php echo _("Commit") ?></th>
   <th class="sortup"><?php echo _("Date") ?></th>
   <th><?php echo _("Author") ?></th>
-  <th class="nosort"><?php echo _("Files") ?></th>
-  <th class="nosort"><?php echo _("Log Message") ?></th>
+  <th class="nosort"><?php echo _("Description") ?></th>
  </tr>
 </thead>
 <tbody id="patchsets_body">
index eb73615..c3fff8f 100644 (file)
@@ -2,13 +2,6 @@
  <td class="pset"><?php echo $patchset_link ?></td>
  <td class="ago" sortval="<?php echo (int)$patchset['date'] ?>"><a title="<?php echo $readableDate ?>"><?php echo $commitDate ?></a></td>
  <td class="author"><?php echo $author ?></td>
- <td class="files">
-  <ul>
-<?php foreach ($files as $file): ?>
-   <li><?php echo $file['file'] . ': ' . $file['from'] . ' -> ' . $file['to'] . ' ' . $file['diff'] ?></li>
-<?php endforeach; ?>
-  </ul>
- </td>
  <td class="log">
   <p class="message"><?php echo $logMessage ?></p>
 <?php if (!empty($tags)): ?>
index 4f0cab2..35c5ecd 100644 (file)
 <?php endif; ?>
 
 <div class="singleps">
- <span class="headerLabel"><?php echo _("Log") ?>:</span>
+ <span class="headerLabel"><?php echo _("Description") ?>:</span>
 </div>
 
 <div class="fixed singlepslog"><?php echo $logMessage ?></div>
 
 <div class="singleps">
- <span class="headerLabel"><?php echo _("Files") ?>:</span>
+ <span class="headerLabel"><?php echo _("Changes") ?>:</span>
 </div>
 
 <ul class="singlepsfiles">