Hi Stefan, > Can you please add a copyright and licence header to the new file > subversion-trunk/tools/examples/info.rb? Thanks! I've attached an updated version of the patch, including the same license header as the other examples.
Gr. Matthijs
[[[ Fix the ruby bindings for svn_auth_get_platform_specific_client_providers. The bindings were present, but due to a missing argout typemap for apr_array_header_t **providers, they threw a not implemented error. This was fixed for perl in r1035745 and for python in r1241530, but was still broken for ruby. [in subversion/bindings/swig] * include/svn_containers.swg (apr_array_header_t **providers): New SWIGRUBY typemap. * ruby/libsvn_swig_ruby/swigutil_rb.c, ruby/libsvn_swig_ruby/swigutil_rb.h (svn_swig_rb_apr_array_to_array_auth_provider_object): Add function. * ruby/svn/core.rb (add_platform_specific_client_providers, add_providers): Add functions. [in tools/examples] * info.rb Add a new example that shows how to do remote access instead of working on an existing working copy (like the existing examples do). This example also shows how to call svn_auth_get_platform_specific_client_providers. Patch by: Matthijs Kooijman <matth...@stdin.nl> ]]] Index: subversion-trunk/subversion/bindings/swig/include/svn_containers.swg =================================================================== --- subversion-trunk.orig/subversion/bindings/swig/include/svn_containers.swg 2012-02-07 19:18:00.948407883 +0100 +++ subversion-trunk/subversion/bindings/swig/include/svn_containers.swg 2012-02-07 19:22:07.725766117 +0100 @@ -884,3 +884,9 @@ } } #endif + +#ifdef SWIGRUBY +%typemap(argout) apr_array_header_t **providers { + %append_output(svn_swig_rb_apr_array_to_array_auth_provider_object(*$1)); +} +#endif Index: subversion-trunk/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c =================================================================== --- subversion-trunk.orig/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c 2012-02-07 19:17:57.328387951 +0100 +++ subversion-trunk/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c 2012-02-07 19:29:57.816351000 +0100 @@ -1313,6 +1313,9 @@ DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_merge_range, c2r_merge_range_dup, EMPTY_CPP_ARGUMENT, svn_merge_range_t *, NULL) +DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_auth_provider_object, + c2r_swig_type, EMPTY_CPP_ARGUMENT, + svn_auth_provider_object_t *, "svn_auth_provider_object_t*") static VALUE c2r_merge_range_array(void *value, void *ctx) Index: subversion-trunk/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.h =================================================================== --- subversion-trunk.orig/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.h 2012-02-07 19:17:57.312387859 +0100 +++ subversion-trunk/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.h 2012-02-07 19:29:57.800350911 +0100 @@ -154,6 +154,8 @@ VALUE svn_swig_rb_apr_array_to_array_external_item2(const apr_array_header_t *ary); SVN_RB_SWIG_SWIGUTIL_EXPORT VALUE svn_swig_rb_apr_array_to_array_merge_range(const apr_array_header_t *ary); +SVN_RB_SWIG_SWIGUTIL_EXPORT +VALUE svn_swig_rb_apr_array_to_array_auth_provider_object(const apr_array_header_t *ary); SVN_RB_SWIG_SWIGUTIL_EXPORT VALUE svn_swig_rb_prop_apr_array_to_hash_prop(const apr_array_header_t *ary); Index: subversion-trunk/tools/examples/info.rb =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ subversion-trunk/tools/examples/info.rb 2012-02-07 19:37:33.606801745 +0100 @@ -0,0 +1,78 @@ +#!/usr/bin/env ruby +# +# info.rb : output some info about a subversion url +# +# Example based on a blogpost by Mark Deepwell +# http://www.markdeepwell.com/2010/06/ruby-subversion-bindings/ +# +###################################################################### +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +###################################################################### +# + +require "svn/core" +require "svn/client" +require "svn/wc" +require "svn/repos" + +# Prompt function mimicking svn's own prompt +simple_prompt = Proc.new do + |result, realm, username, default, may_save, pool| + + puts "Authentication realm: #{realm}" + if username != nil + result.username = username + else + print "Username: " + result.username = STDIN.gets.strip + end + print "Password for '#{result.username}': " + result.password = STDIN.gets.strip +end + + +if ARGV.length != 1 + puts "Usage: info.rb URL[@REV]" +else + ctx = Svn::Client::Context.new() + ctx.add_platform_specific_client_providers + ctx.add_simple_provider + ctx.add_simple_prompt_provider(2, simple_prompt) + ctx.add_username_provider + ctx.add_ssl_server_trust_file_provider + ctx.add_ssl_client_cert_file_provider + ctx.add_ssl_client_cert_pw_file_provider + + repos_uri, revision = ARGV[0].split("@", 2) + if revision + revision = Integer(revision) + end + + begin + ctx.info(repos_uri, revision) do |path, info| + puts("Url: #{info.url}") + puts("Last changed rev: #{info.last_changed_rev}") + puts("Last changed author: #{info.last_changed_author}") + puts("Last changed date: #{info.last_changed_date}") + puts("Kind: #{info.kind}") + end + rescue Svn::Error => e + # catch a generic svn error + raise "Failed to retrieve SVN info at revision " + revision.to_s + end +end Index: subversion-trunk/subversion/bindings/swig/ruby/svn/core.rb =================================================================== --- subversion-trunk.orig/subversion/bindings/swig/ruby/svn/core.rb 2012-02-07 19:17:57.300387794 +0100 +++ subversion-trunk/subversion/bindings/swig/ruby/svn/core.rb 2012-02-07 19:22:07.729766140 +0100 @@ -279,6 +279,10 @@ add_prompt_provider("ssl_client_cert_pw", args, prompt, klass) end + def add_platform_specific_client_providers(config=nil) + add_providers(Core.auth_get_platform_specific_client_providers(config)) + end + private def add_prompt_provider(name, args, prompt, credential_class) real_prompt = Proc.new do |*prompt_args| @@ -294,6 +298,10 @@ end def add_provider(provider) + add_providers([provider]) + end + + def add_providers(new_providers) if auth_baton providers = auth_baton.providers parameters = auth_baton.parameters @@ -301,7 +309,7 @@ providers = [] parameters = {} end - self.auth_baton = AuthBaton.new(providers + [provider], parameters) + self.auth_baton = AuthBaton.new(providers + new_providers, parameters) end end
signature.asc
Description: Digital signature