You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2012/04/18 19:53:46 UTC

svn commit: r1327597 - in /subversion/trunk/subversion/libsvn_client: client.h commit.c copy.c util.c

Author: hwright
Date: Wed Apr 18 17:53:46 2012
New Revision: 1327597

URL: http://svn.apache.org/viewvc?rev=1327597&view=rev
Log:
More improvements on mapping repos_relpaths to local_abspaths in the Ev2 shim
callbacks on the client.

(Only 4 tests fail over ra_serf with this patch.)

* subversion/libsvn_client/util.c
  (shim_callbacks_baton): Remove a few members, and add the relpath_map.
  (rationalize_shim_path): Remove.
  (fetch_props_func, fetch_kind_func, fetch_base_func): Use the relpath map to
    find the correct local_abspath.
  (svn_client__get_shim_callbacks): Update params and baton members.

* subversion/libsvn_client/copy.c
  (wc_to_repos_copy): Populate the relpath_map.

* subversion/libsvn_client/commit.c
  (get_ra_editor): Same.

* subversion/libsvn_client/client.h
  (svn_client__get_shim_callbacks): Update parameter type and name.

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/commit.c
    subversion/trunk/subversion/libsvn_client/copy.c
    subversion/trunk/subversion/libsvn_client/util.c

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1327597&r1=1327596&r2=1327597&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Wed Apr 18 17:53:46 2012
@@ -1083,7 +1083,7 @@ svn_client__get_normalized_stream(svn_st
 svn_delta_shim_callbacks_t *
 svn_client__get_shim_callbacks(svn_wc_context_t *wc_ctx,
                                svn_ra_session_t *ra_session,
-                               const char *anchor_abspath,
+                               apr_hash_t *relpath_map,
                                apr_pool_t *result_pool);
 
 /* Return true if KIND is a revision kind that is dependent on the working

Modified: subversion/trunk/subversion/libsvn_client/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/commit.c?rev=1327597&r1=1327596&r2=1327597&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/commit.c (original)
+++ subversion/trunk/subversion/libsvn_client/commit.c Wed Apr 18 17:53:46 2012
@@ -672,7 +672,7 @@ get_ra_editor(svn_ra_session_t **ra_sess
               apr_pool_t *pool)
 {
   apr_hash_t *commit_revprops;
-  const char *anchor_abspath;
+  apr_hash_t *relpath_map = NULL;
 
   /* Open an RA session to URL. */
   SVN_ERR(svn_client__open_ra_session_internal(ra_session, NULL, base_url,
@@ -698,28 +698,37 @@ get_ra_editor(svn_ra_session_t **ra_sess
                                            log_msg, ctx, pool));
 
 #ifdef ENABLE_EV2_SHIMS
-  /* We need this for the shims. */
-  if (base_dir_abspath)
+  if (commit_items)
     {
-      const char *relpath;
-      const char *wcroot_abspath;
+      int i;
+      apr_pool_t *iterpool = svn_pool_create(pool);
+
+      relpath_map = apr_hash_make(pool);
+      for (i = 0; i < commit_items->nelts; i++)
+        {
+          svn_client_commit_item3_t *item = APR_ARRAY_IDX(commit_items, i,
+                                                  svn_client_commit_item3_t *);
+          const char *relpath;
 
-      SVN_ERR(svn_wc__get_wc_root(&wcroot_abspath, ctx->wc_ctx,
-                                  base_dir_abspath, pool, pool));
+          if (!item->path)
+            continue;
 
-      SVN_ERR(svn_ra_get_path_relative_to_root(*ra_session, &relpath, base_url,
-                                               pool));
-      anchor_abspath = svn_dirent_join(wcroot_abspath, relpath, pool);
+          svn_pool_clear(iterpool);
+          SVN_ERR(svn_wc__node_get_origin(NULL, NULL, &relpath, NULL, NULL, NULL,
+                                          ctx->wc_ctx, item->path, FALSE, pool,
+                                          iterpool));
+          if (relpath)
+            apr_hash_set(relpath_map, relpath, APR_HASH_KEY_STRING, item->path);
+        }
+      svn_pool_destroy(iterpool);
     }
-  else
 #endif
-    anchor_abspath = NULL;
 
   /* Fetch RA commit editor. */
   SVN_ERR(svn_ra__register_editor_shim_callbacks(*ra_session,
                         svn_client__get_shim_callbacks(ctx->wc_ctx,
                                                        *ra_session,
-                                                       anchor_abspath, pool)));
+                                                       relpath_map, pool)));
   SVN_ERR(svn_ra_get_commit_editor3(*ra_session, editor, edit_baton,
                                     commit_revprops, commit_callback,
                                     commit_baton, lock_tokens, keep_locks,

Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1327597&r1=1327596&r2=1327597&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Wed Apr 18 17:53:46 2012
@@ -1136,7 +1136,7 @@ wc_to_repos_copy(const apr_array_header_
   const char *top_src_abspath;
   svn_ra_session_t *ra_session;
   const svn_delta_editor_t *editor;
-  const char *common_wc_abspath = NULL;
+  apr_hash_t *relpath_map = NULL;
   void *edit_baton;
   svn_client__committables_t *committables;
   apr_array_header_t *commit_items;
@@ -1373,22 +1373,25 @@ wc_to_repos_copy(const apr_array_header_
                                             commit_items, pool));
 
 #ifdef ENABLE_EV2_SHIMS
-  for (i = 0; !common_wc_abspath && i < commit_items->nelts; i++)
+  if (commit_items)
     {
-      common_wc_abspath = APR_ARRAY_IDX(commit_items, i,
-                                        svn_client_commit_item3_t *)->path;
-    }
-
-  for (; i < commit_items->nelts; i++)
-    {
-      svn_client_commit_item3_t *item =
-        APR_ARRAY_IDX(commit_items, i, svn_client_commit_item3_t *);
+      relpath_map = apr_hash_make(pool);
+      for (i = 0; i < commit_items->nelts; i++)
+        {
+          svn_client_commit_item3_t *item = APR_ARRAY_IDX(commit_items, i,
+                                                  svn_client_commit_item3_t *);
+          const char *relpath;
 
-      if (!item->path)
-        continue;
+          if (!item->path)
+            continue;
 
-      common_wc_abspath = svn_dirent_get_longest_ancestor(common_wc_abspath,
-                                                          item->path, pool);
+          svn_pool_clear(iterpool);
+          SVN_ERR(svn_wc__node_get_origin(NULL, NULL, &relpath, NULL, NULL, NULL,
+                                          ctx->wc_ctx, item->path, FALSE, pool,
+                                          iterpool));
+          if (relpath)
+            apr_hash_set(relpath_map, relpath, APR_HASH_KEY_STRING, item->path);
+        }
     }
 #endif
 
@@ -1400,8 +1403,7 @@ wc_to_repos_copy(const apr_array_header_
   /* Fetch RA commit editor. */
   SVN_ERR(svn_ra__register_editor_shim_callbacks(ra_session,
                         svn_client__get_shim_callbacks(ctx->wc_ctx,
-                                                       ra_session,
-                                                       common_wc_abspath,
+                                                       ra_session, relpath_map,
                                                        pool)));
   SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton,
                                     commit_revprops,

Modified: subversion/trunk/subversion/libsvn_client/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/util.c?rev=1327597&r1=1327596&r2=1327597&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/util.c (original)
+++ subversion/trunk/subversion/libsvn_client/util.c Wed Apr 18 17:53:46 2012
@@ -365,39 +365,10 @@ svn_client__assert_homogeneous_target_ty
 struct shim_callbacks_baton
 {
   svn_wc_context_t *wc_ctx;
-  const char *repos_root_url;
-  const char *anchor_abspath;
+  apr_hash_t *relpath_map;
 };
 
 static svn_error_t *
-rationalize_shim_path(const char **local_abspath,
-                      struct shim_callbacks_baton *scb,
-                      const char *repos_relpath,
-                      apr_pool_t *result_pool,
-                      apr_pool_t *scratch_pool)
-{
-  const char *wcroot_abspath;
-  const char *wcroot_url;
-  const char *relpath;
-  const char *node_url = svn_path_url_add_component2(scb->repos_root_url,
-                                                     repos_relpath,
-                                                     scratch_pool);
-
-  /* ### We could probably calculate some of this once, and then cache it for
-         use in this function. */
-  SVN_ERR(svn_wc__get_wc_root(&wcroot_abspath, scb->wc_ctx,
-                              scb->anchor_abspath,
-                              scratch_pool, scratch_pool));
-  SVN_ERR(svn_wc__node_get_url(&wcroot_url, scb->wc_ctx, wcroot_abspath,
-                               scratch_pool, scratch_pool));
-
-  relpath = svn_uri_skip_ancestor(wcroot_url, node_url, scratch_pool);
-  *local_abspath = svn_dirent_join(wcroot_abspath, relpath, result_pool);
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
 fetch_props_func(apr_hash_t **props,
                  void *baton,
                  const char *path,
@@ -408,17 +379,13 @@ fetch_props_func(apr_hash_t **props,
   struct shim_callbacks_baton *scb = baton;
   const char *local_abspath;
 
-  /* Early out: if we didn't get an anchor_abspath, it means we don't have a
-     working copy, and hence no method of fetching the requisite information. */
-  if (!scb->anchor_abspath)
+  local_abspath = apr_hash_get(scb->relpath_map, path, APR_HASH_KEY_STRING);
+  if (!local_abspath)
     {
       *props = apr_hash_make(result_pool);
       return SVN_NO_ERROR;
     }
 
-  SVN_ERR(rationalize_shim_path(&local_abspath, scb, path, scratch_pool,
-                                scratch_pool));
-
   SVN_ERR(svn_wc_get_pristine_props(props, scb->wc_ctx, local_abspath,
                                     result_pool, scratch_pool));
 
@@ -439,17 +406,13 @@ fetch_kind_func(svn_kind_t *kind,
   svn_node_kind_t node_kind;
   const char *local_abspath;
 
-  /* Early out: if we didn't get an anchor_abspath, it means we don't have a
-     working copy, and hence no method of fetching the requisite information. */
-  if (!scb->anchor_abspath)
+  local_abspath = apr_hash_get(scb->relpath_map, path, APR_HASH_KEY_STRING);
+  if (!local_abspath)
     {
       *kind = svn_kind_unknown;
       return SVN_NO_ERROR;
     }
 
-  SVN_ERR(rationalize_shim_path(&local_abspath, scb, path, scratch_pool,
-                                scratch_pool));
-
   SVN_ERR(svn_wc_read_kind(&node_kind, scb->wc_ctx, local_abspath, FALSE,
                            scratch_pool));
   *kind = svn__kind_from_node_kind(node_kind, FALSE);
@@ -471,17 +434,13 @@ fetch_base_func(const char **filename,
   svn_stream_t *temp_stream;
   svn_error_t *err;
 
-  /* Early out: if we didn't get an anchor_abspath, it means we don't have a
-     working copy, and hence no method of fetching the requisite information. */
-  if (!scb->anchor_abspath)
+  local_abspath = apr_hash_get(scb->relpath_map, path, APR_HASH_KEY_STRING);
+  if (!local_abspath)
     {
       *filename = NULL;
       return SVN_NO_ERROR;
     }
 
-  SVN_ERR(rationalize_shim_path(&local_abspath, scb, path, scratch_pool,
-                                scratch_pool));
-
   err = svn_wc_get_pristine_contents2(&pristine_stream, scb->wc_ctx,
                                       local_abspath, scratch_pool,
                                       scratch_pool);
@@ -506,7 +465,7 @@ fetch_base_func(const char **filename,
 svn_delta_shim_callbacks_t *
 svn_client__get_shim_callbacks(svn_wc_context_t *wc_ctx,
                                svn_ra_session_t *ra_session,
-                               const char *anchor_abspath,
+                               apr_hash_t *relpath_map,
                                apr_pool_t *result_pool)
 {
   svn_delta_shim_callbacks_t *callbacks =
@@ -514,9 +473,10 @@ svn_client__get_shim_callbacks(svn_wc_co
   struct shim_callbacks_baton *scb = apr_pcalloc(result_pool, sizeof(*scb));
 
   scb->wc_ctx = wc_ctx;
-  scb->anchor_abspath = apr_pstrdup(result_pool, anchor_abspath);
-  svn_error_clear(svn_ra_get_repos_root2(ra_session, &scb->repos_root_url,
-                                         result_pool));
+  if (relpath_map)
+    scb->relpath_map = relpath_map;
+  else
+    scb->relpath_map = apr_hash_make(result_pool);
 
   callbacks->fetch_props_func = fetch_props_func;
   callbacks->fetch_kind_func = fetch_kind_func;