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.
This commit is contained in:
parent
00b576c5a3
commit
7ff6f09f67
@ -340,7 +340,8 @@ class IDF_Scm
|
||||
* 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, ...)
|
||||
|
@ -67,6 +67,7 @@ class IDF_Scm_Git extends IDF_Scm
|
||||
'additions' => array(),
|
||||
'deletions' => array(),
|
||||
'renames' => array(),
|
||||
'copies' => array(),
|
||||
'patches' => array(),
|
||||
'properties' => array(),
|
||||
);
|
||||
|
@ -59,7 +59,7 @@ class IDF_Scm_Mercurial_LogStyle
|
||||
. "\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);
|
||||
@ -457,24 +457,32 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
||||
'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;
|
||||
|
@ -609,6 +609,7 @@ class IDF_Scm_Monotone extends IDF_Scm
|
||||
'additions' => array(),
|
||||
'deletions' => array(),
|
||||
'renames' => array(),
|
||||
'copies' => array(),
|
||||
'patches' => array(),
|
||||
'properties' => array(),
|
||||
);
|
||||
|
@ -34,6 +34,9 @@
|
||||
{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} → {$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} → {$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}
|
||||
|
@ -1058,6 +1058,10 @@ span.scm-action.renamed {
|
||||
background-color: purple;
|
||||
}
|
||||
|
||||
span.scm-action.copied {
|
||||
background-color: orchid;
|
||||
}
|
||||
|
||||
span.scm-action.property-changed {
|
||||
background-color: blue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user