Changeset 53040 in webkit
- Timestamp:
- Jan 9, 2010 2:50:53 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r53018 r53040 1 2010-01-09 Chris Jerdonek <chris.jerdonek@gmail.com> 2 3 Reviewed by David Kilzer. 4 5 Modified VCSUtils::gitdiff2svndiff() to accept strings that 6 end in vertical white space. 7 8 https://bugs.webkit.org/show_bug.cgi?id=33415 9 10 * Scripts/VCSUtils.pm: 11 * Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl: 12 1 13 2010-01-08 Eric Seidel <eric@webkit.org> 2 14 -
trunk/WebKitTools/Scripts/VCSUtils.pm
r52739 r53040 33 33 34 34 use Cwd qw(); # "qw()" prevents warnings about redefining getcwd() with "use POSIX;" 35 use English; # for $POSTMATCH, etc. 35 36 use File::Basename; 36 37 use File::Spec; … … 360 361 } 361 362 363 # Convert a line of a git-formatted patch to SVN format, while 364 # preserving any end-of-line characters. 362 365 sub gitdiff2svndiff($) 363 366 { 364 367 $_ = shift @_; 365 if (m#^diff --git \w/(.+) \w/(.+)#) { 366 return "Index: $1"; 367 } elsif (m#^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}#) { 368 return "==================================================================="; 369 } elsif (m#^--- \w/(.+)#) { 370 return "--- $1"; 371 } elsif (m#^\+\+\+ \w/(.+)#) { 372 return "+++ $1"; 368 369 # \V is any character that is not vertical white space 370 if (m#^diff --git \w/(.+) \w/([^\r\n]+)#) { 371 return "Index: $1$POSTMATCH"; 372 } 373 if (m#^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}#) { 374 return "===================================================================$POSTMATCH"; 375 } 376 if (m#^--- \w/([^\r\n]+)#) { 377 return "--- $1$POSTMATCH"; 378 } 379 if (m#^\+\+\+ \w/([^\r\n]+)#) { 380 return "+++ $1$POSTMATCH"; 373 381 } 374 382 return $_; -
trunk/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl
r52739 r53040 1 #!/usr/bin/perl 1 #!/usr/bin/perl -w 2 2 # 3 3 # Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com) … … 32 32 # Unit tests of VCSUtils::gitdiff2svndiff() 33 33 34 use Test::Simple tests => 6; 34 use strict; 35 use warnings; 36 37 use Test::Simple tests => 20; 35 38 use VCSUtils; 36 39 37 my $out; 38 my $title; 39 40 # New test 41 $title = "gitdiff2svndiff: Convert standard git diff to svn diff"; 40 # We use this for display purposes, to keep each test title on one line. 41 sub excerptString($) 42 { 43 my ($text) = @_; 44 45 my $length = 25; 46 47 my $shortened = substr($text, 0, $length); 48 $shortened .= "..." if (length($text) > $length); 49 50 return $shortened; 51 } 42 52 43 53 my $git_patch = <<END; … … 57 67 END 58 68 59 $out = ""; 69 my @gitLines = split("\n", $git_patch); 70 my @svnLines = split("\n", $svn_patch); 60 71 61 foreach my $line (split('\n', $git_patch)) { 62 $out .= gitdiff2svndiff($line) . "\n"; 72 # New test: check each git header line with different line endings 73 my $titleHeader = "gitdiff2svndiff: "; 74 75 my @lineEndingPairs = ( # display name, value 76 ["", ""], 77 ["\\n", "\n"], 78 ["\\r\\n", "\r\n"], 79 ); 80 81 for (my $i = 0; $i < @gitLines; $i++) { 82 foreach my $pair (@lineEndingPairs) { 83 my $gitLine = $gitLines[$i] . $pair->[1]; 84 my $expected = $svnLines[$i] . $pair->[1]; 85 my $title = $titleHeader . excerptString($gitLine); 86 $title .= " [line-end: \"$pair->[0]\"]"; 87 88 ok($expected eq gitdiff2svndiff($gitLine), $title); 89 } 63 90 } 64 91 65 ok($svn_patch eq $out, $title);66 67 92 # New test 68 $title = "gitdiff2svndiff: Convert mnemonic git diff to svn diff";93 my $title = "gitdiff2svndiff: Convert mnemonic git diff to svn diff"; 69 94 70 95 my @prefixes = ( … … 75 100 { 'a' => '1', 'b' => '2' }, # git diff --no-index a b (compares two non-git things (1) and (2)) 76 101 ); 102 103 my $out = ""; 77 104 78 105 foreach my $prefix (@prefixes) {
Note: See TracChangeset
for help on using the changeset viewer.