cvs diff: Diffing modules/cvslog
Index: modules/cvslog/README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/README.txt,v
retrieving revision 1.3.2.1
diff -u -F^f -r1.3.2.1 README.txt
--- modules/cvslog/README.txt 21 Jun 2006 22:57:07 -0000 1.3.2.1
+++ modules/cvslog/README.txt 16 Oct 2006 04:28:32 -0000
@@ -16,5 +16,10 @@
* Each commit message can be modified in a theme_cvs_entry($cvs) function,
the parameter is an object containing user, timestamp, and message.
+Site-specific customization:
+ * Parts of this code are very specific to how this module is used
+ on drupal.org. I'm trying to isolate as many of these
+ site-specific hacks as possible into the cvs_local.inc file.
+
Note that you must customize the xcvs/xcvs-config.php file if you wish
to use those scripts on your site. See xcvs/README.txt for details.
Index: modules/cvslog/cvs.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.install,v
retrieving revision 1.4.2.3
diff -u -F^f -r1.4.2.3 cvs.install
--- modules/cvslog/cvs.install 18 Sep 2006 22:20:05 -0000 1.4.2.3
+++ modules/cvslog/cvs.install 16 Oct 2006 04:28:33 -0000
@@ -98,6 +98,7 @@ function cvs_install() {
break;
}
+ $ret[] = db_query("UPDATE {system} SET weight = 3 WHERE name = 'cvs'");
return $ret;
}
@@ -159,3 +160,9 @@ function cvs_update_3() {
return $ret;
}
+function cvs_update_4() {
+ $ret = array();
+ $ret[] = update_sql("UPDATE {system} SET weight = 3 WHERE name = 'cvs'");
+ return $ret;
+}
+
Index: modules/cvslog/cvs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.module,v
retrieving revision 1.106.2.19
diff -u -F^f -r1.106.2.19 cvs.module
--- modules/cvslog/cvs.module 18 Sep 2006 10:37:43 -0000 1.106.2.19
+++ modules/cvslog/cvs.module 16 Oct 2006 04:28:34 -0000
@@ -17,6 +17,11 @@
define('CVS_MESSAGE_ANON', 'The Concurrent Versioning System (CVS) is a software development tool available to volunteers with experience in software development, translation, themeing, or documentation who wish to participate in the Drupal project. To request access to the Drupal CVS repository you must create an account and login. Come back to this page after you have logged on.');
define('CVS_MESSAGE_AUTH', 'The Concurrent Versioning System (CVS) is a software development tool used to manage programs and files for the Drupal project. It is available to volunteers with experience in software development, translation, themeing, or documentation who wish to participate in the project. If you are an Open Source software developer, themer, translator, or documentation writer, you can use the form below to request access to Drupal\'s CVS repository. Note that there are two repositories, core and contributions. Access to the Drupal core repository is only available to a handful of people, and CVS access is not required to contribute patches to core. For that, you should submit an issue into the issue queue for Drupal core. You are also not allowed to commit patches to modules maintained by other people without obtaining permission from them to do so. Please do not duplicate modules that overlap with a significant portion of functionality with what you are proposing to write.');
+$path = drupal_get_path('module', 'cvs');
+if (file_exists("$path/cvs_local.inc")) {
+ require_once "$path/cvs_local.inc";
+}
+
/**
* Implementation of hook_help().
*/
@@ -384,38 +389,383 @@ function cvs_nodeapi(&$node, $op, $arg =
*/
function cvs_form_alter($form_id, &$form) {
if ($form_id == 'project_project_node_form') {
- $node = $form['#node'];
- $result = db_query("SELECT rid, name FROM {cvs_repositories}");
- while ($repository = db_fetch_object($result)) {
- $repositories[$repository->rid] = $repository->name;
- }
- $form['cvs_nodeapi'] = array(
- '#type' => 'fieldset',
- '#title' => t('CVS integration'),
- '#collapsible' => TRUE,
- '#collapsed' => $node->cvs_directory ? TRUE : FALSE,
- );
- $projects_allowing_repo = explode(',', strtolower(variable_get('cvs_allow_repo_selection', '')));
- $allow_repo = in_array(strtolower($node->title), $projects_allowing_repo);
- $default_repo = $node->cvs_repository ? $node->cvs_repository : variable_get('cvs_default_repo', '');
- if (!empty($repositories)) {
- $form['cvs_nodeapi']['cvs_repository'] = array(
- '#type' => 'select',
- '#title' => t('Repository'),
- '#default_value' => $default_repo,
- '#options' => $allow_repo ? $repositories : array($default_repo => $repositories[$default_repo]),
- '#description' => t("Specify the project's CVS repository."),
- );
- }
- $form['cvs_nodeapi']['cvs_directory'] = array(
- '#type' => 'textfield',
- '#title' => t('CVS directory'),
- '#default_value' => $node->cvs_directory,
- '#size' => 40,
- '#maxlength' => 255,
- '#description' => t("Specify the project's directory within the specified CVS repository. Directory names should start with a leading slash and end with a trailing slash, and must be unique for each project. For example: /modules/foo/
, /themes/foo/
or /translations/foo/
."),
+ cvs_alter_project_project_form($form);
+ return;
+ }
+ if ($form_id == 'project_release_node_form') {
+ if (function_exists('cvs_local_alter_project_release_form')) {
+ cvs_local_alter_project_release_form($form);
+ }
+ cvs_alter_project_release_form($form);
+ return;
+ }
+}
+
+/**
+ * Alters the project_project node form to add CVS integration
+ * @see cvs_form_alter
+ */
+function cvs_alter_project_project_form(&$form) {
+ $node = $form['#node'];
+ $result = db_query("SELECT rid, name FROM {cvs_repositories}");
+ while ($repository = db_fetch_object($result)) {
+ $repositories[$repository->rid] = $repository->name;
+ }
+ $form['cvs_nodeapi'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('CVS integration'),
+ '#collapsible' => TRUE,
+ '#collapsed' => $node->cvs_directory ? TRUE : FALSE,
+ );
+ $projects_allowing_repo = explode(',', strtolower(variable_get('cvs_allow_repo_selection', '')));
+ $allow_repo = in_array(strtolower($node->title), $projects_allowing_repo);
+ $default_repo = $node->cvs_repository ? $node->cvs_repository : variable_get('cvs_default_repo', '');
+ if (!empty($repositories)) {
+ $form['cvs_nodeapi']['cvs_repository'] = array(
+ '#type' => 'select',
+ '#title' => t('Repository'),
+ '#default_value' => $default_repo,
+ '#options' => $allow_repo ? $repositories : array($default_repo => $repositories[$default_repo]),
+ '#description' => t("Specify the project's CVS repository."),
+ );
+ }
+ $form['cvs_nodeapi']['cvs_directory'] = array(
+ '#type' => 'textfield',
+ '#title' => t('CVS directory'),
+ '#default_value' => $node->cvs_directory,
+ '#size' => 40,
+ '#maxlength' => 255,
+ '#description' => t("Specify the project's directory within the specified CVS repository. Directory names should start with a leading slash and end with a trailing slash, and must be unique for each project. For example: /modules/foo/
, /themes/foo/
or /translations/foo/
."),
+ '#required' => TRUE,
+ );
+}
+
+/**
+ * Alters the project_release node to add build tag UI
+ * @see cvs_form_alter
+ */
+function cvs_alter_project_release_form(&$form) {
+ // If we're not adding it, call a separate method that just worries
+ // about how to alter the edit form, since the add form is so complex.
+ if (arg(1) != 'add') {
+ return cvs_alter_project_release_form_edit($form);
+ }
+
+ $project = $form['project']['#value'];
+ if (!isset($project->releases)) {
+ // This project has no releases, nothing to alter
+ return;
+ }
+
+ $fields = array('version_major', 'version_minor', 'version_patch');
+
+ if (isset($_POST['edit']['tag'])) {
+ $tag_name = $_POST['edit']['tag'];
+ // We have to validate this here, since we're getting called
+ // before a validate callback would be invoked...
+ if (!isset($tag_name)) {
+ form_set_error('tag', t('You have to select a valid CVS tag or branch.'));
+ }
+ $vid = _project_release_get_api_vid();
+ if ($tag_name == 'HEAD') {
+ // Special case validation for the HEAD...
+ $tag->tag = 'HEAD';
+ $tag->branch = 1;
+ $tag->nid = $project->nid;
+ $form['version'] = form_builder('project_release_node_form', $form['version']);
+ foreach ($fields as $field) {
+ $form_val = $form['version']['num'][$field]['#value'];
+ if (isset($form_val) && $form_val !== '') {
+ if (is_numeric($form_val) || $form_val == 'x') {
+ $version->$field = $form_val;
+ }
+ }
+ }
+ $form_val = $form['version']['num']['version_extra']['#value'];
+ if (isset($form_val) && $form_val !== '') {
+ $version->version_extra = check_plain($form_val);
+ }
+ // It'd be nice to just use form_builder() here, like we do with
+ // the rest of the version info. However, something about
+ // form_builder() screws up the usual taxonomy-related FAPI
+ // code, and when we finally hit hook_insert(), our taxonomy
+ // array is clobbered and the terms don't get saved. So, we just
+ // use very careful inspection of $_POST to figure out if the
+ // API selector has already been set and use that in our $version.
+ $needs_api_none = true;
+ if (isset($form['taxonomy'][$vid])) {
+ $post_val = $_POST['edit']['taxonomy'][$vid];
+ if (isset($post_val)) {
+ if (is_numeric($post_val) && !empty($post_val) && db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $post_val, $vid))) {
+ $version->version_api_tid = $post_val;
+ $options[$post_val] = $form['taxonomy'][$vid]['#options'][$post_val];
+ $form['taxonomy'][$vid]['#options'] = $options;
+ $form['taxonomy'][$vid]['#default_value'] = $post_val;
+ $needs_api_none = false;
+ }
+ }
+ if ($needs_api_none) {
+ $form['taxonomy'][$vid]['#options'] = array(0 => t('None')) + $form['taxonomy'][$vid]['#options'];
+ $form['taxonomy'][$vid]['#default_value'] = 0;
+ // Set required to false so we don't get an error as soon
+ // as we land on the page. We'll re-mark it required in
+ // pre_render(), and ensure we don't get "none"...
+ $form['taxonomy'][$vid]['#required'] = false;
+ }
+ }
+ if (function_exists('cvs_local_version_is_valid')) {
+ $version_is_valid = cvs_local_version_is_valid($version, $project);
+ }
+ else {
+ $version_is_valid = isset($version);
+ }
+ if ($version_is_valid) {
+ $version_str = project_release_get_version($version, $project);
+ unset($form['validate_version']);
+ }
+ else {
+ unset($version);
+ _cvs_alter_project_release_form_unset_all($form, false);
+ $elements = element_children($form['taxonomy']);
+ $found_it = false;
+ foreach ($elements as $element) {
+ if ($element != $vid) {
+ unset($form['taxonomy'][$element]);
+ }
+ else {
+ $found_it = true;
+ }
+ }
+ if (!$found_it) {
+ // If we're not leaving the API selection element, unset the
+ // whole thing so we don't leave an empty fieldset.
+ unset($form['taxonomy']);
+ }
+ }
+ }
+ else {
+ $query = db_query("SELECT * FROM {cvs_tags} WHERE nid = %d AND tag = '%s'", $project->nid, $tag_name);
+ $tag = db_fetch_object($query);
+ if (!$tag) {
+ form_set_error('tag', t('The tag you selected does not exist for this project.'));
+ }
+ $query = db_query("SELECT * FROM {project_release_nodes} WHERE pid = %d AND tag = '%s'", $project->nid, $tag_name);
+ if (db_num_rows($query)) {
+ form_set_error('tag', t('The tag or branch you have selected is already in use by another release'));
+ }
+ $version = cvs_get_version_from_tag($tag, $project);
+ $version_str = project_release_get_version($version, $project);
+ // Since we got the version info from the tag, we don't want to try
+ // try to validate the version field elements...
+ unset($form['validate_version']);
+ }
+ unset($form['tag']);
+ $tags[$tag_name] = $tag_name;
+ $form['cvs_tag'] = array('#weight' => -4);
+ $form['cvs_tag']['tag'] = array(
+ '#type' => 'select',
+ '#title' => t('CVS tag'),
+ '#options' => $tags,
+ '#default_value' => $tag->tag,
'#required' => TRUE,
);
+ $form['cvs_tag']['rebuild'] = array(
+ '#type' => 'hidden',
+ '#value' => $tag->branch,
+ );
+ $form['cvs_tag'] = form_builder('project_release_node_form', $form['cvs_tag']);
+ unset($form['version']['version']);
+ if (isset($version_str)) {
+ // Since this is the final page, turn this into a fieldset with
+ // all the nice float/clear goodness
+ $form['cvs_tag']['#type'] = 'fieldset';
+ $form['cvs_tag']['#title'] = t('Release identification');
+ $form['cvs_tag']['#prefix'] = '
' . t('To create a release, you must first create either a new CVS tag on one of the existing branches for this project, or you must add a new CVS branch.'); + $err .= '
' . t('Once you have created a tag or branch that should be used for your new release, try pressing the %retry button to continue.', array('%retry' => theme('placeholder', t('Retry')))); + drupal_set_message($err); + $form['preview']['#value'] = t('Retry'); + } + } + + // Regardless of if we're on page #1 or #2, we want to remove the + // file selector, since if we're doing this via a CVS tag, the file + // will be filled in later by the packaging script. + // TODO (feature): it'd be nice if this was optional, so that some + // sites might want to still allow file attachments for releases... + unset($form['file']); +} + + +/** + * Alters the project_release node form during edits + * @see cvs_form_alter + */ +function cvs_alter_project_release_form_edit(&$form) { + global $user; + $release = $form['#node']; + if (user_access('administer projects')) { + $project = node_load($release->pid); + $tags = array(); + $tags[$release->tag] = $release->tag; + $tags['HEAD'] = 'HEAD'; + $result = db_query("SELECT c.nid, c.tag, c.branch FROM {cvs_tags} c LEFT JOIN {project_release_nodes} p ON c.nid = p.pid AND p.tag = c.tag WHERE c.nid = %d AND p.tag IS NULL AND c.branch = 1 ORDER BY c.tag DESC", $release->pid); + while ($tag = db_fetch_object($result)) { + $version = project_release_get_version(cvs_get_version_from_tag($tag, $project), $project); + $tags[$tag->tag] = $tag->tag .' ('. $version .')'; + } + } + else { + $tags[$release->tag] = $release->tag; + } + $form['cvs_tag'] = array( + '#type' => 'fieldset', + '#title' => t('Release identification'), + '#prefix' => '