Changeset 60015 in webkit


Ignore:
Timestamp:
May 22, 2010 2:40:31 PM (14 years ago)
Author:
dbates@webkit.org
Message:

2010-05-22 Daniel Bates <dbates@rim.com>

Reviewed by Chris Jerdonek.

Add infrastructure to parse SVN property changes
https://bugs.webkit.org/show_bug.cgi?id=38885

Adds function VCSUtils::parseSvnDiffFooter to parse an SVN footer
that consists of one or more properties.

Note, the first line of an SVN footer begins with "Property changes on".

  • Scripts/VCSUtils.pm:
    • Added function parseSvnDiffFooter. Will use this function towards resolving Bug #39409 <https://bugs.webkit.org/show_bug.cgi?id=39409>.
    • Removed FIXME comment above function parseSvnProperty, since it is being used by parseSvnDiffFooter.
  • Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffFooter.pl: Added.
    • Added unit tests.
Location:
trunk/WebKitTools
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r60007 r60015  
     12010-05-22  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Chris Jerdonek.
     4
     5        Add infrastructure to parse SVN property changes
     6        https://bugs.webkit.org/show_bug.cgi?id=38885
     7
     8        Adds function VCSUtils::parseSvnDiffFooter to parse an SVN footer
     9        that consists of one or more properties.
     10
     11        Note, the first line of an SVN footer begins with "Property changes on".
     12
     13        * Scripts/VCSUtils.pm:
     14          - Added function parseSvnDiffFooter. Will use this function
     15            towards resolving Bug #39409 <https://bugs.webkit.org/show_bug.cgi?id=39409>.
     16          - Removed FIXME comment above function parseSvnProperty, since
     17            it is being used by parseSvnDiffFooter.
     18        * Scripts/webkitperl/VCSUtils_unittest/parseSvnDiffFooter.pl: Added.
     19          - Added unit tests.
     20
    1212010-05-22  Eric Seidel  <eric@webkit.org>
    222
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r59593 r60015  
    839839}
    840840
     841# Parse an SVN property change diff from the given file handle, and advance
     842# the handle so the last line read is the first line after this diff.
     843#
     844# For the case of an SVN binary diff, the binary contents will follow the
     845# the property changes.
     846#
     847# This subroutine dies if the first line does not begin with "Property changes on"
     848# or if the separator line that follows this line is missing.
     849#
     850# Args:
     851#   $fileHandle: advanced so the last line read from the handle is the first
     852#                line of the footer to parse.  This line begins with
     853#                "Property changes on".
     854#   $line: the line last read from $fileHandle.
     855#
     856# Returns ($propertyHashRef, $lastReadLine):
     857#   $propertyHashRef: a hash reference representing an SVN diff footer.
     858#     propertyPath: the path of the target file.
     859#     executableBitDelta: the value 1 or -1 if the executable bit was added or
     860#                         removed from the target file, respectively.
     861#   $lastReadLine: the line last read from $fileHandle.
     862#
     863# FIXME: This method is unused as of (05/22/2010).  We will call this function
     864#        as part of parsing a diff.  See <https://bugs.webkit.org/show_bug.cgi?id=39409>.
     865sub parseSvnDiffProperties($$)
     866{
     867    my ($fileHandle, $line) = @_;
     868
     869    $_ = $line;
     870
     871    my $svnFooterDiffStartRegEx = qr#Property changes on: ([^\r\n]+)#; # $1 is normally the same as the index path.
     872
     873    my %footer;
     874    if (/$svnFooterDiffStartRegEx/) {
     875        $footer{propertyPath} = $1;
     876    } else {
     877        die("Failed to find start of SVN property change, \"Property changes on \": \"$_\"");
     878    }
     879
     880    # We advance $fileHandle two lines so that the next line that
     881    # we process is $svnPropertyStartRegEx in a well-formed footer.
     882    # A well-formed footer has the form:
     883    # Property changes on: FileA
     884    # ___________________________________________________________________
     885    # Added: svn:executable
     886    #    + *
     887    $_ = <$fileHandle>; # Not defined if end-of-file reached.
     888    my $separator = "_" x 67;
     889    if (defined($_) && /^$separator[\r\n]+$/) {
     890        $_ = <$fileHandle>;
     891    } else {
     892        die("Failed to find separator line: \"$_\".");
     893    }
     894
     895    # FIXME: We should expand this to support other SVN properties
     896    #        (e.g. return a hash of property key-values that represents
     897    #        all properties).
     898    #
     899    # Notice, we keep processing until we hit end-of-file or some
     900    # line that does not resemble $svnPropertyStartRegEx, such as
     901    # the empty line that precedes the start of the binary contents
     902    # of a patch, or the start of the next diff (e.g. "Index:").
     903    my $propertyHashRef;
     904    while (defined($_) && /$svnPropertyStartRegEx/) {
     905        ($propertyHashRef, $_) = parseSvnProperty($fileHandle, $_);
     906        if ($propertyHashRef->{name} eq "svn:executable") {
     907            # Notice, for SVN properties, propertyChangeDelta is always non-zero
     908            # because a property can only be added or removed.
     909            $footer{executableBitDelta} = $propertyHashRef->{propertyChangeDelta};   
     910        }
     911    }
     912
     913    return(\%footer, $_);
     914}
     915
    841916# Parse the next SVN property from the given file handle, and advance the handle so the last
    842917# line read is the first line after the property.
     
    862937#                          removed, respectively.
    863938#   $lastReadLine: the line last read from $fileHandle.
    864 #
    865 # FIXME: This method is unused as of (05/16/2010).  We will call this function
    866 #        as part of parsing a SVN footer.  See <https://bugs.webkit.org/show_bug.cgi?id=38885>.
    867939sub parseSvnProperty($$)
    868940{
Note: See TracChangeset for help on using the changeset viewer.