added full view of code difference
This commit is contained in:
parent
d5b787036f
commit
11e60639af
@ -336,7 +336,7 @@ class Code extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
function diff ($projectid = '', $path = '', $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_HEAD)
|
||||
function _do_diff ($projectid = '', $path = '', $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_HEAD, $full = FALSE)
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
$this->load->model ('SubversionModel', 'subversion');
|
||||
@ -371,7 +371,7 @@ class Code extends Controller
|
||||
redirect ("main/signin/" . $this->converter->AsciiTohex(current_url()));
|
||||
}
|
||||
|
||||
$file = $this->subversion->getDiff ($projectid, $path, $rev1, $rev2);
|
||||
$file = $this->subversion->getDiff ($projectid, $path, $rev1, $rev2, $full);
|
||||
if ($file === FALSE)
|
||||
{
|
||||
$data['project'] = $project;
|
||||
@ -400,6 +400,16 @@ class Code extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
function diff ($projectid = '', $path = '', $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_HEAD)
|
||||
{
|
||||
return $this->_do_diff ($projectid, $path, $rev1, $rev2, FALSE);
|
||||
}
|
||||
|
||||
function fulldiff ($projectid = '', $path = '', $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_HEAD)
|
||||
{
|
||||
return $this->_do_diff ($projectid, $path, $rev1, $rev2, TRUE);
|
||||
}
|
||||
|
||||
function fetch ($projectid = '', $path = '', $rev = SVN_REVISION_HEAD)
|
||||
{
|
||||
$this->load->model ('ProjectModel', 'projects');
|
||||
|
@ -30,6 +30,7 @@ $lang['File'] = 'File';
|
||||
$lang['Files'] = 'Files';
|
||||
$lang['First'] = 'First';
|
||||
$lang['Folder'] = 'Folder';
|
||||
$lang['Full Difference'] = 'FullDiff';
|
||||
$lang['Head revision'] = 'Head revision';
|
||||
$lang['Hide details'] = 'Hide details';
|
||||
$lang['History'] = 'History';
|
||||
|
@ -28,6 +28,7 @@ $lang['File'] = 'File';
|
||||
$lang['Files'] = 'File';
|
||||
$lang['First'] = 'Pertama';
|
||||
$lang['Folder'] = 'Folder';
|
||||
$lang['Full Difference'] = 'FullDiff';
|
||||
$lang['Head revision'] = 'Kepala revisi';
|
||||
$lang['History'] = 'Sejarah';
|
||||
$lang['Home'] = 'Beranda';
|
||||
|
@ -20,7 +20,7 @@ $lang['Delete'] = '삭제';
|
||||
$lang['Description'] = '설명';
|
||||
$lang['Destyle'] = '모양새제거';
|
||||
$lang['Details'] = '상세내역';
|
||||
$lang['Difference'] = '차이점';
|
||||
$lang['Difference'] = '차이';
|
||||
$lang['Directory'] = '디렉토리';
|
||||
$lang['Download'] = '내려받음';
|
||||
$lang['Edit'] = '수정';
|
||||
@ -30,6 +30,7 @@ $lang['File'] = '파일';
|
||||
$lang['Files'] = '파일';
|
||||
$lang['First'] = '처음';
|
||||
$lang['Folder'] = '폴더';
|
||||
$lang['Full Difference'] = '전체차이';
|
||||
$lang['Head revision'] = '최신리비전';
|
||||
$lang['Hide details'] = '상세내역숨김';
|
||||
$lang['History'] = '변경기록';
|
||||
|
@ -278,14 +278,20 @@ class SubversionModel extends Model
|
||||
return $fileinfo;
|
||||
}
|
||||
|
||||
function _get_diff ($diff, $all, $ent)
|
||||
function _get_diff ($diff, $src1, $src2, $all, $ent)
|
||||
{
|
||||
/* copied from websvn */
|
||||
|
||||
if ($all)
|
||||
{
|
||||
$ofile = fopen ($oldtname, "r");
|
||||
$nfile = fopen ($newtname, "r");
|
||||
//$ofile = fopen ($oldtname, "r");
|
||||
//$nfile = fopen ($newtname, "r");
|
||||
$ofile = fopen("php://memory", 'r+');
|
||||
$nfile = fopen("php://memory", 'r+');
|
||||
fputs($ofile, $src1);
|
||||
fputs($nfile, $src2);
|
||||
rewind($ofile);
|
||||
rewind($nfile);
|
||||
}
|
||||
|
||||
// Ignore the 4 header lines
|
||||
@ -398,15 +404,15 @@ class SubversionModel extends Model
|
||||
$listing[$index]["rev1diffclass"] = "diffdeleted";
|
||||
$listing[$index]["rev2diffclass"] = "diff";
|
||||
|
||||
$listing[$index]["rev1line"] = $text;
|
||||
//$listing[$index]["rev2line"] = " ";
|
||||
$listing[$index]["rev2line"] = '';
|
||||
|
||||
if ($all) {
|
||||
fgets($ofile);
|
||||
$curoline++;
|
||||
}
|
||||
|
||||
$listing[$index]["rev1line"] = $text;
|
||||
//$listing[$index]["rev2line"] = " ";
|
||||
$listing[$index]["rev2line"] = '';
|
||||
|
||||
break;
|
||||
|
||||
case "+":
|
||||
@ -429,23 +435,29 @@ class SubversionModel extends Model
|
||||
$listing[$i]["rev2diffclass"] = "diffchanged";
|
||||
$listing[$i]["rev2line"] = $text;
|
||||
|
||||
if ($all) {
|
||||
if ($all)
|
||||
{
|
||||
fgets($nfile);
|
||||
$curnline++;
|
||||
}
|
||||
|
||||
|
||||
// Don't increment the current index count
|
||||
$index--;
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$listing[$index]["rev1diffclass"] = "diff";
|
||||
$listing[$index]["rev2diffclass"] = "diffadded";
|
||||
|
||||
|
||||
//$listing[$index]["rev1line"] = " ";
|
||||
$listing[$index]["rev1line"] = '';
|
||||
$listing[$index]["rev2line"] = $text;
|
||||
|
||||
if ($all) {
|
||||
if ($all)
|
||||
{
|
||||
fgets($nfile);
|
||||
$curnline++;
|
||||
}
|
||||
@ -459,7 +471,8 @@ class SubversionModel extends Model
|
||||
$listing[$index]["rev1line"] = $text;
|
||||
$listing[$index]["rev2line"] = $text;
|
||||
|
||||
if ($all) {
|
||||
if ($all)
|
||||
{
|
||||
fgets($ofile);
|
||||
fgets($nfile);
|
||||
$curoline++;
|
||||
@ -479,13 +492,18 @@ class SubversionModel extends Model
|
||||
// Output the rest of the files
|
||||
if ($all)
|
||||
{
|
||||
while (!feof($ofile) || !feof($nfile))
|
||||
while (1)
|
||||
{
|
||||
if (feof($ofile) && feof($nfile)) break;
|
||||
|
||||
$listing[$index]["rev1diffclass"] = "diff";
|
||||
$listing[$index]["rev2diffclass"] = "diff";
|
||||
|
||||
$line = rtrim(fgets($ofile));
|
||||
if ($ent) $line = replaceEntities($line, $rep);
|
||||
if (!feof($ofile))
|
||||
{
|
||||
$line = rtrim(fgets($ofile));
|
||||
if ($ent) $line = replaceEntities($line, $rep);
|
||||
}
|
||||
|
||||
if (!feof($ofile)) {
|
||||
//$listing[$index]["rev1line"] = hardspace($line);
|
||||
@ -495,9 +513,13 @@ class SubversionModel extends Model
|
||||
//$listing[$index]["rev1line"] = " ";
|
||||
$listing[$index]["rev1line"] = '';
|
||||
}
|
||||
|
||||
|
||||
$line = rtrim(fgets($nfile));
|
||||
if ($ent) $line = replaceEntities(rtrim(fgets($nfile)), $rep);
|
||||
if (!feof($nfile))
|
||||
{
|
||||
$line = rtrim(fgets($nfile));
|
||||
if ($ent) $line = replaceEntities(rtrim(fgets($nfile)), $rep);
|
||||
}
|
||||
|
||||
if (!feof($nfile)) {
|
||||
//$listing[$index]["rev2line"] = hardspace($line);
|
||||
@ -528,7 +550,7 @@ class SubversionModel extends Model
|
||||
// $rev1 - new revision number
|
||||
// $rev2 - old revision number
|
||||
//
|
||||
function getDiff ($projectid, $path, $rev1, $rev2)
|
||||
function getDiff ($projectid, $path, $rev1, $rev2, $full = FALSE)
|
||||
{
|
||||
//$url = 'file:///'.CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}";
|
||||
$orgurl = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}/{$path}");
|
||||
@ -621,7 +643,16 @@ class SubversionModel extends Model
|
||||
|
||||
fclose($errors);
|
||||
|
||||
$fileinfo['content'] = $this->_get_diff ($diff, FALSE, FALSE);
|
||||
if ($full)
|
||||
{
|
||||
$src1 = @svn_cat ($info2[0]['url'], $info2[0]['revision']);
|
||||
$src2 = @svn_cat ($info1[0]['url'], $info1[0]['revision']);
|
||||
$fileinfo['content'] = $this->_get_diff ($diff, $src1, $src2, TRUE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fileinfo['content'] = $this->_get_diff ($diff, '', '', FALSE, FALSE);
|
||||
}
|
||||
fclose ($diff);
|
||||
|
||||
return $fileinfo;
|
||||
|
@ -219,6 +219,10 @@ $history = $file['history'];
|
||||
print anchor ("code/diff/{$project->id}/{$xpar}/{$history['rev']}", $this->lang->line('Difference'));
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print anchor ("code/fulldiff/{$project->id}/{$xpar}/{$history['rev']}", $this->lang->line('Full Difference'));
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user