User: sits    
  Date: 06/05/25 21:55:26

  Modified:    .        CHANGELOG
               lib/Codestriker/FileParser SubversionDiff.pm
  Log:
  * Added support for parsing diffs generated using Subversion's svnlook
    program.
  
  
  
  Index: CHANGELOG
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
  retrieving revision 1.185
  retrieving revision 1.186
  diff -u -r1.185 -r1.186
  --- CHANGELOG 18 Apr 2006 10:45:39 -0000      1.185
  +++ CHANGELOG 26 May 2006 04:55:25 -0000      1.186
  @@ -53,6 +53,9 @@
     CodestrikerClient.pm module (used for auto-creation of topics on CVS
     commits).  Reported by Martin Apel <[EMAIL PROTECTED]>.
   
  +* Added support for parsing diffs generated using Subversion's svnlook
  +  program.
  +
   Version 1.9.1
   
   * Correct problem introduced in 1.9.0 release where the email address
  
  
  
  
  
  Index: SubversionDiff.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/SubversionDiff.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SubversionDiff.pm 22 May 2005 10:46:34 -0000      1.4
  +++ SubversionDiff.pm 26 May 2006 04:55:26 -0000      1.5
  @@ -25,6 +25,7 @@
       my $line = <$fh>;
       while (defined($line)) {
        # Values associated with the diff.
  +     my $entry_type;
        my $revision;
        my $filename = "";
        my $old_linenumber = -1;
  @@ -33,12 +34,13 @@
        my $diff = "";
   
        # Skip whitespace.
  -     while (defined($line) && $line =~ /^\s*$/) {
  +     while (defined($line) && $line =~ /^\s*$/o) {
            $line = <$fh>;
        }
        return @result unless defined $line;
   
        # For SVN diffs, the start of the diff block is the Index line.
  +     # For SVN look diffs, the start of the diff block contains the change 
type.
        # Also check for presence of property set blocks.
        while ($line =~ /^Property changes on: .*$/o) {
            $line = <$fh>;
  @@ -46,9 +48,12 @@
                $line =~ 
/^___________________________________________________________________$/o;
            
            # Keep reading until we either get to an Index: line, a property
  -         # block, or the end of file.
  +         # block, an Added/Deleted/Modified lines or the end of file.
            while (defined $line &&
                   $line !~ /^Index:/o &&
  +                $line !~ /^Added:/o &&
  +                $line !~ /^Deleted:/o &&
  +                $line !~ /^Modified:/o &&
                   $line !~ /^Property changes on:/o) {
                $line = <$fh>;
            }
  @@ -59,8 +64,10 @@
            }
        }
   
  -     return () unless $line =~ /^Index: (.*)$/o;
  -     $filename = $1;
  +     return () unless
  +         $line =~ /^(Index|Added|Modified|Deleted): (.*)$/o;
  +     $entry_type = $1;
  +     $filename = $2;
        $line = <$fh>;
   
        # The separator line appears next.
  @@ -68,11 +75,8 @@
        $line = <$fh>;
   
        # Check if the delta represents a binary file.
  -     if ($line =~ /^Cannot display: file marked as a binary type\./) {
  -         # The next line indicates the mime type.
  -         $line = <$fh>;
  -         return () unless defined $line;
  -         return () unless $line =~ /^svn:mime\-type/;
  +     if ($line =~ /^Cannot display: file marked as a binary type\./o ||
  +         $line =~ /^\(Binary files differ\)/o) {
   
            # If it is a new binary file, there will be some lines before
            # the next Index: line, or end of file.  In other cases, it is
  @@ -80,15 +84,23 @@
            # removed, and what revision it is based off.
            $line = <$fh>;
            my $count = 0;
  -         while (defined $line && $line !~ /^Index:/) {
  +         while (defined $line && $line !~ /^Index|Added|Modified|Deleted/o) {
                $line = <$fh>;
                $count++;
            }
   
            my $chunk = {};
            $chunk->{filename} = $filename;
  -         $chunk->{revision} = $count > 0 ? $Codestriker::ADDED_REVISION :
  -             $Codestriker::PATCH_REVISION;
  +         if ($entry_type eq "Index") {
  +             $chunk->{revision} = $count > 0 ? $Codestriker::ADDED_REVISION :
  +                 $Codestriker::PATCH_REVISION;
  +         } elsif ($entry_type eq "Added") {
  +             $chunk->{revision} = $Codestriker::ADDED_REVISION;
  +         } elsif ($entry_type eq "Deleted") {
  +             $chunk->{revision} = $Codestriker::REMOVED_REVISION;
  +         } else {
  +             $chunk->{revision} = $Codestriker::PATCH_REVISION;
  +         }
            $chunk->{old_linenumber} = -1;
            $chunk->{new_linenumber} = -1;
            $chunk->{binary} = 1;
  @@ -100,17 +112,19 @@
            # Try and read the base revision this change is against,
            # while handling new and removed files.
            my $base_revision = -1;
  -         if ($line =~ /^\-\-\- .*\s\([Rr]evision (\d+)\)/i) {
  +         if ($line =~ /^\-\-\- .*\s\(revision (\d+)\)/io ||
  +             $line =~ /^\-\-\- .*\s\(rev (\d+)/io) {
                $base_revision = $1;
  -         } elsif ($line !~ /^\-\-\- .*\s\(working copy\)/) {
  +         } elsif ($line !~ /^\-\-\- .*\s\(working copy\)/io) {
                return ();
            }
   
            # Make sure the +++ line is present next.
            $line = <$fh>;
            return () unless defined $line;
  -         if ($line !~ /^\+\+\+ .*\s\(working copy\)/ &&
  -             $line !~ /^\+\+\+ .*\s\([Rr]evision \d+\)/) {
  +         if ($line !~ /^\+\+\+ .*\s\(working copy\)/io &&
  +             $line !~ /^\+\+\+ .*\s\(revision \d+\)/io &&
  +             $line !~ /^\+\+\+ .*\s\(txn .*\)/io) {
                return ();
            }
   
  
  
  


_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to