You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2011/04/13 16:00:50 UTC

svn commit: r1091786 - in /subversion/trunk/subversion/libsvn_client: client.h cmdline.c externals.c merge.c mergeinfo.c url.c util.c

Author: rhuijben
Date: Wed Apr 13 14:00:49 2011
New Revision: 1091786

URL: http://svn.apache.org/viewvc?rev=1091786&view=rev
Log:
A bit more cleanup of libsvn_client's url helper functions.

* subversion/libsvn_client/client.h
  (svn_client__get_repos_root): Remove unused argument.

* subversion/libsvn_client/cmdline.c
  (check_root_url_of_target): Update caller.

* subversion/libsvn_client/externals.c
  (switch_file_external): Update caller.

* subversion/libsvn_client/merge.c
  (merge_locked, merge_reintegrate_locked,
   merge_peg_locked): Update callers.

* subversion/libsvn_client/mergeinfo.c
  (get_mergeinfo): Update caller.

* subversion/libsvn_client/url.c
  (svn_client_url_from_path2): Do the minimal amount of work instead of
    using svn_client__derive_location.
  (svn_client_root_url_from_path): Update caller.

* subversion/libsvn_client/util.c
  (svn_client__path_relative_to_root): Fix TODO by making it explicit that
    there are three cases.
  (svn_client__get_repos_root): Remove unused argument and two unused variables.

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/cmdline.c
    subversion/trunk/subversion/libsvn_client/externals.c
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_client/mergeinfo.c
    subversion/trunk/subversion/libsvn_client/url.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=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Wed Apr 13 14:00:49 2011
@@ -274,15 +274,14 @@ svn_client__ensure_ra_session_url(const 
                                   apr_pool_t *pool);
 
 /* Set REPOS_ROOT, allocated in RESULT_POOL to the URL which represents
-   the root of the repository in with ABSPATH_OR_URL (at PEG_REVISION) is
-   versioned.  Use the authentication baton and working copy context
-   cached in CTX as necessary.
+   the root of the repository in with ABSPATH_OR_URL is versioned.
+   Use the authentication baton and working copy context cached in CTX as
+   necessary.
 
    Use SCRATCH_POOL for temporary allocations. */
 svn_error_t *
 svn_client__get_repos_root(const char **repos_root,
                            const char *abspath_or_url,
-                           const svn_opt_revision_t *peg_revision,
                            svn_client_ctx_t *ctx,
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool);

Modified: subversion/trunk/subversion/libsvn_client/cmdline.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/cmdline.c?rev=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/cmdline.c (original)
+++ subversion/trunk/subversion/libsvn_client/cmdline.c Wed Apr 13 14:00:49 2011
@@ -114,7 +114,7 @@ check_root_url_of_target(const char **ro
   if (!svn_path_is_url(truepath))
     SVN_ERR(svn_dirent_get_absolute(&truepath, truepath, pool));
 
-  err =  svn_client__get_repos_root(&tmp_root_url, truepath, &opt_rev,
+  err =  svn_client__get_repos_root(&tmp_root_url, truepath,
                                     ctx, pool, pool);
 
   if (err)

Modified: subversion/trunk/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/externals.c?rev=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/externals.c (original)
+++ subversion/trunk/subversion/libsvn_client/externals.c Wed Apr 13 14:00:49 2011
@@ -347,13 +347,11 @@ switch_file_external(const char *path,
   if (!locked_here)
     {
       const char *dest_wc_repos_root_url;
-      svn_opt_revision_t peg_rev;
 
       /* Check that the repository root URL for the newly opened
          wc is the same as the file external. */
-      peg_rev.kind = svn_opt_revision_base;
       SVN_ERR(svn_client__get_repos_root(&dest_wc_repos_root_url,
-                                         anchor_abspath, &peg_rev,
+                                         anchor_abspath,
                                          ctx, subpool, subpool));
 
       if (0 != strcmp(repos_root_url, dest_wc_repos_root_url))

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Wed Apr 13 14:00:49 2011
@@ -9158,7 +9158,6 @@ merge_locked(const char *source1,
   svn_ra_session_t *ra_session1, *ra_session2;
   apr_array_header_t *merge_sources;
   merge_source_t *merge_source;
-  svn_opt_revision_t working_rev;
   svn_error_t *err;
   svn_boolean_t use_sleep = FALSE;
   const char *yc_path = NULL;
@@ -9228,10 +9227,8 @@ merge_locked(const char *source1,
                                              scratch_pool));
 
   /* Determine the working copy target's repository root URL. */
-  working_rev.kind = svn_opt_revision_working;
   SVN_ERR(svn_client__get_repos_root(&wc_repos_root, target_abspath,
-                                     &working_rev, ctx,
-                                     scratch_pool, scratch_pool));
+                                     ctx, scratch_pool, scratch_pool));
 
   /* Open some RA sessions to our merge source sides. */
   sesspool = svn_pool_create(scratch_pool);
@@ -10405,15 +10402,12 @@ merge_reintegrate_locked(const char *sou
                              svn_dirent_local_style(source, scratch_pool));
 
   /* Determine the working copy target's repository root URL. */
-  working_revision.kind = svn_opt_revision_working;
   SVN_ERR(svn_client__get_repos_root(&wc_repos_root, target_abspath,
-                                     &working_revision, ctx,
-                                     scratch_pool, scratch_pool));
+                                     ctx, scratch_pool, scratch_pool));
 
   /* Determine the source's repository root URL. */
   SVN_ERR(svn_client__get_repos_root(&source_repos_root, url2,
-                                     peg_revision, ctx,
-                                     scratch_pool, scratch_pool));
+                                     ctx, scratch_pool, scratch_pool));
 
   /* source_repos_root and wc_repos_root are required to be the same,
      as mergeinfo doesn't come into play for cross-repository merging. */
@@ -10455,6 +10449,7 @@ merge_reintegrate_locked(const char *sou
                                "can be the root of the repository"));
 
   /* Find all the subtree's in TARGET_WCPATH that have explicit mergeinfo. */
+  working_revision.kind = svn_opt_revision_working;
   SVN_ERR(svn_client_propget3(&subtrees_with_mergeinfo, SVN_PROP_MERGEINFO,
                               target_abspath, &working_revision,
                               &working_revision, NULL, svn_depth_infinity,
@@ -10692,8 +10687,7 @@ merge_peg_locked(const char *source,
   /* Determine the working copy target's repository root URL. */
   working_rev.kind = svn_opt_revision_working;
   SVN_ERR(svn_client__get_repos_root(&wc_repos_root, target_abspath,
-                                     &working_rev, ctx,
-                                     scratch_pool, scratch_pool));
+                                     ctx, scratch_pool, scratch_pool));
 
   /* Open an RA session to our source URL, and determine its root URL. */
   sesspool = svn_pool_create(scratch_pool);

Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Wed Apr 13 14:00:49 2011
@@ -1020,7 +1020,7 @@ get_mergeinfo(svn_mergeinfo_catalog_t *m
 
       /* Acquire return values. */
       SVN_ERR(svn_client__get_repos_root(repos_root, local_abspath,
-                                         &peg_rev, ctx, result_pool,
+                                         ctx, result_pool,
                                          scratch_pool));
       SVN_ERR(svn_client__get_wc_or_repos_mergeinfo_catalog(
         mergeinfo_catalog, &indirect, include_descendants, FALSE,

Modified: subversion/trunk/subversion/libsvn_client/url.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/url.c?rev=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/url.c (original)
+++ subversion/trunk/subversion/libsvn_client/url.c Wed Apr 13 14:00:49 2011
@@ -47,14 +47,19 @@ svn_client_url_from_path2(const char **u
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_pool)
 {
-  svn_opt_revision_t revision;
-
   if (!svn_path_is_url(path_or_url))
-    SVN_ERR(svn_dirent_get_absolute(&path_or_url, path_or_url, scratch_pool));
+    {
+      SVN_ERR(svn_dirent_get_absolute(&path_or_url, path_or_url,
+                                      scratch_pool));
+
+      return svn_error_return(
+                 svn_wc__node_get_url(url, ctx->wc_ctx, path_or_url,
+                                      result_pool, scratch_pool));
+    }
+  else
+    *url = apr_pstrdup(result_pool, path_or_url);
 
-  revision.kind = svn_opt_revision_unspecified;
-  return svn_client__derive_location(url, NULL, path_or_url, &revision,
-                                     NULL, ctx, result_pool, scratch_pool);
+  return SVN_NO_ERROR;
 }
 
 
@@ -64,19 +69,9 @@ svn_client_root_url_from_path(const char
                               svn_client_ctx_t *ctx,
                               apr_pool_t *pool)
 {
-  svn_opt_revision_t peg_revision;
-
-  if (svn_path_is_url(path_or_url))
-    {
-      peg_revision.kind = svn_opt_revision_head;
-    }
-  else
-    {
-      peg_revision.kind = svn_opt_revision_base;
-      SVN_ERR(svn_dirent_get_absolute(&path_or_url, path_or_url, pool));
-    }
-  return svn_client__get_repos_root(url, path_or_url, &peg_revision,
-                                    ctx, pool, pool);
+  return svn_error_return(
+           svn_client__get_repos_root(url, path_or_url,
+                                      ctx, pool, pool));
 }
 
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_client/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/util.c?rev=1091786&r1=1091785&r2=1091786&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/util.c (original)
+++ subversion/trunk/subversion/libsvn_client/util.c Wed Apr 13 14:00:49 2011
@@ -120,14 +120,11 @@ svn_client__path_relative_to_root(const 
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool)
 {
-  /* ### TODO: Rework this to use svn_ra_get_path_relative_to_root(). */
-
-  SVN_ERR_ASSERT(repos_root != NULL || ra_session != NULL);
+  const char *repos_relpath;
 
   /* If we have a WC path... */
   if (! svn_path_is_url(abspath_or_url))
     {
-      const char *repos_relpath;
       /* ...fetch its entry, and attempt to get both its full URL and
          repository root URL.  If we can't get REPOS_ROOT from the WC
          entry, we'll get it from the RA layer.*/
@@ -139,59 +136,57 @@ svn_client__path_relative_to_root(const 
                                              scratch_pool));
 
       SVN_ERR_ASSERT(repos_relpath != NULL);
-
-      if (include_leading_slash)
-        *rel_path = apr_pstrcat(result_pool, "/", repos_relpath, NULL);
-      else
-        *rel_path = repos_relpath;
-
-      return SVN_NO_ERROR;
     }
-
-  /* If we weren't provided a REPOS_ROOT, or couldn't find one in the
-     WC entry, we'll ask the RA layer.  */
-  if (repos_root == NULL)
-    SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root, scratch_pool));
-
-  /* Check if ABSPATH_OR_URL *is* the repository root URL.  */
-  if (strcmp(repos_root, abspath_or_url) == 0)
+     /* Merge handling passes a root that is not the repos root */
+  else if (repos_root != NULL)
     {
-      *rel_path = include_leading_slash ? "/" : "";
+      if (!svn_uri_is_ancestor(repos_root, abspath_or_url))
+        return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
+                                 _("URL '%s' is not a child of repository "
+                                   "root URL '%s'"),
+                                 abspath_or_url, repos_root);
+
+      repos_relpath = svn_path_uri_decode(
+                            svn_uri_skip_ancestor(repos_root,
+                                                  abspath_or_url),
+                            result_pool);
     }
   else
     {
-      /* See if PATH_OR_URL is a child of REPOS_ROOT.  If we get NULL
-         back from this, the two URLs have no commonality (which
-         should only happen if our caller provided us a REPOS_ROOT and
-         a PATH_OR_URL of something not in that repository).  */
-      const char *rel_url = svn_uri_is_child(repos_root, abspath_or_url,
-                                             scratch_pool);
-      if (! rel_url)
+      svn_error_t *err;
+
+      SVN_ERR_ASSERT(ra_session != NULL);
+
+      /* Ask the RA layer to create a relative path for us */
+      err = svn_ra_get_path_relative_to_root(ra_session, rel_path,
+                                             abspath_or_url, scratch_pool);
+
+      if (err)
         {
-          return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
-                                   _("URL '%s' is not a child of repository "
-                                     "root URL '%s'"),
-                                   abspath_or_url, repos_root);
+          if (err->apr_err == SVN_ERR_RA_ILLEGAL_URL)
+            return svn_error_createf(SVN_ERR_CLIENT_UNRELATED_RESOURCES, err,
+                                     _("URL '%s' is not inside repository"),
+                                     abspath_or_url);
+
+          return svn_error_return(err);
         }
-      if (include_leading_slash)
-        *rel_path = apr_pstrcat(result_pool, "/", rel_url, NULL);
-      else
-        *rel_path = apr_pstrdup(result_pool, rel_url);
     }
 
-  return SVN_NO_ERROR;
+  if (include_leading_slash)
+    *rel_path = apr_pstrcat(result_pool, "/", repos_relpath, NULL);
+  else
+    *rel_path = repos_relpath;
+
+   return SVN_NO_ERROR;
 }
 
 svn_error_t *
 svn_client__get_repos_root(const char **repos_root,
                            const char *abspath_or_url,
-                           const svn_opt_revision_t *peg_revision,
                            svn_client_ctx_t *ctx,
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool)
 {
-  svn_revnum_t rev;
-  const char *target_url;
   svn_ra_session_t *ra_session;
 
   /* If PATH_OR_URL is a local path we can fetch the repos root locally. */



Re: svn commit: r1091786 - in /subversion/trunk/subversion/libsvn_client: client.h cmdline.c externals.c merge.c mergeinfo.c url.c util.c

Posted by Greg Stein <gs...@gmail.com>.
On Wed, Apr 13, 2011 at 10:00,  <rh...@apache.org> wrote:
>...
> +++ subversion/trunk/subversion/libsvn_client/merge.c Wed Apr 13 14:00:49 2011
>...
> @@ -10692,8 +10687,7 @@ merge_peg_locked(const char *source,
>   /* Determine the working copy target's repository root URL. */
>   working_rev.kind = svn_opt_revision_working;
>   SVN_ERR(svn_client__get_repos_root(&wc_repos_root, target_abspath,
> -                                     &working_rev, ctx,
> -                                     scratch_pool, scratch_pool));
> +                                     ctx, scratch_pool, scratch_pool));

working_rev can be removed from this function.

>...
>
>   /* Open an RA session to our source URL, and determine its root URL. */
>   sesspool = svn_pool_create(scratch_pool);
>
> Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1091786&r1=1091785&r2=1091786&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
> +++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Wed Apr 13 14:00:49 2011
> @@ -1020,7 +1020,7 @@ get_mergeinfo(svn_mergeinfo_catalog_t *m
>
>       /* Acquire return values. */
>       SVN_ERR(svn_client__get_repos_root(repos_root, local_abspath,
> -                                         &peg_rev, ctx, result_pool,
> +                                         ctx, result_pool,
>                                          scratch_pool));

The elimination of peg_rev in this branch of the (is_url) test means
that a huge block can be removed from early in the function, and then
peg_rev's declaration and initialization tightened to the inner block.

>...
> +++ subversion/trunk/subversion/libsvn_client/url.c Wed Apr 13 14:00:49 2011
> @@ -47,14 +47,19 @@ svn_client_url_from_path2(const char **u
>                           apr_pool_t *result_pool,
>                           apr_pool_t *scratch_pool)
>  {
> -  svn_opt_revision_t revision;
> -
>   if (!svn_path_is_url(path_or_url))
> -    SVN_ERR(svn_dirent_get_absolute(&path_or_url, path_or_url, scratch_pool));
> +    {
> +      SVN_ERR(svn_dirent_get_absolute(&path_or_url, path_or_url,
> +                                      scratch_pool));
> +
> +      return svn_error_return(
> +                 svn_wc__node_get_url(url, ctx->wc_ctx, path_or_url,
> +                                      result_pool, scratch_pool));
> +    }
> +  else
> +    *url = apr_pstrdup(result_pool, path_or_url);

The 'else' is not required since the true-block returns.

>...

Cheers,
-g