From a269331b93e8a47e5273aeeff17d0360e670aab6 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 9 Jan 2011 20:49:16 -0500 Subject: [PATCH] Faster, github-like revision log viewer for files. This definitely gives up a bit of functionality - and I'd like to find a way to get the arbitrary diff links back - but I think on balance it's better. Faster, too, though there's work to do there still. --- chora/browsefile.php | 50 +++++++------------------------- chora/js/revlog.js | 17 ++++++----- chora/templates/log/footer.inc | 10 ------- chora/templates/log/header.inc | 20 ++----------- chora/templates/log/rev.inc | 30 ------------------- framework/Vcs/lib/Horde/Vcs/File/Git.php | 34 +++++++++------------- 6 files changed, 37 insertions(+), 124 deletions(-) delete mode 100644 chora/templates/log/footer.inc delete mode 100644 chora/templates/log/rev.inc diff --git a/chora/browsefile.php b/chora/browsefile.php index 195413d0b..87f964580 100644 --- a/chora/browsefile.php +++ b/chora/browsefile.php @@ -20,7 +20,7 @@ if ($atdir) { exit; } -$onb = Horde_Util::getFormData('onb'); +$onb = Horde_Util::getFormData('onb', $VC->getDefaultBranch()); try { $fl = $VC->getFileObject($where, array('branch' => $onb)); } catch (Horde_Vcs_Exception $e) { @@ -47,51 +47,23 @@ if ($VC->hasFeature('branches')) { } } -Horde::addScriptFile('tables.js', 'horde'); -Horde::addScriptFile('quickfinder.js', 'horde'); Horde::addScriptFile('revlog.js', 'chora'); require $registry->get('templates', 'horde') . '/common-header.inc'; require CHORA_TEMPLATES . '/menu.inc'; require CHORA_TEMPLATES . '/headerbar.inc'; require CHORA_TEMPLATES . '/log/header.inc'; -$i = 0; -$diff_img = Horde::img('diff.png'); reset($logs); -while (list(,$lg) = each($logs)) { - $rev = $lg->queryRevision(); - $branch_info = $lg->queryBranch(); - - $added = $deleted = null; - $fileinfo = $lg->queryFiles($where); - if ($fileinfo && isset($fileinfo['added'])) { - $added = $fileinfo['added']; - $deleted = $fileinfo['deleted']; - } - - // TODO: Remove in favor of getting info from queryFiles() - $changedlines = $lg->queryChangedLines(); - - $textUrl = Chora::url('co', $where, array('r' => $rev)); - $commitDate = Chora::formatDate($lg->queryDate()); - $readableDate = Chora::readableTime($lg->queryDate(), true); - - $author = Chora::showAuthorName($lg->queryAuthor(), true); - $tags = Chora::getTags($lg, $where); - - if ($prevRevision = $fl->queryPreviousRevision($lg->queryRevision())) { - $diffUrl = Chora::url('diff', $where, array('r1' => $prevRevision, 'r2' => $rev)); - } else { - $diffUrl = ''; - } - - $logMessage = Chora::formatLogMessage($lg->queryLog()); - - require CHORA_TEMPLATES . '/log/rev.inc'; - - if (($i++ > 100) && !Horde_Util::getFormData('all')) { - break; +$view = $injector->createInstance('Horde_View'); +$currentDay = null; +echo '
'; +foreach ($logs as $log) { + $day = date('Y-m-d', $log->queryDate()); + if ($day != $currentDay) { + echo '

' . $day . '

'; + $currentDay = $day; } + echo $view->renderPartial('app/views/logMessage', array('object' => $log)); } -require CHORA_TEMPLATES . '/log/footer.inc'; +echo '
'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/chora/js/revlog.js b/chora/js/revlog.js index d25ba74d3..4b274d038 100644 --- a/chora/js/revlog.js +++ b/chora/js/revlog.js @@ -8,13 +8,16 @@ var Chora_RevLog = { highlight: function() { - $('revlog_body').select('TR').each(function(tr) { - if (Prototype.Browser.IE) { - tr.observe('mouseover', this.rowover.bindAsEventListener(this, 'over')); - tr.observe('mouseover', this.rowover.bindAsEventListener(this, 'out')); - } - tr.observe('click', this.toggle.bindAsEventListener(this)); - }, this); + revlog_body = $('revlog_body'); + if (revlog_body) { + revlog_body.select('TR').each(function(tr) { + if (Prototype.Browser.IE) { + tr.observe('mouseover', this.rowover.bindAsEventListener(this, 'over')); + tr.observe('mouseover', this.rowover.bindAsEventListener(this, 'out')); + } + tr.observe('click', this.toggle.bindAsEventListener(this)); + }, this); + } }, rowover: function(e, type) diff --git a/chora/templates/log/footer.inc b/chora/templates/log/footer.inc deleted file mode 100644 index c738ce46e..000000000 --- a/chora/templates/log/footer.inc +++ /dev/null @@ -1,10 +0,0 @@ - - - -revisionCount() > 100 && !Horde_Util::getFormData('all')): ?> -
- - (may take a while)."), Horde::link(Horde_Util::addParameter(Horde::selfUrl(true), 'all', 1))) ?> - -
- diff --git a/chora/templates/log/header.inc b/chora/templates/log/header.inc index f3883d9e4..ad772f017 100644 --- a/chora/templates/log/header.inc +++ b/chora/templates/log/header.inc @@ -1,9 +1,5 @@
-
- - -
- +
@@ -31,15 +27,3 @@
- - - - - - - - - - - - diff --git a/chora/templates/log/rev.inc b/chora/templates/log/rev.inc deleted file mode 100644 index 473f6d868..000000000 --- a/chora/templates/log/rev.inc +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - diff --git a/framework/Vcs/lib/Horde/Vcs/File/Git.php b/framework/Vcs/lib/Horde/Vcs/File/Git.php index 72cd84ae8..5e3cb3ec1 100644 --- a/framework/Vcs/lib/Horde/Vcs/File/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/File/Git.php @@ -43,13 +43,13 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File { $log_list = null; + if (empty($this->_branch)) { $this->_branch = $this->_rep->getDefaultBranch(); } + /* First, grab the master list of revisions. If quicklog is specified, * we don't need this master list - we are only concerned about the * most recent revision for the given branch. */ if ($this->_quicklog) { - $branchlist = empty($this->_branch) - ? array($this->_rep->getDefaultBranch()) - : array($this->_branch); + $branchlist = array($this->_branch); } else { if (version_compare($this->_rep->version, '1.6.0', '>=')) { $cmd = $this->_rep->getCommand() . ' rev-list --branches -- ' . escapeshellarg($this->queryModulePath()) . ' 2>&1'; @@ -85,27 +85,21 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File $branchlist = array_keys($this->queryBranches()); } - /* Get the list of revisions. Need to get all revisions, not just - * those on $this->_branch, for branch determination reasons. */ - foreach ($branchlist as $key) { - $revs = array(); - $cmd = $this->_rep->getCommand() . ' rev-list ' . ($this->_quicklog ? '-n 1' : '') . ' ' . escapeshellarg($key) . ' -- ' . escapeshellarg($this->queryModulePath()) . ' 2>&1'; - exec($cmd, $revs); + $revs = array(); + $cmd = $this->_rep->getCommand() . ' rev-list' . ($this->_quicklog ? ' -n 1' : '') . ' ' . escapeshellarg($this->_branch) . ' -- ' . escapeshellarg($this->queryModulePath()) . ' 2>&1'; + exec($cmd, $revs); - if (!empty($revs)) { - if (stripos($revs[0], 'fatal') === 0) { - throw new Horde_Vcs_Exception(implode(', ', $revs)); - } + if (!empty($revs)) { + if (stripos($revs[0], 'fatal') === 0) { + throw new Horde_Vcs_Exception(implode(', ', $revs)); + } - $this->_revlist[$key] = $revs; + $this->_revlist[$this->_branch] = $revs; - if (!empty($this->_branch) && ($this->_branch == $key)) { - $log_list = $revs; - } + $log_list = $revs; - if ($this->_quicklog) { - $this->_revs[] = reset($revs); - } + if ($this->_quicklog) { + $this->_revs[] = reset($revs); } } -- 2.11.0
 
- - "> - - " onclick="Chora_RevLog.sdiff(this);"> - abbrev($rev)) ?> - - - - $val))->link() . htmlspecialchars($val) ?> - - - - - () - - (+, - ) - - -

- -

- -