[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-cvs
Subject:    svn commit: r15513 - in trunk/subversion/bindings/swig/ruby: svn
From:       kou () tigris ! org
Date:       2005-07-31 5:54:26
Message-ID: 200507310554.j6V5sQb15500 () morbius ! ch ! collab ! net
[Download RAW message or body]

Author: kou
Date: Sun Jul 31 00:54:23 2005
New Revision: 15513

Modified:
   trunk/subversion/bindings/swig/ruby/svn/client.rb
   trunk/subversion/bindings/swig/ruby/test/test_client.rb
   trunk/subversion/bindings/swig/ruby/test/util.rb

Log:
Add some methods related revprop to Svn::Client::Context.

* subversion/bindings/swig/ruby/test/util.rb
  (SvnTestUtil#setup_basic):  Initialize hook.
  (SvnTestUtil#add_hook,
   SvnTestUtil#add_pre_revprop_change_hook): New method.
  (SvnTestUtil#make_context): Set default user.

* subversion/bindings/swig/ruby/test/test_client.rb
  (SvnClientTest#test_revprop): New test.
   SvnClientTest#test_username_provider): Add test for
  svn_client_get_username_prompt_provider().

* subversion/bindings/swig/ruby/svn/client.rb
  (Svn::Client::Context#revprop,
   Svn::Client::Context#revprop_get,
   Svn::Client::Context#revprop_set,
   Svn::Client::Context#revprop_del): New method.


Modified: trunk/subversion/bindings/swig/ruby/svn/client.rb
Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/bindings/swig/ruby/svn/client. \
rb?rev=15513&p1=trunk/subversion/bindings/swig/ruby/svn/client.rb&p2=trunk/subversion/bindings/swig/ruby/svn/client.rb&r1=15512&r2=15513
 ==============================================================================
--- trunk/subversion/bindings/swig/ruby/svn/client.rb	(original)
+++ trunk/subversion/bindings/swig/ruby/svn/client.rb	Sun Jul 31 00:54:23 2005
@@ -183,6 +183,28 @@
         end
       end
 
+      def revprop(name, uri, rev)
+        value, = revprop_get(name, uri, rev)
+        value
+      end
+      
+      def revprop_get(name, uri, rev)
+        result = Client.revprop_get(name, uri, rev, self)
+        if result.is_a?(Array)
+          result
+        else
+          [nil, result]
+        end
+      end
+      
+      def revprop_set(name, value, uri, rev, force=false)
+        Client.revprop_set(name, value, uri, rev, force, self)
+      end
+      
+      def revprop_del(name, uri, rev, force=false)
+        Client.revprop_set(name, nil, uri, rev, force, self)
+      end
+      
       def add_simple_provider
         add_provider(Client.get_simple_provider)
       end

Modified: trunk/subversion/bindings/swig/ruby/test/test_client.rb
Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/bindings/swig/ruby/test/test_c \
lient.rb?rev=15513&p1=trunk/subversion/bindings/swig/ruby/test/test_client.rb&p2=trunk/subversion/bindings/swig/ruby/test/test_client.rb&r1=15512&r2=15513
 ==============================================================================
--- trunk/subversion/bindings/swig/ruby/test/test_client.rb	(original)
+++ trunk/subversion/bindings/swig/ruby/test/test_client.rb	Sun Jul 31 00:54:23 2005
@@ -158,6 +158,47 @@
     assert_equal(src2, ctx.cat(path))
   end
 
+  def test_revprop
+    log = "sample log"
+    new_log = "new sample log"
+    src = "source\n"
+    file = "sample.txt"
+    path = File.join(@wc_path, file)
+
+    File.open(path, "w") {|f| f.print(src)}
+
+    ctx = make_context(log)
+    ctx.add(path)
+    info = ctx.commit(@wc_path)
+
+    assert_equal([log, info.revision],
+                 ctx.revprop_get(Svn::Core::PROP_REVISION_LOG,
+                                 @repos_uri, info.revision))
+    assert_equal(log,
+                 ctx.revprop(Svn::Core::PROP_REVISION_LOG,
+                             @repos_uri, info.revision))
+
+    assert_equal(info.revision,
+                 ctx.revprop_set(Svn::Core::PROP_REVISION_LOG, new_log,
+                                 @repos_uri, info.revision))
+    assert_equal([new_log, info.revision],
+                 ctx.revprop_get(Svn::Core::PROP_REVISION_LOG,
+                                 @repos_uri, info.revision))
+    assert_equal(new_log,
+                 ctx.revprop(Svn::Core::PROP_REVISION_LOG,
+                             @repos_uri, info.revision))
+
+    assert_equal(info.revision,
+                 ctx.revprop_del(Svn::Core::PROP_REVISION_LOG,
+                                 @repos_uri, info.revision))
+    assert_equal([nil, info.revision],
+                 ctx.revprop_get(Svn::Core::PROP_REVISION_LOG,
+                                 @repos_uri, info.revision))
+    assert_equal(nil,
+                 ctx.revprop(Svn::Core::PROP_REVISION_LOG,
+                             @repos_uri, info.revision))
+  end
+  
   def test_authentication
     log = "sample log"
     src = "source\n"
@@ -242,22 +283,53 @@
   
   def test_username_provider
     log = "sample log"
+    new_log = "sample new log"
     src = "source\n"
     file = "sample.txt"
     path = File.join(@wc_path, file)
+    repos_uri = "#{@repos_uri}/#{file}"
 
     File.open(path, "w") {|f| f.print(src)}
 
-    ctx = Svn::Client::Context.new
+    ctx = make_context(log)
     ctx.add(path)
+    info = ctx.commit(@wc_path)
 
-    assert_raises(Svn::Error::AUTHN_NO_PROVIDER) do
-      ctx.commit(@wc_path)
+    ctx = Svn::Client::Context.new
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_CONFIG_DIR] = @config_path
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_USERNAME] = @author
+    ctx.add_username_provider
+    assert_nothing_raised do
+      ctx.revprop_set(Svn::Core::PROP_REVISION_LOG, new_log,
+                      repos_uri, info.revision)
     end
-    
+
+    ctx = Svn::Client::Context.new
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_CONFIG_DIR] = @config_path
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_USERNAME] = "#{@author}-NG"
     ctx.add_username_provider
+    assert_raise(Svn::Error::REPOS_HOOK_FAILURE) do
+      ctx.revprop_set(Svn::Core::PROP_REVISION_LOG, new_log,
+                      repos_uri, info.revision)
+    end
+
+    ctx = Svn::Client::Context.new
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_CONFIG_DIR] = @config_path
+    ctx.add_username_prompt_provider(0) do |cred, realm, may_save|
+    end
+    assert_raise(Svn::Error::REPOS_HOOK_FAILURE) do
+      ctx.revprop_set(Svn::Core::PROP_REVISION_LOG, new_log,
+                      repos_uri, info.revision)
+    end
+
+    ctx = Svn::Client::Context.new
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_CONFIG_DIR] = @config_path
+    ctx.add_username_prompt_provider(0) do |cred, realm, may_save|
+      cred.username = @author
+    end
     assert_nothing_raised do
-      ctx.commit(@wc_path)
+      ctx.revprop_set(Svn::Core::PROP_REVISION_LOG, new_log,
+                      repos_uri, info.revision)
     end
   end
   

Modified: trunk/subversion/bindings/swig/ruby/test/util.rb
Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/bindings/swig/ruby/test/util.r \
b?rev=15513&p1=trunk/subversion/bindings/swig/ruby/test/util.rb&p2=trunk/subversion/bindings/swig/ruby/test/util.rb&r1=15512&r2=15513
 ==============================================================================
--- trunk/subversion/bindings/swig/ruby/test/util.rb	(original)
+++ trunk/subversion/bindings/swig/ruby/test/util.rb	Sun Jul 31 00:54:23 2005
@@ -18,6 +18,7 @@
     @config_path = File.join("test", "config")
     setup_repository
     @repos = Svn::Repos.open(@repos_path)
+    add_hooks
     @fs = @repos.fs
     setup_svnserve
     setup_config
@@ -116,6 +117,30 @@
       PASSWD
     end
   end
+
+  def add_hooks
+    add_pre_revprop_change_hook
+  end
+
+  def add_pre_revprop_change_hook
+    File.open(@repos.pre_revprop_change_hook, "w") do |hook|
+      hook.print <<-HOOK
+#!/bin/sh
+REPOS="$1"
+REV="$2"
+USER="$3"
+PROPNAME="$4"
+
+if [ "$PROPNAME" = "#{Svn::Core::PROP_REVISION_LOG}" -a \
+     "$USER" = "#{@author}" ]; then
+  exit 0
+fi
+
+exit 1
+      HOOK
+    end
+    FileUtils.chmod(0755, @repos.pre_revprop_change_hook)
+  end
   
   def youngest_rev
     @fs.youngest_rev
@@ -139,6 +164,7 @@
       cred.may_save = false
     end
     ctx.auth_baton[Svn::Core::AUTH_PARAM_CONFIG_DIR] = @config_path
+    ctx.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_USERNAME] = @author
     ctx
   end
   

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic