You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Rall <dl...@collab.net> on 2007/10/01 17:11:29 UTC

[ruby bindings] nil as value for depth parameters

Why is 'nil' a valid value for the depth parameter?  Is it
automatically converted to svn_depth_empty (0) somewhere?  I noticed
that client.status() (and many other Ruby client APIs) use it as a
default value.

Thanks, Dan

Re: [ruby bindings] nil as value for depth parameters

Posted by Daniel Rall <dl...@collab.net>.
On Mon, 01 Oct 2007, Joe Swatosh wrote:

> Hi Day,
> 
> On 10/1/07, Daniel Rall <dl...@collab.net> wrote:
> > Why is 'nil' a valid value for the depth parameter?  Is it
> > automatically converted to svn_depth_empty (0) somewhere?  I noticed
> > that client.status() (and many other Ruby client APIs) use it as a
> > default value.
> >
> 
> I think what you are looking for is svn_swig_rb_to_depth.

Thanks Joe! From
subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c:

svn_depth_t
svn_swig_rb_to_depth(VALUE value)
{
  if (NIL_P(value)) {
    return svn_depth_infinity;
  } else if (value == Qtrue) {
    return SVN_DEPTH_FROM_RECURSE(TRUE);
  } else if (value == Qfalse) {
    return SVN_DEPTH_FROM_RECURSE(FALSE);
  } else if (RTEST(rb_obj_is_kind_of(value, rb_cString)) ||
             RTEST(rb_obj_is_kind_of(value, rb_cSymbol))) {
    value = rb_funcall(value, id_to_s, 0);
    return svn_depth_from_word(StringValueCStr(value));
  } else if (RTEST(rb_obj_is_kind_of(value, rb_cInteger))) {
    return NUM2INT(value);
  } else {
    rb_raise(rb_eArgError,
             "'%s' must be DEPTH_STRING (e.g. \"infinity\" or :infinity) "
             "or Svn::Core::DEPTH_*",
             r2c_inspect(value));
  }
}

This seems to fall victim to issue #2951, [sparse-directories] Fix
non-recursive mode of compat APIs to use depth empty instead of files.

Also, it defaults some APIs (e.g. client.proplist) to
svn_depth_infinity, when I'd more intuitively expect them to use depth
empty (as per their behavior from the command-line client).

Re: [ruby bindings] nil as value for depth parameters

Posted by Joe Swatosh <jo...@gmail.com>.
Hi Day,

On 10/1/07, Daniel Rall <dl...@collab.net> wrote:
> Why is 'nil' a valid value for the depth parameter?  Is it
> automatically converted to svn_depth_empty (0) somewhere?  I noticed
> that client.status() (and many other Ruby client APIs) use it as a
> default value.
>

I think what you are looking for is svn_swig_rb_to_depth.

--
Joe

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org