Kristis Makris wrote on 07/10/08 01:43 PM:

How about we call this new mode "mapped" ?

I implemented this new mode in our local installation on October 10 and we have been using it successfully ever since. It has proven to be a much needed improvement for our specific uses and I figure it is likely to be somewhat useful to other uses.

In the spirit of sharing, please find attached the patch that makes this mapped mode possible. We have not had any problems with it thus far but it probably makes sense for someone else to run the test suite and look at it a bit for potential flaws.

This patch was developed against SCMBUG_RELEASE_0-26-9.

This mode can be used by invoking the following product_name_definition configuration in glue.conf:

product_name_definition => {
        type => 'mapped',
        value => {
                '(test)/(.+?)' => 'Test',
                '(test_two)/(.+?)' => 'Test2',
        },
},

As mentioned in the code comments: "...this allows someone to use traditionally auto-detected product names along with manually mapped product names. To activate the original behaviour simple define the prefix as a key with an undefined value."


Hope this helps someone,

Matt
--
Matt Adams
Development & Network Services
Cypress Interactive
http://cypressinteractive.com, http://edsuite.com
Index: scmbug/usr/share/scmbug/lib/Scmbug/Activity.pm
===================================================================
--- scmbug/usr/share/scmbug/lib/Scmbug/Activity.pm	(revision 188)
+++ scmbug/usr/share/scmbug/lib/Scmbug/Activity.pm	(revision 189)
@@ -218,10 +218,19 @@
     my $product_name_autodetected = '';
     my $product_name = '';
 
+    my @prefixes;
+
     # For each prefix in the list, test if the prefix matches the full
     # path of the filename. In that case, grab the first directory
     # name and use that as the product name.
-    my @prefixes = split( ",", $self->product_name_prefixes() );
+    if (ref($self->product_name_prefixes()) eq "HASH") {
+        # Use manually mapped product names
+        @prefixes = keys %{ $self->product_name_prefixes() };
+    } else {
+        # Use traditionally auto-detected product names 
+        @prefixes = split( ",", $self->product_name_prefixes() );
+    }
+
     foreach my $prefix ( @prefixes ) {
 	$product_name = $filename;
 
@@ -232,6 +241,18 @@
 	    # after the prefix.
 	    $product_name = $1;
 
+            # Support for manually mapped product names
+            if (ref($self->product_name_prefixes()) eq "HASH") {
+                my $prefix_map = $self->product_name_prefixes();
+
+                # This check allows someone to use traditionally auto-detected product names
+                # along with manually mapped product names.  To activate the original behaviour
+                # simply define the prefix as a key with an undefined value.
+                if (defined ${$prefix_map}{$prefix}) {
+                    $product_name = ${$prefix_map}{$prefix};
+		}
+            }
+
 	    # If this is the first time we are detecting, store the
 	    # first match
 	    if ( $product_name_autodetected eq '' ) {
Index: scmbug/usr/share/scmbug/lib/Scmbug/Glue/Glue.pm
===================================================================
--- scmbug/usr/share/scmbug/lib/Scmbug/Glue/Glue.pm	(revision 188)
+++ scmbug/usr/share/scmbug/lib/Scmbug/Glue/Glue.pm	(revision 189)
@@ -393,14 +393,15 @@
 
 	if ( ! defined( $self->policies()->{ product_name_definition }->{ type } ) ||
 	     ( $self->policies()->{ product_name_definition }->{ type } ne 'manual' &&
+	       $self->policies()->{ product_name_definition }->{ type } ne 'mapped' &&
 	       $self->policies()->{ product_name_definition }->{ type } ne 'auto' ) ) {
 	    my $msg = "Policy product_name_definition was set to the invalid type '" .
 		$self->policies()->{ product_name_definition }->{ type } .
-		"' instead of 'manual', or 'auto'\n" ;
+		"' instead of 'manual', 'mapped' or 'auto'\n" ;
 	    log_fatal_error( $GLUE_ERROR_POLICY_PRODUCT_NAME_DEFINITION_INVALID, $msg );
 	} elsif ( $self->policies()->{ product_name_definition }->{ type } eq 'manual' ) {
 	    $self->scm()->activity()->product_name( $self->policies()->{ product_name_definition }->{ value } );
-	} elsif ( $self->policies()->{ product_name_definition }->{ type } eq 'auto' ) {
+	} elsif ( $self->policies()->{ product_name_definition }->{ type } eq 'auto' || $self->policies()->{ product_name_definition }->{ type } eq 'mapped' ) {
 	    # We must autodetect the product name in the future. Do not
 	    # set a product_name, to flag this fact
 	    $self->scm()->activity()->product_name_prefixes( $self->policies()->{ product_name_definition }->{ value } );
_______________________________________________
scmbug-users mailing list
[email protected]
http://lists.mkgnu.net/cgi-bin/mailman/listinfo/scmbug-users

Reply via email to