Alexandre Julliard : patches: Also use References: header to build mail threads.

Alexandre Julliard julliard at winehq.org
Fri Nov 10 09:14:03 CST 2017


Module: tools
Branch: master
Commit: 4e6b4b09d261b86ad0b0768849806294c8292e14
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=4e6b4b09d261b86ad0b0768849806294c8292e14

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Nov  9 12:32:44 2017 +0100

patches: Also use References: header to build mail threads.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 patches/update | 48 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/patches/update b/patches/update
index e4ede03..ca4d2e5 100755
--- a/patches/update
+++ b/patches/update
@@ -154,6 +154,7 @@ foreach my $file (readdir DIR)
         elsif (/^From: (.*)$/) { $patch{"author"} = format_author($1); }
         elsif (/^Message-Id: (.*)$/) { $patch{"msgid"} = $1; }
         elsif (/^In-Reply-To: (.*)$/) { $patch{"reply"} = $1; }
+        elsif (/^References: (.*)$/) { @{$patch{"refs"}} = split /\s+/, $1; }
         last if (/^$/);
     }
     while (<PATCH>)
@@ -225,24 +226,35 @@ closedir DIR;
 
 # build mail threads
 
-foreach my $file (sort keys %patches)
+sub assign_parent($);
+sub assign_parent($)
 {
-    my $patch = $patches{$file};
-    next if defined $patch->{"has_patch"};
-    next unless defined $patch->{"reply"};
-    next unless defined $messages{$patch->{"reply"}};
-    my $parent = $messages{$patch->{"reply"}};
-    # find top parent
-    while (!defined($parent->{"has_patch"}) && defined($parent->{"reply"}))
+    my $patch = shift;
+
+    if (defined($patch->{"parent"})) { return $patch->{"parent"}; }
+
+    return $patch if defined $patch->{"has_patch"};
+    return $patch unless defined $patch->{"reply"};
+
+    foreach ($patch->{"reply"}, @{$patch->{"refs"}})
     {
-        $parent = $messages{$parent->{"reply"}};
+        next unless defined $messages{$_};
+        my $parent = assign_parent( $messages{$_} );
+        next unless $parent;
+        # add it to the parent's children
+        $patch->{"parent"} = $parent;
+        push @{$parent->{"children"}}, $patch;
+        push @{$parent->{"signoff"}}, @{$patch->{"signoff"}} if $patch->{"signoff"};
+        return $parent;
     }
-    next unless defined $parent;
-    # add it to the parent's children and remove it from the list
-    $patch->{"parent"} = $parent;
-    push @{$parent->{"children"}}, $patch;
-    push @{$parent->{"signoff"}}, @{$patch->{"signoff"}} if $patch->{"signoff"};
-    delete $patches{$file};
+    return undef;
+}
+
+foreach my $file (sort keys %patches)
+{
+    assign_parent( $patches{$file} );
+    # remove patches that have a parent
+    delete $patches{$file} if $patches{$file}->{"parent"};
 }
 
 my $row = 0;
@@ -250,6 +262,12 @@ foreach my $file (sort { $patches{$b}->{"order"} <=> $patches{$a}->{"order"} } k
 {
     my $patch = $patches{$file};
 
+    if (!defined $patch->{"has_patch"}) # skip non-patches
+    {
+        next if $patch->{"status"} eq "reply";
+        next unless $patch->{"subject"} =~ /\[.*PATCH.*\]/;
+    }
+
     printf INDEX "<tr class=\"%s %s\"><td class=\"id\">%s</td><td class=\"status\"><a href=\"#legend\">%s</a></td>",
         $row & 1 ? "odd" : "even", $patch->{"status"}, $file, $status_descr{$patch->{"status"}} || $patch->{"status"};
     if (defined $patch->{"children"})




More information about the wine-cvs mailing list