Changeset 102559 in webkit


Ignore:
Timestamp:
Dec 11, 2011 11:07:56 PM (12 years ago)
Author:
haraken@chromium.org
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):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r102537 r102559  
     12011-12-11  Kentaro Hara  <haraken@chromium.org>
     2
     3        [Refactoring] Move top-level code to resolve conflicted ChangeLogs into a method
     4        https://bugs.webkit.org/show_bug.cgi?id=74257
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        We are planning to write unit-tests for prepare-ChangeLog
     9        in a run-leaks_unittest/ manner. This patch is one of the incremental
     10        refactorings to remove all top-level code and global variables from
     11        prepare-ChangeLog.
     12
     13        * Scripts/prepare-ChangeLog: Moved top-level code to get the latest ChangeLogs
     14        into getLatestChangeLogs(), and moved top-level code to resolve conflicted ChangeLogs
     15        into resolveConflictedChangeLogs().
     16        (getLatestChangeLogs):
     17        (resolveConflictedChangeLogs):
     18
    1192011-12-11  Kentaro Hara  <haraken@chromium.org>
    220
  • trunk/Tools/Scripts/prepare-ChangeLog

    r102537 r102559  
    7070sub fetchBugDescriptionFromURL($);
    7171sub findChangeLogs(\%);
     72sub getLatestChangeLogs($);
     73sub resolveConflictedChangeLogs($);
    7274sub generateNewChangeLogs($$$\%);
    7375sub firstDirectoryOrCwd();
     
    206208
    207209# Get the latest ChangeLog files from svn.
    208 my @logs = ();
    209 foreach my $prefix (@$prefixes) {
    210     push @logs, File::Spec->catfile($prefix || ".", "ChangeLog");
    211 }
    212 
    213 if (@logs && $updateChangeLogs && $isSVN) {
    214     print STDERR "  Running 'svn update' to update ChangeLog files.\n";
    215     open ERRORS, "-|", $SVN, "update", @logs
    216         or die "The svn update of ChangeLog files failed: $!.\n";
    217     my @conflictedChangeLogs;
    218     while (my $line = <ERRORS>) {
    219         print STDERR "    ", $line;
    220         push @conflictedChangeLogs, $1 if $line =~ m/^C\s+(.+?)[\r\n]*$/;
    221     }
    222     close ERRORS;
    223 
    224     if (@conflictedChangeLogs) {
    225         print STDERR "  Attempting to merge conflicted ChangeLogs.\n";
    226         my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs");
    227         open RESOLVE, "-|", $resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs
    228             or die "Could not open resolve-ChangeLogs script: $!.\n";
    229         print STDERR "    $_" while <RESOLVE>;
    230         close RESOLVE;
    231     }
     210my $changeLogs = getLatestChangeLogs($prefixes);
     211
     212if (@$changeLogs && $updateChangeLogs && $isSVN) {
     213    resolveConflictedChangeLogs($changeLogs);
    232214}
    233215
     
    248230
    249231# Open ChangeLogs.
    250 if ($openChangeLogs && @logs) {
     232if ($openChangeLogs && @$changeLogs) {
    251233    print STDERR "  Opening the edited ChangeLog files.\n";
    252234    my $editor = $ENV{CHANGE_LOG_EDITOR};
    253235    if ($editor) {
    254         system ((split ' ', $editor), @logs);
     236        system ((split ' ', $editor), @$changeLogs);
    255237    } else {
    256238        $editor = $ENV{CHANGE_LOG_EDIT_APPLICATION};
    257239        if ($editor) {
    258             system "open", "-a", $editor, @logs;
     240            system "open", "-a", $editor, @$changeLogs;
    259241        } else {
    260             system "open", "-e", @logs;
     242            system "open", "-e", @$changeLogs;
    261243        }
    262244    }
     
    447429    }
    448430    return (\%filesInChangeLog, \@prefixes);
     431}
     432
     433sub getLatestChangeLogs($)
     434{
     435    my ($prefixes) = @_;
     436
     437    my @changeLogs = ();
     438    foreach my $prefix (@$prefixes) {
     439        push @changeLogs, File::Spec->catfile($prefix || ".", "ChangeLog");
     440    }
     441    return \@changeLogs;
     442}
     443
     444sub resolveConflictedChangeLogs($)
     445{
     446    my ($changeLogs) = @_;
     447
     448    print STDERR "  Running 'svn update' to update ChangeLog files.\n";
     449    open ERRORS, "-|", $SVN, "update", @$changeLogs
     450        or die "The svn update of ChangeLog files failed: $!.\n";
     451    my @conflictedChangeLogs;
     452    while (my $line = <ERRORS>) {
     453        print STDERR "    ", $line;
     454        push @conflictedChangeLogs, $1 if $line =~ m/^C\s+(.+?)[\r\n]*$/;
     455    }
     456    close ERRORS;
     457
     458    return if !@conflictedChangeLogs;
     459
     460    print STDERR "  Attempting to merge conflicted ChangeLogs.\n";
     461    my $resolveChangeLogsPath = File::Spec->catfile(dirname($0), "resolve-ChangeLogs");
     462    open RESOLVE, "-|", $resolveChangeLogsPath, "--no-warnings", @conflictedChangeLogs
     463        or die "Could not open resolve-ChangeLogs script: $!.\n";
     464    print STDERR "    $_" while <RESOLVE>;
     465    close RESOLVE;
    449466}
    450467
Note: See TracChangeset for help on using the changeset viewer.