User: sits    
  Date: 08/02/20 18:32:10

  Modified:    .        CHANGELOG codestriker.conf
               bin      install.pl
               lib/Codestriker/Action SubmitNewTopic.pm
               lib/Codestriker/BugDB TestDirectorConnection.pm
  Added:       lib/Codestriker/Repository ScmBug.pm
  Log:
  * Support for creating reviews by just entering the bug IDs, and
    retrieving the data from Scmbug.
    Submitted by [EMAIL PROTECTED]
  
  
  
  Index: CHANGELOG
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
  retrieving revision 1.223
  retrieving revision 1.224
  diff -u -r1.223 -r1.224
  --- CHANGELOG 18 Jan 2008 21:20:13 -0000      1.223
  +++ CHANGELOG 21 Feb 2008 02:32:09 -0000      1.224
  @@ -20,6 +20,10 @@
   * Support for TestDirector as a supported bug tracking system.
     Submitted by [EMAIL PROTECTED]
   
  +* Support for creating reviews by just entering the bug IDs, and
  +  retrieving the data from Scmbug.
  +  Submitted by [EMAIL PROTECTED]
  +
   * Make sure if an invalid CGI parameter value is specified that its
     value is encoded when displaying the generic error page.  Reported
     by [EMAIL PROTECTED]
  
  
  
  
  
  Index: codestriker.conf
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/codestriker.conf,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- codestriker.conf  13 Jan 2008 09:15:20 -0000      1.90
  +++ codestriker.conf  21 Feb 2008 02:32:09 -0000      1.91
  @@ -399,6 +399,14 @@
   $bugtracker = 'http://localhost.localdomain/bugzilla/show_bug.cgi?id=';
   #$bugtracker = '/flyspray_dev/?do=details&id=';
   
  +# Some bug tracking systems store details of the files changed under each bug
  +# ID.  A generic plugin for bugzilla is scmbug which can be used to link
  +# with source control systems such as subversion.  The following flag
  +# enables/disables the ability for a user to create a topic by just
  +# using a Bug ID.
  +#$scmbug_hostname = 'hostname-of-scmbug-daemon';
  +#$scmbug_port = 3872;
  +
   # LXR database.  Each repository can be optionally mapped to a
   # different LXR deployment.  If a repository has an associated LXR
   # mapping, then create a new entry where the repository string is the
  
  
  
  
  
  Index: install.pl
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/bin/install.pl,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- install.pl        13 Jan 2008 09:15:21 -0000      1.15
  +++ install.pl        21 Feb 2008 02:32:09 -0000      1.16
  @@ -138,6 +138,14 @@
       push @{$modules}, { name => 'Win32::OLE', version => '0' };
   }
   
  +# Check that the necessary modules are present if ScmBug is used.
  +if (defined $Codestriker::scmbug_hostname &&
  +    $Codestriker::scmbug_hostname ne '') {
  +    push @{$modules}, { name => 'XML::Simple', version => '0' };
  +    push @{$modules}, { name => 'ScmBug::Connection', version => '0' };
  +    push @{$modules}, { name => 'ScmBug::Common', version => '0' };
  +}
  +
   # Check for various character encoding modules that are required.
   if (defined $Codestriker::topic_text_encoding) {
       if ($Codestriker::topic_text_encoding =~ /euc\-cn|gb2312|hz|gbk/) {
  
  
  
  
  
  Index: SubmitNewTopic.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewTopic.pm,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- SubmitNewTopic.pm 7 Jun 2006 00:35:02 -0000       1.30
  +++ SubmitNewTopic.pm 21 Feb 2008 02:32:09 -0000      1.31
  @@ -17,6 +17,7 @@
   use Codestriker::Model::Topic;
   use Codestriker::Http::Render;
   use Codestriker::Repository::RepositoryFactory;
  +use Codestriker::Repository::ScmBug;
   use Codestriker::FileParser::Parser;
   use Codestriker::Model::Project;
   use Codestriker::TopicListeners::Manager;
  @@ -54,7 +55,9 @@
       # Indicate whether the topic text needs to be retrieved by the repository
       # object.
       my $retrieve_text_from_rep = 0;
  -    if (($start_tag ne "" || $end_tag ne "") && $module ne "") {
  +    if ((($start_tag ne "" || $end_tag ne "") && $module ne "") ||
  +     (defined $Codestriker::scmbug_host && $Codestriker::scmbug_host ne '' &&
  +      $bug_ids ne '')) {
        $retrieve_text_from_rep = 1;
   
        # Check if this action is permitted.
  @@ -189,10 +192,22 @@
        }
        binmode $temp_topic_fh;
        binmode $temp_error_fh;
  -     
  -     my $rc = $repository->getDiff($start_tag, $end_tag, $module,
  -                                   $temp_topic_fh, $temp_error_fh,
  -                                   $default_to_head);
  +
  +     my $rc;
  +     if ($start_tag eq '' && $end_tag eq '' && $module eq '') {
  +         # Retrieve the diff from ScmBug and the repository object.
  +         my $scmbug = 
Codestriker::Repository::ScmBug->new($Codestriker::scmbug_hostname,
  +                                                           
$Codestriker::scmbug_port,
  +                                                           $repository);
  +         $rc = $scmbug->getDiff($bug_ids, $temp_topic_fh, $temp_error_fh,
  +                                $default_to_head);
  +         
  +     } else {
  +         # Retrieve the diff directly from the repository object.
  +         $rc = $repository->getDiff($start_tag, $end_tag, $module,
  +                                    $temp_topic_fh, $temp_error_fh,
  +                                    $default_to_head);
  +     }
   
        # Make sure the data has been flushed to disk.
        $temp_topic_fh->flush;
  
  
  
  
  
  Index: TestDirectorConnection.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/BugDB/TestDirectorConnection.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestDirectorConnection.pm 13 Jan 2008 09:15:22 -0000      1.1
  +++ TestDirectorConnection.pm 21 Feb 2008 02:32:09 -0000      1.2
  @@ -11,7 +11,8 @@
   
   use strict;
   
  -use Win32::OLE;
  +# Optional dependency for people who don't use this module.
  +eval("use Win32::OLE;");
   
   # Static method for building a database connection.
   sub get_connection($) {
  
  
  
  
  
  Index: ScmBug.pm
  ===================================================================
  RCS file: ScmBug.pm
  diff -N ScmBug.pm
  --- /dev/null 1 Jan 1970 00:00:00 -0000
  +++ ScmBug.pm 21 Feb 2008 02:32:09 -0000      1.1
  @@ -0,0 +1,151 @@
  
+###############################################################################
  +# Codestriker: Copyright (c) 2001,2002,2003 David Sitsky.  All rights 
reserved.
  +# [EMAIL PROTECTED]
  +#
  +# This program is free software; you can redistribute it and modify it under
  +# the terms of the GPL.
  +
  +# ScmBug repository access package.
  +
  +package Codestriker::Repository::ScmBug;
  +
  +use strict;
  +
  +# Optional dependencies for people who don't require ScmBug functionality.
  +eval("use XML::Simple");
  +eval("use Scmbug::Connection");
  +eval("use Scmbug::Common");
  +
  +# Create a connection to the ScmBug daemon, and maintain a reference to the
  +# delegate repository.
  +sub new {
  +    my ($type, $hostname, $port, $repository) = @_;
  +    
  +    my $self = {};
  +    $self->{repository} = $repository;
  +    $self->{connection} = Scmbug::Connection->new(0);
  +    $self->{connection}->location($hostname);
  +    $self->{connection}->port($port);
  +
  +    bless $self, $type;
  +}
  +
  +
  +#
  +# Retrieve affected files in XML format from the ScmBug daemon.
  +#
  +sub get_affected_files_XML {
  +    my $self = shift;
  +    my $bugids = shift;
  +
  +    my $new_activity = Scmbug::Activity->new();
  +    $new_activity->{name} = $ScmBug::Common::ACTIVITY_GET_AFFECTED_FILES;
  +    $new_activity->{user} = "codestriker";
  +    
  +    # Comma seperated list of bugs
  +    $new_activity->{bugs} = $bugids;
  +
  +    # Process this tagging activity as well
  +    my $affected_files = 
$self->{connection}->process_activity($new_activity);
  +
  +    return $affected_files;
  +}
  +
  +#
  +# Convert the XML format to a nice Perl structured format
  +# grouping all the files together
  +#
  +sub convert_from_xml {
  +    my $self = shift;
  +    my $affected_files_xml = shift;
  +    
  +    my $xml = new XML::Simple (NoAttr=>1);
  +    my $raw = $xml->XMLin($affected_files_xml);
  +    
  +    my @changeList = ();
  +    
  +    my $bugid;
  +    foreach $bugid (keys %{$raw}) {
  +     my $comment_section;
  +     foreach $comment_section (keys %{$raw->{$bugid}}) {
  +         my $file_change;
  +         foreach $file_change (keys %{$raw->{$bugid}->{$comment_section}}) {
  +             my $changeset;
  +             $changeset->{file} = 
$raw->{$bugid}->{$comment_section}->{$file_change}->{filename};
  +             $changeset->{new} = 
$raw->{$bugid}->{$comment_section}->{$file_change}->{new_version};
  +             $changeset->{old} = 
$raw->{$bugid}->{$comment_section}->{$file_change}->{old_version};
  +
  +             # Set the old version for new files to 0
  +             if( "$changeset->{old}" eq "NONE" ) {
  +                 $changeset->{old} = 0;
  +             }
  +             if( "$changeset->{new}" eq "NONE" ) {
  +                 $changeset->{new} = 0;
  +             }
  +             push @changeList, $changeset;
  +         }
  +     }
  +    }
  +    
  +    return [EMAIL PROTECTED];
  +}
  +
  +# Retrieve the data corresponding to $filename and $revision.  Store each 
line
  +# into $content_array_ref.
  +sub retrieve ($$$\$) {
  +    my ($self, $filename, $revision, $content_array_ref) = @_;
  +
  +    $self->{repository}->retrieve($filename, $revision, $content_array_ref);
  +}
  +
  +# Retrieve the "root" of this repository.
  +sub getRoot ($) {
  +    my ($self) = @_;
  +    return $self->{repository}->{repository_url};
  +}
  +
  +# Return a URL which views the specified file and revision.
  +sub getViewUrl ($$$) {
  +    my ($self, $filename, $revision) = @_;
  +
  +    return $self->{repository}->getViewUrl($filename, $revision);
  +}
  +
  +# Return a string representation of this repository.
  +sub toString ($) {
  +    my ($self) = @_;
  +    return $self->{repository}->toString();
  +}
  +
  +# The getDiff operation, pull out a change set based on the bug IDs.
  +sub getDiff {
  +    my ($self, $bugids, $stdout_fh, $stderr_fh, $default_to_head) = @_;
  +
  +    my $affected_files_list =
  +     $self->convert_from_xml($self->get_affected_files_XML($bugids));
  +
  +
  +    foreach my $changeset ( @{ $affected_files_list } ) {
  +     
  +     # Don't diff just directory property changes
  +     if( $changeset->{file} =~ /\/$/ ) {
  +         next;
  +     }
  +
  +     # Call the delgate repository object for retrieving the actual
  +     # content.
  +     my $old_rev = ($changeset->{old} == 0) ? "" : $changeset->{old};
  +     my $new_rev = ($changeset->{new} == 0) ? "" : $changeset->{new};        
        
  +     my $ret = $self->{repository}->getDiff($old_rev, $new_rev,
  +                                            $changeset->{file},
  +                                            $stdout_fh,
  +                                            $stderr_fh,
  +                                            $default_to_head);
  +     return $ret if $ret != $Codestriker::OK;
  +    }
  +
  +    return $Codestriker::OK;
  +}
  +
  +
  +1;
  
  
  

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to