[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] make svnmucc consistently log an error when copy targets exist

From: Kevin Radke <kmradke_at_gmail.com>
Date: Fri, 7 Nov 2008 16:30:40 -0600

svnmucc (over DAV) would allow an user to use "CP REV SRC DST" when both SRC
and DST URLs were directories. It would (silently) "replace" DST with SRC.
This appears to be a known bug with mod_dav_svn, but it has been open
since 2004. Hence this patch has svnmucc specifically check and log an error
if the target exists. This provides consistent operation over all
layers for both files and directories.

For example, this would work fine, even if tags/dira exists:
svnmucc CP HEAD http://server/repo/trunk/dira http://server/repo/tags/dira

This would fail if tags/dira exists:
svnmucc CP HEAD file:///path/repo/trunk/dira file:///path/repo/tags/dira

This simple patch makes it consistently log an error when the target
path exists.

This patch is similar (yet has the opposite operation) to my previous
patch which always overwrote the target. That behavior was deemed
unacceptable and this behavior was preferred. A separate patch
will be generated to allow a new default "overwrite" action.

svnmucc-tests.py successfully passes, but was not updated to include
new tests since it does not appear to support testing failure conditions.

Kevin R.

Consistently log an error when copy targets exist
* contrib/client-side/svnmucc/svnmucc.c
 (build): If copy target path exists log an error

Index: contrib/client-side/svnmucc/svnmucc.c
--- contrib/client-side/svnmucc/svnmucc.c (revision 34099)
+++ contrib/client-side/svnmucc/svnmucc.c (working copy)
@@ -480,6 +480,27 @@
                                 "than base revision");
       operation->operation =
         operation->operation == OP_DELETE ? OP_REPLACE : OP_ADD;
+ if (operation->operation == OP_ADD)
+ {
+ /* There is a bug in the current version of mod_dav_svn
+ which incorrectly replaces existing directories.
+ Therefore we need to check if the target exists
+ and raise an error here. */
+ SVN_ERR(svn_ra_check_path(session,
+ copy_src ? copy_src : path,
+ copy_src ? copy_rev : head,
+ &operation->kind, pool));
+ if (operation->kind != svn_node_none)
+ {
+ if (copy_src && strcmp(path, copy_src))
+ return svn_error_createf(SVN_ERR_BAD_URL, NULL,
+ "'%s' (from '%s:%ld') already exists",
+ path, copy_src, copy_rev);
+ else
+ return svn_error_createf(SVN_ERR_BAD_URL, NULL,
+ "'%s' already exists", path);
+ }
+ }
       SVN_ERR(svn_ra_check_path(session, subtract_anchor(anchor, url, pool),
                                 rev, &operation->kind, pool));
       if (operation->kind == svn_node_none)

To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-11-08 02:51:53 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.