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 13:19:58 UTC
svn commit: r1091746 - /subversion/trunk/subversion/libsvn_client/util.c
Author: rhuijben
Date: Wed Apr 13 11:19:58 2011
New Revision: 1091746
URL: http://svn.apache.org/viewvc?rev=1091746&view=rev
Log:
With the knowledge that WC-NG always knows the repository root for versioned
nodes and that the repository root doesn't change when passing a peg revision
simplify a few libsvn_client util functions.
* subversion/libsvn_client/util.c
(wc_path_to_repos_urls): Remove function.
(svn_client__path_relative_to_root): Don't use the helper when we can
use the real thing.
(svn_client__get_repos_root): Always use wc_db for local paths and always
open the ra layer for urls instead of using a helper that looks for
local paths again.
Modified:
subversion/trunk/subversion/libsvn_client/util.c
Modified: subversion/trunk/subversion/libsvn_client/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/util.c?rev=1091746&r1=1091745&r2=1091746&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/util.c (original)
+++ subversion/trunk/subversion/libsvn_client/util.c Wed Apr 13 11:19:58 2011
@@ -110,32 +110,6 @@ svn_client_proplist_item_dup(const svn_c
return new_item;
}
-/* Return LOCAL_ABSPATH's URL and repository root in *URL and REPOS_ROOT,
- respectively. */
-static svn_error_t *
-wc_path_to_repos_urls(const char **url,
- const char **repos_root,
- svn_wc_context_t *wc_ctx,
- const char *local_abspath,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
-{
- SVN_ERR(svn_client__entry_location(url, NULL, wc_ctx, local_abspath,
- svn_opt_revision_unspecified,
- result_pool, scratch_pool));
-
- /* If we weren't provided a REPOS_ROOT, we'll try to read one from
- the entry. The entry might not hold a URL -- in that case, we'll
- need a fallback plan. */
- if (*repos_root == NULL)
- SVN_ERR(svn_wc__node_get_repos_info(repos_root, NULL, wc_ctx,
- local_abspath, TRUE, FALSE,
- result_pool, scratch_pool));
-
- return SVN_NO_ERROR;
-}
-
-
svn_error_t *
svn_client__path_relative_to_root(const char **rel_path,
svn_wc_context_t *wc_ctx,
@@ -153,12 +127,25 @@ svn_client__path_relative_to_root(const
/* 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.*/
- SVN_ERR(wc_path_to_repos_urls(&abspath_or_url, &repos_root, wc_ctx,
- abspath_or_url, scratch_pool,
- scratch_pool));
+
+ SVN_ERR(svn_wc__node_get_repos_relpath(&repos_relpath,
+ wc_ctx,
+ abspath_or_url,
+ result_pool,
+ 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
@@ -187,7 +174,7 @@ svn_client__path_relative_to_root(const
abspath_or_url, repos_root);
}
if (include_leading_slash)
- *rel_path = svn_fspath__canonicalize(rel_url, result_pool);
+ *rel_path = apr_pstrcat(result_pool, "/", rel_url, NULL);
else
*rel_path = apr_pstrdup(result_pool, rel_url);
}
@@ -205,43 +192,26 @@ svn_client__get_repos_root(const char **
{
svn_revnum_t rev;
const char *target_url;
+ svn_ra_session_t *ra_session;
- /* If PATH_OR_URL is a local path and PEG_REVISION keeps us looking
- locally, we'll first check PATH_OR_URL's entry for a repository
- root URL. */
- if (!svn_path_is_url(abspath_or_url)
- && (peg_revision->kind == svn_opt_revision_working
- || peg_revision->kind == svn_opt_revision_base))
- {
- *repos_root = NULL;
- SVN_ERR(wc_path_to_repos_urls(&abspath_or_url, repos_root,
- ctx->wc_ctx, abspath_or_url,
- result_pool, scratch_pool));
- }
- else
+ /* If PATH_OR_URL is a local path we can fetch the repos root locally. */
+ if (!svn_path_is_url(abspath_or_url))
{
- *repos_root = NULL;
+ SVN_ERR(svn_wc__node_get_repos_info(repos_root, NULL,
+ ctx->wc_ctx, abspath_or_url,
+ TRUE, TRUE,
+ result_pool, scratch_pool));
+
+ return SVN_NO_ERROR;
}
- /* If PATH_OR_URL was a URL, or PEG_REVISION wasn't a client-side
- revision, or we weren't otherwise able to find the repository
- root URL in PATH_OR_URL's WC entry, we use the RA layer to look
- it up. */
- if (*repos_root == NULL)
- {
- svn_ra_session_t *ra_session;
- SVN_ERR(svn_client__ra_session_from_path(&ra_session,
- &rev,
- &target_url,
+ /* If PATH_OR_URL was a URL, we use the RA layer to look it up. */
+ SVN_ERR(svn_client__open_ra_session_internal(&ra_session, NULL,
abspath_or_url,
- NULL,
- peg_revision,
- peg_revision,
- ctx,
- scratch_pool));
+ NULL, NULL, FALSE, TRUE,
+ ctx, scratch_pool));
- SVN_ERR(svn_ra_get_repos_root2(ra_session, repos_root, result_pool));
- }
+ SVN_ERR(svn_ra_get_repos_root2(ra_session, repos_root, result_pool));
return SVN_NO_ERROR;
}