Author: julianfoad
Date: Thu Nov 22 14:06:09 2018
New Revision: 1847176

URL: http://svn.apache.org/viewvc?rev=1847176&view=rev
Log:
A small simplification of svn_client__copy_foreign.

Don't open a new RA session; let the caller provide one.

* subversion/include/private/svn_client_private.h,
  subversion/libsvn_client/copy_foreign.c
  (svn_client__copy_foreign): Take an RA session and a resolved location
    instead of a URL and peg and operative revisions.
  (copy_foreign_dir): Constify a parameter.

* subversion/libsvn_client/copy.c
  (svn_client__repos_to_wc_copy_dir): Adjust the call.

* subversion/tests/libsvn_client/client-test.c
  (test_foreign_repos_copy): Open an RA session and adjust the calls.

Modified:
    subversion/trunk/subversion/include/private/svn_client_private.h
    subversion/trunk/subversion/libsvn_client/copy.c
    subversion/trunk/subversion/libsvn_client/copy_foreign.c
    subversion/trunk/subversion/tests/libsvn_client/client-test.c

Modified: subversion/trunk/subversion/include/private/svn_client_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_client_private.h?rev=1847176&r1=1847175&r2=1847176&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_client_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_client_private.h Thu Nov 22 
14:06:09 2018
@@ -281,9 +281,8 @@ svn_client__wc_node_get_origin(svn_clien
                                apr_pool_t *result_pool,
                                apr_pool_t *scratch_pool);
 
-/* Copy the file or directory on URL in some repository to DST_ABSPATH,
- * copying node information and properties. Resolve URL using PEG_REV and
- * REVISION.
+/* Copy the file or directory at LOC to DST_ABSPATH,
+ * copying node information and properties.
  *
  * If URL specifies a directory, create the copy using depth DEPTH.
  *
@@ -292,14 +291,16 @@ svn_client__wc_node_get_origin(svn_clien
  *
  * The caller should be holding a WC write lock that allows DST_ABSPATH to
  * be created, such as on the parent of DST_ABSPATH.
+ *
+ * Use RA_SESSION to fetch the data. The session may point to a different
+ * URL after returning.
  */
 svn_error_t *
-svn_client__copy_foreign(const char *url,
+svn_client__copy_foreign(const svn_client__pathrev_t *loc,
                          const char *dst_abspath,
-                         const svn_opt_revision_t *peg_revision,
-                         const svn_opt_revision_t *revision,
                          svn_depth_t depth,
                          svn_boolean_t make_parents,
+                         svn_ra_session_t *ra_session,
                          svn_client_ctx_t *ctx,
                          apr_pool_t *scratch_pool);
 

Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1847176&r1=1847175&r2=1847176&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Nov 22 14:06:09 2018
@@ -2346,18 +2346,18 @@ svn_client__repos_to_wc_copy_dir(svn_boo
 
   if (!same_repositories)
     {
-      svn_opt_revision_t src_revision;
+      svn_client__pathrev_t *location;
 
       *timestamp_sleep = TRUE;
 
-      src_revision.kind = svn_opt_revision_number;
-      src_revision.value.number = src_revnum;
-      SVN_ERR(svn_client__copy_foreign(src_url,
+      SVN_ERR(svn_client__pathrev_create_with_session(&location, ra_session,
+                                                      src_revnum, src_url,
+                                                      scratch_pool));
+      SVN_ERR(svn_client__copy_foreign(location,
                                        dst_abspath,
-                                       &src_revision,
-                                       &src_revision,
                                        svn_depth_infinity,
                                        FALSE /* make_parents */,
+                                       ra_session,
                                        ctx, scratch_pool));
 
       return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_client/copy_foreign.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy_foreign.c?rev=1847176&r1=1847175&r2=1847176&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy_foreign.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy_foreign.c Thu Nov 22 
14:06:09 2018
@@ -55,7 +55,7 @@
  */
 static svn_error_t *
 copy_foreign_dir(svn_ra_session_t *ra_session,
-                 svn_client__pathrev_t *location,
+                 const svn_client__pathrev_t *location,
                  const char *dst_abspath,
                  svn_depth_t depth,
                  svn_wc_notify_func2_t notify_func,
@@ -103,31 +103,21 @@ copy_foreign_dir(svn_ra_session_t *ra_se
 
 
 svn_error_t *
-svn_client__copy_foreign(const char *url,
+svn_client__copy_foreign(const svn_client__pathrev_t *loc,
                          const char *dst_abspath,
-                         const svn_opt_revision_t *peg_revision,
-                         const svn_opt_revision_t *revision,
                          svn_depth_t depth,
                          svn_boolean_t make_parents,
+                         svn_ra_session_t *ra_session,
                          svn_client_ctx_t *ctx,
                          apr_pool_t *scratch_pool)
 {
-  svn_ra_session_t *ra_session;
-  svn_client__pathrev_t *loc;
   svn_node_kind_t kind;
   svn_node_kind_t wc_kind;
   const char *dir_abspath;
 
-  SVN_ERR_ASSERT(svn_path_is_url(url));
   SVN_ERR_ASSERT(svn_dirent_is_absolute(dst_abspath));
 
-  /* Do we need to validate/update revisions? */
-
-  SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &loc,
-                                            url, NULL,
-                                            peg_revision,
-                                            revision, ctx,
-                                            scratch_pool));
+  SVN_ERR(svn_ra_reparent(ra_session, loc->url, scratch_pool));
 
   /* The source must exist */
   SVN_ERR(svn_ra_check_path(ra_session, "", loc->rev, &kind, scratch_pool));
@@ -135,7 +125,7 @@ svn_client__copy_foreign(const char *url
     return svn_error_createf(
                 SVN_ERR_ILLEGAL_TARGET, NULL,
                 _("'%s' is not a valid location inside a repository"),
-                url);
+                loc->url);
 
   /* The target path must not exist (at least not as a versioned node) */
   SVN_ERR(svn_wc_read_kind2(&wc_kind, ctx->wc_ctx, dst_abspath, FALSE, TRUE,

Modified: subversion/trunk/subversion/tests/libsvn_client/client-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_client/client-test.c?rev=1847176&r1=1847175&r2=1847176&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/client-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/client-test.c Thu Nov 22 
14:06:09 2018
@@ -735,7 +735,10 @@ test_foreign_repos_copy(const svn_test_o
   const char *repos2_url;
   const char *wc_path;
   svn_client_ctx_t *ctx;
-/* Create a filesytem and repository containing the Greek tree. */
+  svn_ra_session_t *ra_session;
+  svn_client__pathrev_t *loc;
+
+  /* Create a filesytem and repository containing the Greek tree. */
   SVN_ERR(create_greek_repos(&repos_url, "foreign-copy1", opts, pool));
   SVN_ERR(create_greek_repos(&repos2_url, "foreign-copy2", opts, pool));
 
@@ -756,21 +759,24 @@ test_foreign_repos_copy(const svn_test_o
   SVN_ERR(svn_client_checkout3(NULL, repos_url, wc_path, &peg_rev, &rev,
                                svn_depth_infinity, FALSE, FALSE, ctx, pool));
 
+  SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &loc,
+                                            repos2_url, NULL, &peg_rev, &rev,
+                                            ctx, pool));
+
+  loc->url = svn_path_url_add_component2(repos2_url, "A", pool);
   SVN_WC__CALL_WITH_WRITE_LOCK(
-    svn_client__copy_foreign(svn_path_url_add_component2(repos2_url, "A",
-                                                         pool),
+    svn_client__copy_foreign(loc,
                              svn_dirent_join(wc_path, "A-copied", pool),
-                             &peg_rev, &rev, svn_depth_infinity, FALSE,
-                             ctx, pool),
+                             svn_depth_infinity, FALSE,
+                             ra_session, ctx, pool),
     ctx->wc_ctx, wc_path, FALSE, pool);
 
-
+  loc->url = svn_path_url_add_component2(repos2_url, "iota", pool);
   SVN_WC__CALL_WITH_WRITE_LOCK(
-    svn_client__copy_foreign(svn_path_url_add_component2(repos2_url, "iota",
-                                                         pool),
+    svn_client__copy_foreign(loc,
                              svn_dirent_join(wc_path, "iota-copied", pool),
-                             &peg_rev, &rev, svn_depth_infinity, FALSE,
-                             ctx, pool),
+                             svn_depth_infinity, FALSE,
+                             ra_session, ctx, pool),
     ctx->wc_ctx, wc_path, FALSE, pool);
 
   return SVN_NO_ERROR;


Reply via email to