Index: modules/cvslog/cvs.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.module,v retrieving revision 1.145 diff -u -p -r1.145 cvs.module --- modules/cvslog/cvs.module 1 Mar 2007 01:34:58 -0000 1.145 +++ modules/cvslog/cvs.module 12 Mar 2007 07:06:27 -0000 @@ -1014,19 +1014,33 @@ function cvs_alter_project_release_form( function cvs_alter_project_release_form_edit(&$form) { global $user; $release = $form['#node']; - if (user_access('administer projects')) { + $tags = array(); + + // Always include the current tag as an option. + $tags[$release->tag] = $release->tag; + + // See if any other tags should be presented as options. If the user + // has 'administer projects' permission, present all tags that don't + // yet have a release node pointing to them. If it's a HEAD release + // node, see if another tag exists which has the same version info + // but isn't associated with a release. + if (user_access('administer projects') || ($release->tag == 'HEAD')) { $project = node_load($release->pid); - $tags = array(); - $tags[$release->tag] = $release->tag; - $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); + $args[] = $release->pid; + $head_where = ''; + if (!user_access('administer projects')) { + // A non-admin editing a HEAD node. Search for another tag (if + // any) that matches the current version info for this release. + $tag = cvs_get_tag_from_version($release, $project); + $head_where = " AND c.tag = '%s'"; + $args[] = $tag; + } + $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 $head_where ORDER BY c.tag DESC", $args); 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['rel_id']['tag'] = array( '#type' => 'select', '#title' => $release->rebuild ? t('CVS branch') : t('CVS tag'), Index: modules/cvslog/cvs_local.example.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs_local.example.inc,v retrieving revision 1.4 diff -u -p -r1.4 cvs_local.example.inc --- modules/cvslog/cvs_local.example.inc 22 Dec 2006 23:55:29 -0000 1.4 +++ modules/cvslog/cvs_local.example.inc 12 Mar 2007 07:06:27 -0000 @@ -77,11 +77,56 @@ function cvs_get_version_from_tag($tag, return $version; } +/** + * Returns the CVS tag that should match the given version information + */ +function cvs_get_tag_from_version($version, $project) { + $tag = 'DRUPAL-'; // all tags start with this. + $parts[] = $version->version_major; + if (isset($version->version_minor)) { + $parts[] = $version->version_minor; + } + if (isset($version->version_patch)) { + $parts[] = $version->version_patch; + } + else { + $is_branch = true; + } + if (isset($version->version_extra)) { + if ($version->version_extra != 'dev') { + $parts[] = strtoupper($version->version_extra); + // sadly, this will be wrong, since we strip out '_' and '-', + // but we don't really care that much, since this is primarily + // going to be used for branches, not tags. + } + else { + $is_branch = true; + } + } + if ($project->nid != 3060) { + // For contrib, we have to prepend the Drupal core compatibility. + $vid = _project_release_get_api_vid(); + foreach ($version->taxonomy as $term) { + if ($term->vid == $vid) { + $api = preg_replace(array('/\.x/', '/\./'), array('', '-'), $term->name); + break; + } + } + $tag .= $api; + if ($is_branch && $version->version_major == 1) { + // Evil special-case, we're done. + return $tag; + } + $tag .= '--'; + } + $tag .= implode('-', $parts); + return $tag; +} + function _cvs_get_extra($str) { return preg_replace('/[_-]/', '', strtolower($str)); } - /** * drupal.org specific customizations of the release node form */