Hi guys,

I've found some more time to work on this and have now got what I
beleive is a working integration_get_vdd.  I've also fixed
integration_get_bug_reporter_email based on a change Oliver sent.
This diff is against 1.34 of Bugzilla.pm.in.  Kristis - could you take
a look at this, and run the tests on a Bugzilla 2.x environment (I
don't have a 2.x test environment setup).

I still have one failing test - delete tag.  It looks to me like
someone has already worked on this in the diff, so I'm hesitant to
change it.  It would appear that the failure is because there are
still bugs associated with the version we're trying to delete (by
deleting the tag).  Anyone have any ideas?

In the meantime I'm going to give this a go on our real environment
and see how it goes.

cheesr,
dim
Index: Bugzilla.pm.in
===================================================================
RCS file: 
/projects/scmbug/cvsroot/system/src/lib/product/Daemon/Bugzilla.pm.in,v
retrieving revision 1.34
diff -r1.34 Bugzilla.pm.in
71a72,83
> sub is_version_up_to_2_22 {
>     my $self = shift;
> 
>     if ( $self->{ version_type } eq "up_to_2_22" ) {
>       return 1;
>     } else {
>       return 0;
>     }
> }
> 
> 
> 
108,114c120,133
< 
< 
<     # This is the Bugzilla API file.
<     my $package_name = "globals.pl";
<     if ( package_exists( $package_name ) == 0) {
<       return ( 2, "Package '" . $package_name . "' not found in installation 
directory '" .
<                $self->installation_directory() . "'.\n" );
---
>     if ( $self->is_version_latest() ) {
>       $package_name = "Bugzilla";
>       if ( package_exists( $package_name ) == 0 ) {
>             return ( 3, "Package '" . $package_name . "' not found in 
> installation directory '" .
>                    $self->installation_directory() . "'.\n" );
>       }
>     } else {
>       # This is the Bugzilla API file.
>       $package_name = "globals.pl";
>       if ( package_exists( $package_name ) == 0) {
>           return ( 2, "Package '" . $package_name . "' not found in 
> installation directory '" .
>                    $self->installation_directory() . "'.\n" );
>       }
>       do 'globals.pl';
116d134
<     do 'globals.pl';
129c147
<     if ( $self->is_version_up_to_2_20() || $self->is_version_latest() ) {
---
>     if ( $self->is_version_up_to_2_20() || $self->is_version_up_to_2_22() || 
> $self->is_version_latest() ) {
144a163,175
>     if ( $self->is_version_latest() ) {
>       $package_name = "Bugzilla::Product";
>       if ( package_exists($package_name) == 0 ) {
>           return ( 3, "Package '" . $package_name . "' not found in 
> installation directory '" .
>                    $self->installation_directory() . "'.\n" );
>       }
> 
>       $package_name = "Bugzilla::Version";
>       if ( package_exists($package_name) == 0 ) {
>           return ( 3, "Package '" . $package_name . "' not found in 
> installation directory '" .
>                    $self->installation_directory() . "'.\n" );
>       }
>     }
162,168c193,203
<     # If Bugzilla is installed locally to the same machine the daemon
<     # is installed, we can do more
<     if ( $self->installed_locally() ) {
<       # Force Bugzilla to regenerate the version cache file. In this
<       # way, the version changes as a result of tagging are
<       # reflected in the web interface immediately.
<       GenerateVersionTable();
---
>     if ( $self->is_version_latest() ) {
>       # The version cache is obsolete
>     } else {
>       # If Bugzilla is installed locally to the same machine the daemon
>       # is installed, we can do more
>       if ( $self->installed_locally() ) {
>           # Force Bugzilla to regenerate the version cache file. In this
>           # way, the version changes as a result of tagging are
>           # reflected in the web interface immediately.
>           GenerateVersionTable();
>       }
233c268
<               $self->{ version_type } = $BUGTRACKER_VERSION_LATEST;
---
>               $self->{version_type} = "up_to_2_22";
236a272,273
>       } elsif ( $major == 3 && $minor == 0 ) {
>           $self->{version_type} = $BUGTRACKER_VERSION_LATEST;
301c338
<     } elsif ( $self->is_version_latest() ) {
---
>     } elsif ( $self->is_version_up_to_2_22() || $self->is_version_latest() ) {
331d367
<     my $sql;
333,337c369,374
<     if ( $self->is_version_up_to_2_16() ) {
<       $sql = "SELECT product FROM bugs WHERE bug_id = $bugid";
<     } elsif ( $self->is_version_up_to_2_18() || 
$self->is_version_up_to_2_20() || $self->is_version_latest() ) {
<       $sql = "SELECT products.name FROM products, bugs WHERE bugs.bug_id = 
$bugid and bugs.product_id = products.id";
<     }
---
>     if ( $self->is_version_latest() ) {
>       my $bug = new Bugzilla::Bug( $bugid );
> 
>       $bug_product_name = $bug->product();
>     } else {
>       my $sql;
339,342c376,386
<     PushGlobalSQLState();
<     SendSQL( $sql );
<     $bug_product_name = FetchOneColumn();
<     PopGlobalSQLState();
---
>       if ( $self->is_version_up_to_2_16() ) {
>           $sql = "SELECT product FROM bugs WHERE bug_id = $bugid";
>       } elsif ( $self->is_version_up_to_2_18() || 
> $self->is_version_up_to_2_20() || $self->is_version_up_to_2_22() ) {
>           $sql = "SELECT products.name FROM products, bugs WHERE bugs.bug_id 
> = $bugid and bugs.product_id = products.id";
>       }
> 
>       PushGlobalSQLState();
>       SendSQL( $sql );
>       $bug_product_name = FetchOneColumn();
>       PopGlobalSQLState();
>     }
359,362c403,412
<     PushGlobalSQLState();
<     SendSQL("SELECT profiles.login_name FROM profiles, bugs WHERE bugs.bug_id 
= $bugid AND bugs.assigned_to = profiles.userid");
<     $bug_owner = FetchOneColumn();
<     PopGlobalSQLState();
---
>     if ( $self->is_version_latest() ) {
>       my $bug = new Bugzilla::Bug( $bugid );
> 
>       $bug_owner = $bug->assigned_to()->login();
>     } else {
>       PushGlobalSQLState();
>       SendSQL("SELECT profiles.login_name FROM profiles, bugs WHERE 
> bugs.bug_id = $bugid AND bugs.assigned_to = profiles.userid");
>       $bug_owner = FetchOneColumn();
>       PopGlobalSQLState();
>     }
378d427
<     my $sql = "SELECT profiles.login_name FROM profiles, bugs WHERE 
bugs.bug_id = $bugid AND bugs.reporter = profiles.userid";
380,383c429,440
<     PushGlobalSQLState();
<     SendSQL( $sql );
<     $bug_reporter_email = FetchOneColumn();
<     PopGlobalSQLState();
---
>     if ( $self->is_version_latest() ) {
>       my $bug = new Bugzilla::Bug( $bugid );
> 
>       $bug_reporter_email = $bug->reporter()->email();
>     } else {
>       my $sql = "SELECT profiles.login_name FROM profiles, bugs WHERE 
> bugs.bug_id = $bugid AND bugs.reporter = profiles.userid";
> 
>       PushGlobalSQLState();
>       SendSQL( $sql );
>       $bug_reporter_email = FetchOneColumn();
>       PopGlobalSQLState();
>     }
411d467
<     my $sql = "SELECT profiles.login_name from profiles, cc WHERE cc.bug_id= 
$bugid AND cc.who = profiles.userid";
414,417c470,486
<     PushGlobalSQLState();
<     SendSQL( $sql );
<     while (MoreSQLData()) {
<       my $bug_monitor_email;
---
>     if ( $self->is_version_latest() ) {
>       my $bug = new Bugzilla::Bug( $bugid );
>       my ( @cc ) = $bug->cc();
>       if ( @cc ) {
>           foreach my $c ( @cc ) {
>               foreach my $bug_monitor_email ( @$c ) {
>                   push @bug_monitors_email_list, $bug_monitor_email;
>               }
>           }
>       }
>     } else {
>       my $sql = "SELECT profiles.login_name from profiles, cc WHERE 
> cc.bug_id= $bugid AND cc.who = profiles.userid";
>       
>       PushGlobalSQLState();
>       SendSQL( $sql );
>       while (MoreSQLData()) {
>           my $bug_monitor_email;
419,420c488,491
<       $bug_monitor_email = FetchOneColumn();
<       push @bug_monitors_email_list, $bug_monitor_email;
---
>           $bug_monitor_email = FetchOneColumn();
>           push @bug_monitors_email_list, $bug_monitor_email;
>       }
>       PopGlobalSQLState();
422d492
<     PopGlobalSQLState();
454,457c524,532
<     PushGlobalSQLState();
<     SendSQL("SELECT bugs.bug_status FROM bugs WHERE bugs.bug_id=" . $bugid);
<     $bug_status = FetchOneColumn();
<     PopGlobalSQLState();
---
>     if ( $self->is_version_latest() ) {
>       my $bug = new Bugzilla::Bug( $bugid );
>       $bug_status = $bug->bug_status();
>     } else {
>       PushGlobalSQLState();
>       SendSQL("SELECT bugs.bug_status FROM bugs WHERE bugs.bug_id=" . $bugid);
>       $bug_status = FetchOneColumn();
>       PopGlobalSQLState();
>     }
507,510c582,590
<     PushGlobalSQLState();
<     SendSQL("SELECT bugs.short_desc FROM bugs WHERE bugs.bug_id=" . $bugid);
<     $bug_subject = FetchOneColumn();
<     PopGlobalSQLState();
---
>     if ( $self->is_version_latest() ) {
>       my $bug = new Bugzilla::Bug( $bugid );
>       $bug_subject = $bug->short_desc();
>     } else {
>       PushGlobalSQLState();
>       SendSQL("SELECT bugs.short_desc FROM bugs WHERE bugs.bug_id=" . $bugid);
>       $bug_subject = FetchOneColumn();
>       PopGlobalSQLState();
>     }
529d608
< 
537c616
<     } elsif ( $self->is_version_up_to_2_18() || 
$self->is_version_up_to_2_20() || $self->is_version_latest() ) {
---
>     } elsif ( $self->is_version_up_to_2_18() || 
> $self->is_version_up_to_2_20() || $self->is_version_up_to_2_22() ) {
546c625
<       
---
> 
551a631,633
>     } elsif ( $self->is_version_latest() ) {
>       my $product = new Bugzilla::Product( { name => $product_name } );
>       my $version = Bugzilla::Version::create( $tag_name, $product );
570,571d651
<     my $tag_status;
<     my $sql;
573,597c653,662
<     if ( $self->is_version_up_to_2_16() ) {
<       $sql = "SELECT versions.value FROM versions WHERE versions.program=" . 
<           SqlQuote( $product_name ) .
<           " AND versions.value=" .
<           SqlQuote( $tag_name );
<     } elsif ( $self->is_version_up_to_2_18() || 
$self->is_version_up_to_2_20() || $self->is_version_latest() ) {
<       $sql = "SELECT versions.value FROM versions,products WHERE 
versions.value=" .
<           SqlQuote( $tag_name ) .
<           " AND versions.product_id = products.id AND products.name="
<           . SqlQuote( $product_name );
<     }
< 
<     PushGlobalSQLState();
<     SendSQL( $sql );
<     $tag_status = FetchOneColumn();
<     if ( !defined($tag_status) ) {
<         $tag_status = "";
<     }
<     PopGlobalSQLState();
<     
<     if ( $tag_status eq $tag_name ) {
<       # The tag was found
<       return 1;
<     } else {
<       # There was no such tag
---
>     if ( $self->is_version_latest() ) {
>       my $product = new Bugzilla::Product( { name => $product_name } );
>       my $versions = $product->versions();
>       if ( $versions ) {
>           foreach my $version ( @$versions ) {
>               if ( $version->name() eq $tag_name ) {
>                   return 1;
>               }
>           }
>       }
598a664,694
>     } else {
>       my $tag_status;
>       my $sql;
> 
>       if ( $self->is_version_up_to_2_16() ) {
>           $sql = "SELECT versions.value FROM versions WHERE 
> versions.program=" . 
>               SqlQuote( $product_name ) .
>               " AND versions.value=" .
>               SqlQuote( $tag_name );
>       } elsif ( $self->is_version_up_to_2_18() || 
> $self->is_version_up_to_2_20() || $self->is_version_up_to_2_22() ) {
>           $sql = "SELECT versions.value FROM versions,products WHERE 
> versions.value=" .
>               SqlQuote( $tag_name ) .
>               " AND versions.product_id = products.id AND products.name="
>               . SqlQuote( $product_name );
>       }
>       
>       PushGlobalSQLState();
>       SendSQL( $sql );
>       $tag_status = FetchOneColumn();
>       if ( !defined($tag_status) ) {
>           $tag_status = "";
>       }
>       PopGlobalSQLState();
> 
>       if ( $tag_status eq $tag_name ) {
>           # The tag was found
>           return 1;
>       } else {
>           # There was no such tag
>           return 0;
>       }
613d708
<     my $sql;
615,621c710,732
<     if ( $self->is_version_up_to_2_16() ) {
<       $sql = "DELETE FROM versions WHERE value=" . SqlQuote( $tag_name ) . 
<           " AND program=" . SqlQuote( $product_name );
<     } elsif ( $self->is_version_up_to_2_18() || 
$self->is_version_up_to_2_20() || $self->is_version_latest() ) {
<       # First, find the product id of our product
<       my $product_id;
<       $sql = "SELECT id FROM products WHERE name = " . SqlQuote( 
$product_name );
---
>     if ( $self->is_version_latest() ) {
>       my $product = new Bugzilla::Product( { name => $product_name } );
>       my $version = new Bugzilla::Version( $product->id, $tag_name );
>       $version->remove_from_db;
>     } else {
>       my $sql;
> 
>       if ( $self->is_version_up_to_2_16() ) {
>           $sql = "DELETE FROM versions WHERE value=" . SqlQuote( $tag_name ) 
> . 
>               " AND program=" . SqlQuote( $product_name );
>       } elsif ( $self->is_version_up_to_2_18() || 
> $self->is_version_up_to_2_20() || $self->is_version_up_to_2_22() ) {
>           # First, find the product id of our product
>           my $product_id;
>           $sql = "SELECT id FROM products WHERE name = " . SqlQuote( 
> $product_name );
>           
>           PushGlobalSQLState();
>           SendSQL( $sql );
>           $product_id = FetchOneColumn();
>           PopGlobalSQLState();
>           
>           $sql = "DELETE FROM versions WHERE value=" . SqlQuote( $tag_name ) 
> . 
>               " AND product_id=" . $product_id;
>       }
625d735
<       $product_id = FetchOneColumn();
627,629d736
< 
<       $sql = "DELETE FROM versions WHERE value=" . SqlQuote( $tag_name ) . 
<           " AND product_id=" . $product_id;
632,635d738
<     PushGlobalSQLState();
<     SendSQL( $sql );
<     PopGlobalSQLState();
<     
675,676d777
<     PushGlobalSQLState();
<     SendSQL( $sql );
678,692c779,837
<     while (MoreSQLData()) {
<         my %comment;
<       my $bugid;
<         ($comment{'author_username'},
<        $comment{'author_name'},
<        $comment{'author_email'},
<        $bugid,
<        $comment{'summary'},
<        $comment{'status'},
<        $comment{'resolution'},
<        $comment{'severity'},
<        $comment{'priority'},
<        $comment{'date'},
<        $comment{'content'}) = FetchSQLData();
<       
---
> 
>     if ( $self->is_version_latest() ) {
>         my $dbh = Bugzilla->dbh;
>         my $sth = $dbh->prepare($sql);
>         $sth->execute();
>         my $result;
>         while ($result = $sth->fetchrow_arrayref()) {
>             my %comment;
>             my $bugid;
>             ($comment{'author_username'},
>              $comment{'author_name'},
>              $comment{'author_email'},
>              $bugid,
>              $comment{'summary'},
>              $comment{'status'},
>              $comment{'resolution'},
>              $comment{'severity'},
>              $comment{'priority'},
>              $comment{'date'},
>              $comment{'content'}) = $result;
>     
>             categorizeVDD($vdd, %comment, $bugid, ++$comment_counter);
>         }
>     } else {
>         PushGlobalSQLState();
>         SendSQL( $sql );
>         while (MoreSQLData()) {
>             my %comment;
>             my $bugid;
>             ($comment{'author_username'},
>              $comment{'author_name'},
>              $comment{'author_email'},
>              $bugid,
>              $comment{'summary'},
>              $comment{'status'},
>              $comment{'resolution'},
>              $comment{'severity'},
>              $comment{'priority'},
>              $comment{'date'},
>              $comment{'content'}) = FetchSQLData();
> 
>             categorizeVDD($vdd, %comment, $bugid, ++$comment_counter);
>       }
>     }
> 
>     return $vdd;
> }
> 
> # Do the bulk of the work required for integration_get_vdd
> #
> # PARAMETERS:
> # $1 - The VDD to categorize
> # $2 - The comment array
> # $3 - The bug id
> # $4 - The comment counter
> sub categorizeVDD {
>     my $self = shift;
>     my ( $vdd, %comment, $bugid, $comment_counter ) = ( @_ );
> 
790,794d934
<       $comment_counter++;
<     }
<     PopGlobalSQLState();
< 
<     return $vdd;
_______________________________________________
scmbug-users mailing list
[email protected]
http://lists.mkgnu.net/cgi-bin/mailman/listinfo/scmbug-users

Reply via email to