Joe,
Great to see this work happening.  Be aware that some of the APIs are still 
moving targets, so some things might break.

-Hyrum

On Feb 15, 2010, at 12:51 PM, joeswat...@apache.org wrote:

> Author: joeswatosh
> Date: Mon Feb 15 18:51:12 2010
> New Revision: 910298
> 
> URL: http://svn.apache.org/viewvc?rev=910298&view=rev
> Log:
> First baby-step toward supporting WC-NG APIs in the Ruby Bindings: Provide a
> way to create a Context object.
> 
> * subversion/bindings/swig/ruby/test/test_wc.rb
>  (SvnWcTest#test_context_new_default_config,
>   SvnWcTest#test_context_new_specified_config,
>   SvnWcTest#test_context_create): New methods.
> 
> * subversion/bindings/swig/ruby/svn/wc.rb
>  (Svn::Wc::Context): New class.
>  (Svn::Wc::Context.create, Svn::Wc::Context.new, 
>   Svn::Wc::Context#destroy): New methods.
> 
> * subversion/bindings/swig/include/svn_types.swg
>  (OUTPARAM): add svn_wc_context_t for Ruby so it will be wrapped correctly.
>  (%apply apr_pool_t *pool): add *scratch_pool to the list of known names for
>   pools for Ruby bindings so it will be wrapped correctly.
> 
> Modified:
>    subversion/trunk/subversion/bindings/swig/include/svn_types.swg
>    subversion/trunk/subversion/bindings/swig/ruby/svn/wc.rb
>    subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb
> 
> Modified: subversion/trunk/subversion/bindings/swig/include/svn_types.swg
> URL: 
> http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/include/svn_types.swg?rev=910298&r1=910297&r2=910298&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/bindings/swig/include/svn_types.swg (original)
> +++ subversion/trunk/subversion/bindings/swig/include/svn_types.swg Mon Feb 
> 15 18:51:12 2010
> @@ -157,6 +157,10 @@
>   svn_wc_status_t **,
>   svn_wc_status2_t **,
>   svn_wc_committed_queue_t **,
> +#ifdef SWIGRUBY
> +  /* Only tested for Ruby */
> +  svn_wc_context_t **,
> +#endif
>   void **set_locks_baton
> };
> 
> @@ -592,7 +596,8 @@
>     apr_pool_t *dir_pool,
>     apr_pool_t *file_pool,
>     apr_pool_t *node_pool,
> -    apr_pool_t *result_pool
> +    apr_pool_t *result_pool,
> +    apr_pool_t *scratch_pool
> };
> #endif
> 
> 
> Modified: subversion/trunk/subversion/bindings/swig/ruby/svn/wc.rb
> URL: 
> http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/svn/wc.rb?rev=910298&r1=910297&r2=910298&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/bindings/swig/ruby/svn/wc.rb (original)
> +++ subversion/trunk/subversion/bindings/swig/ruby/svn/wc.rb Mon Feb 15 
> 18:51:12 2010
> @@ -704,5 +704,50 @@
>         Wc.process_committed_queue(self, access, new_rev, rev_date, 
> rev_author)
>       end
>     end
> +
> +    Context = SWIG::TYPE_p_svn_wc_context_t
> +    # A context is not associated with a particular working copy, but as
> +    # operations are performed, will load the appropriate working copy
> +    # information.
> +    class Context
> +      class << self
> +
> +        # Creates an new instance of Context.
> +        #
> +        # ==== arguments
> +        #
> +        # * <tt>:config</tt> <i>(default=>nil)</i> A \
> +        # Svn::Core::Config with options that apply to this Context.
> +        def new(arguments={})
> +          optional_arguments_defaults = { :config => nil }
> +          arguments = optional_arguments_defaults.merge(arguments)
> +          context = Wc.context_create(arguments[:config])
> +          return context
> +        end
> +
> +        # Creates an new instance of Context for use in the block, the 
> context 
> +        # is destroyed when the block completes.
> +        #
> +        # ==== arguments
> +        #
> +        # see new.
> +        def create(arguments={})
> +          context = new(arguments)
> +          begin
> +            yield context
> +          ensure
> +            context.destroy if context
> +          end
> +        end
> +
> +      end
> +
> +      # Destroys the context, releasing any acquired resources.
> +      # The context is unavailable for any further operations.
> +      def destroy
> +        Wc.context_destroy(self)
> +      end
> +    end
> +
>   end
> end
> 
> Modified: subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb
> URL: 
> http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb?rev=910298&r1=910297&r2=910298&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb (original)
> +++ subversion/trunk/subversion/bindings/swig/ruby/test/test_wc.rb Mon Feb 15 
> 18:51:12 2010
> @@ -1073,4 +1073,30 @@
>       end
>     end
>   end
> +
> +
> +  def test_context_new_default_config
> +    assert_not_nil context = Svn::Wc::Context.new
> +  ensure
> +    context.destroy
> +  end
> +
> +  def test_context_new_specified_config
> +    config_file = File.join(@config_path, Svn::Core::CONFIG_CATEGORY_CONFIG)
> +    config = Svn::Core::Config.read(config_file)
> +    assert_not_nil context = Svn::Wc::Context.new(:config=>config)
> +  ensure
> +    context.destroy
> +  end
> +
> +  def test_context_create
> +    assert_nothing_raised do
> +      result = Svn::Wc::Context.create do |context| 
> +        assert_not_nil context
> +        assert_kind_of Svn::Wc::Context, context
> +      end
> +      assert_nil result;
> +    end
> +  end
> +
> end
> 
> 

Reply via email to