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

[PATCH] Introduce the translate_paths parameter to svn_ra_get_merge_info()

From: Madan U Sreenivasan <madan_at_collab.net>
Date: 2006-07-19 01:11:39 CEST

Hi,

    Further to a discussion culminating in the mail at
http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=117981, we
decided to implement the translate_paths parameter for
svn_ra_get_merge_info(). Actually dberlin mentioned thus:
we really need to split include_parents into two arguments:
use_parent_info
and
translate_paths

     This could be interpreted as: "give the use_parent_info param to more
than just bool values and interpret the meaning at the fs-layer." But I
decided to leave the include_parents param alone and use a new parameter
because multiple values of include_parents will confuse the reader and
hence would be difficult to maintain.

     Pl. find attached a patch and the corresponding logfile. Its almost
wake-up time now. So, request you to pl. bear with me if I have made any
minor mistakes. :)

[[[
Introduce the translate_paths parameter, to conditionally append
the basename of the target to the mergefrom source paths.

(In branches/merge-tracking)

* subversion/libsvn_ra/ra_loader.c (svn_ra_get_merge_info):
* subversion/libsvn_ra/ra_loader.h (svn_ra__vtable_t.get_merge_info):
* subversion/include/svn_fs.h (svn_fs_get_merge_info):
* subversion/include/svn_repos.h (svn_repos_fs_get_merge_info):
* subversion/include/svn_ra.h (svn_ra_get_merge_info):
* subversion/libsvn_fs/fs-loader.h (root_vtable_t.get_merge_info):
* subversion/libsvn_fs/fs-loader.c (svn_fs_get_merge_info):
* subversion/libsvn_ra_local/ra_plugin.c (svn_ra_local__get_merge_info):
* subversion/libsvn_repos/fs-wrap.c (svn_repos_fs_get_merge_info):
* subversion/libsvn_ra_dav/ra_dav.h (svn_ra_dav__get_merge_info):
* subversion/libsvn_fs_fs/tree.c (fs_get_merge_info):
    Introduce the translate_paths parameter.

* subversion/mod_dav_svn/mergeinfo.c
   (dav_svn__get_merge_info_report): Pass on the translate_paths value
    using the 'S:translate-paths' namespace.

* subversion/libsvn_ra_dav/mergeinfo.c
   (svn_ra_dav__get_merge_info): Read translate_paths value from the
    'S:translate-paths' namespace.

* subversion/libsvn_ra_svn/client.c
   (ra_svn_get_merge_info): Add the translate-paths value to the
get-merge-info
    tuple.

* subversion/svnserve/serve.c
   (get_merge_info): Retreive the translate-paths value from the
get-merge-info
    tuple.

* subversion/libsvn_ra_svn/protocol
   (get-merge-info): Document the translate-path param.

* subversion/tests/libsvn_fs/fs-test.c
   (get_merge_info) : Modify to use the new signature of
    svn_fs_get_merge_info()

* subversion/libsvn_fs_fs/tree.c
   (get_merge_info_for_path): Introduce the translate_paths parameter, and
    execute the translate paths logic only if this variable is TRUE.
]]]

Regards,
Madan.

Index: subversion/libsvn_ra/ra_loader.c
===================================================================
--- subversion/libsvn_ra/ra_loader.c (revision 20729)
+++ subversion/libsvn_ra/ra_loader.c (working copy)
@@ -471,10 +471,12 @@
                                    const apr_array_header_t *paths,
                                    svn_revnum_t revision,
                                    svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                    apr_pool_t *pool)
 {
   return session->vtable->get_merge_info(session, mergeinfo, paths,
- revision, include_parents, pool);
+ revision, include_parents,
+ translate_paths, pool);
 }
 
 svn_error_t *svn_ra_do_update(svn_ra_session_t *session,
Index: subversion/libsvn_ra/ra_loader.h
===================================================================
--- subversion/libsvn_ra/ra_loader.h (revision 20729)
+++ subversion/libsvn_ra/ra_loader.h (working copy)
@@ -109,6 +109,7 @@
                                  const apr_array_header_t *paths,
                                  svn_revnum_t revision,
                                  svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                  apr_pool_t *pool);
   svn_error_t *(*do_update)(svn_ra_session_t *session,
                             const svn_ra_reporter2_t **reporter,
Index: subversion/include/svn_fs.h
===================================================================
--- subversion/include/svn_fs.h (revision 20729)
+++ subversion/include/svn_fs.h (working copy)
@@ -1155,12 +1155,16 @@
  * When @a include_parents is @c TRUE, include inherited merge info
  * from parent directories of @a paths.
  *
+ * When @a translate_paths is @c TRUE, append basename of the target
+ * to the mergedfrom sources.
+ *
  * Do any necessary temporary allocation in @a pool.
  */
 svn_error_t *svn_fs_get_merge_info(apr_hash_t **minfohash,
                                    svn_fs_root_t *root,
                                    const apr_array_header_t *paths,
                                    svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                    apr_pool_t *pool);
 
 /** Merge changes between two nodes into a third node.
Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h (revision 20729)
+++ subversion/include/svn_repos.h (working copy)
@@ -1044,6 +1044,9 @@
  * When @a include_parents is @c TRUE, include inherited merge info
  * from parent directories of @a paths.
  *
+ * When @a translate_paths is @c TRUE, append basename of the target
+ * to the mergedfrom source paths.
+ *
  * If @a revision is @c SVN_INVALID_REVNUM, it defaults to youngest.
  *
  * If optional @a authz_read_func is non-NULL, then use this function
@@ -1061,6 +1064,7 @@
                             const apr_array_header_t *paths,
                             svn_revnum_t revision,
                             svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                             svn_repos_authz_func_t authz_read_func,
                             void *authz_read_baton,
                             apr_pool_t *pool);
Index: subversion/include/svn_ra.h
===================================================================
--- subversion/include/svn_ra.h (revision 20729)
+++ subversion/include/svn_ra.h (working copy)
@@ -714,6 +714,9 @@
  * When @a include_parents is @c TRUE, include inherited merge info
  * from parent directories of @a paths.
  *
+ * When @a translate_paths is @c TRUE, append the basename of the
+ * target path to the mergedfrom source paths.
+ *
  * If @a revision is @c SVN_INVALID_REVNUM, it defaults to youngest.
  *
  * @since New in 1.5.
@@ -723,6 +726,7 @@
                                    const apr_array_header_t *paths,
                                    svn_revnum_t revision,
                                    svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                    apr_pool_t *pool);
 
 /**
Index: subversion/libsvn_fs/fs-loader.h
===================================================================
--- subversion/libsvn_fs/fs-loader.h (revision 20729)
+++ subversion/libsvn_fs/fs-loader.h (working copy)
@@ -295,6 +295,7 @@
                                  svn_fs_root_t *root,
                                  const apr_array_header_t *paths,
                                  svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                  apr_pool_t *pool);
 } root_vtable_t;
 
Index: subversion/libsvn_fs/fs-loader.c
===================================================================
--- subversion/libsvn_fs/fs-loader.c (revision 20729)
+++ subversion/libsvn_fs/fs-loader.c (working copy)
@@ -732,10 +732,11 @@
                       svn_fs_root_t *root,
                       const apr_array_header_t *paths,
                       svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                       apr_pool_t *pool)
 {
   return root->vtable->get_merge_info(minfohash, root, paths, include_parents,
- pool);
+ translate_paths, pool);
 }
 
 svn_error_t *
Index: subversion/libsvn_ra_local/ra_plugin.c
===================================================================
--- subversion/libsvn_ra_local/ra_plugin.c (revision 20729)
+++ subversion/libsvn_ra_local/ra_plugin.c (working copy)
@@ -628,6 +628,7 @@
                              const apr_array_header_t *paths,
                              svn_revnum_t revision,
                              svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                              apr_pool_t *pool)
 {
   svn_ra_local__session_baton_t *baton = session->priv;
@@ -635,6 +636,7 @@
 
   SVN_ERR(svn_repos_fs_get_merge_info(&tmp_mergeinfo, baton->repos, paths,
                                       revision, include_parents,
+ translate_paths,
                                       NULL, NULL, pool));
   if (tmp_mergeinfo != NULL && apr_hash_count(tmp_mergeinfo) > 0)
     {
Index: subversion/mod_dav_svn/mergeinfo.c
===================================================================
--- subversion/mod_dav_svn/mergeinfo.c (revision 20729)
+++ subversion/mod_dav_svn/mergeinfo.c (working copy)
@@ -56,6 +56,7 @@
   /* These get determined from the request document. */
   svn_revnum_t rev = SVN_INVALID_REVNUM;
   svn_boolean_t include_parents = 0; /* off by default */
+ svn_boolean_t translate_paths = 0; /* off by default */
   apr_array_header_t *paths
     = apr_array_make(resource->pool, 0, sizeof(const char *));
 
@@ -83,6 +84,8 @@
         rev = SVN_STR_TO_REV(dav_xml_get_cdata(child, resource->pool, 1));
       else if (strcmp(child->name, "include-parents") == 0)
         include_parents = 1;
+ else if (strcmp(child->name, "translate-paths") == 0)
+ translate_paths = 1;
       else if (strcmp(child->name, "path") == 0)
         {
           const char *target;
@@ -106,7 +109,7 @@
 
 
   serr = svn_repos_fs_get_merge_info(&mergeinfo, repos->repos, paths, rev,
- include_parents,
+ include_parents, translate_paths,
                                      dav_svn_authz_read_func(&arb),
                                      &arb, resource->pool);
   if (serr)
Index: subversion/tests/libsvn_fs/fs-test.c
===================================================================
--- subversion/tests/libsvn_fs/fs-test.c (revision 20729)
+++ subversion/tests/libsvn_fs/fs-test.c (working copy)
@@ -4476,10 +4476,12 @@
 
   paths = apr_array_make(pool, 1, sizeof (const char *));
   APR_ARRAY_PUSH(paths, const char *) = "/A/E";
- SVN_ERR(svn_fs_get_merge_info(&result, revision_root, paths, TRUE, pool));
+ SVN_ERR(svn_fs_get_merge_info(&result, revision_root, paths, TRUE,
+ TRUE, pool));
   paths = apr_array_make(pool, 1, sizeof (const char *));
   APR_ARRAY_PUSH(paths, const char *) = "/A/B/E";
- SVN_ERR(svn_fs_get_merge_info(&result, revision_root, paths, TRUE, pool));
+ SVN_ERR(svn_fs_get_merge_info(&result, revision_root, paths, TRUE,
+ TRUE, pool));
   return SVN_NO_ERROR;
 }
 
Index: subversion/libsvn_repos/fs-wrap.c
===================================================================
--- subversion/libsvn_repos/fs-wrap.c (revision 20729)
+++ subversion/libsvn_repos/fs-wrap.c (working copy)
@@ -576,6 +576,7 @@
                             const apr_array_header_t *paths,
                             svn_revnum_t rev,
                             svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                             svn_repos_authz_func_t authz_read_func,
                             void *authz_read_baton,
                             apr_pool_t *pool)
@@ -626,7 +627,7 @@
      the change itself. */
   if (readable_paths->nelts > 0)
     SVN_ERR(svn_fs_get_merge_info(mergeinfo, root, readable_paths,
- include_parents, pool));
+ include_parents, translate_paths, pool));
   else
     *mergeinfo = NULL;
 
Index: subversion/libsvn_ra_svn/client.c
===================================================================
--- subversion/libsvn_ra_svn/client.c (revision 20729)
+++ subversion/libsvn_ra_svn/client.c (working copy)
@@ -1103,6 +1103,7 @@
                                           const apr_array_header_t *paths,
                                           svn_revnum_t revision,
                                           svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                           apr_pool_t *pool)
 {
   ra_svn_session_baton_t *sess_baton = session->priv;
@@ -1119,8 +1120,8 @@
       path = APR_ARRAY_IDX(paths, i, const char *);
       SVN_ERR(svn_ra_svn_write_cstring(conn, pool, path));
     }
- SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "!)(?r)b)", revision,
- include_parents));
+ SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "!)(?r)bb)", revision,
+ include_parents, translate_paths));
 
   SVN_ERR(handle_auth_request(sess_baton, pool));
   SVN_ERR(svn_ra_svn_read_cmd_response(conn, pool, "(?l)", &mergeinfo_tuple));
Index: subversion/libsvn_ra_svn/protocol
===================================================================
--- subversion/libsvn_ra_svn/protocol (revision 20729)
+++ subversion/libsvn_ra_svn/protocol (working copy)
@@ -282,7 +282,8 @@
     New in svn 1.2. If path is non-existent, an empty response is returned.
 
   get-merge-info
- params: ( ( path:string ... ) [ rev:number ] include-parents:bool )
+ params: ( ( path:string ... ) [ rev:number ] include-parents:bool
+ translate-paths:bool )
     response: ( ( ( path:string merge-info:string) ... ) )
     New in svn 1.5. If no paths are specified, an empty response is
     returned. If rev is not specified, the youngest revision is used.
Index: subversion/libsvn_ra_dav/ra_dav.h
===================================================================
--- subversion/libsvn_ra_dav/ra_dav.h (revision 20729)
+++ subversion/libsvn_ra_dav/ra_dav.h (working copy)
@@ -253,6 +253,7 @@
                                          const apr_array_header_t *paths,
                                          svn_revnum_t revision,
                                          svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                          apr_pool_t *pool);
 
 svn_error_t * svn_ra_dav__do_update(svn_ra_session_t *session,
Index: subversion/libsvn_ra_dav/mergeinfo.c
===================================================================
--- subversion/libsvn_ra_dav/mergeinfo.c (revision 20729)
+++ subversion/libsvn_ra_dav/mergeinfo.c (working copy)
@@ -151,6 +151,7 @@
                                          const apr_array_header_t *paths,
                                          svn_revnum_t revision,
                                          svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                                          apr_pool_t *pool)
 {
   /* The Plan: Send a request to the server for a merge-info report.
@@ -190,6 +191,13 @@
                                             "<S:include_parents/>"));
     }
 
+ if (translate_paths)
+ {
+ svn_stringbuf_appendcstr(request_body,
+ apr_psprintf(pool,
+ "<S:translate-paths/>"));
+ }
+
   if (paths)
     {
       for (i = 0; i < paths->nelts; i++)
Index: subversion/svnserve/serve.c
===================================================================
--- subversion/svnserve/serve.c (revision 20729)
+++ subversion/svnserve/serve.c (working copy)
@@ -1350,15 +1350,16 @@
   apr_hash_index_t *hi;
   const char *path, *info;
   svn_boolean_t include_parents;
+ svn_boolean_t translate_paths;
 
- SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "l(?r)b", &paths, &rev,
- &include_parents));
+ SVN_ERR(svn_ra_svn_parse_tuple(params, pool, "l(?r)bb", &paths, &rev,
+ &include_parents, &translate_paths));
   for (i = 0; i < paths->nelts; i++)
     APR_ARRAY_IDX(paths, i, const char *) =
       svn_path_canonicalize(APR_ARRAY_IDX(paths, i, const char *), pool);
   SVN_ERR(trivial_auth_request(conn, pool, b));
   SVN_CMD_ERR(svn_repos_fs_get_merge_info(&mergeinfo, b->repos, paths, rev,
- include_parents,
+ include_parents, translate_paths,
                                           authz_check_access_cb_func(b), b,
                                           pool));
   if (mergeinfo != NULL && apr_hash_count(mergeinfo) > 0)
Index: subversion/libsvn_fs_fs/tree.c
===================================================================
--- subversion/libsvn_fs_fs/tree.c (revision 20729)
+++ subversion/libsvn_fs_fs/tree.c (working copy)
@@ -1223,6 +1223,7 @@
                         apr_hash_t *cache,
                         svn_boolean_t setresult,
                         svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                         apr_pool_t *pool)
 {
   apr_hash_t *cacheresult;
@@ -1291,7 +1292,7 @@
 
       SVN_ERR(get_merge_info_for_path(db, parentpath->data, rev,
                                       result, cache, FALSE, include_parents,
- pool));
+ translate_paths, pool));
       if (setresult)
         {
           /* Now translate the result for our parent to our path */
@@ -1301,21 +1302,29 @@
             apr_hash_set(result, path, APR_HASH_KEY_STRING, NULL);
           else if (cacheresult)
             {
- const char *p;
- int i;
- apr_hash_t *translatedhash;
- char *toappend;
+ if (translate_paths)
+ {
+ const char *p;
+ int i;
+ apr_hash_t *translatedhash;
+ char *toappend;
 
- /* We want to append from the part after the / to the end of the
+ /* We want to append from the part after the / to the end of the
                  path string. */
- toappend = apr_pcalloc(pool,
- (strlen(path) - parentpath->len) + 1);
- for (i = 0, p = &path[parentpath->len + 1]; *p; i++, p++)
- *(toappend + i) = *p;
- append_component_to_paths(&translatedhash, cacheresult,
- toappend, pool);
- apr_hash_set(result, path, APR_HASH_KEY_STRING,
- translatedhash);
+ toappend = apr_pcalloc(pool,
+ (strlen(path) - parentpath->len) + 1);
+ for (i = 0, p = &path[parentpath->len + 1]; *p; i++, p++)
+ *(toappend + i) = *p;
+ append_component_to_paths(&translatedhash, cacheresult,
+ toappend, pool);
+ apr_hash_set(result, path, APR_HASH_KEY_STRING,
+ translatedhash);
+ }
+ else
+ {
+ apr_hash_set(result, path, APR_HASH_KEY_STRING,
+ cacheresult);
+ }
             }
         }
     }
@@ -1329,6 +1338,7 @@
                   svn_fs_root_t *root,
                   const apr_array_header_t *paths,
                   svn_boolean_t include_parents,
+ svn_boolean_t translate_paths,
                   apr_pool_t *pool)
 {
   apr_hash_t *mergeinfo_cache = apr_hash_make (pool);
@@ -1354,7 +1364,8 @@
 
       SVN_ERR (get_merge_info_for_path (db, path, rev, *mergeinfo,
                                         mergeinfo_cache, TRUE,
- include_parents, pool));
+ include_parents, translate_paths,
+ pool));
     }
 
   for (i = 0; i < paths->nelts; i++)

Introduce the translate_paths parameter, to conditionally append
the basename of the target to the mergefrom source paths.

(In branches/merge-tracking)

* subversion/libsvn_ra/ra_loader.c (svn_ra_get_merge_info):
* subversion/libsvn_ra/ra_loader.h (svn_ra__vtable_t.get_merge_info):
* subversion/include/svn_fs.h (svn_fs_get_merge_info):
* subversion/include/svn_repos.h (svn_repos_fs_get_merge_info):
* subversion/include/svn_ra.h (svn_ra_get_merge_info):
* subversion/libsvn_fs/fs-loader.h (root_vtable_t.get_merge_info):
* subversion/libsvn_fs/fs-loader.c (svn_fs_get_merge_info):
* subversion/libsvn_ra_local/ra_plugin.c (svn_ra_local__get_merge_info):
* subversion/libsvn_repos/fs-wrap.c (svn_repos_fs_get_merge_info):
* subversion/libsvn_ra_dav/ra_dav.h (svn_ra_dav__get_merge_info):
* subversion/libsvn_fs_fs/tree.c (fs_get_merge_info):
   Introduce the translate_paths parameter.

* subversion/mod_dav_svn/mergeinfo.c
  (dav_svn__get_merge_info_report): Pass on the translate_paths value
   using the 'S:translate-paths' namespace.

* subversion/libsvn_ra_dav/mergeinfo.c
  (svn_ra_dav__get_merge_info): Read translate_paths value from the
   'S:translate-paths' namespace.

* subversion/libsvn_ra_svn/client.c
  (ra_svn_get_merge_info): Add the translate-paths value to the get-merge-info
   tuple.

* subversion/svnserve/serve.c
  (get_merge_info): Retreive the translate-paths value from the get-merge-info
   tuple.

* subversion/libsvn_ra_svn/protocol
  (get-merge-info): Document the translate-path param.

* subversion/tests/libsvn_fs/fs-test.c
  (get_merge_info) : Modify to use the new signature of
   svn_fs_get_merge_info()

* subversion/libsvn_fs_fs/tree.c
  (get_merge_info_for_path): Introduce the translate_paths parameter, and
   execute the translate paths logic only if this variable is TRUE.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jul 19 00:43:31 2006

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