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

Re: svn commit: r22426 - branches/multiple-moves/subversion/libsvn_client

From: Ivan Zhakov <chemodax_at_gmail.com>
Date: 2006-11-24 22:51:20 CET

On 11/25/06, hwright@tigris.org <hwright@tigris.org> wrote:
> Author: hwright
> Date: Fri Nov 24 13:27:07 2006
> New Revision: 22426
>
> Log:
> Allow setup_copy() to accept multiple source arguments. If there is one
> src_path, copy src_path to dst_path. If there is more than one src_path, then
> copy all the src_paths as children of the dst_path. Checks to make sure all
> the source paths are either all working copy paths or all repository URLs.
>
> Also, introduce the concept of a copy_pair, which is a convenience structure
> used to hold information about a particular src and dst pair.
>
> With this patch, we still pass only one source and destination to each of the
> *_copy functions, and the client commands still work on only the first and last
> arguments. It does set us up for implementing multiple moves and copies in the
> *_copy functions, though.
>
> * subversion/libsvn_client/copy.c
> (setup_copy): Change src_path arg from a single string to an array of strings.
> Declare a couple of strings to hold the first src and dst, and update the
> calls to the *_copy functions to use these strings.
> (svn_client_copy3, svn_client_copy_into, svn_client_move4, svn_client_move,
> svn_client_move_into): Update call to setup_copy to use an array for
> src_paths.
>
> * subversion/libsvn_client/client.h
> (copy_pair): New.
>
>
> Modified:
> branches/multiple-moves/subversion/libsvn_client/client.h
> branches/multiple-moves/subversion/libsvn_client/copy.c
>

> Modified: branches/multiple-moves/subversion/libsvn_client/copy.c
> URL: http://svn.collab.net/viewvc/svn/branches/multiple-moves/subversion/libsvn_client/copy.c?pathrev=22426&r1=22425&r2=22426
> ==============================================================================
> --- branches/multiple-moves/subversion/libsvn_client/copy.c (original)
> +++ branches/multiple-moves/subversion/libsvn_client/copy.c Fri Nov 24 13:27:07 2006
> @@ -30,6 +30,7 @@
> #include "svn_path.h"
> #include "svn_opt.h"
> #include "svn_time.h"
> +#include "svn_pools.h"
>
> #include "client.h"
>
> @@ -930,37 +931,107 @@
>
> static svn_error_t *
> setup_copy(svn_commit_info_t **commit_info_p,
> - const char *src_path,
> + const apr_array_header_t *src_paths,
> const svn_opt_revision_t *src_revision,
> - const char *dst_path,
> + const char *dst_path_in,
> svn_boolean_t is_move,
> svn_boolean_t force,
> svn_client_ctx_t *ctx,
> apr_pool_t *pool)
> {
> - svn_boolean_t src_is_url, dst_is_url;
> + apr_pool_t *subpool;
> + apr_array_header_t *copy_pairs = apr_array_make(pool, src_paths->nelts,
> + sizeof(struct copy_pair *));
> + svn_boolean_t srcs_are_urls, dst_is_url;
> + const char *src, *dst;
> + int i;
> +
> + /* Are either of our paths URLs?
> + * Just check the first src_path. If there are more than one, we'll check
> + * for homogeneity amoung them down below. */
> + srcs_are_urls = svn_path_is_url(((const char **) (src_paths->elts))[0]);
(some paranoia) Is it guaranteed that src_paths has at least one element?

> + dst_is_url = svn_path_is_url(dst_path_in);
> +
> + /* If we have multiple source paths, it implies the dst_path is a directory
> + * we are moving or copying into. Populate the dst_paths array to contain
> + * a destination path for each of the source paths. */
> + if (src_paths->nelts > 1)
> + {
> + subpool = svn_pool_create(pool);
>
> - /* Are either of our paths URLs? */
> - src_is_url = svn_path_is_url(src_path);
> - dst_is_url = svn_path_is_url(dst_path);
> -
> - if (!src_is_url && !dst_is_url
> - && svn_path_is_child(src_path, dst_path, pool))
> - return svn_error_createf
> - (SVN_ERR_UNSUPPORTED_FEATURE, NULL,
> - _("Cannot copy path '%s' into its own child '%s'"),
> - svn_path_local_style(src_path, pool),
> - svn_path_local_style(dst_path, pool));
> + for ( i = 0; i < src_paths->nelts; i++)
> + {
> + const char *src_path = ((const char **) (src_paths->elts))[i];
> + const char *src_basename;
> + copy_pair *pair = apr_palloc(pool, sizeof(*pair));
> + svn_boolean_t src_is_url;
> +
> + svn_pool_clear(subpool);
> + src_basename = svn_path_basename(src_path, subpool);
> +
> + /* Check to see if all the sources are urls or all working copy
> + * paths. */
> + src_is_url = svn_path_is_url(src_path);
> + if (src_is_url != srcs_are_urls)
For me is better to rewrite it with temporary variable, because it
mixes with srcs_are_urls. Just write:
if (svn_path_is_url(src_path) != srcs_are_urls)

-- 
Ivan Zhakov
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Nov 24 22:51:34 2006

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