mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-22 04:39:55 +09:00
source_compare
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5956 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
9b4a5489d0
commit
0919ae7e03
3 changed files with 100 additions and 62 deletions
|
|
@ -195,6 +195,75 @@
|
|||
return $output;
|
||||
}
|
||||
|
||||
function parseComp(&$list)
|
||||
{
|
||||
$cnt = count($list);
|
||||
$output = array();
|
||||
$obj = null;
|
||||
$idx = 0;
|
||||
for($i=0;$i<$cnt;$i++) {
|
||||
$str = $list[$i];
|
||||
if(preg_match('/^Index: (.*)$/', $str, $m)) {
|
||||
if($blockobj != null)
|
||||
{
|
||||
$obj->blocks[$blockobj->before_line_start] = $blockobj;
|
||||
ksort($obj->blocks);
|
||||
}
|
||||
if($obj!==null) $output[] = $obj;
|
||||
$obj = null;
|
||||
$obj->filename = $m[1];
|
||||
$idx = 0;
|
||||
$obj->blocks = array();
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^(\=+)$/',$str)) continue;
|
||||
if(preg_match('/^--- ([^\(]+)\(revision ([0-9]+)\)$/i',$str,$m)) {
|
||||
$obj->before_revision = $m[2];
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^\+\+\+ ([^\(]+)\(revision ([0-9]+)\)$/i',$str,$m)) {
|
||||
$obj->after_revision = $m[2];
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^@@ \-([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@$/', $str, $m)) {
|
||||
if($blockobj != null) $obj->blocks[$blockobj->before_line_start] = $blockobj;
|
||||
$blockobj = null;
|
||||
$blockobj->before_line_start = (int) $m[1];
|
||||
$blockobj->after_line_start = (int) $m[3];
|
||||
$cur_before_line = $blockobj->before_line_start;
|
||||
$cur_after_line = $blockobj->after_line_start;
|
||||
$blockobj->lines = array();
|
||||
continue;
|
||||
}
|
||||
$line = null;
|
||||
if(preg_match('/^\-(.*)$/i',$str)) {
|
||||
$line->data = ' '.substr($str,1);
|
||||
$line->type = "deleted";
|
||||
$line->before_line_number = $cur_before_line ++;
|
||||
}
|
||||
else if(preg_match('/^\+(.*)$/i',$str)) {
|
||||
$line->data = ' '.substr($str,1);
|
||||
$line->type = "added";
|
||||
$line->after_line_number = $cur_after_line ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$line->data = $str;
|
||||
$line->before_line_number = $cur_before_line ++;
|
||||
$line->after_line_number = $cur_after_line ++;
|
||||
}
|
||||
$blockobj->lines[] = $line;
|
||||
}
|
||||
if($obj!==null)
|
||||
{
|
||||
if($blockobj != null) $obj->blocks[$blockobj->before_line_start] = $blockobj;
|
||||
ksort($obj->blocks);
|
||||
$output[] = $obj;
|
||||
}
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
function getComp($path, $brev, $erev) {
|
||||
if(!$brev) {
|
||||
$command = sprintf('%s --non-interactive %s --config-dir %s log --xml --limit 2 %s%s@%d', $this->svn_cmd, $this->_getAuthInfo(), $this->tmp_dir, $this->url, $path, $erev);
|
||||
|
|
@ -216,52 +285,10 @@
|
|||
$erev
|
||||
);
|
||||
$output = $this->execCmd($command, $error);
|
||||
|
||||
debugPrint($output);
|
||||
$list = explode("\n",$output);
|
||||
$cnt = count($list);
|
||||
$output = array();
|
||||
$obj = null;
|
||||
$idx = 0;
|
||||
for($i=0;$i<$cnt;$i++) {
|
||||
$str = $list[$i];
|
||||
if(preg_match('/^Index: (.*)$/', $str, $m)) {
|
||||
if($obj!==null) $output[] = $obj;
|
||||
$obj = null;
|
||||
$obj->filename = $m[1];
|
||||
$idx = 0;
|
||||
$code_idx = -1;
|
||||
$code_changed = false;
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^(\=+)$/',$str)) continue;
|
||||
if(preg_match('/^--- ([^\(]+)\(revision ([0-9]+)\)$/i',$str,$m)) {
|
||||
$obj->before_revision = $m[2];
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^\+\+\+ ([^\(]+)\(revision ([0-9]+)\)$/i',$str,$m)) {
|
||||
$obj->after_revision = $m[2];
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^@@ \-([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@$/', $str, $m)) {
|
||||
$obj->changed[$idx]->before_line = sprintf('%d ~ %d', $m[1], $m[2]);
|
||||
$obj->changed[$idx]->after_line = sprintf('%d ~ %d', $m[3], $m[4]);
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^\-(.*)$/i',$str)) {
|
||||
if(!$code_changed) {
|
||||
$code_changed = true;
|
||||
$code_idx++;
|
||||
}
|
||||
$obj->changed[$idx]->before_code[$code_idx] .= substr($str,1)."\n";
|
||||
continue;
|
||||
}
|
||||
if(preg_match('/^\+(.*)$/i',$str)) {
|
||||
$obj->changed[$idx]->after_code[$code_idx] .= substr($str,1)."\n";
|
||||
$code_changed = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if($obj!==null) $output[] = $obj;
|
||||
$output = $this->parseComp($list);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,3 +296,6 @@ dt span.closed { text-decoration: line-through; }
|
|||
.extraVarForm ul { margin:0; padding:0; list-style:none; }
|
||||
.extraVarForm .date { border:1px solid; border-color:#a6a6a6 #d8d8d8 #d8d8d8 #a6a6a6; padding:3px; margin-right:10px; width:100px; }
|
||||
.extraVarForm .address { border:1px solid; border-color:#a6a6a6 #d8d8d8 #d8d8d8 #a6a6a6; padding:3px; margin-right:10px; width:300px; }
|
||||
|
||||
.diff .deleted { background: #FFDDDD none; }
|
||||
.diff .added { background: #DDFFDD none; }
|
||||
|
|
|
|||
|
|
@ -10,30 +10,38 @@
|
|||
<!--@if($comp)-->
|
||||
<!--@foreach($comp as $item)-->
|
||||
<table>
|
||||
<col width="*" />
|
||||
<col width="20" />
|
||||
<col width="20" />
|
||||
<col width="*" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2" class="filename">{$item->filename}</th>
|
||||
<th colspan="3" class="filename">{$item->filename}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody class="diff">
|
||||
<tr class="revision">
|
||||
<td class="before">Rev. {$item->before_revision}</td>
|
||||
<td class="after">Rev. {$item->after_revision}</td>
|
||||
<td class="before">{$item->before_revision}</td>
|
||||
<td class="after">{$item->after_revision}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!--@foreach($item->changed as $change)-->
|
||||
<tr class="line">
|
||||
<td class="before">line {$change->before_line}</td>
|
||||
<td class="after">line {$change->after_line}</td>
|
||||
</tr>
|
||||
<!--@for($i=0;$i<count($change->before_code);$i++)-->
|
||||
<tr class="code">
|
||||
<td>{nl2br(str_replace(' ',' ',htmlspecialchars($change->before_code[$i])))}</td>
|
||||
<td>{nl2br(str_replace(' ',' ',htmlspecialchars($change->after_code[$i])))}</td>
|
||||
</tr>
|
||||
<!--@end-->
|
||||
<!--@end-->
|
||||
{@ $bStart = true }
|
||||
<!--@foreach($item->blocks as $block)-->
|
||||
<!--@if(!$bStart)-->
|
||||
<tr>
|
||||
<td>...</td>
|
||||
<td>...</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!--@endif-->
|
||||
<!--@foreach($block->lines as $line)-->
|
||||
<tr>
|
||||
<td>{$line->before_line_number}</td>
|
||||
<td>{$line->after_line_number}</td>
|
||||
<td <!--@if($line->type)-->class="{$line->type}"<!--@endif--> >{nl2br(str_replace("\t"," ",str_replace(' ',' ',htmlspecialchars($line->data))))}</td>
|
||||
</tr>
|
||||
<!--@endforeach-->
|
||||
{@ $bStart = false }
|
||||
<!--@endforeach-->
|
||||
</tbody>
|
||||
</table>
|
||||
<!--@end-->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue