[[[ (svn_io_file_rename)
 Work around Windows Samba issue where renaming a read-only
 file fails with "access denied" error
]]]
Index: io.c
===================================================================
--- io.c	(revision 33277)
+++ io.c	(working copy)
@@ -2835,7 +2835,27 @@
   return SVN_NO_ERROR;
 }
 
+  /* file_chk_readonly_rename() is called from within the 
+	 WIN32_RETRY_LOOP macro and fixes an issue with access denied 
+	 errors. Access denied errors can be caused by a read only file 
+	 on a Samba share. In this case setting the file to read/write 
+	 allows the rename to succeed. We should really put the file back 
+	 to read-only if it was read-only, but thats a lot of extra work.
+  */
+#ifdef WIN32
+static apr_status_t 
+file_chk_readonly_rename(const char *from_path_apr, 
+						 const char *to_path_apr,
+						 apr_status_t last_status,
+						 apr_pool_t *pool )
+{
+  if(APR_TO_OS_ERROR(last_status) == ERROR_ACCESS_DENIED)
+	apr_file_attrs_set(from_path_apr,0,APR_FILE_ATTR_READONLY,pool);
+  return apr_file_rename(from_path_apr, to_path_apr, pool);
+}
+#endif
 
+
 svn_error_t *
 svn_io_file_rename(const char *from_path, const char *to_path,
                    apr_pool_t *pool)
@@ -2853,9 +2873,10 @@
   SVN_ERR(svn_path_cstring_from_utf8(&to_path_apr, to_path, pool));
 
   status = apr_file_rename(from_path_apr, to_path_apr, pool);
-  WIN32_RETRY_LOOP(status,
-                   apr_file_rename(from_path_apr, to_path_apr, pool));
+  WIN32_RETRY_LOOP(status, 
+	file_chk_readonly_rename(from_path_apr, to_path_apr, status, pool));
 
+
   if (status)
     return svn_error_wrap_apr(status, _("Can't move '%s' to '%s'"),
                               svn_path_local_style(from_path, pool),
