Just use svn_io_file_move() instead of all this.
On Fri, Sep 18, 2009 at 08:02, Stefan Sperling <stsp_at_elego.de> wrote:
> Author: stsp
> Date: Fri Sep 18 05:02:07 2009
> New Revision: 39430
>
> Log:
> * subversion/libsvn_client/patch.c
> (apply_one_patch): If renaming the patched result on top of the target
> file fails, try copy+delete before giving up.
>
> Modified:
> trunk/subversion/libsvn_client/patch.c
>
> Modified: trunk/subversion/libsvn_client/patch.c
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_client/patch.c?pathrev=39430&r1=39429&r2=39430
> ==============================================================================
> --- trunk/subversion/libsvn_client/patch.c Fri Sep 18 04:44:22 2009 (r39429)
> +++ trunk/subversion/libsvn_client/patch.c Fri Sep 18 05:02:07 2009 (r39430)
> @@ -1010,10 +1010,24 @@ apply_one_patch(svn_patch_t *patch, cons
> }
> else
> {
> + svn_error_t *err;
> +
> /* Install patched temporary file over working file.
> * ### Should this rather be done in a loggy fashion? */
> - SVN_ERR(svn_io_file_rename(target->result_path,
> - target->abs_path, pool));
> + err = svn_io_file_rename(target->result_path,
> + target->abs_path, pool);
> + if (err)
> + {
> + /* Renaming failed, try to copy+delete instead.
> + * We may have attempted a cross-device rename. */
> + svn_error_clear(err);
> + SVN_ERR(svn_io_copy_file(target->result_path,
> + target->abs_path, FALSE,
> + pool));
> + SVN_ERR(svn_io_remove_file2(target->result_path,
> + FALSE, pool));
> + }
> +
> if (target->executable)
> SVN_ERR(svn_io_set_file_executable(target->abs_path,
> TRUE, FALSE, pool));
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=2396389
>
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2396586
Received on 2009-09-18 21:14:06 CEST