You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "S.Ramaswamy" <ra...@collab.net> on 2005/03/13 17:58:46 UTC

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

Partial patch for Issue #1776 to make parent directories. The code changes
to introduce a new cmd line option - '-p|--parents', to make parent
directories in the working copy, and the related tests in the test suite
are from Stephen Oberholtzer. I am including it here to make it easier to
review the patch. My changes and test are for directly creating parent
directories in the repository.

Log :

* subversion/libsvn_client/add.c
    (svn_client_mkdir):
      Changed to defer to svn_client_mkdir2.

    (svn_client__mksubdir): New.
      Used by svn_client_mkdir2 to create and add directories.

    (svn_client_mkdir2): New, from svn_client_mkdir.

* subversion/clients/cmdline/mkdir-cmd.c
    (svn_cl__mkdir):
      Changed to call svn_client_mkdir2, passing in
      opt_state->parents.

* subversion/clients/cmdline/cl.h

    (svn_cl__opt_state_t):
      Added 'parents' member.

* subversion/clients/cmdline/main.c
    (svn_cl__options):
      Added 'parents' ('p') option.

    (svn_cl__cmd_table):
      Added 'p' option to "mkdir" command.

    (main):
      Added case for 'p'.

* subversion/tests/clients/cmdline/basic_tests.py
    (basic_mkdir_missing_parent): New.
      Tests 'svn mkdir foo/bar' with no foo,
      expects failure.

    (basic_mkdir_missing_parent_p): New.
      Tests 'svn mkdir -p foo/bar' with no foo,
      expects 'foo' and 'bar' to both be added.

    (basic_mkdir_wcpath): New.
      Tests 'svn mkdir foo foo/bar', like
      basic_mkdir_url but for the WC.

    (test_list): Inserted the three previously
      mention tests after the basic_mkdir_urls
      test.

* subversion/libsvn_client/add.c
  (mkdir_urls): Added boolean parameter - 'make_parents'to determine if
  parent directories should be created directly in the repository.
  'mkdir_urls' calls svn_client__url_paths to find the section of the
  url that exists and and the new path to be created. A common url and
  a list of targets are also determined to drive the delta path driver.

  (svn_client_mkdir2): Call mkdir_urls with new make_parents parameter.

  (svn_client__url_paths): New function to find section of url that exists
  and the path to be created; called by mkdir_urls. Opens ra session to user
  specified url, and finds the existing section of the url and the path to
  be created.

* subversion/tests/clients/cmdline/basic_tests.py
  (basic_mkdir_url_p): New test to check making a parent directory
  directly in the repository.

  (test_list): Added 'basic_mkdir_url_p' to the list of tests.










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

Posted by Madan U Sreenivasan <ma...@collab.net>.
On Wed, 2005-03-16 at 13:47, S.Ramaswamy wrote:
> > Thanks for helping with this work.  These comments are about the issue
> > in  general, not specifically about the part that you wrote.
> >
> > S.Ramaswamy wrote:[...]
> Agreed, (a)wc->wc copy (b) wc->wc move (c) url->wc copy are done, since it
> only involves re-using a function introduced in the patch for 'svn mkdir
>  --parents'.
> 
> I will try to post a patch with changes to copy and move as well.
uh, oh... doesnt his conflict with Issue #2214 ?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by "S.Ramaswamy" <ra...@collab.net>.
> Thanks for helping with this work.  These comments are about the issue
> in  general, not specifically about the part that you wrote.
>
> S.Ramaswamy wrote:
>> Partial patch for Issue #1776 to make parent directories. The code
>> changes to introduce a new cmd line option - '-p|--parents', to make
>> parent
>
> I'm not sure that the short option name '-p' is deserved, since few of
> the svn  commands can use it.

Looks like you prefer the long option "--parents" to be the sole option for
creating parent directories. This could be changed in the next version of
the patch.

>
>> directories in the working copy, and the related tests in the test
>> suite are from Stephen Oberholtzer. I am including it here to make it
>> easier to review the patch. My changes and test are for directly
>> creating parent directories in the repository.
>>
>> Log :
>
> The log message(s) will need a summary, will need tidying up, and will
> need  completing (e.g. it doesn't mention the changes in svn_client.h).
>  I realise  that you have just pasted partial messages from the two
> patches in issue #1776  for us to have a quick look, and that you don't
> have much time for this now.  Perhaps Stephen Oberholtzer or somebody
> else can pick it up?
>
> As noted in the issue, the commands to which this is relevant and their
> current  behaviours are:
>   svn import        creates intermediate directories
>   svn mkdir         does not
>   svn copy          does not
>   svn move          does not
>
> These commands should all be able to create intermediate directories.
> It would  be nice to add the option to mkdir, copy and move
> simultaneously.  (This patch  only covers 'mkdir'.)

Agreed, (a)wc->wc copy (b) wc->wc move (c) url->wc copy are done, since it
only involves re-using a function introduced in the patch for 'svn mkdir
 --parents'.

I will try to post a patch with changes to copy and move as well.

Thanks
Ramaswamy






---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Julian Foad <ju...@btopenworld.com>.
Thanks for helping with this work.  These comments are about the issue in 
general, not specifically about the part that you wrote.

S.Ramaswamy wrote:
> Partial patch for Issue #1776 to make parent directories. The code changes
> to introduce a new cmd line option - '-p|--parents', to make parent

I'm not sure that the short option name '-p' is deserved, since few of the svn 
commands can use it.

> directories in the working copy, and the related tests in the test suite
> are from Stephen Oberholtzer. I am including it here to make it easier to
> review the patch. My changes and test are for directly creating parent
> directories in the repository.
> 
> Log :

The log message(s) will need a summary, will need tidying up, and will need 
completing (e.g. it doesn't mention the changes in svn_client.h).  I realise 
that you have just pasted partial messages from the two patches in issue #1776 
for us to have a quick look, and that you don't have much time for this now. 
Perhaps Stephen Oberholtzer or somebody else can pick it up?

As noted in the issue, the commands to which this is relevant and their current 
behaviours are:
   svn import        creates intermediate directories
   svn mkdir         does not
   svn copy          does not
   svn move          does not

These commands should all be able to create intermediate directories.  It would 
be nice to add the option to mkdir, copy and move simultaneously.  (This patch 
only covers 'mkdir'.)  It would also be nice if the same option was required in 
order for "import" to create directories, but it's too late to change that 
until we reach version 2.

I haven't reviewed any of the code.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by "S.Ramaswamy" <ra...@collab.net>.
On Mon, 2005-03-21 at 23:54 +0000, Philip Martin wrote:
> "S.Ramaswamy" <ra...@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

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

Posted by "C. Michael Pilato" <cm...@collab.net>.
Philip Martin <ph...@codematters.co.uk> writes:

> Calling svn_path_condense_targets still looks like a mistake.  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.

Agree.  It'd be nice if import, repos-to-repos copy, wc-to-repos-copy,
and mkdir could all share code.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Philip Martin <ph...@codematters.co.uk>.
"S.Ramaswamy" <ra...@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 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.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org