svn-create-patch duplicates diffs when adding directories
https://bugs.webkit.org/show_bug.cgi?id=199842

Reviewed by Dewei Zhu.

* Scripts/svn-create-patch:
(findKind): Add function which returns what 'kind' of file the provided path is.
(generateFileList): If the path is a directory and being added, don't add it.
Instead, rely on the fact that its children will be added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247503 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 0e3b9929..3c15f7c 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,15 @@
+2019-07-16  Jonathan Bedard  <jbedard@apple.com>
+
+        svn-create-patch duplicates diffs when adding directories
+        https://bugs.webkit.org/show_bug.cgi?id=199842
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/svn-create-patch:
+        (findKind): Add function which returns what 'kind' of file the provided path is.
+        (generateFileList): If the path is a directory and being added, don't add it.
+        Instead, rely on the fact that its children will be added.
+
 2019-07-16  Tim Horton  <timothy_horton@apple.com>
 
         NSTextFinder holes don't scroll with the page
diff --git a/Tools/Scripts/svn-create-patch b/Tools/Scripts/svn-create-patch
index 97221d1..96803e7 100755
--- a/Tools/Scripts/svn-create-patch
+++ b/Tools/Scripts/svn-create-patch
@@ -51,6 +51,7 @@
 sub binarycmp($$);
 sub diffOptionsForFile($);
 sub findBaseUrl($);
+sub findKind($);
 sub findMimeType($;$);
 sub findModificationType($);
 sub findSourceFileAndRevision($);
@@ -176,6 +177,24 @@
     return $baseUrl;
 }
 
+sub findKind($)
+{
+    my ($path) = @_;
+    my $kind;
+    my $escapedInfoPath = escapeSubversionPath($path);
+
+    print STDERR "Performing \"svn info '$escapedInfoPath'\"\n" if $verbose;
+
+    open INFO, "svn info '$escapedInfoPath' |" or die;
+    while (<INFO>) {
+        if (/^Node Kind: (.+?)[\r\n]*$/) {
+            $kind = $1;
+        }
+    }
+    close INFO;
+    return $kind;
+}
+
 sub findMimeType($;$)
 {
     my ($file, $revision) = @_;
@@ -329,6 +348,10 @@
             next;
         }
 
+        if (findKind($path) eq "directory") {
+            next;
+        }
+
         $diffFiles->{$path}->{path} = $path;
         $diffFiles->{$path}->{modificationType} = $modificationType;
         $diffFiles->{$path}->{isBinary} = isBinaryMimeType($path);