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

Re: svnadmin create complains about subrepositories

From: Stefan Sperling <stsp_at_elego.de>
Date: Sat, 12 Feb 2011 17:50:48 +0100

On Sat, Feb 12, 2011 at 05:31:50PM +0200, Daniel Shahaf wrote:
> Stefan Sperling wrote on Sat, Feb 12, 2011 at 13:59:16 +0100:
> > What I am saying is that the following should error out:
> > $ svnadmin create repos
> > $ cd repos/db
> > $ svnadmin create repos
> > $
>
> Oh, sorry, Stefan. I missed that it doesn't error when the cwd is
> repos/db. (When the cwd is elsewhere it does error.)

My (admittedly light) testing shows that the check only works in the
top-level directory of a repos. E.g. repos/hook has the same problem
as does repos/db in my example. So does repos/db/revs etc.

> The fix is to convert PATH (a dirent) to an absolute path before passing
> it in svn_repos_create() to svn_repos_find_root_path(). If someone
> could remind me what the APR wrapper for os.path.abspath() is, I'll
> commit a fix.

Ah, thanks for the hint! This seems to fix it:

[[[
* subversion/libsvn_repos/repos.c
  (svn_repos-create): Prevent repository creation within all subdirectories
   of a repository, not just within the top-level one.
   While here, show absolute paths in error messages, and send a less
   confusing error message when the user tries to create a repository
   at the location of an existing repository.
]]]

Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c (revision 1070107)
+++ subversion/libsvn_repos/repos.c (working copy)
@@ -1369,6 +1369,7 @@ svn_repos_create(svn_repos_t **repos_p,
   svn_repos_t *repos;
   svn_error_t *err;
   const char *root_path;
+ const char *local_abspath;
 
   /* Allocate a repository object, filling in the format we will create. */
   repos = create_svn_repos_t(path, pool);
@@ -1388,13 +1389,21 @@ svn_repos_create(svn_repos_t **repos_p,
     repos->fs_type = DEFAULT_FS_TYPE;
 
   /* Don't create a repository inside another repository. */
- root_path = svn_repos_find_root_path(path, pool);
+ SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+ root_path = svn_repos_find_root_path(local_abspath, pool);
   if (root_path != NULL)
- return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL, _("'%s' is a "
- "subdirectory of an existing repository rooted "
- "at '%s'"),
- svn_dirent_local_style(path, pool),
- svn_dirent_local_style(root_path, pool));
+ {
+ if (strcmp(root_path, local_abspath) == 0)
+ return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL,
+ _("'%s' is an existing repository"),
+ svn_dirent_local_style(root_path, pool));
+ else
+ return svn_error_createf(SVN_ERR_REPOS_BAD_ARGS, NULL,
+ _("'%s' is a subdirectory of an existing "
+ "repository " "rooted at '%s'"),
+ svn_dirent_local_style(local_abspath, pool),
+ svn_dirent_local_style(root_path, pool));
+ }
 
   /* Create the various files and subdirectories for the repository. */
   SVN_ERR_W(create_repos_structure(repos, path, fs_config, pool),
Received on 2011-02-12 17:51:37 CET

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

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