Index: subversion/bindings/swig/ruby/test/test_client.rb =================================================================== --- subversion/bindings/swig/ruby/test/test_client.rb (revision 27580) +++ subversion/bindings/swig/ruby/test/test_client.rb (working copy) @@ -1295,6 +1295,135 @@ assert_equal({name2 => value2}, dir_props) end + def recurse_and_depth_choices + [ false, true, "unknown", "exclude", "empty", "files", "immediates", + "infinity" ] + end + + def test_file_prop + setup_greek_tree + + log = "sample log" + ctx = make_context(log) + + # when no props set, everything is empty + recurse_and_depth_choices.each do |rd| + assert_equal([], + ctx.prop_list(wc_path_for(Mu), nil, nil, rd), + "prop_list with Depth '#{rd}'") + end + + recurse_and_depth_choices.each do |rd| + assert_equal({}, + ctx.prop_get(rd.to_s, wc_path_for(Mu), nil, nil, rd), + "prop_get with Depth '#{rd}'") + end + + # set some props + recurse_and_depth_choices.each do |rd| + ctx.prop_set(rd.to_s, rd.to_s, wc_path_for(Mu), rd) + end + ctx.commit(wc_path_for(Mu)) + + # get the props + recurse_and_depth_choices.each do |rd| + assert_equal({uri_for(Mu) => rd.to_s}, + ctx.prop_get(rd.to_s, wc_path_for(Mu), nil, nil, rd), + "prop_get with Depth '#{rd}'") + end + + prop_hash = {} + recurse_and_depth_choices.each{|rd| prop_hash[rd.to_s] = rd.to_s } + + # list the props + recurse_and_depth_choices.each do |rd| + assert_equal([uri_for(Mu)], + ctx.prop_list(wc_path_for(Mu), nil, nil, rd).collect{|item| item.node_name}, + "prop_list (node_name) with Depth '#{rd}'") + + assert_equal([prop_hash], + ctx.plist(wc_path_for(Mu), nil, nil, rd).collect{|item| item.prop_hash}, + "prop_list (prop_hash) with Depth '#{rd}'") + + recurse_and_depth_choices.each do |rd1| + assert_equal([rd1.to_s], + ctx.plist(wc_path_for(Mu), nil, nil, rd).collect{|item| item[rd1.to_s]}, + "prop_list (#{rd1.to_s}]) with Depth '#{rd}'") + end + end + + end + + def test_dir_prop + setup_greek_tree + + log = "sample log" + ctx = make_context(log) + + # when no props set, everything is empty + recurse_and_depth_choices.each do |rd| + assert_equal([], + ctx.prop_list(wc_path_for(B), nil, nil, rd), + "prop_list with Depth '#{rd}'") + end + + recurse_and_depth_choices.each do |rd| + assert_equal({}, + ctx.prop_get(rd.to_s, wc_path_for(B), nil, nil, rd), + "prop_get with Depth '#{rd}'") + end + + # set some props with various depths + recurse_and_depth_choices.each do |rd| + ctx.prop_set(rd.to_s, rd.to_s, wc_path_for(B), rd) + end + ctx.commit(wc_path_for(B)) + + expected_props = + { true => [ Beta, B, Lambda, E, F, Alpha ], + false => [ B ], + 'unknown' => [ B ], + 'exclude' => [ B ], + 'empty' => [ B ], + 'files' => [ B, Lambda ], + 'immediates' => [ B, Lambda, E, F ], + 'infinity' => [ Beta, B, Lambda, E, F, Alpha ] } + + paths = [ B, E, Alpha, Beta, F, Lambda ] + + # how are the props set? + + recurse_and_depth_choices.each do |rd| + paths.each do |p| + expected = expected_props[rd].include?(p) ? {uri_for(p)=>rd.to_s} : {} + assert_equal(expected, + ctx.prop_get(rd.to_s, wc_path_for(p), nil, nil, false), + "prop_get #{p} with Depth 'rd.to_s'") + end + end + + recurse_and_depth_choices.each do |rd_for_prop| + recurse_and_depth_choices.each do |rd_for_depth| + + expected = {} + (expected_props[rd_for_depth] & expected_props[rd_for_prop]).each do |p| + expected[uri_for(p)] = rd_for_prop.to_s + end + + assert_equal(expected, + ctx.prop_get(rd_for_prop.to_s, wc_path_for(B), nil, nil, rd_for_depth), + "prop_get '#{rd_for_prop.to_s}' with Depth '#{rd_for_depth}'") + + end + end + + recurse_and_depth_choices.each do |rd| + assert_equal(expected_props[rd].collect{|p| uri_for(p)}.sort, + ctx.prop_list(wc_path_for(B), nil, nil, rd).collect{|item| item.node_name}.sort, + "prop_list (node_name) with Depth '#{rd}'") + end + end + def test_cat log = "sample log" src1 = "source1\n" Index: subversion/bindings/swig/ruby/svn/client.rb =================================================================== --- subversion/bindings/swig/ruby/svn/client.rb (revision 27580) +++ subversion/bindings/swig/ruby/svn/client.rb (working copy) @@ -188,10 +188,10 @@ Client.resolved(path, recurse, self) end - def propset(name, value, target, recurse=true, force=false, + def propset(name, value, target, depth_or_recurse=nil, force=false, base_revision_for_url=nil) base_revision_for_url ||= Svn::Core::INVALID_REVNUM - depth = recurse ? Svn::Core::DEPTH_INFINITY : Svn::Core::DEPTH_EMPTY + depth = depth_from_depth_or_recurse(depth_or_recurse) Client.propset3(name, value, target, depth, force, base_revision_for_url, self) end @@ -208,10 +208,10 @@ # Returns a value of a property, with +name+ attached to +target+, # as a Hash such as {uri1 => value1, uri2 => value2, ...}. - def propget(name, target, rev=nil, peg_rev=nil, recurse=true) + def propget(name, target, rev=nil, peg_rev=nil, depth_or_recurse=nil) rev ||= "HEAD" peg_rev ||= rev - depth = recurse ? Svn::Core::DEPTH_INFINITY : Svn::Core::DEPTH_EMPTY + depth = depth_from_depth_or_recurse(depth_or_recurse) Client.propget4(name, target, peg_rev, rev, depth, self).first end alias prop_get propget @@ -223,10 +223,11 @@ # Returns list of properties attached to +target+ as an Array of # Svn::Client::PropListItem. # Paths and URIs are available as +target+. - def proplist(target, rev=nil, peg_rev=nil, depth=nil, &block) + def proplist(target, rev=nil, peg_rev=nil, depth_or_recurse=nil, &block) rev ||= "HEAD" peg_rev ||= rev items = [] + depth = depth_from_depth_or_recurse(depth_or_recurse) receiver = Proc.new do |path, prop_hash| items << PropListItem.new(path, prop_hash) block.call(path, prop_hash) if block @@ -624,6 +625,14 @@ # URI as far as subversion is concerned. uri.scheme and uri.host end + + def depth_from_depth_or_recurse(depth_or_recurse) + depth = case depth_or_recurse + when true, nil: Svn::Core::DEPTH_INFINITY + when false: Svn::Core::DEPTH_EMPTY + else depth_or_recurse + end + end end # Following methods are also available: