From e39723db456649ac05122e5f6e91c8c4ed07c0f8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 16 Jun 2009 23:09:14 -0600 Subject: [PATCH] Improved patchset display. Big improvement: the ability to view a single patchset. Ultimate goal is to get this display to look similar/identical to a commit message, so that this page becomes the one-stop shop when it comes to a commit (instead of linking to the various diff pages in commit e-mails for each file, we instead link to a single patchset page for each commit). Input and/or tweaking of the display of this page would be great. Additionally, tweak error display on unavailable patchset, link to the checkout page for file name (instead of patchset page), and add full revision tooltip information to revision links. --- chora/patchsets.php | 39 ++++++++++++++++++++---------- chora/templates/patchsets/header.inc | 12 --------- chora/templates/patchsets/header_table.inc | 11 +++++++++ chora/templates/patchsets/ps_single.inc | 30 +++++++++++++++++++++++ chora/themes/screen.css | 19 +++++++++++++++ framework/Vcs/lib/Horde/Vcs/Git.php | 6 ++++- 6 files changed, 91 insertions(+), 26 deletions(-) create mode 100644 chora/templates/patchsets/header_table.inc create mode 100644 chora/templates/patchsets/ps_single.inc diff --git a/chora/patchsets.php b/chora/patchsets.php index 3dfea65e2..c454ebf43 100644 --- a/chora/patchsets.php +++ b/chora/patchsets.php @@ -24,6 +24,9 @@ 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) for %s"), $ps_id, $where); +} else { + $title = sprintf(_("Patchsets for %s"), $where); } try { @@ -33,7 +36,10 @@ try { Chora::fatal($e); } -$title = sprintf(_("Patchsets for %s"), $where); +if (empty($patchsets)) { + Chora::fatal(_("Patchset Not Found"), '400 Bad Request'); +} + $extraLink = Chora::getFileViews($where, 'patchsets'); Horde::addScriptFile('prototype.js', 'horde', true); @@ -51,35 +57,36 @@ 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'; +} + +$diff_img = Horde::img('diff.png', _("Diff")); + reset($patchsets); while (list($id, $patchset) = each($patchsets)) { - // The diff should be from the top of the source tree so as to - // get all files. - // @TODO: Fix this (support needs to be written in diff page) - // $patchset_link = Horde::link(Chora::url('diff', substr($where, 0, strpos($where, '/', 1)), array('r1' => $id - 1, 'r2' => $id, 't' => 'unified'))) . $VC->abbrev($id) . ''; - $patchset_link = htmlspecialchars($VC->abbrev($id)); + $patchset_link = Horde::link(Chora::url('patchsets', $where, array('ps' => $id)), sprintf("Patchset for %s", $id)) . htmlspecialchars($VC->abbrev($id)) . ''; $files = $tags = array(); - $diff_img = Horde::img('diff.png', _("Diff")); foreach ($patchset['members'] as $member) { $file = array(); - $file['file'] = Horde::link(Chora::url('patchsets', $member['file'])) . htmlspecialchars($member['file']) . ''; + $file['file'] = Horde::link(Chora::url('co', $member['file'])) . htmlspecialchars($member['file']) . ''; if ($member['status'] == Horde_Vcs_Patchset::ADDED) { $file['from'] = '' . _("New File") . ''; $file['diff'] = ''; } else { - $file['from'] = Horde::link(Chora::url('co', $member['file'], array('r' => $member['from']))) . htmlspecialchars($VC->abbrev($member['from'])) . ''; - $file['diff'] = Horde::link(Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to']))) . ' ' . $diff_img . ''; + $file['from'] = Horde::link(Chora::url('co', $member['file'], array('r' => $member['from'])), $member['from']) . htmlspecialchars($VC->abbrev($member['from'])) . ''; + $file['diff'] = Horde::link(Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to'])), _("Diff")) . ' ' . $diff_img . ''; } if ($member['status'] == Horde_Vcs_Patchset::DELETED) { $file['to'] = '' . _("Deleted") . ''; $file['diff'] = ''; } else { - $file['to'] = Horde::link(Chora::url('co', $member['file'], array('r' => $member['to']))) . htmlspecialchars($VC->abbrev($member['to'])) . ''; + $file['to'] = Horde::link(Chora::url('co', $member['file'], array('r' => $member['to'])), $member['to']) . htmlspecialchars($VC->abbrev($member['to'])) . ''; } $files[] = $file; @@ -98,8 +105,14 @@ while (list($id, $patchset) = each($patchsets)) { $tags = array_merge($tags, $patchset['tag']); } - require CHORA_TEMPLATES . '/patchsets/ps.inc'; + if ($ps_id) { + require CHORA_TEMPLATES . '/patchsets/ps_single.inc'; + } else { + require CHORA_TEMPLATES . '/patchsets/ps.inc'; + } } -require CHORA_TEMPLATES . '/patchsets/footer.inc'; +if (!$ps_id) { + require CHORA_TEMPLATES . '/patchsets/footer.inc'; +} require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/chora/templates/patchsets/header.inc b/chora/templates/patchsets/header.inc index e9a8c780e..b3065f38e 100644 --- a/chora/templates/patchsets/header.inc +++ b/chora/templates/patchsets/header.inc @@ -10,15 +10,3 @@ - - - - - - - - - - - - diff --git a/chora/templates/patchsets/header_table.inc b/chora/templates/patchsets/header_table.inc new file mode 100644 index 000000000..fbba0e152 --- /dev/null +++ b/chora/templates/patchsets/header_table.inc @@ -0,0 +1,11 @@ +
+ + + + + + + + + + diff --git a/chora/templates/patchsets/ps_single.inc b/chora/templates/patchsets/ps_single.inc new file mode 100644 index 000000000..c8eacbe66 --- /dev/null +++ b/chora/templates/patchsets/ps_single.inc @@ -0,0 +1,30 @@ +
+ : + +
+ +
+ : +
+ + +
+ : +
+ + +
+ : +
+ +
+ +
+ : +
+ + diff --git a/chora/themes/screen.css b/chora/themes/screen.css index d4d0e51a6..b060a3204 100644 --- a/chora/themes/screen.css +++ b/chora/themes/screen.css @@ -151,6 +151,25 @@ h3.revision_log, h3.checkout { width: 35%; } +.singleps span.headerLabel { + font-size: 110%; + font-weight: bold; + padding-right: 5px; +} +.singleps span.ago a:hover { + text-decoration: none; +} +.singlepslog { + padding: 10px 0 20px 20px; +} +ul.singlepsfiles { + list-style: none; + padding: 10px 0 0 20px; +} +ul.singlepsfiles li { + padding-bottom: 4px; +} + /* Checkout. */ div.checkout { padding: 3px; diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 2299b6110..d288f55e9 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -797,7 +797,11 @@ class Horde_Vcs_Patchset_Git extends Horde_Vcs_Patchset } reset($revs); - while(list($rev, $log) = each($revs)) { + while (list($rev, $log) = each($revs)) { + if (empty($log)) { + continue; + } + $this->_patchsets[$rev] = array( 'date' => $log->queryDate(), 'author' => $log->queryAuthor(), -- 2.11.0