From: Michael M Slusarz Date: Thu, 22 Jan 2009 23:56:16 +0000 (-0700) Subject: Move branch query code to Vcs library X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f63bc796fa3c9469e0cdf85272b9c2911e1e77ab;p=horde.git Move branch query code to Vcs library --- diff --git a/chora/browse.php b/chora/browse.php index ce7b9edbf..aaf209004 100644 --- a/chora/browse.php +++ b/chora/browse.php @@ -147,7 +147,7 @@ foreach ($fl->symrev as $sm => $rv) { $selAllBranches = ''; if ($VC->hasFeature('branches')) { foreach (array_keys($fl->branches) as $sym) { - $selAllBranches .= ''; + $selAllBranches .= ''; } } @@ -163,7 +163,7 @@ require CHORA_TEMPLATES . '/log/header.inc'; $i = 0; foreach ($fl->logs as $lg) { $rev = $lg->queryRevision(); - $branch_info = Chora::getBranch($fl, $rev); + $branch_info = $lg->queryBranch(); $textUrl = Chora::url('co', $where, array('r' => $rev)); $commitDate = Chora::formatDate($lg->queryDate()); diff --git a/chora/co.php b/chora/co.php index ecfe0ecaf..0d0efd133 100644 --- a/chora/co.php +++ b/chora/co.php @@ -70,7 +70,7 @@ if (!$plain) { Chora::url('co', $where, array('r' => $r, 'p' => 1)), _("Download")); $tags = Chora::getTags($log, $where); - $branch_info = Chora::getBranch($file, $r); + $branch_info = $log->queryBranch(); $log_print = Chora::formatLogMessage($log->queryLog()); $author = Chora::showAuthorName($log->queryAuthor(), true); diff --git a/chora/diff.php b/chora/diff.php index 614890cc4..83ef8c0af 100644 --- a/chora/diff.php +++ b/chora/diff.php @@ -64,7 +64,7 @@ foreach ($VC->getRevisionRange($fl, $r1, $r2) as $val) { 'rev' => $val, 'msg' => Chora::formatLogMessage($clog->queryLog()), 'author' => Chora::showAuthorName($clog->queryAuthor(), true), - 'branchinfo' => Chora::getBranch($fl, $val), + 'branchinfo' => $clog->queryBranch(), 'date' => Chora::formatDate($clog->queryDate()), 'tags' => Chora::getTags($clog, $where), ); diff --git a/chora/lib/Chora.php b/chora/lib/Chora.php index 0b402290f..42d87c185 100644 --- a/chora/lib/Chora.php +++ b/chora/lib/Chora.php @@ -580,32 +580,6 @@ class Chora } /** - * Return branch information for a given revision. - * - * @param Horde_Vcs_File $fl The Horde_Vcs_File object. - * @param string $rev The revision string. - * - * @return array TODO - */ - static public function getBranch($fl, $rev) - { - return $GLOBALS['VC']->hasFeature('branches') - ? array_keys($fl->branches, $rev) - : array(); - - /* - $rev_ob = $fl->rep->getRevisionObject(); - $branchRev = $rev_ob->strip($rev, 1); - if (isset($fl->branches[$rev])) { - $branchName = $fl->branches[$rev]; - } elseif (isset($fl->branches[$branchRev])) { - $branchName = $fl->branches[$branchRev]; - } - return array($branchName, $branchRev); - */ - } - - /** * Return formatted date information. * * @param integer $date Number of seconds since epoch we wish to display. diff --git a/framework/Vcs/lib/Horde/Vcs.php b/framework/Vcs/lib/Horde/Vcs.php index 535a364fd..627fb6aec 100644 --- a/framework/Vcs/lib/Horde/Vcs.php +++ b/framework/Vcs/lib/Horde/Vcs.php @@ -945,6 +945,11 @@ class Horde_Vcs_Log return $this->log; } + public function queryBranch() + { + return array(); + } + public function queryChangedLines() { return isset($this->lines) ? $this->lines : ''; diff --git a/framework/Vcs/lib/Horde/Vcs/Cvs.php b/framework/Vcs/lib/Horde/Vcs/Cvs.php index b24efa20a..18a8c2709 100644 --- a/framework/Vcs/lib/Horde/Vcs/Cvs.php +++ b/framework/Vcs/lib/Horde/Vcs/Cvs.php @@ -725,6 +725,18 @@ class Horde_Vcs_Log_Cvs extends Horde_Vcs_Log array(); } + public function queryBranch() + { + $key = array_search($this->rev, $this->file->branches); + if ($key) { + return array($key); + } + + $rev_ob = $this->file->rep->getRevisionObject(); + $key = array_search($rev_ob->strip($this->rev, 1), $this->file->branches); + return $key ? array($key) : array(); + } + } /** diff --git a/framework/Vcs/lib/Horde/Vcs/Git.php b/framework/Vcs/lib/Horde/Vcs/Git.php index 96d5f1a30..6bbd14e39 100644 --- a/framework/Vcs/lib/Horde/Vcs/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Git.php @@ -463,9 +463,8 @@ class Horde_Vcs_File_Git extends Horde_Vcs_File * @author Chuck Hagenbuch * @package Horde_Vcs */ -class Horde_Vcs_Log_Git extends Horde_Vcs_Log { - - public $err; +class Horde_Vcs_Log_Git extends Horde_Vcs_Log +{ public $files = array(); public static function factory($file, $rev) @@ -476,10 +475,9 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log { $cacheVersion = 1; $cacheId = $file->rep->sourceroot() . '_r' . $rev . '_v' . $cacheVersion; - /* @TODO: No caching during dev */ - if (0 && - $file->rep->cache && + if ($file->rep->cache && // Individual revisions can be cached forever + // return array_keys( $file->rep->cache->exists($cacheId, 0)) { $logOb = unserialize($file->rep->cache->get($cacheId, 0)); $logOb->setRepository($file->rep); @@ -603,6 +601,14 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log { return array(); } + public function queryBranch() + { + $branches = $ret = array(); + $command = $this->rep->getCommand() . ' branch --contains ' . escapeshellarg($this->rev) . ' 2>&1'; + exec($command, $branches); + return array_map('trim', $branches, array_fill(0, count($branches), '* ')); + } + } /**