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