Re: Confusing error: "Cannot replace a directory from within"
From: David Glasser <glasser_at_mit.edu>
Date: 2007-05-10 04:30:29 CEST
On 5/9/07, David Glasser <glasser@mit.edu> wrote:
Karl, do you think the following patch is fixing the problem at the
--dave
-- David Glasser | glasser_at_mit.edu | http://www.davidglasser.net/ [[[ Provide a less cryptic error message when you try to "svn switch" to an URL that doesn't exist. * subversion/libsvn_client/switch.c (svn_client__switch_internal): Check to make sure that switch_url is actually a directory or file before going too far. ]]] === subversion/libsvn_client/switch.c ================================================================== --- subversion/libsvn_client/switch.c (revision 117906) +++ subversion/libsvn_client/switch.c (local) @@ -67,9 +67,10 @@ const svn_ra_reporter3_t *reporter; void *report_baton; const svn_wc_entry_t *entry; - const char *URL, *anchor, *target; + const char *URL, *anchor, *target, *source_root; svn_ra_session_t *ra_session; svn_revnum_t revnum; + svn_node_kind_t switch_url_kind; svn_error_t *err = SVN_NO_ERROR; svn_wc_adm_access_t *adm_access, *dir_access; const char *diff3_cmd; @@ -125,7 +126,32 @@ ctx, pool)); SVN_ERR(svn_client__get_revision_number (&revnum, ra_session, revision, path, pool)); + SVN_ERR(svn_ra_get_repos_root(ra_session, &source_root, pool)); + + /* Disallow a switch operation to change the repository root of the target. */ + if (! svn_path_is_ancestor(source_root, switch_url)) + return svn_error_createf + (SVN_ERR_WC_INVALID_SWITCH, NULL, + _("'%s'\n" + "is not the same repository as\n" + "'%s'"), switch_url, source_root); + /* Check to make sure that the switch target actually exists. */ + SVN_ERR(svn_ra_reparent(ra_session, source_root, pool)); + SVN_ERR(svn_ra_check_path(ra_session, + svn_path_is_child(source_root, switch_url, pool), + revnum, + &switch_url_kind, + pool)); + + if (switch_url_kind == svn_node_none) + return svn_error_createf + (SVN_ERR_WC_INVALID_SWITCH, NULL, + _("No such path '%s'"), switch_url); + + SVN_ERR(svn_ra_reparent(ra_session, URL, pool)); + + /* Fetch the switch (update) editor. If REVISION is invalid, that's okay; the RA driver will call editor->set_target_revision() later on. */ SVN_ERR(svn_wc_get_switch_editor3(&revnum, adm_access, target, --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org For additional commands, e-mail: dev-help@subversion.tigris.orgReceived on Thu May 10 04:31:15 2007 |
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.