6712ef
Date: Tue, 20 Dec 2011 21:08:00 -0800
6712ef
From: Vincent Batts <vbatts@slackware.com>
6712ef
Subject: Re: [PATCH] enabling ruby in the subversion build
6712ef
Message-ID: <20111221050800.GA17350@slackware.com>
6712ef
6712ef
--- subversion-1.7.2/configure.ac.ruby19
6712ef
+++ subversion-1.7.2/configure.ac
6712ef
@@ -1130,13 +1130,6 @@ if test "$RUBY" != "none"; then
6712ef
 
6712ef
     AC_SUBST(RUBY_MAJOR)
6712ef
     AC_SUBST(RUBY_MINOR)
6712ef
-    if test ! \( "$RUBY_MAJOR" -eq "1" -a "$RUBY_MINOR" -eq "8" \); then
6712ef
-      # Disallow Ruby 1.9 or later until the binding tests get fixed
6712ef
-      # to run with those versions.
6712ef
-      RUBY="none"
6712ef
-      AC_MSG_WARN([The detected Ruby is too new for Subversion to use])
6712ef
-      AC_MSG_WARN([Only 1.8.x releases are supported at this time])
6712ef
-    fi
6712ef
   else
6712ef
     AC_MSG_RESULT([no])
6712ef
     RUBY="none"
6712ef
--- subversion-1.7.2/Makefile.in.ruby19
6712ef
+++ subversion-1.7.2/Makefile.in
6712ef
@@ -318,7 +318,7 @@ INSTALL_EXTRA_SWIG_RB=\
6712ef
     $(INSTALL_DATA) "$$i" $(DESTDIR)$(SWIG_RB_SITE_LIB_DIR)/svn; \
6712ef
   done
6712ef
 
6712ef
-APXS = @APXS@ 
6712ef
+APXS = @APXS@
6712ef
 
6712ef
 PYTHON = @PYTHON@
6712ef
 PERL = @PERL@
6712ef
@@ -818,9 +818,14 @@ swig-rb: autogen-swig-rb
6712ef
 
6712ef
 check-swig-rb: swig-rb svnserve
6712ef
 	cd $(SWIG_RB_DIR); \
6712ef
-	  $(RUBY) -I $(SWIG_RB_SRC_DIR) \
6712ef
-	    $(SWIG_RB_SRC_DIR)/test/run-test.rb \
6712ef
-	    --verbose=$(SWIG_RB_TEST_VERBOSE)
6712ef
+	  if [ "$(RUBY_MAJOR)" -eq 1 -a "$(RUBY_MINOR)" -lt 9 ] ; then \
6712ef
+	    $(RUBY) -I $(SWIG_RB_SRC_DIR) \
6712ef
+	      $(SWIG_RB_SRC_DIR)/test/run-test.rb \
6712ef
+	      --verbose=$(SWIG_RB_TEST_VERBOSE); \
6712ef
+	  else \
6712ef
+	    $(RUBY) -I $(SWIG_RB_SRC_DIR) \
6712ef
+	      $(SWIG_RB_SRC_DIR)/test/run-test.rb; \
6712ef
+	  fi
6712ef
 
6712ef
 EXTRACLEAN_SWIG_RB=rm -f $(SWIG_RB_SRC_DIR)/svn_*.c $(SWIG_RB_SRC_DIR)/core.c
6712ef
 
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/svn/info.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/svn/info.rb
6712ef
@@ -229,7 +229,9 @@ module Svn
6712ef
 
6712ef
     def parse_diff_unified(entry)
6712ef
       in_content = false
6712ef
-      entry.body.each do |line|
6712ef
+      # accomodation for ruby 1.9 and 1.8
6712ef
+      each_meth = entry.body.respond_to?(:each_line) ? :each_line : :each
6712ef
+      entry.body.send(each_meth) do |line|
6712ef
         case line
6712ef
         when /^@@/
6712ef
           in_content = true
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/svn/util.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/svn/util.rb
6712ef
@@ -36,7 +36,7 @@ module Svn
6712ef
   module Util #:nodoc:
6712ef
     module_function
6712ef
     def to_ruby_class_name(name)
6712ef
-      name.split("_").collect do |x|
6712ef
+      name.to_s.split("_").collect do |x|
6712ef
         "#{x[0,1].upcase}#{x[1..-1].downcase}"
6712ef
       end.join("")
6712ef
     end
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/my-assertions.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/my-assertions.rb
6712ef
@@ -24,20 +24,33 @@ module Test
6712ef
   module Unit
6712ef
     module Assertions
6712ef
 
6712ef
+      # make an intermediary assertion block handler
6712ef
+      def _my_assert_block(&block)
6712ef
+	if RUBY_VERSION > '1.9'
6712ef
+	  assert_block do
6712ef
+	    yield
6712ef
+	  end
6712ef
+	else
6712ef
+	  _wrap_assertion do
6712ef
+	    yield
6712ef
+	  end
6712ef
+	end
6712ef
+      end
6712ef
+
6712ef
       def assert_true(boolean, message=nil)
6712ef
-        _wrap_assertion do
6712ef
+        _my_assert_block do
6712ef
           assert_equal(true, boolean, message)
6712ef
         end
6712ef
       end
6712ef
 
6712ef
       def assert_false(boolean, message=nil)
6712ef
-        _wrap_assertion do
6712ef
+        _my_assert_block do
6712ef
           assert_equal(false, boolean, message)
6712ef
         end
6712ef
       end
6712ef
 
6712ef
       def assert_nested_sorted_array(expected, actual, message=nil)
6712ef
-        _wrap_assertion do
6712ef
+        _my_assert_block do
6712ef
           assert_equal(expected.collect {|elem| elem.sort},
6712ef
                        actual.collect {|elem| elem.sort},
6712ef
                        message)
6712ef
@@ -45,7 +58,7 @@ module Test
6712ef
       end
6712ef
 
6712ef
       def assert_equal_log_entries(expected, actual, message=nil)
6712ef
-        _wrap_assertion do
6712ef
+        _my_assert_block do
6712ef
           actual = actual.collect do |entry|
6712ef
             changed_paths = entry.changed_paths
6712ef
             changed_paths.each_key do |path|
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test_client.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test_client.rb
6712ef
@@ -2203,7 +2203,11 @@ class SvnClientTest < Test::Unit::TestCa
6712ef
 
6712ef
     make_context(log) do |ctx|
6712ef
       items = nil
6712ef
-      ctx.set_log_msg_func do |items|
6712ef
+      ctx.set_log_msg_func do |l_items|
6712ef
+	# ruby 1.8 magically carried the assignment of 'items' back from this Proc block, 
6712ef
+        # but in 1.9, we need to have names that don't conflict, and set the outside 'items'.
6712ef
+        # This works in 1.8 as well
6712ef
+        items = l_items
6712ef
         [true, log]
6712ef
       end
6712ef
 
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test_core.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test_core.rb
6712ef
@@ -1,3 +1,4 @@
6712ef
+# encoding: UTF-8
6712ef
 # ====================================================================
6712ef
 #    Licensed to the Apache Software Foundation (ASF) under one
6712ef
 #    or more contributor license agreements.  See the NOTICE file
6712ef
@@ -52,7 +53,13 @@ class SvnCoreTest < Test::Unit::TestCase
6712ef
     now = Time.now.gmtime
6712ef
     str = now.strftime("%Y-%m-%dT%H:%M:%S.") + "#{now.usec}Z"
6712ef
 
6712ef
-    assert_equal(now, Time.from_svn_format(str))
6712ef
+    if RUBY_VERSION > '1.9'
6712ef
+      # ruby 1.9 Time comparison gets into the nano-seconds, that strftime
6712ef
+      # shaves off. So we can compare epoch time instead
6712ef
+      assert_equal(now.to_i, Time.from_svn_format(str).gmtime.to_i)
6712ef
+    else
6712ef
+      assert_equal(now, Time.from_svn_format(str).gmtime)
6712ef
+    end
6712ef
 
6712ef
     apr_time = now.to_i * 1000000 + now.usec
6712ef
     assert_equal(apr_time, now.to_apr_time)
6712ef
@@ -244,7 +251,11 @@ class SvnCoreTest < Test::Unit::TestCase
6712ef
       config_infos << [section, name, value]
6712ef
     end
6712ef
     assert_equal(infos.sort, config_infos.sort)
6712ef
-    assert_equal(infos.sort, config.collect {|args| args}.sort)
6712ef
+    if RUBY_VERSION > '1.9'
6712ef
+      assert_equal(infos.sort, config.collect {|sect,name,val| [sect,name,val]}.sort)
6712ef
+    else
6712ef
+      assert_equal(infos.sort, config.collect {|args| args}.sort)
6712ef
+    end
6712ef
   end
6712ef
 
6712ef
   def test_config_find_group
6712ef
@@ -532,7 +543,13 @@ EOD
6712ef
     date_str = now.strftime("%Y-%m-%dT%H:%M:%S")
6712ef
     date_str << ".#{now.usec}Z"
6712ef
     info.date = date_str
6712ef
-    assert_equal(now, info.date)
6712ef
+    if RUBY_VERSION > '1.9'
6712ef
+      # ruby 1.9 Time comparison gets into the nano-seconds, that strftime
6712ef
+      # shaves off. So we can compare epoch time instead
6712ef
+      assert_equal(now.to_i, info.date.gmtime.to_i)
6712ef
+    else
6712ef
+      assert_equal(now, info.date.gmtime)
6712ef
+    end
6712ef
   end
6712ef
 
6712ef
   def test_svn_prop
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test_delta.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test_delta.rb
6712ef
@@ -17,9 +17,10 @@
6712ef
 #    under the License.
6712ef
 # ====================================================================
6712ef
 
6712ef
+require "my-assertions"
6712ef
 require "util"
6712ef
 require "stringio"
6712ef
-require 'md5'
6712ef
+require 'digest/md5'
6712ef
 require 'tempfile'
6712ef
 
6712ef
 require "svn/info"
6712ef
@@ -46,8 +47,8 @@ class SvnDeltaTest < Test::Unit::TestCas
6712ef
     target = StringIO.new(t)
6712ef
     stream = Svn::Delta::TextDeltaStream.new(source, target)
6712ef
     assert_nil(stream.md5_digest)
6712ef
-    _wrap_assertion do
6712ef
-      stream.each do |window|
6712ef
+    _my_assert_block do
6712ef
+      ret = stream.each do |window|
6712ef
         window.ops.each do |op|
6712ef
           op_size = op.offset + op.length
6712ef
           case op.action_code
6712ef
@@ -62,8 +63,9 @@ class SvnDeltaTest < Test::Unit::TestCas
6712ef
           end
6712ef
         end
6712ef
       end
6712ef
+      true if RUBY_VERSION > '1.9' # this block returns nil in > ruby '1.9'
6712ef
     end
6712ef
-    assert_equal(MD5.new(t).hexdigest, stream.md5_digest)
6712ef
+    assert_equal(Digest::MD5.hexdigest(t), stream.md5_digest)
6712ef
   end
6712ef
 
6712ef
   def test_txdelta_window_compose
6712ef
@@ -81,7 +83,7 @@ class SvnDeltaTest < Test::Unit::TestCas
6712ef
       end
6712ef
     end
6712ef
 
6712ef
-    _wrap_assertion do
6712ef
+    assert_block do
6712ef
       composed_window.ops.each do |op|
6712ef
         op_size = op.offset + op.length
6712ef
         case op.action_code
6712ef
@@ -169,6 +171,7 @@
6712ef
     stream = Svn::Delta::TextDeltaStream.new(source, target)
6712ef
 
6712ef
     output = StringIO.new("")
6712ef
+    output.set_encoding Encoding::ASCII_8BIT if output.respond_to? :set_encoding
6712ef
     handler = Svn::Delta.svndiff_handler(output)
6712ef
 
6712ef
     Svn::Delta.send(target_text, handler)
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test_fs.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test_fs.rb
6712ef
@@ -20,7 +20,7 @@
6712ef
 require "my-assertions"
6712ef
 require "util"
6712ef
 require "time"
6712ef
-require "md5"
6712ef
+require "digest/md5"
6712ef
 
6712ef
 require "svn/core"
6712ef
 require "svn/fs"
6712ef
@@ -49,14 +49,15 @@ class SvnFsTest < Test::Unit::TestCase
6712ef
 
6712ef
     assert(!File.exist?(path))
6712ef
     fs = nil
6712ef
-    callback = Proc.new do |fs|
6712ef
+    callback = Proc.new do |t_fs|
6712ef
       assert(File.exist?(path))
6712ef
       assert_equal(fs_type, Svn::Fs.type(path))
6712ef
-      fs.set_warning_func do |err|
6712ef
+      t_fs.set_warning_func do |err|
6712ef
         p err
6712ef
         abort
6712ef
       end
6712ef
-      assert_equal(path, fs.path)
6712ef
+      assert_equal(path, t_fs.path)
6712ef
+      fs = t_fs
6712ef
     end
6712ef
     yield(:create, [path, config], callback)
6712ef
 
6712ef
@@ -162,7 +163,7 @@ class SvnFsTest < Test::Unit::TestCase
6712ef
 
6712ef
       assert_equal(src, @fs.root.file_contents(path_in_repos){|f| f.read})
6712ef
       assert_equal(src.length, @fs.root.file_length(path_in_repos))
6712ef
-      assert_equal(MD5.new(src).hexdigest,
6712ef
+      assert_equal(Digest::MD5.hexdigest(src),
6712ef
                    @fs.root.file_md5_checksum(path_in_repos))
6712ef
 
6712ef
       assert_equal([path_in_repos], @fs.root.paths_changed.keys)
6712ef
@@ -364,7 +365,7 @@ class SvnFsTest < Test::Unit::TestCase
6712ef
 
6712ef
       File.open(path, "w") {|f| f.print(modified)}
6712ef
       @fs.transaction do |txn|
6712ef
-        checksum = MD5.new(normalize_line_break(result)).hexdigest
6712ef
+        checksum = Digest::MD5.hexdigest(normalize_line_break(result))
6712ef
         stream = txn.root.apply_text(path_in_repos, checksum)
6712ef
         stream.write(normalize_line_break(result))
6712ef
         stream.close
6712ef
@@ -392,8 +393,8 @@ class SvnFsTest < Test::Unit::TestCase
6712ef
 
6712ef
       File.open(path, "w") {|f| f.print(modified)}
6712ef
       @fs.transaction do |txn|
6712ef
-        base_checksum = MD5.new(normalize_line_break(src)).hexdigest
6712ef
-        checksum = MD5.new(normalize_line_break(result)).hexdigest
6712ef
+        base_checksum = Digest::MD5.hexdigest(normalize_line_break(src))
6712ef
+        checksum = Digest::MD5.hexdigest(normalize_line_break(result))
6712ef
         handler = txn.root.apply_textdelta(path_in_repos,
6712ef
                                            base_checksum, checksum)
6712ef
         assert_raises(Svn::Error::ChecksumMismatch) do
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test_repos.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test_repos.rb
6712ef
@@ -98,11 +98,12 @@ class SvnReposTest < Test::Unit::TestCas
6712ef
     fs_type = Svn::Fs::TYPE_FSFS
6712ef
     fs_config = {Svn::Fs::CONFIG_FS_TYPE => fs_type}
6712ef
     repos = nil
6712ef
-    Svn::Repos.create(tmp_repos_path, {}, fs_config) do |repos|
6712ef
+    Svn::Repos.create(tmp_repos_path, {}, fs_config) do |t_repos|
6712ef
       assert(File.exist?(tmp_repos_path))
6712ef
-      fs_type_path = File.join(repos.fs.path, Svn::Fs::CONFIG_FS_TYPE)
6712ef
+      fs_type_path = File.join(t_repos.fs.path, Svn::Fs::CONFIG_FS_TYPE)
6712ef
       assert_equal(fs_type, File.open(fs_type_path) {|f| f.read.chop})
6712ef
-      repos.fs.set_warning_func(&warning_func)
6712ef
+      t_repos.fs.set_warning_func(&warning_func)
6712ef
+      repos = t_repos
6712ef
     end
6712ef
 
6712ef
     assert(repos.closed?)
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test-unit-ext/priority.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test-unit-ext/priority.rb
6712ef
@@ -179,7 +179,7 @@ module Test
6712ef
         apply_priority
6712ef
         !@tests.empty?
6712ef
       end
6712ef
-    end
6712ef
+    end if RUBY_VERSION < '1.9.3'
6712ef
 
6712ef
     class AutoRunner
6712ef
       alias_method :original_options, :options
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test-unit-ext.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test-unit-ext.rb
6712ef
@@ -17,7 +17,7 @@
6712ef
 #    under the License.
6712ef
 # ====================================================================
6712ef
 
6712ef
-require "test-unit-ext/always-show-result"
6712ef
+require "test-unit-ext/always-show-result" if RUBY_VERSION < '1.9.3'
6712ef
 require "test-unit-ext/priority"
6712ef
-require "test-unit-ext/backtrace-filter"
6712ef
-require "test-unit-ext/long-display-for-emacs"
6712ef
+require "test-unit-ext/backtrace-filter" if RUBY_VERSION < '1.9.3'
6712ef
+require "test-unit-ext/long-display-for-emacs" if RUBY_VERSION < '1.9.3'
6712ef
--- subversion-1.7.2/subversion/bindings/swig/ruby/test/test_wc.rb.ruby19
6712ef
+++ subversion-1.7.2/subversion/bindings/swig/ruby/test/test_wc.rb
6712ef
@@ -530,7 +530,7 @@ EOE
6712ef
       ctx.ci(lf_path)
6712ef
 
6712ef
       Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
6712ef
-        _wrap_assertion do
6712ef
+        _my_assert_block do
6712ef
           File.open(src_path, "wb") {|f| f.print(source)}
6712ef
           args = [method_name, src_path, crlf_path, Svn::Wc::TRANSLATE_FROM_NF]
6712ef
           result = yield(access.send(*args), source)
6712ef
@@ -1084,7 +1084,11 @@ EOE
6712ef
         assert_not_nil context
6712ef
         assert_kind_of Svn::Wc::Context, context
6712ef
       end
6712ef
-      assert_nil result;
6712ef
+      if RUBY_VERSION > '1.9'
6712ef
+        assert_equal(result,true)
6712ef
+      else
6712ef
+        assert_nil result
6712ef
+      end
6712ef
     end
6712ef
   end
6712ef