Changeset 63062 in webkit


Ignore:
Timestamp:
Jul 11, 2010 11:29:06 PM (14 years ago)
Author:
dbates@webkit.org
Message:

2010-07-11 Daniel Bates <dbates@rim.com>

Reviewed by David Kilzer.

Enable executable support for svn-apply and svn-unapply
https://bugs.webkit.org/show_bug.cgi?id=39409

Connect up the Git and SVN executable bit support in parseDiff() so that
executable bit changes are propagated via the returned diff hash to the
patch function in svn-apply and svn-unapply.

  • Scripts/VCSUtils.pm:
    • Modified parseDiff() to call parseSvnDiffProperties when it finds the start of an SVN property change diff.
    • Removed FIXME comment above parseSvnDiffProperties() since it is now being used by parseDiff().
    • Export method scmToggleExecutableBit() now that we added the executableBitDelta hash key. (This should have been exported when we added this function in Bug #38423 <https://bugs.webkit.org/show_bug.cgi?id=38423>).
  • Scripts/webkitperl/VCSUtils_unittest/parseDiff.pl:
    • Updated results for: "rename (with executable bit change)"
      • Test value of executableBitDelta (now that we have support).
      "SVN: binary file (isBinary true)"
      • Remove the property change diff from svnConvertedText. We plan to remove svnConvertedText in the future. So, we decided against adding such support to any new code, such as the property parsing routines. Therefore, we do not keep SVN converted text for property change diffs.
    • Added unit tests: "SVN: file change diff with property change diff" "SVN: file change diff, followed by property change diff on different file" "SVN: property diff, followed by file change diff" "SVN: copied file with property change" "SVN: two consecutive property diffs" "SVN: binary file with executable bit change" "SVN: binary file followed by property change on different file" "SVN: binary file followed by file change on different file" "SVN: file change diff with property change, followed by property change diff" "SVN: file change diff with property change, followed by file change diff"
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r63061 r63062  
     12010-07-11  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        Enable executable support for svn-apply and svn-unapply
     6        https://bugs.webkit.org/show_bug.cgi?id=39409
     7
     8        Connect up the Git and SVN executable bit support in parseDiff() so that
     9        executable bit changes are propagated via the returned diff hash to the
     10        patch function in svn-apply and svn-unapply.
     11
     12        * Scripts/VCSUtils.pm:
     13          - Modified parseDiff() to call parseSvnDiffProperties when
     14            it finds the start of an SVN property change diff.
     15          - Removed FIXME comment above parseSvnDiffProperties() since
     16            it is now being used by parseDiff().
     17          - Export method scmToggleExecutableBit() now that we added the
     18            executableBitDelta hash key. (This should have been exported
     19            when we added this function in Bug #38423 <https://bugs.webkit.org/show_bug.cgi?id=38423>).
     20        * Scripts/webkitperl/VCSUtils_unittest/parseDiff.pl:
     21          - Updated results for:
     22            "rename (with executable bit change)"
     23              - Test value of executableBitDelta (now that we have support).
     24            "SVN: binary file (isBinary true)"
     25              - Remove the property change diff from svnConvertedText. We plan
     26                to remove svnConvertedText in the future. So, we decided
     27                against adding such support to any new code, such as the
     28                property parsing routines. Therefore, we do not keep SVN
     29                converted text for property change diffs.
     30          - Added unit tests:
     31            "SVN: file change diff with property change diff"
     32            "SVN: file change diff, followed by property change diff on different file"
     33            "SVN: property diff, followed by file change diff"
     34            "SVN: copied file with property change"
     35            "SVN: two consecutive property diffs"
     36            "SVN: binary file with executable bit change"
     37            "SVN: binary file followed by property change on different file"
     38            "SVN: binary file followed by file change on different file"
     39            "SVN: file change diff with property change, followed by property change diff"
     40            "SVN: file change diff with property change, followed by file change diff"
     41
    1422010-07-11  Maciej Stachowiak  <mjs@apple.com>
    243
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r62755 r63062  
    6969        &prepareParsedPatch
    7070        &runPatchCommand
     71        &scmToggleExecutableBit
    7172        &setChangeLogDateAndReviewer
    7273        &svnRevisionForDirectory
     
    9192my $gitDiffStartRegEx = qr#^diff --git (\w/)?(.+) (\w/)?([^\r\n]+)#;
    9293my $svnDiffStartRegEx = qr#^Index: ([^\r\n]+)#;
     94my $svnPropertiesStartRegEx = qr#^Property changes on: ([^\r\n]+)#; # $1 is normally the same as the index path.
    9395my $svnPropertyStartRegEx = qr#^(Modified|Name|Added|Deleted): ([^\r\n]+)#; # $2 is the name of the property.
    9496my $svnPropertyValueStartRegEx = qr#^   (\+|-) ([^\r\n]+)#; # $2 is the start of the property's value (which may span multiple lines).
     
    736738#   copiedFromPath: the path from which the file was copied if the diff
    737739#                   is a copy.
     740#   executableBitDelta: the value 1 or -1 if the executable bit was added or
     741#                       removed from the target file, respectively.
    738742#   indexPath: the path of the target file.  For SVN-formatted diffs,
    739743#              this is the same as the path in the "Index:" line.
     
    755759# This subroutine preserves any leading junk encountered before the header.
    756760#
     761# Composition of an SVN diff
     762#
     763# There are three parts to an SVN diff: the header, the property change, and
     764# the binary contents, in that order. Either the header or the property change
     765# may be ommitted, but not both. If there are binary changes, then you always
     766# have all three.
     767#
    757768# Args:
    758769#   $fileHandle: a file handle advanced to the first line of the next
     
    774785
    775786    my $headerHashRef; # Last header found, as returned by parseDiffHeader().
     787    my $svnPropertiesHashRef; # Last SVN properties diff found, as returned by parseSvnDiffProperties().
    776788    my $svnText;
    777789    while (defined($line)) {
     
    783795        }
    784796
     797        if ($line =~ $svnPropertiesStartRegEx) {
     798            my $propertyPath = $1;
     799            if ($svnPropertiesHashRef || $headerHashRef && ($propertyPath ne $headerHashRef->{indexPath})) {
     800                # This is the start of the second diff in the while loop, which happens to
     801                # be a property diff.  If $svnPropertiesHasRef is defined, then this is the
     802                # second consecutive property diff, otherwise it's the start of a property
     803                # diff for a file that only has property changes.
     804                last;
     805            }
     806            ($svnPropertiesHashRef, $line) = parseSvnDiffProperties($fileHandle, $line);
     807            next;
     808        }
    785809        if ($line !~ $headerStartRegEx) {
    786810            # Then we are in the body of the diff.
     
    790814        } # Otherwise, we found a diff header.
    791815
    792         if ($headerHashRef) {
    793             # Then this is the second diff header of this while loop.
     816        if ($svnPropertiesHashRef || $headerHashRef) {
     817            # Then either we just processed an SVN property change or this
     818            # is the start of the second diff header of this while loop.
    794819            last;
    795820        }
     
    813838        $copyHash{indexPath} = $headerHashRef->{indexPath};
    814839        $copyHash{sourceRevision} = $headerHashRef->{sourceRevision} if $headerHashRef->{sourceRevision};
     840        if ($headerHashRef->{isSvn}) {
     841            $copyHash{executableBitDelta} = $svnPropertiesHashRef->{executableBitDelta} if $svnPropertiesHashRef->{executableBitDelta};
     842        }
    815843        push @diffHashRefs, \%copyHash;
    816844    }
    817     if (!$headerHashRef->{copiedFromPath} || $headerHashRef->{isCopyWithChanges}) {
     845
     846    # Note, the order of evaluation for the following if conditional has been explicitly chosen so that
     847    # it evaluates to false when there is no headerHashRef (e.g. a property change diff for a file that
     848    # only has property changes).
     849    if ($headerHashRef->{isCopyWithChanges} || (%$headerHashRef && !$headerHashRef->{copiedFromPath})) {
    818850        # Then add the usual file modification.
    819851        my %diffHash;
    820         # FIXME: Add executableBitDelta as a key.
     852        # FIXME: We should expand this code to support other properties.  In the future,
     853        #        parseSvnDiffProperties may return a hash whose keys are the properties.
     854        if ($headerHashRef->{isSvn}) {
     855            # SVN records the change to the executable bit in a separate property change diff
     856            # that follows the contents of the diff, except for binary diffs.  For binary
     857            # diffs, the property change diff follows the diff header.
     858            $diffHash{executableBitDelta} = $svnPropertiesHashRef->{executableBitDelta} if $svnPropertiesHashRef->{executableBitDelta};
     859        } elsif ($headerHashRef->{isGit}) {
     860            # Git records the change to the executable bit in the header of a diff.
     861            $diffHash{executableBitDelta} = $headerHashRef->{executableBitDelta} if $headerHashRef->{executableBitDelta};
     862        }
    821863        $diffHash{indexPath} = $headerHashRef->{indexPath};
    822864        $diffHash{isBinary} = $headerHashRef->{isBinary} if $headerHashRef->{isBinary};
     
    832874        # FIXME: Remove the need for svnConvertedText.  See the %diffHash
    833875        #        code comments above for more information.
    834         $diffHash{svnConvertedText} = $svnText;
     876        #
     877        # Note, we may not always have SVN converted text since we intend
     878        # to deprecate it in the future.  For example, a property change
     879        # diff for a file that only has property changes will not return
     880        # any SVN converted text.
     881        $diffHash{svnConvertedText} = $svnText if $svnText;
    835882        push @diffHashRefs, \%diffHash;
     883    }
     884
     885    if (!%$headerHashRef && $svnPropertiesHashRef) {
     886        # A property change diff for a file that only has property changes.
     887        my %propertyChangeHash;
     888        $propertyChangeHash{executableBitDelta} = $svnPropertiesHashRef->{executableBitDelta} if $svnPropertiesHashRef->{executableBitDelta};
     889        $propertyChangeHash{indexPath} = $svnPropertiesHashRef->{propertyPath};
     890        $propertyChangeHash{isSvn} = 1;
     891        push @diffHashRefs, \%propertyChangeHash;
    836892    }
    837893
     
    860916#                         removed from the target file, respectively.
    861917#   $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>.
    865918sub parseSvnDiffProperties($$)
    866919{
     
    869922    $_ = $line;
    870923
    871     my $svnFooterDiffStartRegEx = qr#Property changes on: ([^\r\n]+)#; # $1 is normally the same as the index path.
    872 
    873924    my %footer;
    874     if (/$svnFooterDiffStartRegEx/) {
     925    if (/$svnPropertiesStartRegEx/) {
    875926        $footer{propertyPath} = $1;
    876927    } else {
  • trunk/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/parseDiff.pl

    r59048 r63062  
    9292svn:mime-type = application/octet-stream
    9393
    94 Property changes on: test_file.swf
    95 ___________________________________________________________________
    96 Name: svn:mime-type
    97    + application/octet-stream
    9894
    9995
     
    235231undef],
    236232    expectedNextLine => undef,
     233},
     234####
     235# Property Changes: Simple
     236##
     237{
     238    # New test
     239    diffName => "SVN: file change diff with property change diff",
     240    inputText => <<'END',
     241Index: Makefile
     242===================================================================
     243--- Makefile    (revision 60021)
     244+++ Makefile    (working copy)
     245@@ -1,3 +1,4 @@
     246+
     247 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     248
     249 all:
     250
     251Property changes on: Makefile
     252___________________________________________________________________
     253Name: svn:executable
     254   + *
     255END
     256    expectedReturn => [
     257[{
     258    svnConvertedText =>  <<'END', # Same as input text
     259Index: Makefile
     260===================================================================
     261--- Makefile    (revision 60021)
     262+++ Makefile    (working copy)
     263@@ -1,3 +1,4 @@
     264+
     265 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     266
     267 all:
     268
     269END
     270    executableBitDelta => 1,
     271    indexPath => "Makefile",
     272    isSvn => 1,
     273    sourceRevision => "60021",
     274}],
     275undef],
     276    expectedNextLine => undef,
     277},
     278{
     279    # New test
     280    diffName => "SVN: file change diff, followed by property change diff on different file",
     281    inputText => <<'END',
     282Index: Makefile
     283===================================================================
     284--- Makefile    (revision 60021)
     285+++ Makefile    (working copy)
     286@@ -1,3 +1,4 @@
     287+
     288 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     289
     290 all:
     291
     292Property changes on: Makefile.shared
     293___________________________________________________________________
     294Name: svn:executable
     295   + *
     296END
     297    expectedReturn => [
     298[{
     299    svnConvertedText =>  <<'END', # Same as input text
     300Index: Makefile
     301===================================================================
     302--- Makefile    (revision 60021)
     303+++ Makefile    (working copy)
     304@@ -1,3 +1,4 @@
     305+
     306 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     307
     308 all:
     309
     310END
     311    indexPath => "Makefile",
     312    isSvn => 1,
     313    sourceRevision => "60021",
     314}],
     315"Property changes on: Makefile.shared\n"],
     316    expectedNextLine => "___________________________________________________________________\n",
     317},
     318{
     319    # New test
     320    diffName => "SVN: property diff, followed by file change diff",
     321    inputText => <<'END',
     322Property changes on: Makefile
     323___________________________________________________________________
     324Deleted: svn:executable
     325   - *
     326
     327Index: Makefile.shared
     328===================================================================
     329--- Makefile.shared     (revision 60021)
     330+++ Makefile.shared     (working copy)
     331@@ -1,3 +1,4 @@
     332+
     333SCRIPTS_PATH ?= ../WebKitTools/Scripts
     334XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()'` $(ARGS)
     335END
     336    expectedReturn => [
     337[{
     338    executableBitDelta => -1,
     339    indexPath => "Makefile",
     340    isSvn => 1,
     341}],
     342"Index: Makefile.shared\n"],
     343    expectedNextLine => "===================================================================\n",
     344},
     345{
     346    # New test
     347    diffName => "SVN: copied file with property change",
     348    inputText => <<'END',
     349Index: NMakefile
     350===================================================================
     351--- NMakefile   (revision 60021)        (from Makefile:60021)
     352+++ NMakefile   (working copy)
     353@@ -0,0 +1,1 @@
     354+MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     355
     356Property changes on: NMakefile
     357___________________________________________________________________
     358Added: svn:executable
     359   + *
     360END
     361    expectedReturn => [
     362[{
     363    copiedFromPath => "Makefile",
     364    executableBitDelta => 1,
     365    indexPath => "NMakefile",
     366    sourceRevision => "60021",
     367}],
     368undef],
     369    expectedNextLine => undef,
     370},
     371{
     372    # New test
     373    diffName => "SVN: two consecutive property diffs",
     374    inputText => <<'END',
     375Property changes on: Makefile
     376___________________________________________________________________
     377Added: svn:executable
     378   + *
     379
     380
     381Property changes on: Makefile.shared
     382___________________________________________________________________
     383Added: svn:executable
     384   + *
     385END
     386    expectedReturn => [
     387[{
     388    executableBitDelta => 1,
     389    indexPath => "Makefile",
     390    isSvn => 1,
     391}],
     392"Property changes on: Makefile.shared\n"],
     393    expectedNextLine => "___________________________________________________________________\n",
     394},
     395####
     396# Property Changes: Binary files
     397##
     398{
     399    # New test
     400    diffName => "SVN: binary file with executable bit change",
     401    inputText => <<'END',
     402Index: test_file.swf
     403===================================================================
     404Cannot display: file marked as a binary type.
     405svn:mime-type = application/octet-stream
     406
     407Property changes on: test_file.swf
     408___________________________________________________________________
     409Name: svn:mime-type
     410   + application/octet-stream
     411Name: svn:executable
     412   + *
     413
     414
     415Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     416END
     417    expectedReturn => [
     418[{
     419    svnConvertedText =>  <<'END', # Same as input text
     420Index: test_file.swf
     421===================================================================
     422Cannot display: file marked as a binary type.
     423svn:mime-type = application/octet-stream
     424
     425
     426
     427Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     428END
     429    executableBitDelta => 1,
     430    indexPath => "test_file.swf",
     431    isBinary => 1,
     432    isSvn => 1,
     433}],
     434undef],
     435    expectedNextLine => undef,
     436},
     437{
     438    # New test
     439    diffName => "SVN: binary file followed by property change on different file",
     440    inputText => <<'END',
     441Index: test_file.swf
     442===================================================================
     443Cannot display: file marked as a binary type.
     444svn:mime-type = application/octet-stream
     445
     446Property changes on: test_file.swf
     447___________________________________________________________________
     448Name: svn:mime-type
     449   + application/octet-stream
     450
     451
     452Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     453
     454Property changes on: Makefile
     455___________________________________________________________________
     456Added: svn:executable
     457   + *
     458END
     459    expectedReturn => [
     460[{
     461    svnConvertedText =>  <<'END', # Same as input text
     462Index: test_file.swf
     463===================================================================
     464Cannot display: file marked as a binary type.
     465svn:mime-type = application/octet-stream
     466
     467
     468
     469Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     470
     471END
     472    indexPath => "test_file.swf",
     473    isBinary => 1,
     474    isSvn => 1,
     475}],
     476"Property changes on: Makefile\n"],
     477    expectedNextLine => "___________________________________________________________________\n",
     478},
     479{
     480    # New test
     481    diffName => "SVN: binary file followed by file change on different file",
     482    inputText => <<'END',
     483Index: test_file.swf
     484===================================================================
     485Cannot display: file marked as a binary type.
     486svn:mime-type = application/octet-stream
     487
     488Property changes on: test_file.swf
     489___________________________________________________________________
     490Name: svn:mime-type
     491   + application/octet-stream
     492
     493
     494Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     495
     496Index: Makefile
     497===================================================================
     498--- Makefile    (revision 60021)
     499+++ Makefile    (working copy)
     500@@ -1,3 +1,4 @@
     501+
     502 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     503
     504 all:
     505END
     506    expectedReturn => [
     507[{
     508    svnConvertedText =>  <<'END', # Same as input text
     509Index: test_file.swf
     510===================================================================
     511Cannot display: file marked as a binary type.
     512svn:mime-type = application/octet-stream
     513
     514
     515
     516Q1dTBx0AAAB42itg4GlgYJjGwMDDyODMxMDw34GBgQEAJPQDJA==
     517
     518END
     519    indexPath => "test_file.swf",
     520    isBinary => 1,
     521    isSvn => 1,
     522}],
     523"Index: Makefile\n"],
     524    expectedNextLine => "===================================================================\n",
     525},
     526####
     527# Property Changes: File change with property change
     528##
     529{
     530    # New test
     531    diffName => "SVN: file change diff with property change, followed by property change diff",
     532    inputText => <<'END',
     533Index: Makefile
     534===================================================================
     535--- Makefile    (revision 60021)
     536+++ Makefile    (working copy)
     537@@ -1,3 +1,4 @@
     538+
     539 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     540
     541 all:
     542
     543Property changes on: Makefile
     544___________________________________________________________________
     545Added: svn:executable
     546   + *
     547
     548
     549Property changes on: Makefile.shared
     550___________________________________________________________________
     551Deleted: svn:executable
     552   - *
     553END
     554    expectedReturn => [
     555[{
     556    svnConvertedText =>  <<'END', # Same as input text
     557Index: Makefile
     558===================================================================
     559--- Makefile    (revision 60021)
     560+++ Makefile    (working copy)
     561@@ -1,3 +1,4 @@
     562+
     563 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     564
     565 all:
     566
     567
     568
     569END
     570    executableBitDelta => 1,
     571    indexPath => "Makefile",
     572    isSvn => 1,
     573    sourceRevision => "60021",
     574}],
     575"Property changes on: Makefile.shared\n"],
     576    expectedNextLine => "___________________________________________________________________\n",
     577},
     578{
     579    # New test
     580    diffName => "SVN: file change diff with property change, followed by file change diff",
     581    inputText => <<'END',
     582Index: Makefile
     583===================================================================
     584--- Makefile    (revision 60021)
     585+++ Makefile    (working copy)
     586@@ -1,3 +1,4 @@
     587+
     588 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     589
     590 all:
     591
     592Property changes on: Makefile
     593___________________________________________________________________
     594Name: svn:executable
     595   - *
     596
     597Index: Makefile.shared
     598===================================================================
     599--- Makefile.shared     (revision 60021)
     600+++ Makefile.shared     (working copy)
     601@@ -1,3 +1,4 @@
     602+
     603SCRIPTS_PATH ?= ../WebKitTools/Scripts
     604XCODE_OPTIONS = `perl -I$(SCRIPTS_PATH) -Mwebkitdirs -e 'print XcodeOptionString()'` $(ARGS)
     605END
     606    expectedReturn => [
     607[{
     608    svnConvertedText =>  <<'END', # Same as input text
     609Index: Makefile
     610===================================================================
     611--- Makefile    (revision 60021)
     612+++ Makefile    (working copy)
     613@@ -1,3 +1,4 @@
     614+
     615 MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
     616
     617 all:
     618
     619
     620END
     621    executableBitDelta => -1,
     622    indexPath => "Makefile",
     623    isSvn => 1,
     624    sourceRevision => "60021",
     625}],
     626"Index: Makefile.shared\n"],
     627    expectedNextLine => "===================================================================\n",
    237628},
    238629####
     
    452843},
    453844{
     845    executableBitDelta => 1,
    454846    indexPath => "foo_new",
    455847    isGit => 1,
Note: See TracChangeset for help on using the changeset viewer.