On 10/05/2012 09:29 AM, Bert Huijben wrote: > Currently this function fails with an error when called on the working copy > root, with and without force set to TRUE. > (Probably because we originally handled force to suppress some light errors, > while we can't add a working copy root to its parent) > > Maybe we should fix this as well if we are touching this code anyway?
Gonna kick off some tests of the attached patch while I run to lunch. Care to review in the meantime? -- C. Michael Pilato <[email protected]> CollabNet <> www.collab.net <> Enterprise Cloud Development
Make 'svn add --force /path/to/wc-root' work as expected.
* subversion/libsvn_client/add.c
(svn_client_add4): Check the to-be-added path to see if it's a
working copy root. If so, we know it's under version control so
--force is required to go further. We also know that we can't get
a WC lock on its parent, so adjust our locking parameters
accordingly.
Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c (revision 1394552)
+++ subversion/libsvn_client/add.c (working copy)
@@ -671,6 +671,7 @@
const char *parent_abspath;
const char *local_abspath;
const char *existing_parent_abspath;
+ svn_boolean_t is_wc_root;
if (svn_path_is_url(path))
return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
@@ -678,6 +679,17 @@
SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+ /* See if we're being asked to add a wc-root. That's typically not
+ okay, unless we're in "force" mode. */
+ SVN_ERR(svn_wc_is_wc_root2(&is_wc_root, ctx->wc_ctx,
+ local_abspath, pool));
+ if (is_wc_root && (! force))
+ {
+ return svn_error_createf(SVN_ERR_ENTRY_EXISTS, NULL,
+ _("'%s' is already under version control"),
+ svn_dirent_local_style(local_abspath, pool));
+ }
+
/* ### this is a hack.
### before we switched to absolute paths, if a user tried to do
### 'svn add .', PATH would be "" and PARENT_PATH would also be "",
@@ -708,7 +720,9 @@
add(local_abspath, depth, force, no_ignore, existing_parent_abspath,
ctx, pool),
ctx->wc_ctx,
- existing_parent_abspath ? existing_parent_abspath : parent_abspath,
+ is_wc_root ? local_abspath
+ : (existing_parent_abspath ? existing_parent_abspath
+ : parent_abspath),
FALSE /* lock_anchor */, pool);
return SVN_NO_ERROR;
}
signature.asc
Description: OpenPGP digital signature

