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 {
|
* stdClass object {
|
||||||
* 'additions' => array('path/to/file', 'path/to/directory', ...),
|
* 'additions' => array('path/to/file', 'path/to/directory', ...),
|
||||||
* 'deletions' => 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', ...),
|
* 'patches' => array('path/to/file', ...),
|
||||||
* 'properties' => array('path/to/file' => array(
|
* 'properties' => array('path/to/file' => array(
|
||||||
* 'propname' => 'propvalue', 'deletedprop' => null, ...)
|
* 'propname' => 'propvalue', 'deletedprop' => null, ...)
|
||||||
|
@ -67,6 +67,7 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
'additions' => array(),
|
'additions' => array(),
|
||||||
'deletions' => array(),
|
'deletions' => array(),
|
||||||
'renames' => array(),
|
'renames' => array(),
|
||||||
|
'copies' => array(),
|
||||||
'patches' => array(),
|
'patches' => array(),
|
||||||
'properties' => array(),
|
'properties' => array(),
|
||||||
);
|
);
|
||||||
|
@ -59,7 +59,7 @@ class IDF_Scm_Mercurial_LogStyle
|
|||||||
. "\n"
|
. "\n"
|
||||||
. 'file_del = "{file_del}\0"'
|
. 'file_del = "{file_del}\0"'
|
||||||
. "\n"
|
. "\n"
|
||||||
. 'file_copy = "{name}\0{source}\0"'
|
. 'file_copy = "{source}\0{name}\0"'
|
||||||
. "\n";
|
. "\n";
|
||||||
} else {
|
} else {
|
||||||
throw new IDF_Scm_Exception('invalid type ' . $type);
|
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),
|
'patches' => preg_split('/\0/', $log->file_mods, -1, PREG_SPLIT_NO_EMPTY),
|
||||||
// hg has no support for built-in attributes, so this keeps empty
|
// hg has no support for built-in attributes, so this keeps empty
|
||||||
'properties' => array(),
|
'properties' => array(),
|
||||||
// this is filled below
|
// these two are filled below
|
||||||
|
'copies' => array(),
|
||||||
'renames' => array(),
|
'renames' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$file_copies = preg_split('/\0/', $log->file_copies, -1, PREG_SPLIT_NO_EMPTY);
|
$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_
|
// copies are treated as renames if they have an add _and_ a drop;
|
||||||
// an drop, otherwise they're just treated as adds
|
// only if they only have an add, but no drop, they're treated as copies
|
||||||
for ($i=0; $i<count($file_copies); $i+=2) {
|
for ($i=0; $i<count($file_copies); $i+=2) {
|
||||||
$new = $file_copies[$i];
|
$src = $file_copies[$i];
|
||||||
$old = $file_copies[$i+1];
|
$trg = $file_copies[$i+1];
|
||||||
$newidx = array_search($new, $return->additions);
|
$srcidx = array_search($src, $return->deletions);
|
||||||
$oldidx = array_search($old, $return->deletions);
|
$trgidx = array_search($trg, $return->additions);
|
||||||
if ($newidx !== false && $oldidx !== false) {
|
if ($srcidx !== false && $trgidx !== false) {
|
||||||
$return->renames[$old] = $new;
|
$return->renames[$src] = $trg;
|
||||||
unset($return->additions[$newidx]);
|
unset($return->deletions[$srcidx]);
|
||||||
unset($return->deletions[$oldidx]);
|
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;
|
return $return;
|
||||||
|
@ -609,6 +609,7 @@ class IDF_Scm_Monotone extends IDF_Scm
|
|||||||
'additions' => array(),
|
'additions' => array(),
|
||||||
'deletions' => array(),
|
'deletions' => array(),
|
||||||
'renames' => array(),
|
'renames' => array(),
|
||||||
|
'copies' => array(),
|
||||||
'patches' => array(),
|
'patches' => array(),
|
||||||
'properties' => array(),
|
'properties' => array(),
|
||||||
);
|
);
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
{foreach $changes.renames as $oldname => $newname}
|
{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>
|
<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}
|
||||||
|
{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}
|
{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>
|
<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}
|
{/foreach}
|
||||||
|
@ -1058,6 +1058,10 @@ span.scm-action.renamed {
|
|||||||
background-color: purple;
|
background-color: purple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.scm-action.copied {
|
||||||
|
background-color: orchid;
|
||||||
|
}
|
||||||
|
|
||||||
span.scm-action.property-changed {
|
span.scm-action.property-changed {
|
||||||
background-color: blue;
|
background-color: blue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user