From df086f7a61c4c054c4552a6c59fecf4aa12eebc0 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Tue, 20 Jan 2009 13:12:17 +0100 Subject: [PATCH] Improved Subversion and Mercurial backend performance. --- src/IDF/Scm/Mercurial.php | 13 ++++++++----- src/IDF/Scm/Svn.php | 12 +++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index 499f2ee..d25a9d7 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -275,13 +275,16 @@ class IDF_Scm_Mercurial /** * Get commit details. * - * @param string Commit ('HEAD'). - * @return array Changes. + * @param string Commit ('HEAD') + * @param bool Get commit diff (false) + * @return array Changes */ - public function getCommit($commit='tip') + public function getCommit($commit='tip', $getdiff=false) { - - $cmd = sprintf('hg log -p -r %s -R %s', escapeshellarg($commit), escapeshellarg($this->repo)); + $tmpl = ($getdiff) ? + 'hg log -p -r %s -R %s' : 'hg log -r %s -R %s'; + $cmd = sprintf($tmpl, + escapeshellarg($commit), escapeshellarg($this->repo)); $out = array(); IDF_Scm::exec($cmd, $out); $log = array(); diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php index 02ee6a4..bf7663f 100644 --- a/src/IDF/Scm/Svn.php +++ b/src/IDF/Scm/Svn.php @@ -266,10 +266,11 @@ class IDF_Scm_Svn /** * Get commit details. * - * @param string Commit ('HEAD'). - * @return array Changes. + * @param string Commit ('HEAD') + * @param bool Get commit diff (false) + * @return array Changes */ - public function getCommit($rev='HEAD') + public function getCommit($rev='HEAD', $getdiff=false) { $res = array(); $cmd = sprintf('svn log --xml -v --username=%s --password=%s %s@%s', @@ -279,15 +280,12 @@ class IDF_Scm_Svn escapeshellarg($rev)); $xmlRes = IDF_Scm::shell_exec($cmd); $xml = simplexml_load_string($xmlRes); - $res['author'] = (string) $xml->logentry->author; $res['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $xml->logentry->date)); $res['title'] = (string) $xml->logentry->msg; $res['commit'] = (string) $xml->logentry['revision']; - $res['changes'] = $this->getDiff($rev); + $res['changes'] = ($getdiff) ? $this->getDiff($rev) : ''; $res['tree'] = ''; - - return (object) $res; }