Changeset 69177 in webkit
- Timestamp:
- Oct 5, 2010 9:58:55 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r69171 r69177 1 2010-10-05 Daniel Bates <dbates@rim.com> 2 3 Reviewed by David Kilzer. 4 5 Add infrastructure to towards detecting change log diffs that aren't at the top of the ChangeLog 6 https://bugs.webkit.org/show_bug.cgi?id=46058 7 8 Make VCSUtils::fixChangeLogPatch() return a reference to a hash 9 structure so as to support returning additional information 10 about a change log diff. 11 12 Currently, VCSUtils::fixChangeLogPatch() returns a string that 13 represents the change log diff. Towards supporting the return 14 of additional information, such as whether the change log diff 15 inserts an entry at the top of the ChangeLog file, we need to 16 make VCSUtils::fixChangeLogPatch() return a reference to hash 17 structure. 18 19 * Scripts/VCSUtils.pm: 20 - Modified fixChangeLogPatch() to return a reference to a 21 hash structure. 22 - Added documentation to fixChangeLogPatch(). 23 - Modified call site in mergeChangeLogs() as necessary. 24 * Scripts/svn-apply: 25 - Modified call site in patch() as necessary. 26 * Scripts/svn-create-patch: 27 - Modified call site in generateDiff() as necessary. 28 * Scripts/svn-unapply: 29 - Modified call site in patch() as necessary. 30 * Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl: 31 - Modified the unit tests as necessary. 32 1 33 2010-10-05 Tony Chang <tony@chromium.org> 2 34 -
trunk/WebKitTools/Scripts/VCSUtils.pm
r66800 r69177 1285 1285 # 1286 1286 # This subroutine has unit tests in VCSUtils_unittest.pl. 1287 # 1288 # Returns $changeLogHashRef: 1289 # $changeLogHashRef: a hash reference representing a change log patch. 1290 # patch: a ChangeLog patch equivalent to the given one, but with the 1291 # newest ChangeLog entry inserted at the top of the file, if possible. 1292 # hasOverlappingLines: the value 1 if the change log entry overlaps 1293 # some lines of another change log entry. This can 1294 # happen when deliberately inserting a new ChangeLog 1295 # entry earlier in the file above an entry with 1296 # the same date and author. 1287 1297 sub fixChangeLogPatch($) 1288 1298 { … … 1302 1312 } 1303 1313 my $chunkStartIndex = ++$i; 1314 my %changeLogHashRef; 1304 1315 1305 1316 # Optimization: do not process if new lines already begin the chunk. 1306 1317 if (substr($lines[$i], 0, 1) eq "+") { 1307 return $patch; 1318 $changeLogHashRef{patch} = $patch; 1319 return \%changeLogHashRef; 1308 1320 } 1309 1321 … … 1322 1334 next; 1323 1335 } 1324 return $patch; # Do not change if, for example, "-" or "@" found. 1336 $changeLogHashRef{patch} = $patch; # Do not change if, for example, "-" or "@" found. 1337 return \%changeLogHashRef; 1325 1338 } 1326 1339 if ($i >= @lines) { 1327 return $patch; # Do not change if date not found. 1340 $changeLogHashRef{patch} = $patch; # Do not change if date not found. 1341 return \%changeLogHashRef; 1328 1342 } 1329 1343 my $dateStartIndex = $i; … … 1368 1382 my $newLine = pop(@overlappingLines); 1369 1383 if ($text ne substr($newLine, 1)) { 1370 return $patch; # Unexpected difference. 1384 $changeLogHashRef{patch} = $patch; # Unexpected difference. 1385 return \%changeLogHashRef; 1371 1386 } 1372 1387 $lines[$i] = "+$text"; … … 1380 1395 # are okay but should not be altered. That way we can find out 1381 1396 # if improvements to the script ever become necessary. 1382 return $patch; # Error: unexpected patch string format. 1397 $changeLogHashRef{patch} = $patch; # Error: unexpected patch string format. 1398 return \%changeLogHashRef; 1383 1399 } 1384 1400 my $skippedFirstLineCount = $1 - 1; … … 1389 1405 # This can happen, for example, when deliberately inserting 1390 1406 # a new ChangeLog entry earlier in the file. 1391 return $patch; 1407 $changeLogHashRef{hasOverlappingLines} = 1; 1408 $changeLogHashRef{patch} = $patch; 1409 return \%changeLogHashRef; 1392 1410 } 1393 1411 # If @overlappingLines > 0, this is where we make use of the … … 1399 1417 $lines[$chunkStartIndex - 1] = "@@ -1,$sourceLineCount +1,$targetLineCount @@"; 1400 1418 1401 return join($lineEnding, @lines) . "\n"; # patch(1) expects an extra trailing newline. 1419 $changeLogHashRef{patch} = join($lineEnding, @lines) . "\n"; # patch(1) expects an extra trailing newline. 1420 return \%changeLogHashRef; 1402 1421 } 1403 1422 … … 1551 1570 1552 1571 open(PATCH, "| patch --force --fuzz=3 --binary $fileNewer > " . File::Spec->devnull()) or die $!; 1553 print PATCH ($traditionalReject ? $patch : fixChangeLogPatch($patch)); 1572 if ($traditionalReject) { 1573 print PATCH $patch; 1574 } else { 1575 my $changeLogHash = fixChangeLogPatch($patch); 1576 print PATCH $changeLogHash->{patch}; 1577 } 1554 1578 close(PATCH); 1555 1579 -
trunk/WebKitTools/Scripts/svn-apply
r67115 r69177 317 317 if (basename($fullPath) eq "ChangeLog") { 318 318 my $changeLogDotOrigExisted = -f "${fullPath}.orig"; 319 my $newPatch = setChangeLogDateAndReviewer(fixChangeLogPatch($patch), $reviewer, $epochTime); 319 my $changeLogHash = fixChangeLogPatch($patch); 320 my $newPatch = setChangeLogDateAndReviewer($changeLogHash->{patch}, $reviewer, $epochTime); 320 321 applyPatch($newPatch, $fullPath, ["--fuzz=3"]); 321 322 unlink("${fullPath}.orig") if (! $changeLogDotOrigExisted); -
trunk/WebKitTools/Scripts/svn-create-patch
r57380 r69177 233 233 } 234 234 close DIFF; 235 $patch = fixChangeLogPatch($patch) if basename($file) eq "ChangeLog"; 235 if (basename($file) eq "ChangeLog") { 236 my $changeLogHash = fixChangeLogPatch($patch); 237 $patch = $changeLogHash->{patch}; 238 } 236 239 print $patch; 237 240 if ($fileData->{isBinary}) { -
trunk/WebKitTools/Scripts/svn-unapply
r64072 r69177 159 159 if (basename($fullPath) eq "ChangeLog") { 160 160 my $changeLogDotOrigExisted = -f "${fullPath}.orig"; 161 unapplyPatch(unsetChangeLogDate($fullPath, fixChangeLogPatch($patch)), $fullPath, ["--fuzz=3"]); 161 my $changeLogHash = fixChangeLogPatch($patch); 162 unapplyPatch(unsetChangeLogDate($fullPath, $changeLogHash->{patch}), $fullPath, ["--fuzz=3"]); 162 163 unlink("${fullPath}.orig") if (! $changeLogDotOrigExisted); 163 164 } else { -
trunk/WebKitTools/Scripts/webkitperl/VCSUtils_unittest/fixChangeLogPatch.pl
r67832 r69177 2 2 # 3 3 # Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com) 4 # Copyright (C) Research In Motion 2010. All rights reserved. 4 5 # 5 6 # Redistribution and use in source and binary forms, with or without … … 31 32 # Unit tests of VCSUtils::fixChangeLogPatch(). 32 33 33 use Test::Simple tests => 12; 34 use strict; 35 use warnings; 36 37 use Test::More; 34 38 use VCSUtils; 35 39 … … 54 58 # * File2: 55 59 56 my $title; 57 my $in; 58 my $out; 59 60 # New test 61 $title = "fixChangeLogPatch: [no change] In-place change."; 62 63 $in = <<'END'; 60 my @testCaseHashRefs = ( 61 { # New test 62 diffName => "fixChangeLogPatch: [no change] In-place change.", 63 inputText => <<'END', 64 64 --- ChangeLog 65 65 +++ ChangeLog … … 72 72 Changed some code on 2010-12-22. 73 73 END 74 75 ok(fixChangeLogPatch($in) eq $in, $title); 76 77 # New test 78 $title = "fixChangeLogPatch: [no change] Remove first entry."; 79 80 $in = <<'END'; 74 expectedReturn => { 75 patch => <<'END', 76 --- ChangeLog 77 +++ ChangeLog 78 @@ -1,5 +1,5 @@ 79 2010-12-22 Bob <bob@email.address> 80 81 - Reviewed by Sue. 82 + Reviewed by Ray. 83 84 Changed some code on 2010-12-22. 85 END 86 } 87 }, 88 { # New test 89 diffName => "fixChangeLogPatch: [no change] Remove first entry.", 90 inputText => <<'END', 81 91 --- ChangeLog 82 92 +++ ChangeLog … … 94 104 Reviewed by Ray. 95 105 END 96 97 ok(fixChangeLogPatch($in) eq $in, $title); 98 99 # New test 100 $title = "fixChangeLogPatch: [no change] Remove entry in the middle."; 101 102 $in = <<'END'; 106 expectedReturn => { 107 patch => <<'END', 108 --- ChangeLog 109 +++ ChangeLog 110 @@ -1,11 +1,3 @@ 111 -2010-12-22 Bob <bob@email.address> 112 - 113 - Reviewed by Ray. 114 - 115 - Changed some code on 2010-12-22. 116 - 117 - * File: 118 - 119 2010-12-22 Alice <alice@email.address> 120 121 Reviewed by Ray. 122 END 123 } 124 }, 125 { # New test 126 diffName => "fixChangeLogPatch: [no change] Remove entry in the middle.", 127 inputText => <<'END', 103 128 --- ChangeLog 104 129 +++ ChangeLog … … 115 140 Reviewed by Ray. 116 141 END 117 118 ok(fixChangeLogPatch($in) eq $in, $title); 119 120 # New test 121 $title = "fixChangeLogPatch: [no change] Far apart changes (i.e. more than one chunk)."; 122 123 $in = <<'END'; 142 expectedReturn => { 143 patch => <<'END', 144 --- ChangeLog 145 +++ ChangeLog 146 @@@ -7,10 +7,6 @@ 147 148 * File: 149 150 -2010-12-22 Bob <bob@email.address> 151 - 152 - Changed some code on 2010-12-22. 153 - 154 2010-12-22 Alice <alice@email.address> 155 156 Reviewed by Ray. 157 END 158 } 159 }, 160 { # New test 161 diffName => "fixChangeLogPatch: [no change] Far apart changes (i.e. more than one chunk).", 162 inputText => <<'END', 124 163 --- ChangeLog 125 164 +++ ChangeLog … … 142 181 Changed some code on 2010-12-21. 143 182 END 144 145 ok(fixChangeLogPatch($in) eq $in, $title); 146 147 # New test 148 $title = "fixChangeLogPatch: [no change] First line is new line."; 149 150 $in = <<'END'; 183 expectedReturn => { 184 patch => <<'END', 185 --- ChangeLog 186 +++ ChangeLog 187 @@ -7,7 +7,7 @@ 188 189 * File: 190 191 -2010-12-22 Bob <bob@email.address> 192 +2010-12-22 Bobby <bob@email.address> 193 194 Changed some code on 2010-12-22. 195 196 @@ -21,7 +21,7 @@ 197 198 * File2: 199 200 -2010-12-21 Bob <bob@email.address> 201 +2010-12-21 Bobby <bob@email.address> 202 203 Changed some code on 2010-12-21. 204 END 205 } 206 }, 207 { # New test 208 diffName => "fixChangeLogPatch: [no change] First line is new line.", 209 inputText => <<'END', 151 210 --- ChangeLog 152 211 +++ ChangeLog … … 164 223 Reviewed by Ray. 165 224 END 166 167 ok(fixChangeLogPatch($in) eq $in, $title); 168 169 # New test 170 $title = "fixChangeLogPatch: [no change] No date string."; 171 172 $in = <<'END'; 225 expectedReturn => { 226 patch => <<'END', 227 --- ChangeLog 228 +++ ChangeLog 229 @@ -1,3 +1,11 @@ 230 +2009-12-22 Bob <bob@email.address> 231 + 232 + Reviewed by Ray. 233 + 234 + Changed some more code on 2009-12-22. 235 + 236 + * File: 237 + 238 2009-12-22 Alice <alice@email.address> 239 240 Reviewed by Ray. 241 END 242 } 243 }, 244 { # New test 245 diffName => "fixChangeLogPatch: [no change] No date string.", 246 inputText => <<'END', 173 247 --- ChangeLog 174 248 +++ ChangeLog … … 182 256 183 257 END 184 185 ok(fixChangeLogPatch($in) eq $in, $title); 186 187 # New test 188 $title = "fixChangeLogPatch: [no change] New entry inserted in middle."; 189 190 $in = <<'END'; 258 expectedReturn => { 259 patch => <<'END', 260 --- ChangeLog 261 +++ ChangeLog 262 @@ -6,6 +6,7 @@ 263 264 * File: 265 * File2: 266 + * File3: 267 268 2009-12-21 Alice <alice@email.address> 269 270 END 271 } 272 }, 273 { # New test 274 diffName => "fixChangeLogPatch: [no change] New entry inserted in middle.", 275 inputText => <<'END', 191 276 --- ChangeLog 192 277 +++ ChangeLog … … 207 292 * File: 208 293 END 209 210 ok(fixChangeLogPatch($in) eq $in, $title); 211 212 # New test 213 $title = "fixChangeLogPatch: [no change] New entry inserted earlier in the file, but after an entry with the same author and date."; 214 215 $in = <<'END'; 294 expectedReturn => { 295 hasOverlappingLines => 1, 296 patch => <<'END', 297 --- ChangeLog 298 +++ ChangeLog 299 @@ -11,6 +11,14 @@ 300 301 Reviewed by Ray. 302 303 + Changed some more code on 2009-12-21. 304 + 305 + * File: 306 + 307 +2009-12-21 Alice <alice@email.address> 308 + 309 + Reviewed by Ray. 310 + 311 Changed some code on 2009-12-21. 312 313 * File: 314 END 315 } 316 }, 317 { # New test 318 diffName => "fixChangeLogPatch: [no change] New entry inserted earlier in the file, but after an entry with the same author and date.", 319 inputText => <<'END', 216 320 --- ChangeLog 217 321 +++ ChangeLog … … 232 336 Changed some code on 2009-12-22. 233 337 END 234 235 ok(fixChangeLogPatch($in) eq $in, $title); 236 237 # New test 238 $title = "fixChangeLogPatch: Leading context includes first line."; 239 240 $in = <<'END'; 338 expectedReturn => { 339 hasOverlappingLines => 1, 340 patch => <<'END', 341 --- ChangeLog 342 +++ ChangeLog 343 @@ -70,6 +70,14 @@ 344 345 2009-12-22 Alice <alice@email.address> 346 347 + Reviewed by Sue. 348 + 349 + Changed some more code on 2009-12-22. 350 + 351 + * File: 352 + 353 +2009-12-22 Alice <alice@email.address> 354 + 355 Reviewed by Ray. 356 357 Changed some code on 2009-12-22. 358 END 359 } 360 }, 361 { # New test 362 diffName => "fixChangeLogPatch: Leading context includes first line.", 363 inputText => <<'END', 241 364 --- ChangeLog 242 365 +++ ChangeLog … … 256 379 Changed some code on 2009-12-22. 257 380 END 258 259 $out = <<'END'; 381 expectedReturn => { 382 patch => <<'END', 260 383 --- ChangeLog 261 384 +++ ChangeLog … … 273 396 Reviewed by Ray. 274 397 END 275 276 ok(fixChangeLogPatch($in) eq $out, $title); 277 278 # New test 279 $title = "fixChangeLogPatch: Leading context does not include first line."; 280 281 $in = <<'END'; 398 } 399 }, 400 { # New test 401 diffName => "fixChangeLogPatch: Leading context does not include first line.", 402 inputText => <<'END', 282 403 @@ -2,6 +2,14 @@ 283 404 … … 296 417 * File: 297 418 END 298 299 $out = <<'END'; 419 expectedReturn => { 420 patch => <<'END', 300 421 @@ -1,3 +1,11 @@ 301 422 +2009-12-22 Alice <alice@email.address> … … 311 432 Reviewed by Ray. 312 433 END 313 314 ok(fixChangeLogPatch($in) eq $out, $title); 315 316 # New test 317 $title = "fixChangeLogPatch: Non-consecutive line additions."; 434 } 435 }, 436 { # New test 437 diffName => "fixChangeLogPatch: Non-consecutive line additions.", 318 438 319 439 # This can occur, for example, if the new ChangeLog entry includes … … 322 442 # ChangeLog entry with the first blank line of the old. 323 443 # The svn diff command with the default --diff-cmd has done this. 324 $in = <<'END'; 444 inputText => <<'END', 325 445 @@ -1,5 +1,11 @@ 326 446 2009-12-22 Alice <alice@email.address> … … 336 456 Changed some code on 2009-12-22. 337 457 END 338 339 $out = <<'END'; 458 expectedReturn => { 459 patch => <<'END', 340 460 @@ -1,3 +1,9 @@ 341 461 +2009-12-22 Alice <alice@email.address> … … 349 469 Reviewed by Ray. 350 470 END 351 352 ok(fixChangeLogPatch($in) eq $out, $title); 353 354 # New test 355 $title = "fixChangeLogPatch: Additional edits after new entry."; 356 357 $in = <<'END'; 471 } 472 }, 473 { # New test 474 diffName => "fixChangeLogPatch: Additional edits after new entry.", 475 inputText => <<'END', 358 476 @@ -2,10 +2,17 @@ 359 477 … … 376 494 377 495 END 378 379 $out = <<'END'; 496 expectedReturn => { 497 patch => <<'END', 380 498 @@ -1,11 +1,18 @@ 381 499 +2009-12-22 Alice <alice@email.address> … … 399 517 400 518 END 401 402 ok(fixChangeLogPatch($in) eq $out, $title); 519 } 520 }, 521 ); 522 523 my $testCasesCount = @testCaseHashRefs; 524 plan(tests => $testCasesCount); # Total number of assertions. 525 526 foreach my $testCase (@testCaseHashRefs) { 527 my $testNameStart = "fixChangeLogPatch(): $testCase->{diffName}: comparing"; 528 529 my $got = VCSUtils::fixChangeLogPatch($testCase->{inputText}); 530 my $expectedReturn = $testCase->{expectedReturn}; 531 532 is_deeply($got, $expectedReturn, "$testNameStart return value."); 533 }
Note: See TracChangeset
for help on using the changeset viewer.