From 49c7fa15a0ec890a2d71ed417d8eb830a5082cf8 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Wed, 24 Nov 2010 00:01:11 -0500 Subject: [PATCH] Split single and multiple patchset views. Don't show individual files in multiple patchset views. --- chora/.htaccess | 10 ++- chora/commit.php | 100 +++++++++++++++++++++++++++++ chora/patchsets.php | 68 ++------------------ chora/templates/patchsets/header_table.inc | 12 +++- chora/templates/patchsets/ps.inc | 7 -- chora/templates/patchsets/ps_single.inc | 4 +- 6 files changed, 126 insertions(+), 75 deletions(-) create mode 100644 chora/commit.php diff --git a/chora/.htaccess b/chora/.htaccess index 7e738d7e7..f4a4cc150 100644 --- a/chora/.htaccess +++ b/chora/.htaccess @@ -2,10 +2,16 @@ Allow from all 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] diff --git a/chora/commit.php b/chora/commit.php new file mode 100644 index 000000000..ad6478669 --- /dev/null +++ b/chora/commit.php @@ -0,0 +1,100 @@ + + * @author Chuck Hagenbuch + * @author Michael Slusarz + * @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']) . ''; + + if ($member['status'] == Horde_Vcs_Patchset::ADDED) { + $file['from'] = '' . _("New File") . ''; + $file['diff'] = ''; + } else { + $file['from'] = Chora::url('co', $member['file'], array('r' => $member['from'])) + ->link(array('title' => $member['from'])) + . htmlspecialchars($VC->abbrev($member['from'])) . ''; + $file['diff'] = Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to'])) + ->link(array('title' => _("Diff"))) + . ' ' . $diff_img . ''; + } + + if ($member['status'] == Horde_Vcs_Patchset::DELETED) { + $file['to'] = '' . _("Deleted") . ''; + $file['diff'] = ''; + } else { + $file['to'] = Chora::url('co', $member['file'], array('r' => $member['to'])) + ->link(array('title' => $member['to'])) + . htmlspecialchars($VC->abbrev($member['to'])) . ''; + } + + 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'; diff --git a/chora/patchsets.php b/chora/patchsets.php index c5c403586..1093bf1af 100644 --- a/chora/patchsets.php +++ b/chora/patchsets.php @@ -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)) . ''; $files = $tags = array(); - foreach ($patchset['members'] as $member) { - $file = array(); - - $file['file'] = Chora::url('co', $member['file'])->link() - . htmlspecialchars($member['file']) . ''; - - if ($member['status'] == Horde_Vcs_Patchset::ADDED) { - $file['from'] = '' . _("New File") . ''; - $file['diff'] = ''; - } else { - $file['from'] = Chora::url('co', $member['file'], array('r' => $member['from'])) - ->link(array('title' => $member['from'])) - . htmlspecialchars($VC->abbrev($member['from'])) . ''; - $file['diff'] = Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to'])) - ->link(array('title' => _("Diff"))) - . ' ' . $diff_img . ''; - } - - if ($member['status'] == Horde_Vcs_Patchset::DELETED) { - $file['to'] = '' . _("Deleted") . ''; - $file['diff'] = ''; - } else { - $file['to'] = Chora::url('co', $member['file'], array('r' => $member['to'])) - ->link(array('title' => $member['to'])) - . htmlspecialchars($VC->abbrev($member['to'])) . ''; - } - - 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'; diff --git a/chora/templates/patchsets/header_table.inc b/chora/templates/patchsets/header_table.inc index fbba0e152..20bff4d72 100644 --- a/chora/templates/patchsets/header_table.inc +++ b/chora/templates/patchsets/header_table.inc @@ -1,11 +1,17 @@ +
+ + + + +
+ - + - - + diff --git a/chora/templates/patchsets/ps.inc b/chora/templates/patchsets/ps.inc index eb73615e7..c3fff8f57 100644 --- a/chora/templates/patchsets/ps.inc +++ b/chora/templates/patchsets/ps.inc @@ -2,13 +2,6 @@ -
-
    - -
  • ' . $file['to'] . ' ' . $file['diff'] ?>
  • - -
-

diff --git a/chora/templates/patchsets/ps_single.inc b/chora/templates/patchsets/ps_single.inc index 4f0cab21f..35c5ecdd4 100644 --- a/chora/templates/patchsets/ps_single.inc +++ b/chora/templates/patchsets/ps_single.inc @@ -14,13 +14,13 @@
- : + :
- : + :
    -- 2.11.0