Added a partial fix of issue 93 to limit memory exhaustion.
This is not perfect because it means that we cannot get the corresponding commit message and author for each file in the tree view. This is just a work around that will not affect most of the repositories but the biggest ones with files not changes for a long time. To fully fix this problem, one needs to build at each commit time a cache table with the data of each commit (including the hash of each file at each commit).
This commit is contained in:
parent
4f682c2e93
commit
0a02916e81
@ -132,7 +132,7 @@ class IDF_Scm_Git
|
|||||||
// get the raw log corresponding to this commit to find the
|
// get the raw log corresponding to this commit to find the
|
||||||
// origin of each file.
|
// origin of each file.
|
||||||
$rawlog = array();
|
$rawlog = array();
|
||||||
$cmd = sprintf('GIT_DIR=%s git log --raw --abbrev=40 --pretty=oneline %s',
|
$cmd = sprintf('GIT_DIR=%s git log --raw --abbrev=40 --pretty=oneline -5000 %s',
|
||||||
escapeshellarg($this->repo), escapeshellarg($commit));
|
escapeshellarg($this->repo), escapeshellarg($commit));
|
||||||
IDF_Scm::exec($cmd, $rawlog);
|
IDF_Scm::exec($cmd, $rawlog);
|
||||||
// We reverse the log to be able to use a fixed efficient
|
// We reverse the log to be able to use a fixed efficient
|
||||||
@ -150,8 +150,8 @@ class IDF_Scm_Git
|
|||||||
$file->author = $fc->author;
|
$file->author = $fc->author;
|
||||||
} else if ($file->type == 'blob') {
|
} else if ($file->type == 'blob') {
|
||||||
$file->date = $co->date;
|
$file->date = $co->date;
|
||||||
$file->log = $co->title;
|
$file->log = '----';
|
||||||
$file->author = $co->author; // May be wrong in some cases.
|
$file->author = 'Unknown';
|
||||||
}
|
}
|
||||||
$file->fullpath = ($folder) ? $folder.'/'.$file->file : $file->file;
|
$file->fullpath = ($folder) ? $folder.'/'.$file->file : $file->file;
|
||||||
$res[] = $file;
|
$res[] = $file;
|
||||||
@ -309,27 +309,29 @@ class IDF_Scm_Git
|
|||||||
{
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
$c = array();
|
$c = array();
|
||||||
$i = 0;
|
|
||||||
$hdrs += 2;
|
$hdrs += 2;
|
||||||
|
$inheads = true;
|
||||||
|
$next_is_title = false;
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
$i++;
|
if (preg_match('/^commit (\w{40})$/', $line)) {
|
||||||
if (0 === strpos($line, 'commit')) {
|
|
||||||
if (count($c) > 0) {
|
if (count($c) > 0) {
|
||||||
$c['full_message'] = trim($c['full_message']);
|
$c['full_message'] = trim($c['full_message']);
|
||||||
$res[] = (object) $c;
|
$res[] = (object) $c;
|
||||||
}
|
}
|
||||||
$c = array();
|
$c = array();
|
||||||
$c['commit'] = trim(substr($line, 7));
|
$c['commit'] = trim(substr($line, 7, 40));
|
||||||
$c['full_message'] = '';
|
$c['full_message'] = '';
|
||||||
$i=1;
|
$inheads = true;
|
||||||
|
$next_is_title = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($i == $hdrs) {
|
if ($next_is_title) {
|
||||||
$c['title'] = trim($line);
|
$c['title'] = trim($line);
|
||||||
|
$next_is_title = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$match = array();
|
$match = array();
|
||||||
if (preg_match('/(\S+)\s*:\s*(.*)/', $line, $match)) {
|
if ($inheads and preg_match('/(\S+)\s*:\s*(.*)/', $line, $match)) {
|
||||||
$match[1] = strtolower($match[1]);
|
$match[1] = strtolower($match[1]);
|
||||||
$c[$match[1]] = trim($match[2]);
|
$c[$match[1]] = trim($match[2]);
|
||||||
if ($match[1] == 'date') {
|
if ($match[1] == 'date') {
|
||||||
@ -337,13 +339,16 @@ class IDF_Scm_Git
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($i > ($hdrs+1)) {
|
if ($inheads and !$next_is_title and $line == '') {
|
||||||
|
$next_is_title = true;
|
||||||
|
$inheads = false;
|
||||||
|
}
|
||||||
|
if (!$inheads) {
|
||||||
$c['full_message'] .= trim($line)."\n";
|
$c['full_message'] .= trim($line)."\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$c['full_message'] = trim($c['full_message']);
|
$c['full_message'] = trim($c['full_message']);
|
||||||
|
|
||||||
$res[] = (object) $c;
|
$res[] = (object) $c;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
|
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
|
||||||
<td{if $file.type != 'blob'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>
|
<td{if $file.type != 'blob'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>
|
||||||
{if $file.type == 'blob'}
|
{if $file.type == 'blob'}
|
||||||
{if isset($file.date)}
|
{if isset($file.date) and $file.log != '----'}
|
||||||
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td>
|
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td>
|
||||||
<td><span class="smaller">{$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false}</span></td>
|
<td><span class="smaller">{$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false}</span></td>
|
||||||
{else}<td colspan="2"></td>{/if}
|
{else}<td colspan="2"></td>{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user