Improved Subversion and Mercurial backend performance.

This commit is contained in:
Loic d'Anterroches 2009-01-20 13:12:17 +01:00
parent bab9ec661d
commit df086f7a61
2 changed files with 13 additions and 12 deletions

View File

@ -275,13 +275,16 @@ class IDF_Scm_Mercurial
/** /**
* Get commit details. * Get commit details.
* *
* @param string Commit ('HEAD'). * @param string Commit ('HEAD')
* @return array Changes. * @param bool Get commit diff (false)
* @return array Changes
*/ */
public function getCommit($commit='tip') public function getCommit($commit='tip', $getdiff=false)
{ {
$tmpl = ($getdiff) ?
$cmd = sprintf('hg log -p -r %s -R %s', escapeshellarg($commit), escapeshellarg($this->repo)); 'hg log -p -r %s -R %s' : 'hg log -r %s -R %s';
$cmd = sprintf($tmpl,
escapeshellarg($commit), escapeshellarg($this->repo));
$out = array(); $out = array();
IDF_Scm::exec($cmd, $out); IDF_Scm::exec($cmd, $out);
$log = array(); $log = array();

View File

@ -266,10 +266,11 @@ class IDF_Scm_Svn
/** /**
* Get commit details. * Get commit details.
* *
* @param string Commit ('HEAD'). * @param string Commit ('HEAD')
* @return array Changes. * @param bool Get commit diff (false)
* @return array Changes
*/ */
public function getCommit($rev='HEAD') public function getCommit($rev='HEAD', $getdiff=false)
{ {
$res = array(); $res = array();
$cmd = sprintf('svn log --xml -v --username=%s --password=%s %s@%s', $cmd = sprintf('svn log --xml -v --username=%s --password=%s %s@%s',
@ -279,15 +280,12 @@ class IDF_Scm_Svn
escapeshellarg($rev)); escapeshellarg($rev));
$xmlRes = IDF_Scm::shell_exec($cmd); $xmlRes = IDF_Scm::shell_exec($cmd);
$xml = simplexml_load_string($xmlRes); $xml = simplexml_load_string($xmlRes);
$res['author'] = (string) $xml->logentry->author; $res['author'] = (string) $xml->logentry->author;
$res['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $xml->logentry->date)); $res['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $xml->logentry->date));
$res['title'] = (string) $xml->logentry->msg; $res['title'] = (string) $xml->logentry->msg;
$res['commit'] = (string) $xml->logentry['revision']; $res['commit'] = (string) $xml->logentry['revision'];
$res['changes'] = $this->getDiff($rev); $res['changes'] = ($getdiff) ? $this->getDiff($rev) : '';
$res['tree'] = ''; $res['tree'] = '';
return (object) $res; return (object) $res;
} }