Title: [102559] trunk/Tools
Revision
102559
Author
[email protected]
Date
2011-12-11 23:07:56 -0800 (Sun, 11 Dec 2011)

Log Message

[Refactoring] Move top-level code to resolve conflicted ChangeLogs into a method
https://bugs.webkit.org/show_bug.cgi?id=74257

Reviewed by Ryosuke Niwa.

We are planning to write unit-tests for prepare-ChangeLog
in a run-leaks_unittest/ manner. This patch is one of the incremental
refactorings to remove all top-level code and global variables from
prepare-ChangeLog.

* Scripts/prepare-ChangeLog: Moved top-level code to get the latest ChangeLogs
into getLatestChangeLogs(), and moved top-level code to resolve conflicted ChangeLogs
into resolveConflictedChangeLogs().
(getLatestChangeLogs):
(resolveConflictedChangeLogs):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (102558 => 102559)


--- trunk/Tools/ChangeLog	2011-12-12 07:01:29 UTC (rev 102558)
+++ trunk/Tools/ChangeLog	2011-12-12 07:07:56 UTC (rev 102559)
@@ -1,5 +1,23 @@
 2011-12-11  Kentaro Hara  <[email protected]>
 
+        [Refactoring] Move top-level code to resolve conflicted ChangeLogs into a method
+        https://bugs.webkit.org/show_bug.cgi?id=74257
+
+        Reviewed by Ryosuke Niwa.
+
+        We are planning to write unit-tests for prepare-ChangeLog
+        in a run-leaks_unittest/ manner. This patch is one of the incremental
+        refactorings to remove all top-level code and global variables from
+        prepare-ChangeLog.
+
+        * Scripts/prepare-ChangeLog: Moved top-level code to get the latest ChangeLogs
+        into getLatestChangeLogs(), and moved top-level code to resolve conflicted ChangeLogs
+        into resolveConflictedChangeLogs().
+        (getLatestChangeLogs):
+        (resolveConflictedChangeLogs):
+
+2011-12-11  Kentaro Hara  <[email protected]>
+
         [Refactoring] Move top-level code to generate a new ChangeLog into a method
         https://bugs.webkit.org/show_bug.cgi?id=74253
 

Modified: trunk/Tools/Scripts/prepare-ChangeLog (102558 => 102559)


--- trunk/Tools/Scripts/prepare-ChangeLog	2011-12-12 07:01:29 UTC (rev 102558)
+++ trunk/Tools/Scripts/prepare-ChangeLog	2011-12-12 07:07:56 UTC (rev 102559)
@@ -69,6 +69,8 @@
 sub changeLogNameFromArgs($);
 sub fetchBugDescriptionFromURL($);
 sub findChangeLogs(\%);
+sub getLatestChangeLogs($);
+sub resolveConflictedChangeLogs($);
 sub generateNewChangeLogs($$$\%);
 sub firstDirectoryOrCwd();
 sub diffFromToString();
@@ -205,30 +207,10 @@
 my ($filesInChangeLog, $prefixes) = findChangeLogs(%functionLists);
 
 # Get the latest ChangeLog files from svn.
-my @logs = ();
-foreach my $prefix (@$prefixes) {
-    push @logs, File::Spec->catfile($prefix || ".", "ChangeLog");
-}
+my $changeLogs = getLatestChangeLogs($prefixes);
 
-if (@logs && $updateChangeLogs && $isSVN) {
-    print STDERR "  Running 'svn update' to update ChangeLog files.\n";
-    open ERRORS, "-|", $SVN, "update", @logs
-        or die "The svn update of ChangeLog files failed: $!.\n";
-    my @conflictedChangeLogs;
-    while (my $line = <ERRORS>) {
-        print STDERR "    ", $line;
-        push @conflictedChangeLogs, $1 if $line =~ m/^C\s+(.+?)[\r\n]*$/;
-    }
-    close ERRORS;
-
-    if (@conflictedChangeLogs) {
-        print STDERR "  Attempting to merge conflicted ChangeLogs.\n";
-        my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs");
-        open RESOLVE, "-|", $resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs
-            or die "Could not open resolve-ChangeLogs script: $!.\n";
-        print STDERR "    $_" while <RESOLVE>;
-        close RESOLVE;
-    }
+if (@$changeLogs && $updateChangeLogs && $isSVN) {
+    resolveConflictedChangeLogs($changeLogs);
 }
 
 generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, %functionLists);
@@ -247,17 +229,17 @@
 }
 
 # Open ChangeLogs.
-if ($openChangeLogs && @logs) {
+if ($openChangeLogs && @$changeLogs) {
     print STDERR "  Opening the edited ChangeLog files.\n";
     my $editor = $ENV{CHANGE_LOG_EDITOR};
     if ($editor) {
-        system ((split ' ', $editor), @logs);
+        system ((split ' ', $editor), @$changeLogs);
     } else {
         $editor = $ENV{CHANGE_LOG_EDIT_APPLICATION};
         if ($editor) {
-            system "open", "-a", $editor, @logs;
+            system "open", "-a", $editor, @$changeLogs;
         } else {
-            system "open", "-e", @logs;
+            system "open", "-e", @$changeLogs;
         }
     }
 }
@@ -448,6 +430,41 @@
     return (\%filesInChangeLog, \@prefixes);
 }
 
+sub getLatestChangeLogs($)
+{
+    my ($prefixes) = @_;
+
+    my @changeLogs = ();
+    foreach my $prefix (@$prefixes) {
+        push @changeLogs, File::Spec->catfile($prefix || ".", "ChangeLog");
+    }
+    return \@changeLogs;
+}
+
+sub resolveConflictedChangeLogs($)
+{
+    my ($changeLogs) = @_;
+
+    print STDERR "  Running 'svn update' to update ChangeLog files.\n";
+    open ERRORS, "-|", $SVN, "update", @$changeLogs
+        or die "The svn update of ChangeLog files failed: $!.\n";
+    my @conflictedChangeLogs;
+    while (my $line = <ERRORS>) {
+        print STDERR "    ", $line;
+        push @conflictedChangeLogs, $1 if $line =~ m/^C\s+(.+?)[\r\n]*$/;
+    }
+    close ERRORS;
+
+    return if !@conflictedChangeLogs;
+
+    print STDERR "  Attempting to merge conflicted ChangeLogs.\n";
+    my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs");
+    open RESOLVE, "-|", $resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs
+        or die "Could not open resolve-ChangeLogs script: $!.\n";
+    print STDERR "    $_" while <RESOLVE>;
+    close RESOLVE;
+}
+
 sub generateNewChangeLogs($$$\%)
 {
     my ($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists) = @_;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to