<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[171954] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/171954">171954</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2014-08-01 16:10:50 -0700 (Fri, 01 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>commit-log-editor uses a non-standard message format when git index contains no ChangeLog changes
https://bugs.webkit.org/show_bug.cgi?id=135527

Reviewed by Tim Horton.

* Scripts/commit-log-editor:
In the case of a git repository when there are no changed ChangeLog files, changed to pass
the --delimiters option to prepare-ChangeLog, then process each entry in the output using
commitMessageFromChangeLogEntry.
(commitMessageFromChangeLogEntry): Factored out from createCommitMessage.
(sortKey): Factored out from createCommitMessage.
(createCommitMessage): Changed to use new sortKey and commitMessageFromChangeLogEntry
subroutines.

* Scripts/prepare-ChangeLog:
(main): Parse new --delimiters option.
(generateNewChangeLogs): When --no-write and --delimiters are both specified, always print
the label before each change log entry, and a &quot;~&quot; delimiter on a new line after each entry.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptscommitlogeditor">trunk/Tools/Scripts/commit-log-editor</a></li>
<li><a href="#trunkToolsScriptsprepareChangeLog">trunk/Tools/Scripts/prepare-ChangeLog</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (171953 => 171954)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-08-01 22:49:51 UTC (rev 171953)
+++ trunk/Tools/ChangeLog        2014-08-01 23:10:50 UTC (rev 171954)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-08-01  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        commit-log-editor uses a non-standard message format when git index contains no ChangeLog changes
+        https://bugs.webkit.org/show_bug.cgi?id=135527
+
+        Reviewed by Tim Horton.
+
+        * Scripts/commit-log-editor:
+        In the case of a git repository when there are no changed ChangeLog files, changed to pass
+        the --delimiters option to prepare-ChangeLog, then process each entry in the output using
+        commitMessageFromChangeLogEntry.
+        (commitMessageFromChangeLogEntry): Factored out from createCommitMessage.
+        (sortKey): Factored out from createCommitMessage.
+        (createCommitMessage): Changed to use new sortKey and commitMessageFromChangeLogEntry
+        subroutines.
+
+        * Scripts/prepare-ChangeLog:
+        (main): Parse new --delimiters option.
+        (generateNewChangeLogs): When --no-write and --delimiters are both specified, always print
+        the label before each change log entry, and a &quot;~&quot; delimiter on a new line after each entry.
+
</ins><span class="cx"> 2014-08-01  Bear Travis  &lt;betravis@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Feature Queries] Enable Feature Queries on EFL/GTK
</span></span></pre></div>
<a id="trunkToolsScriptscommitlogeditor"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/commit-log-editor (171953 => 171954)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/commit-log-editor        2014-08-01 22:49:51 UTC (rev 171953)
+++ trunk/Tools/Scripts/commit-log-editor        2014-08-01 23:10:50 UTC (rev 171954)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> use VCSUtils;
</span><span class="cx"> use webkitdirs;
</span><span class="cx"> 
</span><ins>+sub commitMessageFromChangeLogEntry($);
+sub sortKey($);
</ins><span class="cx"> sub createCommitMessage(@);
</span><span class="cx"> sub loadTermReadKey();
</span><span class="cx"> sub normalizeLineEndings($$);
</span><span class="lines">@@ -176,11 +178,34 @@
</span><span class="cx">         chomp($webkitGenerateCommitMessage = `git config --bool core.webkitGenerateCommitMessage`);
</span><span class="cx">     }
</span><span class="cx">     if ($webkitGenerateCommitMessage ne &quot;false&quot;) {
</span><del>-        open CHANGELOG_ENTRIES, &quot;-|&quot;, &quot;$FindBin::Bin/prepare-ChangeLog --git-index --no-write --no-style&quot; or die &quot;prepare-ChangeLog failed: $!.\n&quot;;
-        while (&lt;CHANGELOG_ENTRIES&gt;) {
-            print NEWLOG normalizeLineEndings($_, $endl);
</del><ins>+        my %changeLogSort;
+        my %changeLogContents;
+        open my $changeLogEntries, &quot;-|&quot;, &quot;$FindBin::Bin/prepare-ChangeLog --git-index --no-write --no-style --delimiters&quot; or die &quot;prepare-ChangeLog failed: $!.\n&quot;;
+
+        while (!eof($changeLogEntries)) {
+            my $label = &lt;$changeLogEntries&gt;;
+            chomp $label;
+            $label =~ s/:$//;
+            ($changeLogContents{$label}) = commitMessageFromChangeLogEntry($changeLogEntries);
+            $changeLogSort{sortKey($label)} = $label;
</ins><span class="cx">         }
</span><del>-        close CHANGELOG_ENTRIES;
</del><ins>+        close $changeLogEntries;
+
+        my $commonPrefix = removeLongestCommonPrefixEndingInNewline(%changeLogContents);
+
+        my @result;
+        push @result, normalizeLineEndings($commonPrefix, $endl);
+        for my $sortKey (sort keys %changeLogSort) {
+            my $label = $changeLogSort{$sortKey};
+            next if ($changeLogContents{$label} eq &quot;\n&quot;);
+            if (keys %changeLogSort &gt; 1) {
+                push @result, normalizeLineEndings(&quot;\n&quot;, $endl);
+                push @result, normalizeLineEndings(&quot;$label: &quot;, $endl);
+            }
+            push @result, normalizeLineEndings($changeLogContents{$label}, $endl);
+        }
+
+        print NEWLOG join '', @result;
</ins><span class="cx">     }
</span><span class="cx"> } else {
</span><span class="cx">     print NEWLOG createCommitMessage(@changeLogs);
</span><span class="lines">@@ -209,68 +234,89 @@
</span><span class="cx"> 
</span><span class="cx"> unlink &quot;$log.edit&quot;;
</span><span class="cx"> 
</span><del>-sub createCommitMessage(@)
</del><ins>+sub commitMessageFromChangeLogEntry($)
</ins><span class="cx"> {
</span><del>-    my @changeLogs = @_;
</del><ins>+    my ($changeLog) = @_;
</ins><span class="cx"> 
</span><del>-    my $topLevel = determineVCSRoot();
</del><ins>+    my $commitMessage = &quot;&quot;;
+    my $blankLines = &quot;&quot;;
+    my $lineCount = 0;
+    my $date = &quot;&quot;;
+    my $author = &quot;&quot;;
+    my $email = &quot;&quot;;
+    my $hasAuthorInfoToWrite = 0;
</ins><span class="cx"> 
</span><del>-    my %changeLogSort;
-    my %changeLogContents;
-    for my $changeLog (@changeLogs) {
-        open CHANGELOG, $changeLog or die &quot;Can't open $changeLog&quot;;
-        my $contents = &quot;&quot;;
-        my $blankLines = &quot;&quot;;
-        my $lineCount = 0;
-        my $date = &quot;&quot;;
-        my $author = &quot;&quot;;
-        my $email = &quot;&quot;;
-        my $hasAuthorInfoToWrite = 0;
-        while (&lt;CHANGELOG&gt;) {
-            if (/^\S/) {
-                last if $contents;
-            }
-            if (/\S/) {
-                $contents .= $blankLines if $contents;
-                $blankLines = &quot;&quot;;
</del><ins>+    while (&lt;$changeLog&gt;) {
+        if (/^\S/) {
+            last if $commitMessage;
+        }
+        if (/\S/) {
+            $commitMessage .= $blankLines if $commitMessage;
+            $blankLines = &quot;&quot;;
</ins><span class="cx"> 
</span><del>-                my $line = $_;
</del><ins>+            my $line = $_;
+            # Remove indentation spaces
+            $line =~ s/^ {8}//;
</ins><span class="cx"> 
</span><del>-                # Remove indentation spaces
-                $line =~ s/^ {8}//;
</del><ins>+            # Grab the author and the date line
+            if ($line =~ m/^([0-9]{4}-[0-9]{2}-[0-9]{2})\s+(.*[^\s])\s+&lt;(.*)&gt;/ &amp;&amp; $lineCount == 0) {
+                $date = $1;
+                $author = $2;
+                $email = $3;
+                $hasAuthorInfoToWrite = 1;
+                next;
+            }
</ins><span class="cx"> 
</span><del>-                # Grab the author and the date line
-                if ($line =~ m/^([0-9]{4}-[0-9]{2}-[0-9]{2})\s+(.*[^\s])\s+&lt;(.*)&gt;/ &amp;&amp; $lineCount == 0) {
-                    $date = $1;
-                    $author = $2;
-                    $email = $3;
-                    $hasAuthorInfoToWrite = 1;
-                    next;
-                }
</del><ins>+            if ($hasAuthorInfoToWrite) {
+                my $isReviewedByLine = $line =~ m/^(?:Reviewed|Rubber[ \-]?stamped) by/;
+                my $isModifiedFileLine = $line =~ m/^\* .*:/;
</ins><span class="cx"> 
</span><del>-                if ($hasAuthorInfoToWrite) {
-                    my $isReviewedByLine = $line =~ m/^(?:Reviewed|Rubber[ \-]?stamped) by/;
-                    my $isModifiedFileLine = $line =~ m/^\* .*:/;
-
-                    # Insert the authorship line if needed just above the &quot;Reviewed by&quot; line or the
-                    # first modified file (whichever comes first).
-                    if ($isReviewedByLine || $isModifiedFileLine) {
-                        $hasAuthorInfoToWrite = 0;
-                        my $authorshipString = patchAuthorshipString($author, $email, $date);
-                        if ($authorshipString) {
-                            $contents .= &quot;$authorshipString\n&quot;;
-                            $contents .= &quot;\n&quot; if $isModifiedFileLine;
-                        }
</del><ins>+                # Insert the authorship line if needed just above the &quot;Reviewed by&quot; line or the
+                # first modified file (whichever comes first).
+                if ($isReviewedByLine || $isModifiedFileLine) {
+                    $hasAuthorInfoToWrite = 0;
+                    my $authorshipString = patchAuthorshipString($author, $email, $date);
+                    if ($authorshipString) {
+                        $commitMessage .= &quot;$authorshipString\n&quot;;
+                        $commitMessage .= &quot;\n&quot; if $isModifiedFileLine;
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><ins>+            }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-                $lineCount++;
-                $contents .= $line;
-            } else {
-                $blankLines .= $_;
-            }
</del><ins>+            $lineCount++;
+            $commitMessage .= $line;
+        } else {
+            $blankLines .= $_;
</ins><span class="cx">         }
</span><ins>+    }
+    return ($commitMessage, $hasAuthorInfoToWrite, $date, $author, $email);
+}
+
+sub sortKey($)
+{
+    my ($label) = @_;
+    my $sortKey = lc $label;
+    if ($label eq &quot;top level&quot;) {
+        $sortKey = &quot;&quot;;
+    } elsif ($label eq &quot;LayoutTests&quot;) {
+        $sortKey = lc &quot;~, LayoutTests last&quot;;
+    }
+    return $sortKey;
+}
+
+sub createCommitMessage(@)
+{
+    my @changeLogs = @_;
+
+    my $topLevel = determineVCSRoot();
+
+    my %changeLogSort;
+    my %changeLogContents;
+    for my $changeLog (@changeLogs) {
+        open my $changeLogFile, $changeLog or die &quot;Can't open $changeLog&quot;;
+
+        my ($contents, $hasAuthorInfoToWrite, $date, $author, $email) = commitMessageFromChangeLogEntry($changeLogFile);
</ins><span class="cx">         if ($hasAuthorInfoToWrite) {
</span><span class="cx">             # We didn't find anywhere to put the authorship info, so just put it at the end.
</span><span class="cx">             my $authorshipString = patchAuthorshipString($author, $email, $date);
</span><span class="lines">@@ -278,21 +324,14 @@
</span><span class="cx">             $hasAuthorInfoToWrite = 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        close CHANGELOG;
</del><ins>+        close $changeLogFile;
</ins><span class="cx"> 
</span><span class="cx">         $changeLog = File::Spec-&gt;abs2rel(File::Spec-&gt;rel2abs($changeLog), $topLevel);
</span><span class="cx"> 
</span><span class="cx">         my $label = dirname($changeLog);
</span><span class="cx">         $label = &quot;top level&quot; unless length $label;
</span><span class="cx"> 
</span><del>-        my $sortKey = lc $label;
-        if ($label eq &quot;top level&quot;) {
-            $sortKey = &quot;&quot;;
-        } elsif ($label eq &quot;LayoutTests&quot;) {
-            $sortKey = lc &quot;~, LayoutTests last&quot;;
-        }
-
-        $changeLogSort{$sortKey} = $label;
</del><ins>+        $changeLogSort{sortKey($label)} = $label;
</ins><span class="cx">         $changeLogContents{$label} = $contents;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptsprepareChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/prepare-ChangeLog (171953 => 171954)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/prepare-ChangeLog        2014-08-01 22:49:51 UTC (rev 171953)
+++ trunk/Tools/Scripts/prepare-ChangeLog        2014-08-01 23:10:50 UTC (rev 171954)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> sub generateFileList(\%$$$);
</span><span class="cx"> sub generateFunctionLists($$$$$);
</span><span class="cx"> sub generateFunctionListsByRanges($$$$);
</span><del>-sub generateNewChangeLogs($$$$$$$$$$$);
</del><ins>+sub generateNewChangeLogs($$$$$$$$$$$$);
</ins><span class="cx"> sub getLatestChangeLogs($);
</span><span class="cx"> sub get_function_line_ranges($$);
</span><span class="cx"> sub get_function_line_ranges_for_cpp($$);
</span><span class="lines">@@ -131,12 +131,14 @@
</span><span class="cx">     my $checkWebKitStyle;
</span><span class="cx">     my $openChangeLogs = 0;
</span><span class="cx">     my $writeChangeLogs = 1;
</span><ins>+    my $delimiters = 0;
</ins><span class="cx">     my $showHelp = 0;
</span><span class="cx">     my $spewDiff = $ENV{&quot;PREPARE_CHANGELOG_DIFF&quot;};
</span><span class="cx">     my $updateChangeLogs = 1;
</span><span class="cx">     my $parseOptionsResult =
</span><span class="cx">         GetOptions(&quot;diff|d!&quot; =&gt; \$spewDiff,
</span><span class="cx">                    &quot;bug|b:i&quot; =&gt; \$bugNumber,
</span><ins>+                   &quot;delimiters&quot; =&gt; \$delimiters,
</ins><span class="cx">                    &quot;description:s&quot; =&gt; \$bugDescription,
</span><span class="cx">                    &quot;name:s&quot; =&gt; \$name,
</span><span class="cx">                    &quot;email:s&quot; =&gt; \$emailAddress,
</span><span class="lines">@@ -164,6 +166,7 @@
</span><span class="cx">         print STDERR &quot;  -o|--open       Open ChangeLogs in an editor when done\n&quot;;
</span><span class="cx">         print STDERR &quot;  --[no-]update   Update ChangeLogs from svn before adding entry (default: update)\n&quot;;
</span><span class="cx">         print STDERR &quot;  --[no-]write    Write ChangeLogs to disk (otherwise send new entries to stdout) (default: write)\n&quot;;
</span><ins>+        print STDERR &quot;  --delimiters    When writing to stdout, label and print a \&quot;~\&quot; after each entry\n&quot;;
</ins><span class="cx">         print STDERR &quot;  --email=        Specify the email address to be used in the patch\n&quot;;
</span><span class="cx">         return 1;
</span><span class="cx">     }
</span><span class="lines">@@ -222,7 +225,7 @@
</span><span class="cx">         resolveConflictedChangeLogs($changeLogs);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs);
</del><ins>+    generateNewChangeLogs($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters);
</ins><span class="cx"> 
</span><span class="cx">     if ($writeChangeLogs) {
</span><span class="cx">         print STDERR &quot;-- Please remember to include a detailed description in your ChangeLog entry. --\n-- See &lt;http://webkit.org/coding/contributing.html&gt; for more info --\n&quot;;
</span><span class="lines">@@ -522,9 +525,9 @@
</span><span class="cx">     close RESOLVE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub generateNewChangeLogs($$$$$$$$$$$)
</del><ins>+sub generateNewChangeLogs($$$$$$$$$$$$)
</ins><span class="cx"> {
</span><del>-    my ($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs) = @_;
</del><ins>+    my ($prefixes, $filesInChangeLog, $addedRegressionTests, $functionLists, $bugURL, $bugDescription, $name, $emailAddress, $gitReviewer, $gitCommit, $writeChangeLogs, $delimiters) = @_;
</ins><span class="cx"> 
</span><span class="cx">     # Generate new ChangeLog entries and (optionally) write out new ChangeLog files.
</span><span class="cx">     foreach my $prefix (@$prefixes) {
</span><span class="lines">@@ -547,7 +550,7 @@
</span><span class="cx">             open CHANGE_LOG, &quot;&gt; ${changeLogPath}&quot; or die &quot;Could not write ${changeLogPath}\n.&quot;;
</span><span class="cx">         } else {
</span><span class="cx">             open CHANGE_LOG, &quot;&gt;-&quot; or die &quot;Could not write to STDOUT\n.&quot;;
</span><del>-            print substr($prefix, 0, length($prefix) - 1) . &quot;:\n\n&quot; unless (scalar @$prefixes) == 1;
</del><ins>+            print substr($prefix, 0, length($prefix) - 1) . &quot;:\n\n&quot; unless (scalar @$prefixes) == 1 &amp;&amp; !$delimiters;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         my $date = changeLogDate(ChangeLogTimeZone);
</span><span class="lines">@@ -582,6 +585,7 @@
</span><span class="cx">             print CHANGE_LOG normalizeLineEndings(&quot;\n&quot;, $endl), @old_change_log;
</span><span class="cx">         } else {
</span><span class="cx">             print CHANGE_LOG &quot;\n&quot;;
</span><ins>+            print &quot;~\n&quot;  if $delimiters;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         close CHANGE_LOG;
</span></span></pre>
</div>
</div>

</body>
</html>