Indefero

Indefero Commit Details


Date:2010-12-07 18:48:26 (14 years 14 days ago)
Author:Thomas Keller
Branch: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:39c29dbe10ed608778736c031f16ca930c371ad2
Parents: 51c42a65c55f02dc3d60a936a463c5d520f64fc4
Message:Started on issue 544, extended commit details

* Scm.php: new SCM method "getChanges" which returns all available
change information grouped by type
* Monotone.php: implement getChanges via get_revision
* <other scms>: rename "changes" member for getCommit to "diff" which
matches better
* Source.php: query the commit's changes and set them in the template
* commit.html: render the changes, type-by-type. Link to the tree or
the individual diff if applicable
* styles.css: some initial style sheet work
Changes:

File differences

src/IDF/Scm.php
317317
318318
319319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
320348
321349
322350
}
/**
* Returns all recorded changes which lead to the particular commit
* or revision.
*
* Example output:
*
* stdClass object {
* 'additions' => array('path/to/file', 'path/to/directory', ...),
* 'deletions' => array('path/to/file', 'path/to/directory', ...),
* 'renames' => array('old/path/to/file' => 'new/path/to/file', ...)
* 'patches' => array('path/to/file', ...),
* 'properties' => array('path/to/file' => array(
* 'propname' => 'propvalue', 'deletedprop' => null, ...)
* ),
* ...)
* }
*
* Each member of the returned object is mandatory, but may contain
* an empty array if no changes were recorded.
*
* @param string A commit identifier
* @return object with arrays of individual changes
*/
public function getChanges($commit)
{
throw new Pluf_Exception_NotImplemented();
}
/**
* Get latest changes.
*
* It default to the main branch. If possible you should code in a
src/IDF/Scm/Git.php
431431
432432
433433
434
434
435435
436436
437
437
438438
439439
440440
}
}
$out = self::parseLog($log);
$out[0]->changes = implode("\n", $change);
$out[0]->diff = implode("\n", $change);
} else {
$out = self::parseLog($out);
$out[0]->changes = '';
$out[0]->diff = '';
}
$out[0]->branch = implode(', ', $this->inBranches($commit, null));
src/IDF/Scm/Mercurial.php
359359
360360
361361
362
362
363363
364364
365365
}
}
$out = self::parseLog($log, 6);
$out[0]->changes = implode("\n", $change);
$out[0]->diff = implode("\n", $change);
return $out[0];
}
src/IDF/Scm/Monotone.php
600600
601601
602602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
603672
604673
605674
......
626695
627696
628697
629
698
630699
631700
632701
}
/**
* @see IDF_Scm::getChanges()
*/
public function getChanges($commit)
{
$revs = $this->_resolveSelector($commit);
if (count($revs) == 0)
return null;
$revision = $revs[0];
$out = $this->stdio->exec(array('get_revision', $revision));
$stanzas = IDF_Scm_Monotone_BasicIO::parse($out);
$return = (object) array(
'additions' => array(),
'deletions' => array(),
'renames' => array(),
'patches' => array(),
'properties' => array(),
);
foreach ($stanzas as $stanza) {
if ($stanza[0]['key'] == 'format_version' ||
$stanza[0]['key'] == 'old_revision' ||
$stanza[0]['key'] == 'new_manifest')
continue;
if ($stanza[0]['key'] == 'add_file' ||
$stanza[0]['key'] == 'add_dir') {
$return->additions[] = $stanza[0]['values'][0];
continue;
}
if ($stanza[0]['key'] == 'delete') {
$return->deletions[] = $stanza[0]['values'][0];
continue;
}
if ($stanza[0]['key'] == 'rename') {
$return->renames[$stanza[0]['values'][0]] =
$stanza[1]['values'][0];
continue;
}
if ($stanza[0]['key'] == 'patch') {
$return->patches[] = $stanza[0]['values'][0];
continue;
}
if ($stanza[0]['key'] == 'clear' ||
$stanza[0]['key'] == 'set') {
$filename = $stanza[0]['values'][0];
if (!array_key_exists($filename, $return->properties)) {
$return->properties[$filename] = array();
}
$key = $stanza[1]['values'][0];
$value = null;
if (isset($stanza[2])) {
$value = $stanza[2]['values'][0];
}
$return->properties[$filename][$key] = $value;
continue;
}
}
return $return;
}
/**
* @see IDF_Scm::getCommit()
*/
public function getCommit($commit, $getdiff=false)
$res['branch'] = implode(', ', $certs['branch']);
$res['commit'] = $revs[0];
$res['changes'] = ($getdiff) ? $this->_getDiff($revs[0]) : '';
$res['diff'] = ($getdiff) ? $this->_getDiff($revs[0]) : '';
return (object) $res;
}
src/IDF/Scm/Svn.php
414414
415415
416416
417
417
418418
419419
420420
$res['date'] = gmdate('Y-m-d H:i:s', strtotime((string) $xml->logentry->date));
$res['title'] = (string) $xml->logentry->msg;
$res['commit'] = (string) $xml->logentry['revision'];
$res['changes'] = ($getdiff) ? $this->getDiff($commit) : '';
$res['diff'] = ($getdiff) ? $this->getDiff($commit) : '';
$res['tree'] = '';
$res['branch'] = '';
return (object) $res;
src/IDF/Views/Source.php
297297
298298
299299
300
300
301301
302
302303
303304
304305
......
311312
312313
313314
315
314316
315317
316318
$title = sprintf(__('%s Commit Details'), (string) $request->project);
$page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit);
$rcommit = IDF_Commit::getOrAdd($cobject, $request->project);
$diff = new IDF_Diff($cobject->changes);
$diff = new IDF_Diff($cobject->diff);
$diff->parse();
$changes = $scm->getChanges($commit);
$scmConf = $request->conf->getVal('scm', 'git');
$branches = $scm->getBranches();
$in_branches = $scm->inBranches($cobject->commit, '');
'diff' => $diff,
'cobject' => $cobject,
'commit' => $commit,
'changes' => $changes,
'branches' => $branches,
'tree_in' => $in_branches,
'tags' => $tags,
src/IDF/templates/idf/source/commit.html
1818
1919
2020
21
2221
23
22
2423
25
26
27
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
2852
53
2954
3055
31
3256
57
3358
34
59
3560
3661
3762
<tr>
<th><strong>{trans 'Message:'}</strong></th><td>{issuetext $cobject.title, $request}{if isset($cobject.full_message)}<br/><br/>{issuetext $cobject.full_message, $request, true, false, true, true, true}{/if}</td>
</tr>
{if count($diff.files)}
<tr>
<th><strong>{trans 'Files:'}</strong></th>
<th><strong>{trans 'Changes:'}</strong></th>
<td>
{foreach $diff.files as $filename=>$diffdef}
{assign $ndiff = count($diffdef['chunks'])}
<a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $filename)}">{$filename}</a> (<a href="#diff-{$filename|md5}">{blocktrans $ndiff}{$ndiff} diff{plural}{$ndiff} diffs{/blocktrans}</a>)<br/>
<table class="changes">
{foreach $changes.deletions as $filename}
<tr><td>D</td><td>{$filename}{if !empty($diff.files[$filename])} (<a href="#diff-{$filename|md5}">{trans 'full'}</a>){/if}</td></tr>
{/foreach}
{foreach $changes.renames as $oldname => $newname}
<tr><td>R</td><td><a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $newname)}">{$oldname} -> {$newname}</a></td></tr>
{/foreach}
{foreach $changes.additions as $filename}
<tr><td>A</td><td><a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $filename)}">{$filename}</a>{if !empty($diff.files[$filename])} (<a href="#diff-{$filename|md5}">{trans 'full'}</a>){/if}</td></tr>
{/foreach}
{foreach $changes.patches as $filename}
{assign $ndiff = count($diff.files[$filename]['chunks'])}
<tr><td>M</td><td><a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $filename)}">{$filename}</a>{if !empty($diff.files[$filename])} (<a href="#diff-{$filename|md5}">{blocktrans $ndiff}{$ndiff} diff{plural}{$ndiff} diffs{/blocktrans}</a>){/if}</td></tr>
{/foreach}
{foreach $changes.properties as $filename => $properties}
<tr><td>P</td><td><a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $filename)}">{$filename}</a>
<table class="properties">
{foreach $properties as $key => $value}
<tr><td>{$key}</td>
{if $value == null}
<td class="removed">{trans 'removed'}</td>
{else}
<td>{$value}</td>
{/if}
</tr>
{/foreach}
</table>
</td></tr>
{/foreach}
</table>
</td>
</tr>
{/if}
</table>
{if count($diff.files)}
<h2>{trans 'Change Details'}</h2>
<h2>{trans 'File differences'}</h2>
{$diff.as_html()}
{/if}{if count($diff.files) or $large_commit}
www/media/idf/css/style.css
504504
505505
506506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
507522
508523
509524
table.commit td, table.commit th {
padding: 3px;
}
table.commit table.changes td {
padding: 2px;
}
table.commit table.changes table.properties {
margin: 0;
}
table.commit table.changes table.properties tr:nth-child(even) {
background: #E4E8E0;
}
table.commit table.changes table.properties td {
white-space: pre-wrap;
}
table.commit table.changes table.properties td.removed {
font-style: italic;
}
/**
* syntax highlighting of diffs

Archive Download the corresponding diff file

Page rendered in 0.15172s using 14 queries.