From 4c75471f13559ad336a7dc9bc129a50f174c4991 Mon Sep 17 00:00:00 2001
From: James McCoy <jamessan@apache.org>
Date: Thu, 2 Apr 2020 03:01:43 +0000
Subject: [PATCH] Fix Proc.new warnings in Ruby bindings with Ruby >= 2.7

Per Ruby 2.7's release notes[1], use the block-capturing syntax instead of
explicit Proc.new to resolve warnings like these in the Ruby SWIG APIs:

subversion/bindings/swig/ruby/svn/client.rb:640: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
subversion/bindings/swig/ruby/svn/core.rb:258: warning: Capturing the given block using Proc.new is deprecated; use `&block` instead

[1]: https://github.com/ruby/ruby/blob/v2_7_0/NEWS#proclambda-without-block-is-deprecated-

* subversion/bindings/swig/ruby/svn/client.rb:
  (set_log_msg_func, set_log_msg_func2, set_notify_func, set_cancel_func):
   Replace callback=Proc.new parameter with &callback
  (def_init_callbacks): Remove explicit nil parameters to above functions,
   leveraging deafaults

* subversion/bindings/swig/ruby/svn/core.rb:
  (add_simple_prompt_provider, add_username_prompt_provider,
   add_ssl_server_trust_prompt_provider, add_ssl_client_cert_prompt_provider,
   add_ssl_client_cert_pw_prompt_provider): Replace prompt=Proc.new parameter
    with &prompt


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1876020 13f79535-47bb-0310-9956-ffa450edef68
---
 subversion/bindings/swig/ruby/svn/client.rb | 16 ++++++++--------
 subversion/bindings/swig/ruby/svn/core.rb   | 10 +++++-----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/subversion/bindings/swig/ruby/svn/client.rb b/subversion/bindings/swig/ruby/svn/client.rb
index 50a0385592eb..30d328bcd895 100644
--- a/subversion/bindings/swig/ruby/svn/client.rb
+++ b/subversion/bindings/swig/ruby/svn/client.rb
@@ -637,25 +637,25 @@ def switch(path, uri, peg_rev=nil, rev=nil, depth=nil,
                        ignore_externals, allow_unver_obstruction, self)
       end
 
-      def set_log_msg_func(callback=Proc.new)
+      def set_log_msg_func(&callback)
         callback_wrapper = Proc.new do |items|
           items = items.collect do |item|
             item_wrapper = CommitItemWrapper.new(item)
           end
           callback.call(items)
         end
-        set_log_msg_func2(callback_wrapper)
+        set_log_msg_func2(&callback_wrapper)
       end
 
-      def set_log_msg_func2(callback=Proc.new)
+      def set_log_msg_func2(&callback)
         @log_msg_baton = Client.set_log_msg_func3(self, callback)
       end
 
-      def set_notify_func(callback=Proc.new)
+      def set_notify_func(&callback)
         @notify_baton = Client.set_notify_func2(self, callback)
       end
 
-      def set_cancel_func(callback=Proc.new)
+      def set_cancel_func(&callback)
         @cancel_baton = Client.set_cancel_func(self, callback)
       end
 
@@ -707,9 +707,9 @@ def remove_from_changelists(changelists_names, paths, depth=nil)
 
       private
       def init_callbacks
-        set_log_msg_func(nil)
-        set_notify_func(nil)
-        set_cancel_func(nil)
+        set_log_msg_func
+        set_notify_func
+        set_cancel_func
       end
       %w(log_msg notify cancel).each do |type|
         private "#{type}_func", "#{type}_baton"
diff --git a/subversion/bindings/swig/ruby/svn/core.rb b/subversion/bindings/swig/ruby/svn/core.rb
index 15ebe139b6a2..26e5e84d4fba 100644
--- a/subversion/bindings/swig/ruby/svn/core.rb
+++ b/subversion/bindings/swig/ruby/svn/core.rb
@@ -249,31 +249,31 @@ def add_windows_ssl_server_trust_provider
         end
       end
 
-      def add_simple_prompt_provider(retry_limit, prompt=Proc.new)
+      def add_simple_prompt_provider(retry_limit, &prompt)
         args = [retry_limit]
         klass = AuthCredSimple
         add_prompt_provider("simple", args, prompt, klass)
       end
 
-      def add_username_prompt_provider(retry_limit, prompt=Proc.new)
+      def add_username_prompt_provider(retry_limit, &prompt)
         args = [retry_limit]
         klass = AuthCredUsername
         add_prompt_provider("username", args, prompt, klass)
       end
 
-      def add_ssl_server_trust_prompt_provider(prompt=Proc.new)
+      def add_ssl_server_trust_prompt_provider(&prompt)
         args = []
         klass = AuthCredSSLServerTrust
         add_prompt_provider("ssl_server_trust", args, prompt, klass)
       end
 
-      def add_ssl_client_cert_prompt_provider(retry_limit, prompt=Proc.new)
+      def add_ssl_client_cert_prompt_provider(retry_limit, &prompt)
         args = [retry_limit]
         klass = AuthCredSSLClientCert
         add_prompt_provider("ssl_client_cert", args, prompt, klass)
       end
 
-      def add_ssl_client_cert_pw_prompt_provider(retry_limit, prompt=Proc.new)
+      def add_ssl_client_cert_pw_prompt_provider(retry_limit, &prompt)
         args = [retry_limit]
         klass = AuthCredSSLClientCertPw
         add_prompt_provider("ssl_client_cert_pw", args, prompt, klass)
