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,10 +343,8 @@ class IDF_Scm
$key = 'IDF_Scm:'.$project->shortname.':lastsync'; $key = 'IDF_Scm:'.$project->shortname.':lastsync';
if (null === ($res=$cache->get($key))) { if (null === ($res=$cache->get($key))) {
$scm = IDF_Scm::get($project); $scm = IDF_Scm::get($project);
foreach ($scm->getBranches() as $branche => $path) { foreach ($scm->getChangeLog($scm->getMainBranch(), 25) as $change) {
foreach ($scm->getChangeLog($branche, 25) as $change) { IDF_Commit::getOrAdd($change, $project);
IDF_Commit::getOrAdd($change, $project);
}
} }
$cache->set($key, true, (int)(Pluf::f('cache_timeout', 300)/2)); $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'])) { if (isset($this->cache['branches'])) {
return $this->cache['branches']; return $this->cache['branches'];
} }
$res = array();
$cmd = sprintf(Pluf::f('svn_path', 'svn').' ls --username=%s --password=%s %s@HEAD', $cmd = sprintf(Pluf::f('svn_path', 'svn').' ls --username=%s --password=%s %s@HEAD',
escapeshellarg($this->username), escapeshellarg($this->username),
escapeshellarg($this->password), escapeshellarg($this->password),
@ -365,13 +366,17 @@ class IDF_Scm_Svn extends IDF_Scm
/** /**
* Get latest changes. * Get latest changes.
* *
* @param string Commit ('HEAD'). * @param string Revision or ('HEAD').
* @param int Number of changes (10). * @param int Number of changes (10).
* *
* @return array Changes. * @return array Changes.
*/ */
public function getChangeLog($rev='HEAD', $n=10) 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(); $res = array();
$cmd = sprintf(Pluf::f('svn_path', 'svn').' log --xml -v --limit %s --username=%s --password=%s %s@%s', $cmd = sprintf(Pluf::f('svn_path', 'svn').' log --xml -v --limit %s --username=%s --password=%s %s@%s',
escapeshellarg($n), escapeshellarg($n),
@ -381,8 +386,6 @@ class IDF_Scm_Svn extends IDF_Scm
escapeshellarg($rev)); escapeshellarg($rev));
$xmlRes = shell_exec($cmd); $xmlRes = shell_exec($cmd);
$xml = simplexml_load_string($xmlRes); $xml = simplexml_load_string($xmlRes);
$res = array();
foreach ($xml->logentry as $entry) { foreach ($xml->logentry as $entry) {
$log = array(); $log = array();
$log['author'] = (string) $entry->author; $log['author'] = (string) $entry->author;
@ -393,7 +396,6 @@ class IDF_Scm_Svn extends IDF_Scm
$res[] = (object) $log; $res[] = (object) $log;
} }
return $res; return $res;
} }