From a950cb9e30fe26d72b6f00921b2d6d568239d751 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 12 Apr 2015 15:31:09 +0000 Subject: [PATCH] # incremented the version number to 0.3.0 to begin working on the 0.3.0 release # added svn_tag_property to support soft tagging/labeling # changed some code views to show the tag # enhanced the revision view to tag/untag the revision --- codepot/configure | 20 +-- codepot/configure.ac | 2 +- codepot/etc/codepot.ini.in | 5 + codepot/src/codepot/controllers/code.php | 127 ++++++++++++++---- .../src/codepot/models/subversionmodel.php | 15 ++- codepot/src/codepot/views/code_blame.php | 18 ++- codepot/src/codepot/views/code_file.php | 19 ++- codepot/src/codepot/views/code_folder.php | 10 +- codepot/src/codepot/views/code_history.php | 8 +- codepot/src/codepot/views/code_revision.php | 70 +++++++++- codepot/src/config.php.in | 2 + codepot/src/css/common.css | 26 ++++ 12 files changed, 268 insertions(+), 54 deletions(-) diff --git a/codepot/configure b/codepot/configure index 440a484e..c89de088 100755 --- a/codepot/configure +++ b/codepot/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for codepot 0.2.0. +# Generated by GNU Autoconf 2.69 for codepot 0.3.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -576,8 +576,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='codepot' PACKAGE_TARNAME='codepot' -PACKAGE_VERSION='0.2.0' -PACKAGE_STRING='codepot 0.2.0' +PACKAGE_VERSION='0.3.0' +PACKAGE_STRING='codepot 0.3.0' PACKAGE_BUGREPORT='' PACKAGE_URL='http://code.abiyo.net/@codepot' @@ -1227,7 +1227,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures codepot 0.2.0 to adapt to many kinds of systems. +\`configure' configures codepot 0.3.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1293,7 +1293,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of codepot 0.2.0:";; + short | recursive ) echo "Configuration of codepot 0.3.0:";; esac cat <<\_ACEOF @@ -1373,7 +1373,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -codepot configure 0.2.0 +codepot configure 0.3.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1390,7 +1390,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by codepot $as_me 0.2.0, which was +It was created by codepot $as_me 0.3.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2209,7 +2209,7 @@ fi # Define the identity of the package. PACKAGE='codepot' - VERSION='0.2.0' + VERSION='0.3.0' cat >>confdefs.h <<_ACEOF @@ -3776,7 +3776,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by codepot $as_me 0.2.0, which was +This file was extended by codepot $as_me 0.3.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3839,7 +3839,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -codepot config.status 0.2.0 +codepot config.status 0.3.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/codepot/configure.ac b/codepot/configure.ac index 0d693c2a..a5790c95 100644 --- a/codepot/configure.ac +++ b/codepot/configure.ac @@ -1,7 +1,7 @@ dnl AC_PREREQ(2.59) -AC_INIT([codepot],[0.2.0],,,[http://code.abiyo.net/@codepot]) +AC_INIT([codepot],[0.3.0],,,[http://code.abiyo.net/@codepot]) AC_CONFIG_HEADER([./config.h]) AC_CONFIG_AUX_DIR([ac/aux]) AC_CONFIG_MACRO_DIR([ac/m4]) diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index ef25e06e..4cbc8c21 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -223,6 +223,11 @@ cloc_command_path = "@CFGDIR@/cloc.pl" ;------------------------------------------------------------------------------ code_folder_readme = "README.wiki,README.txt,README" +;------------------------------------------------------------------------------ +; Codepot sets this revision property to assign a tag to a specific revision. +;------------------------------------------------------------------------------ +svn_tag_property = "codepot:tag" + ;------------------------------------------------------------------------------ ; Subversion read access is limited to the specified user type. The types ; include anonymous, authenticated, member. This applies to a public project diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index 7fc816b5..1f7636b2 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -89,15 +89,27 @@ class Code extends Controller $file['next_rev'] = $this->subversion->getNextRev ( $projectid, $path, $file['created_rev']); + $file['created_tag'] = $this->subversion->getRevProp ($projectid, $file['created_rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($file['created_tag'] === FALSE) $file['created_tag'] = ''; + + $file['head_tag'] = $this->subversion->getRevProp ($projectid, $file['head_rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($file['head_tag'] === FALSE) $file['head_tag'] = ''; + + $data['project'] = $project; $data['headpath'] = $path; $data['file'] = $file; $data['revision'] = $rev; + + $this->load->view ($this->VIEW_FILE, $data); } } else { + $file['created_tag'] = $this->subversion->getRevProp ($projectid, $file['created_rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($file['created_tag'] === FALSE) $file['created_tag'] = ''; + $data['project'] = $project; $data['headpath'] = $path; $data['file'] = $file; @@ -188,11 +200,19 @@ class Code extends Controller $file['next_rev'] = $this->subversion->getNextRev ( $projectid, $path, $file['created_rev']); + $file['created_tag'] = $this->subversion->getRevProp ($projectid, $file['created_rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($file['created_tag'] === FALSE) $file['created_tag'] = ''; + + $file['head_tag'] = $this->subversion->getRevProp ($projectid, $file['head_rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($file['head_tag'] === FALSE) $file['head_tag'] = ''; + + $data['project'] = $project; $data['headpath'] = $path; $data['file'] = $file; $data['revision'] = $rev; + $this->load->view ($this->VIEW_BLAME, $data); } } @@ -243,6 +263,21 @@ class Code extends Controller } else { + if (array_key_exists('history', $file)) + { + // Inject the codepot defined tag. + foreach ($file['history'] as &$h) + { + if (array_key_exists('rev', $h)) + { + $h['tag'] = $this->subversion->getRevProp ($projectid, $h['rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($h['tag'] === FALSE) $h['tag'] = ''; + } + else $h['tag'] = ''; + } + } + + $data['project'] = $project; $data['fullpath'] = $path; $data['file'] = $file; @@ -295,38 +330,64 @@ class Code extends Controller } $data['popup_error_message'] = ''; - if ($login['id'] != '' && - $login['id'] == $this->subversion->getRevProp($projectid, $rev, 'svn:author') && - $this->input->post('edit_log_message')) + if ($login['id'] != '') { - // the current user must be the author of the revision to be able to - // change the log message. - $this->load->helper ('form'); - $this->load->library ('form_validation'); - - $this->form_validation->set_rules ('edit_log_message', 'Message', 'required|min_length[2]'); - $this->form_validation->set_error_delimiters('',''); - - if ($this->form_validation->run()) + $tag = $this->input->post('tag_revision'); + if ($tag !== FALSE) { - $logmsg = $this->input->post('edit_log_message'); - if ($logmsg != $this->subversion->getRevProp ($projectid, $rev, 'svn:log')) + $tag = trim($tag); + if (empty($tag)) { - $actual_rev = $this->subversion->setRevProp ( - $projectid, $rev, 'svn:log', $logmsg, $login['id']); - if ($actual_rev === FALSE) - { - $data['popup_error_message'] = 'Cannot change revision log message'; - } - else - { - $this->form_validation->_field_data = array(); - } + // delete the tag if the value is empty + $affected_rev = $this->subversion->killRevProp ( + $projectid, $rev, CODEPOT_SVN_TAG_PROPERTY, $login['id']); + } + else + { + $affected_rev = $this->subversion->setRevProp ( + $projectid, $rev, CODEPOT_SVN_TAG_PROPERTY, $tag, $login['id']); + } + if ($affected_rev === FALSE) + { + $data['popup_error_message'] = 'Cannot tag revision'; + } + else + { + $this->form_validation->_field_data = array(); } } - else + else if ($login['id'] == $this->subversion->getRevProp($projectid, $rev, 'svn:author') && + $this->input->post('edit_log_message')) { - $data['popup_error_message'] = 'Invalid revision log message'; + // the current user must be the author of the revision to be able to + // change the log message. + $this->load->helper ('form'); + $this->load->library ('form_validation'); + + $this->form_validation->set_rules ('edit_log_message', 'Message', 'required|min_length[2]'); + $this->form_validation->set_error_delimiters('',''); + + if ($this->form_validation->run()) + { + $logmsg = $this->input->post('edit_log_message'); + if ($logmsg != $this->subversion->getRevProp ($projectid, $rev, 'svn:log')) + { + $affected_rev = $this->subversion->setRevProp ( + $projectid, $rev, 'svn:log', $logmsg, $login['id']); + if ($affected_rev === FALSE) + { + $data['popup_error_message'] = 'Cannot change revision log message'; + } + else + { + $this->form_validation->_field_data = array(); + } + } + } + else + { + $data['popup_error_message'] = 'Invalid revision log message'; + } } } @@ -421,6 +482,18 @@ class Code extends Controller } else { + if (array_key_exists('history', $file)) + { + // Inject the codepot defined tag. + $h = &$file['history']; + if (array_key_exists('rev', $h)) + { + $h['tag'] = $this->subversion->getRevProp ($projectid, $h['rev'], CODEPOT_SVN_TAG_PROPERTY); + if ($h['tag'] === FALSE) $h['tag'] = ''; + } + else $h['tag'] = ''; + } + $data['project'] = $project; $data['headpath'] = $path; $data['file'] = $file; @@ -431,7 +504,7 @@ class Code extends Controller $this->subversion->getPrevRev ($projectid, $path, $rev); $data['next_revision'] = $this->subversion->getNextRev ($projectid, $path, $rev); - + $this->load->view ($this->VIEW_REVISION, $data); } } diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 024804a9..e7b4155e 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -179,7 +179,7 @@ class SubversionModel extends Model if ($info === FALSE || count($info) != 1) { // - // Try further with a given operatal revision + // Try further with the original revision // $rev = $orgrev; $info = @svn_info ($url, FALSE, $rev); @@ -839,6 +839,19 @@ class SubversionModel extends Model return $result; } + function killRevProp ($projectid, $rev, $prop, $user) + { + $url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}"); + + $orguser = @svn_auth_get_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME); + @svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $user); + + $result = @svn_revprop_delete ($url, $rev, $prop); + + @svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $orguser); + return $result; + } + function _cloc_revision ($projectid, $path, $rev) { diff --git a/codepot/src/codepot/views/code_blame.php b/codepot/src/codepot/views/code_blame.php index 0cb2611f..a633279f 100644 --- a/codepot/src/codepot/views/code_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -170,10 +170,20 @@ print anchor ("code/fetch/{$project->id}/${xpar}{$revreq}", $this->lang->line('D
- id}/${xpar}/{$file['prev_rev']}", '<<')?> - lang->line('Revision')?>: - id}/${xpar}/{$file['next_rev']}", '>>')?> | - lang->line('Size')?>: | + id}/${xpar}/{$file['prev_rev']}", '<<'); + printf ('%s: %s', $this->lang->line('Revision'), $file['created_rev']); + if (!empty($file['created_tag'])) + { + print (''); + print htmlspecialchars($file['created_tag']); + print (''); + } + print anchor ("code/blame/{$project->id}/${xpar}/{$file['next_rev']}", '>>'); + + print ' | '; + printf ('%s: %s', $this->lang->line('Size'), $file['size']); + ?> lang->line('Details')?>
diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 74bcd03d..c6a47a32 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -212,10 +212,21 @@ $this->load->view (
- id}/${xpar}/{$file['prev_rev']}", '<<')?> - lang->line('Revision')?>: - id}/${xpar}/{$file['next_rev']}", '>>')?> | - lang->line('Size')?>: | + + id}/${xpar}/{$file['prev_rev']}", '<<'); + printf ('%s: %s', $this->lang->line('Revision'), $file['created_rev']); + if (!empty($file['created_tag'])) + { + print (''); + print htmlspecialchars($file['created_tag']); + print (''); + } + print anchor ("code/file/{$project->id}/${xpar}/{$file['next_rev']}", '>>'); + + print ' | '; + printf ('%s: %s', $this->lang->line('Size'), $file['size']); + ?> lang->line('Details')?>
diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index b9aeaee5..f8758e10 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -292,7 +292,15 @@ $this->load->view ( | - lang->line('Revision')?>: + lang->line('Revision'), $file['created_rev']); + if (!empty($file['created_tag'])) + { + print (''); + print htmlspecialchars($file['created_tag']); + print (''); + } + ?> 0): ?> | lang->line('Details')?> diff --git a/codepot/src/codepot/views/code_history.php b/codepot/src/codepot/views/code_history.php index 25538cb0..bd7ff77b 100644 --- a/codepot/src/codepot/views/code_history.php +++ b/codepot/src/codepot/views/code_history.php @@ -120,6 +120,13 @@ $this->load->view ( ($fullpath == '')? '.': $fullpath); print anchor ("code/file/{$project->id}/{$xfullpath}/{$h['rev']}", $h['rev']); + + if (!empty($h['tag'])) + { + print ''; + print htmlspecialchars($h['tag']); + print ''; + } print ''; print ''; @@ -139,7 +146,6 @@ $this->load->view ( print ''; print ''; - if ($file['type'] == 'file') { print ''; diff --git a/codepot/src/codepot/views/code_revision.php b/codepot/src/codepot/views/code_revision.php index d17810db..55d303aa 100644 --- a/codepot/src/codepot/views/code_revision.php +++ b/codepot/src/codepot/views/code_revision.php @@ -20,6 +20,27 @@ $(function() { + $("#code_revision_tag_div").dialog ( + { + title: 'lang->line('Tag')?>', + width: 'auto', + height: 'auto', + resizable: false, + autoOpen: false, + modal: true, + buttons: { + 'lang->line('OK')?>': function () { + $('#code_revision_tag_form').submit (); + $(this).dialog('close'); + }, + 'lang->line('Cancel')?>': function () { + $(this).dialog('close'); + } + }, + close: function() { } + } + ); + $("#code_revision_edit_div").dialog ( { title: 'lang->line('Edit')?>', @@ -41,6 +62,13 @@ $(function() { } ); + $("#code_revision_tag_button").button().click ( + function () { + $("#code_revision_tag_div").dialog('open'); + return false; + } + ); + $("#code_revision_edit_logmsg_button").button().click ( function () { $("#code_revision_edit_div").dialog('open'); @@ -281,11 +309,30 @@ $history = $file['history'];
- id}/${xpar}/{$prev_revision}", '<<')?> - lang->line('Revision')?>: - id}/${xpar}/{$next_revision}", '>>')?> | - lang->line('Committer')?>: | - lang->line('Last updated on')?>: + id}/${xpar}/{$prev_revision}", '<<'); + printf ('%s: %s', $this->lang->line('Revision'), $history['rev']); + if (!empty($history['tag'])) + { + print (''); + print htmlspecialchars($history['tag']); + print (''); + } + print anchor ("code/revision/{$project->id}/${xpar}/{$next_revision}", '>>'); + + if ($can_edit) + { + print ''; + print anchor ("#", $this->lang->line('Tag'), array ('id' => 'code_revision_tag_button')); + print ''; + } + + print ' | '; + printf ('%s: %s', $this->lang->line('Committer'), htmlspecialchars($history['author'])); + print ' | '; + + printf ('%s: %s', $this->lang->line('Last updated on'), date('r', strtotime($history['date']))); + ?>
@@ -407,6 +454,19 @@ $history = $file['history']; +
+ id}${revreqroot}", 'id="code_revision_tag_form"')?> + 'tag_revision', + 'value' => $history['tag'], + 'id' => 'code_revision_tag') + ) + + ?> + +
+
id}${revreqroot}", 'id="code_revision_edit_logmsg_form"')?>