Indefero

Indefero Commit Details


Date:2009-01-17 11:46:26 (15 years 11 months ago)
Author:Loic d'Anterroches
Branch:dev, develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:835eab9c2419492ec3a39f445d3ee6446c6296bf
Parents: 61bc7a70b6bacad2533154132df77e1c3226ba94
Message:Fixed issue 93 by preventing the display of a large commit diff.

Still needs to implement the equivalent for subversion and mercurial,
maybe with a simple command $scm->isCommitLarge($commit).
Changes:

File differences

src/IDF/Scm/Git.php
287287
288288
289289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
290323
291324
292325
}
/**
* Get commit size.
*
* Get the sum of all the added/removed lines and the number of
* affected files.
*
* @param string Commit ('HEAD')
* @return array array(added, removed, affected)
*/
public function getCommitSize($commit='HEAD')
{
$cmd = sprintf('GIT_DIR=%s git log --numstat -1 --pretty=format:%s %s',
escapeshellarg($this->repo),
"'commit %H%n'",
escapeshellarg($commit));
$out = array();
IDF_Scm::exec($cmd, $out);
$affected = count($out) - 2;
$added = 0;
$removed = 0;
$c=0;
foreach ($out as $line) {
$c++;
if ($c < 3) {
continue;
}
list($a, $r, $f) = preg_split("/[\s]+/", $line, 3, PREG_SPLIT_NO_EMPTY);
$added+=$a;
$removed+=$r;
}
return array($added, $removed, $affected);
}
/**
* Get latest changes.
*
* @param string Commit ('HEAD').
src/IDF/Scm/Mercurial.php
302302
303303
304304
305
306
307
308
309
310
311
312
313
314
315
316
317
305318
306319
307320
return $out[0];
}
/**
* Get commit size.
*
* Get the sum of all the added/removed lines and the number of
* affected files.
*
* @param string Commit ('HEAD')
* @return array array(added, removed, affected)
*/
public function getCommitSize($commit='HEAD')
{
return array(0, 0, 0);
}
/**
* Get latest changes.
src/IDF/Scm/Svn.php
291291
292292
293293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
294308
295309
296310
return (object) $res;
}
/**
* Get commit size.
*
* Get the sum of all the added/removed lines and the number of
* affected files.
*
* @param string Commit ('HEAD')
* @return array array(added, removed, affected)
*/
public function getCommitSize($commit='HEAD')
{
return array(0, 0, 0);
}
private function getDiff($rev='HEAD')
{
$res = array();
src/IDF/Views/Source.php
216216
217217
218218
219
219
220
221
220222
221223
222224
......
231233
232234
233235
236
234237
235238
236239
}
$title = sprintf(__('%s Commit Details'), (string) $request->project);
$page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit);
$cobject = $scm->getCommit($commit, true);
$size = $scm->getCommitSize($commit);
$large = ($size[2] > 100 or ($size[0] + $size[1]) > 20000);
$cobject = $scm->getCommit($commit, !$large);
$rcommit = IDF_Commit::getOrAdd($cobject, $request->project);
$diff = new IDF_Diff($cobject->changes);
$diff->parse();
'branches' => $branches,
'scm' => $scmConf,
'rcommit' => $rcommit,
'large_commit' => $large,
),
$request);
}
src/IDF/templates/idf/source/commit.html
3131
3232
3333
34
3435
3536
36
3737
38
3839
3940
4041
<h2>{trans 'Change Details'}</h2>
{$diff.as_html()}
{/if}{if count($diff.files) or $large_commit}
{aurl 'url', 'IDF_Views_Source::downloadDiff', array($project.shortname, $commit)}
<p class="right soft"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <a href="{$url}">{trans 'Download the corresponding diff file'}</a></p>
{/if}
{/block}
{block context}
{if $scm == 'git'}

Archive Download the corresponding diff file

Page rendered in 0.08543s using 14 queries.