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

Re: Javahl mkdir use

From: Mark Phippard <markphip_at_gmail.com>
Date: 2007-11-12 16:36:59 CET

On 11/12/07, Gonzalez Diaz, Xoan <G2485@caixagalicia.es> wrote:
>
>
>
>
> I'm trying to integrate Subversion with the project management software of one of our clients.
>
> One of the actions to implement is to create a template of directories inside the repository, with a predefined layout (to all new projects). This is done when a project begins.
>
> So, I am using mkdir (SVNClient, javahl). If I try to create a given directory, with parent directories that don't exist, an exception is thrown. I guess this is normal behaviour of function.
>
> But browsing the trunk I noticed that is being implemented the complementary behaviour: create automatically all parent directories.
>
>
>
> Until 1.5 arrives I have to implement this behaviour by hand.
>
>
>
> Given a list of paths, for example:
>
> Trunk/App1/countrycode/organization/app/module
>
> Trunk/doc/countrycode/organization/app/module
>
> Trunk/dist/jars
>
>
>
> I would have to create :
>
> -Trunk
>
> -Trunk/App1
>
> -Trunk/App1/countrycode
>
> -Trunk/App1/countrycode/organization
>
>
>
> ...and so on
>
>
>
> Is there another way more optimal than checking if a directory exists and create if not?
>
> If there is not such way, how can I ask if a directory exists in the repository (especifying an url)?

We had a similar need in Subclipse. This is how we implemented it in
svnClientAdapter library:

    public void mkdir(SVNUrl url, boolean makeParents, String message)
            throws SVNClientException {
        if (makeParents) {
            SVNUrl parent = url.getParent();
            if (parent != null) {
                        ISVNInfo info = null;
                        try {
                            info = this.getInfo(parent);
                        } catch (SVNClientException e) {
                        }
                        if (info == null)
                            this.mkdir(parent, makeParents, message);
            }
        }
        this.mkdir(url, message);
    }

The svnClientAdapter code is just slightly different from JavaHL so it
should be easy enough to convert the idea being used.

-- 
Thanks
Mark Phippard
http://markphip.blogspot.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Nov 12 16:37:25 2007

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.