Index: subversion/bindings/swig/ruby/test/test_wc.rb =================================================================== --- subversion/bindings/swig/ruby/test/test_wc.rb (revision 27776) +++ subversion/bindings/swig/ruby/test/test_wc.rb (working copy) @@ -795,6 +795,49 @@ end end + def test_update_editor_options + log = "sample log" + file1 = "hello.txt" + file2 = "hello2.txt" + src = "Hello" + dir = "dir" + dir_path = File.join(@wc_path, dir) + path1 = File.join(dir_path, file1) + path2 = File.join(dir_path, file2) + + ctx = make_context(log) + config = {} + callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton) + session = Svn::Ra::Session.open(@repos_uri) + + FileUtils.mkdir(dir_path) + File.open(path1, "w") {|f| f.print(src)} + ctx.add(dir_path) + rev1 = ctx.commit(@wc_path).revision + + File.open(path1, "w") {|f| f.print(src * 2)} + File.open(path2, "w") {|f| f.print(src)} + ctx.add(path2) + rev2 = ctx.commit(@wc_path).revision + + assert(File.exists?(path2)) + assert_equal(0, ctx.up(@wc_path, 0)) + assert(!File.exists?(path2)) + notification_count = 0 + Svn::Wc::AdmAccess.open(nil, @wc_path) do |access| + assert_raises(ArgumentError) do + access.update_editor2(0, @wc_path, :notify_fun=>lambda{|n| p notification_count+=1}) + end + editor = access.update_editor2(0, @wc_path, :notify_func=>lambda{|n| notification_count+=1}) + assert_equal(0, editor.target_revision) + + reporter = session.update2(rev2, "", editor) + access.crawl_revisions(@wc_path, reporter) + assert_equal(rev2, editor.target_revision) + end + assert_equal(4, notification_count, "wrong number of notifications") + end + def test_switch_editor log = "sample log" file1 = "hello.txt" Index: subversion/bindings/swig/ruby/svn/wc.rb =================================================================== --- subversion/bindings/swig/ruby/svn/wc.rb (revision 27776) +++ subversion/bindings/swig/ruby/svn/wc.rb (working copy) @@ -307,25 +307,37 @@ editor end - def update_editor2(target_revision, target, use_commit_times=true, - depth=nil, allow_unver_obstruction=false, diff3_cmd=nil, - notify_func=nil, cancel_func=nil, traversal_info=nil, - preserved_exts=nil) - preserved_exts ||= [] - traversal_info ||= _traversal_info + def update_editor2(target_revision, target, options={}) + defaults = { + :use_commit_times => true, + :depth => nil, + :allow_unver_obstruction => false, + :diff3_cmd => nil, + :notify_func => nil, + :cancel_func => nil, + :traversal_info => _traversal_info, + :preserved_exts => [] } + actuals = validate_options(defaults, options) # TODO(rb support fetch_fun): implement support for the fetch_func # callback. - fetch_func = nil + actuals[:fetch_func] = nil + # TODO(rb support conflict_fun): implement support for the # conflict_func callback. - conflict_func=nil + actuals[:conflict_func] = nil + results = Wc.get_update_editor3(target_revision, self, target, - use_commit_times, depth, - allow_unver_obstruction, - notify_func, cancel_func, conflict_func, - fetch_func, diff3_cmd, - preserved_exts, traversal_info) + actuals[:use_commit_times], + actuals[:depth], + actuals[:allow_unver_obstruction], + actuals[:notify_func], + actuals[:cancel_func], + actuals[:conflict_func], + actuals[:fetch_func], + actuals[:diff3_cmd], + actuals[:preserved_exts], + actuals[:traversal_info]) target_revision_address, editor, editor_baton = results editor.__send__(:target_revision_address=, target_revision_address) editor.baton = editor_baton @@ -344,23 +356,33 @@ editor end - def switch_editor2(target_revision, target, switch_url, - use_commit_times=true, depth=nil, - allow_unver_obstruction=false, diff3_cmd=nil, - notify_func=nil, cancel_func=nil, traversal_info=nil, - preserved_exts=nil) - preserved_exts ||= [] - traversal_info ||= _traversal_info + def switch_editor2(target_revision, target, switch_url, options={}) + defaults = { + :use_commit_times => true, + :depth => nil, + :allow_unver_obstruction => false, + :diff3_cmd => nil, + :notify_func => nil, + :cancel_func => nil, + :traversal_info => _traversal_info, + :preserved_exts => [] } + actuals = validate_options(defaults, options) + # TODO(rb support conflict_fun): implement support for the # conflict_func callback. - conflict_func=nil + actuals[:conflict_func]=nil + results = Wc.get_switch_editor3(target_revision, self, target, - switch_url, use_commit_times, depth, - allow_unver_obstruction, - notify_func, cancel_func, - conflict_func, - diff3_cmd, preserved_exts, - traversal_info) + switch_url, + actuals[:use_commit_times], + actuals[:depth], + actuals[:allow_unver_obstruction], + actuals[:notify_func], + actuals[:cancel_func], + actuals[:conflict_func], + actuals[:diff3_cmd], + actuals[:preserved_exts], + actuals[:traversal_info]) target_revision_address, editor, editor_baton = results editor.__send__(:target_revision_address=, target_revision_address) editor.baton = editor_baton @@ -496,6 +518,14 @@ def _traversal_info @traversal_info ||= nil end + + def validate_options(valid_options, passed_options) + unknown_keys = passed_options.keys - valid_options.keys + unless unknown_keys.empty? + raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") + end + valid_options.merge(passed_options) + end end class DiffCallbacksWrapper