Changeset 211543 in webkit
- Timestamp:
- Feb 1, 2017 5:41:24 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r211539 r211543 1 2017-02-01 Daniel Bates <dabates@apple.com> 2 3 REGRESSION (r210820): svn-create-patch does not emit property change only diff 4 https://bugs.webkit.org/show_bug.cgi?id=167169 5 6 Reviewed by David Kilzer. 7 8 More directly handle the SVN 1.9 or newer syntax change for a diff of a copied or moved file 9 - a SVN diff header and an empty body. In particular, remove a duplicate leading SVN diff 10 header from the output of "svn diff" on a file that was copied or moved. 11 12 Following r210820 svn-create-patch emits to standard output a diff only if it has at least one 13 chunk range line (e.g. @@ -0,0 +1,7 @@) as a means to workaround a syntax change in the diff 14 output of a copied or moved file in SVN version 1.9 or newer. In SVN 1.9 or newer "svn diff" 15 of a copied or moved file always emits to standard output a leading SVN diff header (an "Index:" 16 line followed by a separator line) with an empty body; => no chunk range lines. However a diff 17 of a file with only a property change also does not contain any chunk range lines. Therefore 18 svn-create-patch no longer emitted to standard output such a diff. Instead of indirectly detecting 19 a SVN diff header with an empty body by counting the number of chunk range lines in the diff 20 we should directly test for the presence of a leading SVN diff header with an empty body and 21 remove such lines from the diff. 22 23 * Scripts/VCSUtils.pm: 24 (fixSVNPatchForAdditionWithHistory): Added. 25 * Scripts/svn-create-patch: 26 (generateDiff): Pass the output from "svn diff" to fixSVNPatchForAdditionWithHistory() when 27 we have a non empty patch for an added file with history (i.e. a copied or moved file). 28 * Scripts/webkitperl/VCSUtils_unittest/fixSVNPatchForAdditionWithHistory.pl: Added. 29 1 30 2017-02-01 Eric Carlson <eric.carlson@apple.com> 2 31 -
trunk/Tools/Scripts/VCSUtils.pm
r210551 r211543 1737 1737 } 1738 1738 1739 # Removes a leading Subversion header without an associated diff if one exists. 1740 # 1741 # This subroutine dies if the specified patch does not begin with an "Index:" line. 1742 # 1743 # In SVN 1.9 or newer, "svn diff" of a moved/copied file without post changes always 1744 # emits a leading header without an associated diff: 1745 # Index: B.txt 1746 # =================================================================== 1747 # (end of file or next header) 1748 # 1749 # If the same file has a property change then the patch has the form: 1750 # Index: B.txt 1751 # =================================================================== 1752 # Index: B.txt 1753 # =================================================================== 1754 # --- B.txt (revision 1) 1755 # +++ B.txt (working copy) 1756 # 1757 # Property change on B.txt 1758 # ___________________________________________________________________ 1759 # Added: svn:executable 1760 # ## -0,0 +1 ## 1761 # +* 1762 # \ No newline at end of property 1763 # 1764 # We need to apply this function to the ouput of "svn diff" for an addition with history 1765 # to remove a duplicate header so that svn-apply can apply the resulting patch. 1766 sub fixSVNPatchForAdditionWithHistory($) 1767 { 1768 my ($patch) = @_; 1769 1770 $patch =~ /(\r?\n)/; 1771 my $lineEnding = $1; 1772 my @lines = split(/$lineEnding/, $patch); 1773 1774 if ($lines[0] !~ /$svnDiffStartRegEx/) { 1775 die("First line of SVN diff does not begin with \"Index \": \"$lines[0]\""); 1776 } 1777 if (@lines <= 2) { 1778 return ""; 1779 } 1780 splice(@lines, 0, 2) if $lines[2] =~ /$svnDiffStartRegEx/; 1781 return join($lineEnding, @lines); 1782 } 1783 1739 1784 # If possible, returns a ChangeLog patch equivalent to the given one, 1740 1785 # but with the newest ChangeLog entry inserted at the top of the -
trunk/Tools/Scripts/svn-create-patch
r211048 r211543 226 226 227 227 my $patch = ""; 228 if ($fileData->{modificationType} eq "additionWithHistory") { 228 my $isAdditionWithHistory = $fileData->{modificationType} eq "additionWithHistory"; 229 if ($isAdditionWithHistory) { 229 230 manufacturePatchForAdditionWithHistory($fileData); 230 231 } … … 233 234 my $escapedFile = escapeSubversionPath($file); 234 235 open DIFF, "svn diff --diff-cmd diff -x -$diffOptions '$escapedFile' |" or die; 235 my $numTextChunks = 0;236 236 while (<DIFF>) { 237 $numTextChunks += 1 if parseChunkRange($_);238 237 $patch .= $_; 239 238 } 240 239 close DIFF; 241 if (!$numTextChunks) { 242 # For moved/copied files without post changes SVN 1.9 or greater emits a diff with an empty 243 # body as opposed to emitting nothing as in earlier versions of SVN. For example, move file 244 # A.txt to B.txt then the diff of B.txt in SVN 1.9 or greater is: 245 # Index: B.txt 246 # =================================================================== 247 # Therefore we ignore emitting such a diff. 248 $patch = ""; 249 } 240 $patch = fixSVNPatchForAdditionWithHistory($patch) if $patch && $isAdditionWithHistory; 250 241 if (basename($file) eq "ChangeLog") { 251 242 my $changeLogHash = fixChangeLogPatch($patch);
Note: See TracChangeset
for help on using the changeset viewer.