summaryrefslogtreecommitdiffstats
path: root/subversion-1.7.2-ruby19.patch
blob: e11dc0e0709631cca5d1101483a350d1f79a5a7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
Date: Tue, 20 Dec 2011 21:08:00 -0800
From: Vincent Batts <vbatts@slackware.com>
Subject: Re: [PATCH] enabling ruby in the subversion build
Message-ID: <20111221050800.GA17350@slackware.com>

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