diff --git a/codepot/src/codepot/controllers/source.php b/codepot/src/codepot/controllers/source.php index bd33e572..46e759c1 100644 --- a/codepot/src/codepot/controllers/source.php +++ b/codepot/src/codepot/controllers/source.php @@ -7,6 +7,7 @@ class Source extends Controller var $VIEW_FILE = 'source_file'; var $VIEW_BLAME = 'source_blame'; var $VIEW_HISTORY = 'source_history'; + var $VIEW_REVISION = 'source_revision'; var $VIEW_DIFF = 'source_diff'; function Source () @@ -115,7 +116,13 @@ class Source extends Controller $data['project'] = $project; $data['folder'] = $path; $data['files'] = $files; + $data['revision'] = $rev; + $data['prev_revision'] = + $this->subversion->getPrevRev ($projectid, $path, $rev); + $data['next_revision'] = + $this->subversion->getNextRev ($projectid, $path, $rev); + $this->load->view ($this->VIEW_FOLDER, $data); } } @@ -213,6 +220,7 @@ class Source extends Controller $data['login'] = $login; $path = $this->converter->HexToAscii ($path); + if ($path == '.') $path = ''; /* treat a period specially */ $project = $this->projects->get ($projectid); if ($project === FALSE) @@ -246,6 +254,50 @@ class Source extends Controller } } + function revision ($projectid, $path, $rev) + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('SubversionModel', 'subversion'); + + $login = $this->login->getUser (); + if (CODEPOT_ALWAYS_REQUIRE_SIGNIN && $login['id'] == '') + redirect ('main/signin'); + $data['login'] = $login; + + $path = $this->converter->HexToAscii ($path); + if ($path == '.') $path = ''; /* treat a period specially */ + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = "NO SUCH PROJECT - $projectid"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $file = $this->subversion->getRevisionHistory ($projectid, $path, $rev); + if ($file === FALSE) + { + $data['message'] = 'Failed to get log content'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $data['project'] = $project; + //$data['folder'] = substr ($path, 0, strrpos($path, '/')); + $data['folder'] = $path; + $data['file'] = $file; + $data['revision'] = $rev; + $this->load->view ($this->VIEW_REVISION, $data); + } + } + } + function diff ($projectid, $path, $rev1 = SVN_REVISION_HEAD, $rev2 = SVN_REVISION_PREV) { $this->load->model ('ProjectModel', 'projects'); diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index db6c269b..bd3d1227 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -8,6 +8,7 @@ $lang['Delete'] = 'Delete'; $lang['Description'] = 'Description'; $lang['Details'] = 'Details'; $lang['Difference'] = 'Diff'; +$lang['Directory'] = 'Directory'; $lang['Download'] = 'Download'; $lang['Edit'] = 'Edit'; $lang['Head revision'] = 'Head revision'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index 8c3e540d..79bcb69d 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -8,6 +8,7 @@ $lang['Delete'] = 'Hapus'; $lang['Description'] = 'Penjelasan'; $lang['Details'] = 'Detail'; $lang['Difference'] = 'Beda'; +ng['Directory'] = 'Direktori'; $lang['Download'] = 'Download'; $lang['Edit'] = 'Rubah'; $lang['Head revision'] = 'Kepala Revisi'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 7f3a11db..802e57a6 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -8,6 +8,7 @@ $lang['Delete'] = '삭제'; $lang['Description'] = '설명'; $lang['Details'] = '상세내역'; $lang['Difference'] = '차이점'; +$lang['Directory'] = '파일목록'; $lang['Download'] = '내려받기'; $lang['Edit'] = '수정'; $lang['Head revision'] = '최신리비전'; diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 796d27f8..9ee5cd5e 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -69,6 +69,23 @@ class SubversionModel extends Model return $fileinfo; } + function getRevisionHistory ($projectid, $file, $rev) + { + $path = 'file:///' . CODEPOT_SVNREPO_DIR . '/' . $projectid . '/' . $file; + + $last = substr(strrchr($path, '/'), 1); + $info['name'] = $last; + $fileinfo = $info; + + $str = @svn_log ($path, $rev, $rev); + if ($str === FALSE) return FALSE; + + if (count($str) != 1) return FALSE; + + $fileinfo['history'] = $str[0]; + return $fileinfo; + } + function _get_diff ($diff, $all, $ent) { /* copied from websvn */ diff --git a/codepot/src/codepot/views/Makefile.am b/codepot/src/codepot/views/Makefile.am index d1a765eb..1b6efb40 100644 --- a/codepot/src/codepot/views/Makefile.am +++ b/codepot/src/codepot/views/Makefile.am @@ -18,6 +18,7 @@ www_DATA = \ source_file.php \ source_folder.php \ source_history.php \ + source_revision.php \ taskbar.php \ user_home.php \ wiki_delete.php \ diff --git a/codepot/src/codepot/views/Makefile.in b/codepot/src/codepot/views/Makefile.in index 7148cb6f..ae9e5725 100644 --- a/codepot/src/codepot/views/Makefile.in +++ b/codepot/src/codepot/views/Makefile.in @@ -181,6 +181,7 @@ www_DATA = \ source_file.php \ source_folder.php \ source_history.php \ + source_revision.php \ taskbar.php \ user_home.php \ wiki_delete.php \ diff --git a/codepot/src/codepot/views/source_history.php b/codepot/src/codepot/views/source_history.php index ce012004..da9aaa4a 100644 --- a/codepot/src/codepot/views/source_history.php +++ b/codepot/src/codepot/views/source_history.php @@ -49,23 +49,29 @@ function print_path ($project, $path, $type, $converter, $rev = SVN_REVISION_HEA $par .= '/' . $exps[$i]; $hexpar = $converter->AsciiToHex ($par); print '/'; - $xpar = "source/$type/" . $project->id . '/' . $hexpar; - if ($rev != '') $xpar .= '/' . $rev; + $xpar = "source/history/$type/{$project->id}/{$hexpar}"; + if ($rev != '') $xpar .= "/{$rev}"; print anchor ($xpar, htmlspecialchars($exps[$i])); } } -print anchor ('/source/folder/' . $project->id, htmlspecialchars($project->name)); +print anchor ("/source/history/folder/{$project->id}", htmlspecialchars($project->name)); if ($folder != '') print_path ($project, $folder, 'folder', $this->converter); ?>