Indefero

Indefero Commit Details


Date:2011-06-09 18:34:33 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:7ff6f09f6718eec2038c1eb214b1bb37482f53d1
Parents: 00b576c5a3aab4d328e2d5e228f5464167228682
Message:We can actually differentiate between copies and renames in Hg, so lets add support for another change type, 'copies'. The previous implementation for Hg was also slightly flawed in the way that it mixed sources with targets.

Changes:

File differences

src/IDF/Scm.php
340340
341341
342342
343
343
344
344345
345346
346347
* 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', ...)
* 'renames' => array('old/path/to/file' => 'new/path/to/file', ...),
* 'copies' => array('path/to/source' => 'path/to/target', ...),
* 'patches' => array('path/to/file', ...),
* 'properties' => array('path/to/file' => array(
* 'propname' => 'propvalue', 'deletedprop' => null, ...)
src/IDF/Scm/Git.php
6767
6868
6969
70
7071
7172
7273
'additions' => array(),
'deletions' => array(),
'renames' => array(),
'copies' => array(),
'patches' => array(),
'properties' => array(),
);
src/IDF/Scm/Mercurial.php
5959
6060
6161
62
62
6363
6464
6565
......
457457
458458
459459
460
460
461
461462
462463
463464
464465
465466
466
467
467
468
468469
469
470
471
472
473
474
475
476
470
471
472
473
474
475
476
477
478
479
480
481
482
483
477484
485
478486
479487
480488
. "\n"
. 'file_del = "{file_del}\0"'
. "\n"
. 'file_copy = "{name}\0{source}\0"'
. 'file_copy = "{source}\0{name}\0"'
. "\n";
} else {
throw new IDF_Scm_Exception('invalid type ' . $type);
'patches' => preg_split('/\0/', $log->file_mods, -1, PREG_SPLIT_NO_EMPTY),
// hg has no support for built-in attributes, so this keeps empty
'properties' => array(),
// this is filled below
// these two are filled below
'copies' => array(),
'renames' => array(),
);
$file_copies = preg_split('/\0/', $log->file_copies, -1, PREG_SPLIT_NO_EMPTY);
// FIXME: copies are only treated as renames if they have an add _and_
// an drop, otherwise they're just treated as adds
// copies are treated as renames if they have an add _and_ a drop;
// only if they only have an add, but no drop, they're treated as copies
for ($i=0; $i<count($file_copies); $i+=2) {
$new = $file_copies[$i];
$old = $file_copies[$i+1];
$newidx = array_search($new, $return->additions);
$oldidx = array_search($old, $return->deletions);
if ($newidx !== false && $oldidx !== false) {
$return->renames[$old] = $new;
unset($return->additions[$newidx]);
unset($return->deletions[$oldidx]);
$src = $file_copies[$i];
$trg = $file_copies[$i+1];
$srcidx = array_search($src, $return->deletions);
$trgidx = array_search($trg, $return->additions);
if ($srcidx !== false && $trgidx !== false) {
$return->renames[$src] = $trg;
unset($return->deletions[$srcidx]);
unset($return->additions[$trgidx]);
continue;
}
if ($srcidx === false && $trgidx !== false) {
$return->copies[$src] = $trg;
unset($return->additions[$trgidx]);
continue;
}
// file sutures (counter-operation to copy) not supported
}
return $return;
src/IDF/Scm/Monotone.php
609609
610610
611611
612
612613
613614
614615
'additions' => array(),
'deletions' => array(),
'renames' => array(),
'copies' => array(),
'patches' => array(),
'properties' => array(),
);
src/IDF/templates/idf/source/commit.html
3434
3535
3636
37
38
39
3740
3841
3942
{foreach $changes.renames as $oldname => $newname}
<tr><td><span class="scm-action renamed" title="{trans 'renamed'}">R</span></td><td><a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $newname)}">{$oldname} &rarr; {$newname}</a></td></tr>
{/foreach}
{foreach $changes.copies as $srcname => $destname}
<tr><td><span class="scm-action copied" title="{trans 'copied'}">C</span></td><td><a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $destname)}">{$srcname} &rarr; {$destname}</a></td></tr>
{/foreach}
{foreach $changes.additions as $filename}
<tr><td><span class="scm-action added" title="{trans 'added'}">A</span></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}
www/media/idf/css/style.css
10581058
10591059
10601060
1061
1062
1063
1064
10611065
10621066
10631067
background-color: purple;
}
span.scm-action.copied {
background-color: orchid;
}
span.scm-action.property-changed {
background-color: blue;
}

Archive Download the corresponding diff file

Page rendered in 0.08843s using 13 queries.