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

Re: [PATCH]Issue #1776 (v2) - Create parent directories with 'svn mkdir'

From: S.Ramaswamy <ramaswamy_at_collab.net>
Date: 2005-03-23 12:17:41 CET

On Mon, 2005-03-21 at 23:54 +0000, Philip Martin wrote:
> "S.Ramaswamy" <ramaswamy@collab.net> writes:
>
> > +/* Set 'existing_url' to the portion of 'url' that exists, and 'new_path'
> > + to the non-existent portion of the 'url'*/
> > +static svn_error_t *
> > +svn_client__url_paths (const char **existing_url,
> > + const char **new_path,
> > + const char *url,
> > + svn_client_ctx_t *ctx,
> > + apr_pool_t *pool)
> > +{
> > + svn_ra_session_t *ra_session;
> > + svn_node_kind_t kind;
> > + const char *dir;
> > + const char *base;
> > + const char *pcommon;
> > + apr_array_header_t *new_paths;
> > + apr_array_header_t *temp_paths = apr_array_make (pool, 2,
> > + sizeof(const char*));
> > + apr_pool_t *subpool;
> >
> > + subpool = svn_pool_create (pool);
> > + APR_ARRAY_PUSH (temp_paths, const char *) = url;
> > +
> > + do
> > + {
> > + svn_pool_clear (subpool);
> > + if (ctx->cancel_func)
> > + SVN_ERR (ctx->cancel_func (ctx->cancel_baton));
> > +
> > + SVN_ERR (svn_client__open_ra_session (&ra_session, url, NULL,
> > + NULL, NULL, FALSE, TRUE,
> > + ctx, subpool));
> > + SVN_ERR (svn_ra_check_path (ra_session, "", SVN_INVALID_REVNUM,
> > + &kind, subpool));
> > + if (kind == svn_node_none)
> > + {
> > + svn_path_split (url, &dir, &base, pool);
> > + url = dir;
> > + }
> > + } while (kind == svn_node_none);
> > +
> > + if (kind == svn_node_dir)
> > + {
> > + *existing_url = apr_pstrdup (pool, url);
> > + if (url == APR_ARRAY_IDX (temp_paths, 0, const char*))
> > + {
> > + *new_path = NULL;
> > + }
> > + else
> > + {
> > + APR_ARRAY_PUSH (temp_paths, const char *) = *existing_url;
> > + SVN_ERR (svn_path_condense_targets (&pcommon, &new_paths,
> > + temp_paths, FALSE, pool));
> > + *new_path = APR_ARRAY_IDX (new_paths, 0, const char *);
> > + }
> > + }
> > + svn_pool_destroy (subpool);
> > +
> > + return SVN_NO_ERROR;
> > +}
>
> Calling svn_path_condense_targets still looks like a mistake.

I just found out that calling svn_path_is_child(path1, path2, ...)
returns the difference between the two paths. This is much easier than
using svn_path_condense_targets().

> I still
> think you should reuse the import code if possible, moving it into a
> common function. The import code builds an apr_array_t rather which
> looks to be better than your new_path, since you end up having to
> decompose it.
>

ok. I realized that once I started looking at adding the "--parents"
option to repos_to_repos_copy() - there were lots of similarities. The
code in svn_client_import calls get_ra_editor with a do-while and then
reverses the apr_array of new paths. This could be combined into a
separate function that import, mkdir, copy and move, share. Let me know
if there are any better ways of doing this.

Thanks
Ramaswamy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 23 12:22:38 2005

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.