Re: SVN API: Identify repositories on server filesystem

2021-11-16 Thread Stefan Sperling
On Tue, Nov 16, 2021 at 03:38:11PM +, Jens Restemeier wrote:
> Hi Stefan,
> No, I hadn't seen that page.
> 
> Is the repository automatically closed when the pool gets released, or is 
> there a function I need to call to release any locks/resources allocated when 
> opening it?
> 

Yes, this is handled via pools. The pool that you pass in should not be
cleared or destroyed while the repository data structure is in use.


RE: SVN API: Identify repositories on server filesystem

2021-11-16 Thread Jens Restemeier
Hi Stefan,
No, I hadn't seen that page.

Is the repository automatically closed when the pool gets released, or is there 
a function I need to call to release any locks/resources allocated when opening 
it?

Cheers,
Jens

-Original Message-
From: Stefan Sperling  
Sent: 15 November 2021 23:08
To: Jens Restemeier 
Cc: users@subversion.apache.org
Subject: Re: SVN API: Identify repositories on server filesystem

On Mon, Nov 15, 2021 at 07:05:35PM +, Jens Restemeier wrote:
> Hi,
> Not sure if this is a better dev or user question...
> Is there an official way to tell if a file path points to a svn repository in 
> the C API? I looked at the documentation, but it seem to require quite some 
> knowledge about the architecture, and it is sometimes hard to tell if 
> something is referring to a repository path or a host filesystem path.
> 
> I am on the server, and have access to the directory the repositories are 
> served from. I could obviously check if the directory contains "format", 
> "conf" or "db". I am linking against the svn libraries anyway, and I'd like a 
> future-proof method. Is there anything like svn_is_repository(path)? I could 
> try to open a path and see if I get an error?
> 
> Cheers,
> Jens
> 

Hi Jens,

In case you have not seen it yet, this page lists some things you may need to 
know in order to make sense of Subversion's code base:
https://subversion.apache.org/docs/community-guide/conventions.html

I guess the simplest thing you could do is call svn_repos_open() on a given 
path.

If your input path is not UTF-8 encoded then run it through
svn_utf_cstring_to_utf8() beforehand. Then you should run the resulting 
UTF-encoded path through svn_dirent_internal_style() in order to ensure that 
the path will be considered valid.
Code in subversion/svnadmin/svnadmin.c contains examples of this.

svn_open_repos() is declared in svn_repos.h and expects just a path and an APR 
pool as input. It should raise some sort of error if the path does not contain 
a repository. It is marked deprecated but it can be called regardless. Newer 
versions of this function only add more parameters you do not need, and this 
deprecated version will fill in suitable defaults for you.

/** Similar to svn_repos_open2() with @a fs_config set to NULL.
 *
 * @deprecated Provided for backward compatibility with 1.6 API.
 */
SVN_DEPRECATED
svn_error_t *
svn_repos_open(svn_repos_t **repos_p,
   const char *path,
   apr_pool_t *pool);


Re: SVN API: Identify repositories on server filesystem

2021-11-15 Thread Stefan Sperling
On Mon, Nov 15, 2021 at 07:05:35PM +, Jens Restemeier wrote:
> Hi,
> Not sure if this is a better dev or user question...
> Is there an official way to tell if a file path points to a svn repository in 
> the C API? I looked at the documentation, but it seem to require quite some 
> knowledge about the architecture, and it is sometimes hard to tell if 
> something is referring to a repository path or a host filesystem path.
> 
> I am on the server, and have access to the directory the repositories are 
> served from. I could obviously check if the directory contains "format", 
> "conf" or "db". I am linking against the svn libraries anyway, and I'd like a 
> future-proof method. Is there anything like svn_is_repository(path)? I could 
> try to open a path and see if I get an error?
> 
> Cheers,
> Jens
> 

Hi Jens,

In case you have not seen it yet, this page lists some things you may
need to know in order to make sense of Subversion's code base:
https://subversion.apache.org/docs/community-guide/conventions.html

I guess the simplest thing you could do is call svn_repos_open()
on a given path.

If your input path is not UTF-8 encoded then run it through
svn_utf_cstring_to_utf8() beforehand. Then you should run the
resulting UTF-encoded path through svn_dirent_internal_style()
in order to ensure that the path will be considered valid.
Code in subversion/svnadmin/svnadmin.c contains examples of this.

svn_open_repos() is declared in svn_repos.h and expects just a path
and an APR pool as input. It should raise some sort of error if
the path does not contain a repository. It is marked deprecated
but it can be called regardless. Newer versions of this function
only add more parameters you do not need, and this deprecated
version will fill in suitable defaults for you.

/** Similar to svn_repos_open2() with @a fs_config set to NULL.
 *
 * @deprecated Provided for backward compatibility with 1.6 API.
 */
SVN_DEPRECATED
svn_error_t *
svn_repos_open(svn_repos_t **repos_p,
   const char *path,
   apr_pool_t *pool);