subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1135651 - in /subversion/trunk/subversion: libsvn_ra_neon/lock.c tests/cmdline/lock_tests.py
Date Tue, 14 Jun 2011 15:39:58 GMT
Author: philip
Date: Tue Jun 14 15:39:58 2011
New Revision: 1135651

URL: http://svn.apache.org/viewvc?rev=1135651&view=rev
Log:
With ra_neon unlocking a file would succeed on the client side
even if the pre-unlock hook prevents the unlock.  Fix to make sure
failed unlock error is always returned to the user.

* subversion/libsvn_ra_neon/lock.c
  (do_unlock): Always return any error.

* subversion/tests/cmdline/lock_tests.py
  (block_unlock_if_pre_unlock_hook_fails): New test.
  (test_list): Add block_unlock_if_pre_unlock_hook_fails to the list.

Patch by: Vijayaguru G <vijay{_AT_}collab.net>

Modified:
    subversion/trunk/subversion/libsvn_ra_neon/lock.c
    subversion/trunk/subversion/tests/cmdline/lock_tests.py

Modified: subversion/trunk/subversion/libsvn_ra_neon/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_neon/lock.c?rev=1135651&r1=1135650&r2=1135651&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_neon/lock.c (original)
+++ subversion/trunk/subversion/libsvn_ra_neon/lock.c Tue Jun 14 15:39:58 2011
@@ -399,6 +399,7 @@ do_unlock(svn_ra_session_t *session,
   const char *url;
   const char *url_path;
   ne_uri uri;
+  svn_error_t *err = SVN_NO_ERROR;
 
   apr_hash_t *extra_headers = apr_hash_make(pool);
 
@@ -441,7 +442,6 @@ do_unlock(svn_ra_session_t *session,
 
   {
     int code = 0;
-    svn_error_t *err;
 
     err = svn_ra_neon__simple_request(&code, ras, "UNLOCK", url_path,
                                       extra_headers, NULL, 204, 0, pool);
@@ -460,13 +460,11 @@ do_unlock(svn_ra_session_t *session,
                                        _("No lock on path '%s'"
                                          " (%d Bad Request)"), path, code);
             default:
-              break; /* Handle as error */
+              break;
           }
       }
-    else
-      SVN_ERR(err);
   }
-  return SVN_NO_ERROR;
+  return svn_error_return(err);
 }
 
 

Modified: subversion/trunk/subversion/tests/cmdline/lock_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/lock_tests.py?rev=1135651&r1=1135650&r2=1135651&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/lock_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/lock_tests.py Tue Jun 14 15:39:58 2011
@@ -1693,6 +1693,33 @@ def update_locked_deleted(sbox):
                                         None, expected_status)
 
 
+#----------------------------------------------------------------------
+def block_unlock_if_pre_unlock_hook_fails(sbox):
+  "block unlock operation if pre-unlock hook fails"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  repo_dir = sbox.repo_dir
+
+  svntest.actions.create_failing_hook(repo_dir, "pre-unlock", "error text")
+
+  # lock a file.
+  pi_path = os.path.join(wc_dir, 'A', 'D', 'G', 'pi')
+  expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+  expected_status.tweak('A/D/G/pi', writelocked='K')
+
+  svntest.actions.run_and_verify_svn(None, ".*locked by user", [], 'lock',
+                                     '-m', '', pi_path)
+
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+  # Make sure the unlock operation fails as pre-unlock hook blocks it.
+  expected_unlock_fail_err_re = ".*error text|.*500 Internal Server Error"
+  svntest.actions.run_and_verify_svn2(None, None, expected_unlock_fail_err_re,
+                                      1, 'unlock', pi_path)
+  svntest.actions.run_and_verify_status(wc_dir, expected_status)
+
+
 ########################################################################
 # Run the tests
 
@@ -1739,6 +1766,7 @@ test_list = [ None,
               replace_and_propset_locked_path,
               cp_isnt_ro,
               update_locked_deleted,
+              block_unlock_if_pre_unlock_hook_fails,
             ]
 
 if __name__ == '__main__':



Mime
View raw message