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 7 Oct 2006 17:56:08 -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.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 7 Oct 2006 17:56:09 -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,237 @@ 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/."), + return cvs_alter_project_project_form($form); + } + if ($form_id == 'project_release_node_form') { + return cvs_alter_project_release_form($form); + } +} + +/** + * 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) { + $release = $form['#node']; + $project = $form['project']['#value']; + + if (!isset($project->releases)) { + // This project has no releases, nothing to alter + return; + } + + $form['#pre_render'][] = 'cvs_project_release_form_pre_render'; + + $fields = array('version_api_major', 'version_api_minor', '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.')); + } + if ($tag_name == 'TRUNK') { + // Special case validation for the TRUNK... + $tag->tag = 'TRUNK'; + $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'][$field]['#value']; + if (isset($form_val) && $form_val !== '') { + if (is_numeric($form_val) || $form_val == 'x') { + $version->$field = $form_val; + } + } + } + $form_val = $form['version']['version_extra']['#value']; + if (isset($form_val) && $form_val !== '') { + $version->version_extra = check_plain($form_val); + } + if (isset($version)) { + $version_str = project_release_get_version($version, $project); + } + else { + _cvs_alter_project_release_form_unset_all($form, false); + } + } + 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); + } + unset($form['tag']); + $tags[$tag_name] = $tag_name; + $form['cvs_tag'] = array( + '#weight' => -10, +/* + // TODO: This isn't really working. Might need CSS float/clear badness + '#prefix' => '
', + '#suffix' => '
', +*/ + ); + $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' => 'value', + '#value' => $tag->branch, + ); + $form['cvs_tag'] = form_builder('project_release_node_form', $form['cvs_tag']); + unset($form['version']['version']); + if (isset($version_str)) { + $form['cvs_tag']['version'] = array( + '#type' => 'textfield', + '#title' => 'Version string', + '#default_value' => $version_str, + '#attributes' => array('readonly' => true, 'style' => 'width:auto'), + '#required' => TRUE, + '#size' => 30, + '#maxlength' => 40, + ); + } + if (isset($version)) { + foreach (array_merge($fields, array('version_extra')) as $field) { + if (isset($version->$field)) { + $form['version'][$field]['#type'] = 'hidden'; + $form['version'][$field]['#value'] = $version->$field; + } + else { + unset($form['version'][$field]); + } + } + $form['version'] = form_builder('project_release_node_form', $form['version']); + } + // We don't want body to be required, or it'll get marked as an + // error as soon as we land on page 2... + $form['body_filter']['body']['#required'] = FALSE; + } + else { + // Add a tag selector + $tags = array(); + $tags['Tags'] = array(); + $tags['Branches']['TRUNK'] = 'TRUNK'; + $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 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); + if ($tag->branch) { + $tags['Branches'][$tag->tag] = $tag->tag .' ('. $version .')'; + } + else { + $tags['Tags'][$tag->tag] = $tag->tag .' ('. $version .')'; + } + } + if (!empty($tags)) { + unset($form['tag']); + $form['cvs_tag']['tag'] = array( + '#type' => 'select', + '#title' => t('CVS tag'), + '#options' => $tags, + '#weight' => -10, + '#required' => TRUE, + '#description' => t("Select the CVS tag (and therefore version number) for this release."), + ); + } + else { + drupal_set_message(t('WARNING: There are no CVS tags for this module that do not already have a release associated with them')); + // TODO: print out something reasonable + } + _cvs_alter_project_release_form_unset_all($form, true); + } + + // 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']); +} + +function _cvs_alter_project_release_form_unset_all(&$form, $unset_version) { + if ($unset_version) { + // Get rid of the form elements we don't want until we have a tag + unset($form['version']); + } + + // Get rid of all the node form elements, too, for page #1 + unset($form['body_filter']); + unset($form['author']); + unset($form['options']); + unset($form['comment_settings']); + unset($form['menu']); + unset($form['path']); + unset($form['attachments']); + + // Change preview to next and hide submit + $form['preview'] = array( + '#type' => 'button', + '#value' => t('Next'), + '#weight' => 19, + ); + $form['submit'] = array( + '#type' => 'value', + '#value' => 'hidden', + ); + $form['#redirect'] = FALSE; +} + + +function cvs_project_release_form_pre_render($form_id, &$form) { + if ($form_id == 'project_release_node_form') { + $form['body_filter']['body']['#required'] = TRUE; } } Index: modules/cvslog/cvs_local.inc =================================================================== RCS file: modules/cvslog/cvs_local.inc diff -N modules/cvslog/cvs_local.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/cvslog/cvs_local.inc 7 Oct 2006 17:56:09 -0000 @@ -0,0 +1,58 @@ +tag); + $first = explode('-', $first_ver, 5); + $second = empty($second_ver) ? array() : explode('-', $second_ver); + + if ($project->nid == 3060) { + if (isset($first[3])) { + // Looks like "DRUPAL-X-Y-Z", must be a release tag from before 5.x. + // Ignore the 'DRUPAL' part in $first[0] + $version->version_major = $first[1]; + $version->version_minor = $first[2]; + $version->version_patch = $first[3]; + $version->version_extra = $first[4]; + } + else { + // Looks like "DRUPAL-X-Y", could be either "DRUPAL-4-7" (branch) or + // "DRUPAL-5-0" (the 5.0 release tag). Use $tag->branch to decide. + if ($tag->branch) { + $version->version_major = $first[1]; + $version->version_minor = $first[2]; + $version->version_patch = 'x'; + $version->version_extra = 'dev'; + } + else { + $version->version_major = $first[1]; + $version->version_patch = $first[2]; + } + } + } + else { + // Contrib tags don't need any special cases + $version->version_api_major = $first[1]; + $version->version_api_minor = $first[2]; + $version->version_major = $second[0] ? $second[0] : 0; + $version->version_patch = $tag->branch ? 'X' : $second[1]; + $version->version_extra = $tag->branch ? 'dev' : $second[2]; + } + // TODO: add code to validate we parsed something reasonable, and ignore bad tags. + return $version; +} + cvs diff: Diffing modules/cvslog/xcvs