diff --git a/Source/Source.API.php b/Source/Source.API.php index 2dd1d2f..42a3b0e 100644 --- a/Source/Source.API.php +++ b/Source/Source.API.php @@ -19,11 +19,11 @@ */ # branch mapping strategies -define( 'SOURCE_EXPLICIT', 0 ); -define( 'SOURCE_NEAR', 1 ); -define( 'SOURCE_FAR', 2 ); -define( 'SOURCE_FIRST', 3 ); -define( 'SOURCE_LAST', 4 ); +define( 'SOURCE_EXPLICIT', 1 ); +define( 'SOURCE_NEAR', 2 ); +define( 'SOURCE_FAR', 3 ); +define( 'SOURCE_FIRST', 4 ); +define( 'SOURCE_LAST', 5 ); global $g_Source_cache_types; $g_Source_cache_types = null; @@ -1047,23 +1047,20 @@ var $branch; var $type; - var $version_id; + var $version; var $regex; - static $s_versions = array(); - static $s_versions_sorted = array(); - /** * Initialize a mapping object. * @param int Repository ID * @param string Branch name * @param int Mapping type */ - function __construct( $p_repo_id, $p_branch, $p_type, $p_version_id=0, $p_regex='' ) { + function __construct( $p_repo_id, $p_branch, $p_type, $p_version='', $p_regex='' ) { $this->repo_id = $p_repo_id; $this->branch = $p_branch; $this->type = $p_type; - $this->version_id = $p_version_id; + $this->version = $p_version; $this->regex = $p_regex; } @@ -1074,14 +1071,14 @@ $t_branch_table = plugin_table( 'branch' ); if ( $this->_new ) { - $t_query = "INSERT INTO $t_branch_table ( repo_id, branch, type, version_id, regex ) VALUES (" . + $t_query = "INSERT INTO $t_branch_table ( repo_id, branch, type, version, regex ) VALUES (" . db_param() . ', ' .db_param() . ', ' .db_param() . ', ' .db_param() . ', ' . db_param() . ')'; - db_query_bound( $t_query, array( $this->repo_id, $this->branch, $this->type, $this->version_id, $this->regex ) ); + db_query_bound( $t_query, array( $this->repo_id, $this->branch, $this->type, $this->version, $this->regex ) ); } else { - $t_query = "UPDATE $t_branch_table SET type=" . db_param() . ', version_id=' . db_param() . + $t_query = "UPDATE $t_branch_table SET type=" . db_param() . ', version=' . db_param() . ', regex=' . db_param() . ' WHERE repo_id=' . db_param() . ' AND branch=' . db_param(); - db_query_bound( $t_query, array( $this->type, $this->version_id, $this->regex, $this->repo_id, $this->branch ) ); + db_query_bound( $t_query, array( $this->type, $this->version, $this->regex, $this->repo_id, $this->branch ) ); } } @@ -1099,7 +1096,7 @@ $t_mappings = array(); while( $t_row = db_fetch_array( $t_result ) ) { - $t_mapping = new SourceMapping( $t_row['repo_id'], $t_row['branch'], $t_row['type'], $t_row['version_id'], $t_row['regex'] ); + $t_mapping = new SourceMapping( $t_row['repo_id'], $t_row['branch'], $t_row['type'], $t_row['version'], $t_row['regex'] ); $t_mapping->_new = false; $t_mappings[$t_mapping->branch] = $t_mapping; @@ -1115,9 +1112,12 @@ * @return int Version ID */ function apply( $p_bug_id ) { + static $s_versions = array(); + static $s_versions_sorted = array(); + # if it's explicit, return the version_id before doing anything else if ( $this->type == SOURCE_EXPLICIT ) { - return $this->version_id; + return $this->version; } # cache project/version sets, and the appropriate sorting @@ -1128,7 +1128,7 @@ # handle empty version sets if ( count( $s_versions[ $t_project_id ] ) < 1 ) { - return null; + return ''; } # cache the version set based on the current algorithm @@ -1156,18 +1156,18 @@ # handle non-regex mappings if ( is_blank( $this->regex ) ) { - return $t_versions[0]['id']; + return $t_versions[0]['version']; } # handle regex mappings foreach( $t_versions as $t_version ) { if ( preg_match( $this->regex, $t_version['version'] ) ) { - return $t_version['id']; + return $t_version['version']; } } # no version matches the regex - return null; + return ''; } function cmp_near( $a, $b ) { diff --git a/Source/Source.php b/Source/Source.php index c6e8317..1346d40 100644 --- a/Source/Source.php +++ b/Source/Source.php @@ -187,8 +187,8 @@ repo_id I NOTNULL UNSIGNED PRIMARY, branch C(128) NOTNULL PRIMARY, type I NOTNULL UNSIGNED DEFAULT '0', - version_id I NOTNULL UNSIGNED, - regex C(64) NOTNULL DEFAULT \" '' \" + version C(64) NOTNULL DEFAULT \" '' \", + regex C(128) NOTNULL DEFAULT \" '' \" " ) ), ); } diff --git a/Source/lang/strings_english.txt b/Source/lang/strings_english.txt index c6fad2e..1705713 100644 --- a/Source/lang/strings_english.txt +++ b/Source/lang/strings_english.txt @@ -93,18 +93,18 @@ $s_plugin_Source_enable_porting = 'Porting Status'; $s_plugin_Source_branch_mapping = 'Branch Mappings'; +$s_plugin_Source_mapping_update = 'Update Mappings'; $s_plugin_Source_mapping_strategy = 'Strategy'; +$s_plugin_Source_mapping_version = 'Version'; +$s_plugin_Source_mapping_version_info = '?'; $s_plugin_Source_mapping_regex = 'Regular Expression'; -$s_plugin_Source_mapping_regex_info = 'Only selects versions matching the given expression. Only used with "Regex" strategies.'; -$s_plugin_Source_mapping[SOURCE_EXPLICIT] = 'Explicit Version'; -$s_plugin_Source_mapping[SOURCE_NEAR] = 'Nearest Release Date'; -$s_plugin_Source_mapping[SOURCE_FAR] = 'furthest Release Date'; -$s_plugin_Source_mapping[SOURCE_FIRST] = 'Sorted First'; -$s_plugin_Source_mapping[SOURCE_LAST] = 'Sorted Last'; -$s_plugin_Source_mapping[SOURCE_NEAR_REGEX] = 'Nearest Release Date (Regex)'; -$s_plugin_Source_mapping[SOURCE_FAR_REGEX] = 'Furthest Release Date (Regex)'; -$s_plugin_Source_mapping[SOURCE_FIRST_REGEX] = 'Sorted First (Regex)'; -$s_plugin_Source_mapping[SOURCE_LAST_REGEX] = 'Sorted Last (Regex)'; +$s_plugin_Source_mapping_regex_info = '?'; +$s_plugin_Source_mapping_create = 'Create Mapping'; +$s_plugin_Source_mapping_explicit = 'Explicit Version'; +$s_plugin_Source_mapping_near = 'Nearest Release Date'; +$s_plugin_Source_mapping_far = 'Furthest Release Date'; +$s_plugin_Source_mapping_first = 'Version Sorted First'; +$s_plugin_Source_mapping_last = 'Version Sorted Last'; $s_plugin_Source_changeset_attached = 'Changeset attached'; $s_plugin_Source_changeset_removed = 'Changeset removed'; diff --git a/Source/pages/repo_manage_page.php b/Source/pages/repo_manage_page.php index 7770f46..77a8141 100644 --- a/Source/pages/repo_manage_page.php +++ b/Source/pages/repo_manage_page.php @@ -18,6 +18,25 @@ $t_repo = SourceRepo::load( $f_repo_id ); $t_type = SourceType($t_repo->type); +$t_mappings = $t_repo->load_mappings(); + +function display_strategies( $p_type=null ) { + if ( is_null( $p_type ) ) { + echo ''; + } + + echo '', + '', + '', + '', + ''; +} + html_page_top1( plugin_lang_get( 'title' ) ); html_page_top2(); ?> @@ -91,6 +110,50 @@ + +
+
+ + + + + + + + + + + + + + + +> + + + + + + + + + +> + + + + + + + + + + +
+
+ + +