Fixed issue 227, timeline fails on SVN repositories.

This commit is contained in:
Loic d'Anterroches 2009-05-26 21:20:10 +02:00
parent 0abb706ded
commit 88ce10b8e6
2 changed files with 8 additions and 8 deletions

View File

@ -343,11 +343,9 @@ class IDF_Scm
$key = 'IDF_Scm:'.$project->shortname.':lastsync';
if (null === ($res=$cache->get($key))) {
$scm = IDF_Scm::get($project);
foreach ($scm->getBranches() as $branche => $path) {
foreach ($scm->getChangeLog($branche, 25) as $change) {
foreach ($scm->getChangeLog($scm->getMainBranch(), 25) as $change) {
IDF_Commit::getOrAdd($change, $project);
}
}
$cache->set($key, true, (int)(Pluf::f('cache_timeout', 300)/2));
}
}

View File

@ -260,6 +260,7 @@ class IDF_Scm_Svn extends IDF_Scm
if (isset($this->cache['branches'])) {
return $this->cache['branches'];
}
$res = array();
$cmd = sprintf(Pluf::f('svn_path', 'svn').' ls --username=%s --password=%s %s@HEAD',
escapeshellarg($this->username),
escapeshellarg($this->password),
@ -365,13 +366,17 @@ class IDF_Scm_Svn extends IDF_Scm
/**
* Get latest changes.
*
* @param string Commit ('HEAD').
* @param string Revision or ('HEAD').
* @param int Number of changes (10).
*
* @return array Changes.
*/
public function getChangeLog($rev='HEAD', $n=10)
{
if ($rev != 'HEAD' and !preg_match('/^\d+$/', $rev)) {
// we accept only revisions or HEAD
$rev = 'HEAD';
}
$res = array();
$cmd = sprintf(Pluf::f('svn_path', 'svn').' log --xml -v --limit %s --username=%s --password=%s %s@%s',
escapeshellarg($n),
@ -381,8 +386,6 @@ class IDF_Scm_Svn extends IDF_Scm
escapeshellarg($rev));
$xmlRes = shell_exec($cmd);
$xml = simplexml_load_string($xmlRes);
$res = array();
foreach ($xml->logentry as $entry) {
$log = array();
$log['author'] = (string) $entry->author;
@ -393,7 +396,6 @@ class IDF_Scm_Svn extends IDF_Scm
$res[] = (object) $log;
}
return $res;
}