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/14 13:57:22 UTC
svn commit: r1092150 - in /subversion/trunk/subversion/libsvn_client: ra.c
url.c
Author: rhuijben
Date: Thu Apr 14 11:57:22 2011
New Revision: 1092150
URL: http://svn.apache.org/viewvc?rev=1092150&view=rev
Log:
Following up on r1092145, use svn_wc__node_get_origin() in the major
libsvn_client url helper functions.
* subversion/libsvn_client/ra.c
(svn_client__repos_locations): Use the origin function to avoid further db
calls in the very common working case.
* subversion/libsvn_client/url.c
(svn_client__entry_location): Rewrite to take advantage of
svn_wc__node_get_origin() for all common code paths.
Modified:
subversion/trunk/subversion/libsvn_client/ra.c
subversion/trunk/subversion/libsvn_client/url.c
Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1092150&r1=1092149&r2=1092150&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Thu Apr 14 11:57:22 2011
@@ -611,32 +611,46 @@ svn_client__repos_locations(const char *
the copyfrom information. */
if (! svn_path_is_url(path))
{
- const char *node_url, *copyfrom_url;
- svn_revnum_t copyfrom_rev;
-
SVN_ERR(svn_dirent_get_absolute(&local_abspath_or_url, path, subpool));
- SVN_ERR(svn_wc__node_get_url(&node_url, ctx->wc_ctx,
- local_abspath_or_url, pool, subpool));
- SVN_ERR(svn_wc__node_get_copyfrom_info(NULL, NULL,
- ©from_url, ©from_rev,
- NULL, ctx->wc_ctx,
- local_abspath_or_url,
- pool, subpool));
- if (copyfrom_url && revision->kind == svn_opt_revision_working)
+
+ if (revision->kind == svn_opt_revision_working)
{
- url = copyfrom_url;
- peg_revnum = copyfrom_rev;
- if (!node_url || strcmp(node_url, copyfrom_url) != 0)
+ const char *repos_root_url;
+ const char *repos_relpath;
+ svn_boolean_t is_copy;
+
+ SVN_ERR(svn_wc__node_get_origin(&is_copy, NULL, &repos_relpath,
+ &repos_root_url, NULL,
+ ctx->wc_ctx, local_abspath_or_url,
+ FALSE, subpool, subpool));
+
+ if (repos_relpath)
+ url = svn_path_url_add_component2(repos_root_url, repos_relpath,
+ pool);
+ else
+ url = NULL;
+
+ if (url && is_copy && ra_session)
{
- /* We can't use the caller provided RA session in this case */
- ra_session = NULL;
+ const char *session_url;
+ SVN_ERR(svn_ra_get_session_url(ra_session, &session_url,
+ subpool));
+
+ if (strcmp(session_url, url) != 0)
+ {
+ /* We can't use the caller provided RA session now :( */
+ ra_session = NULL;
+ }
}
}
- else if (node_url)
- {
- url = node_url;
- }
else
+ url = NULL;
+
+ if (! url)
+ SVN_ERR(svn_wc__node_get_url(&url, ctx->wc_ctx,
+ local_abspath_or_url, pool, subpool));
+
+ if (!url)
{
return svn_error_createf(SVN_ERR_ENTRY_MISSING_URL, NULL,
_("'%s' has no URL"),
Modified: subversion/trunk/subversion/libsvn_client/url.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/url.c?rev=1092150&r1=1092149&r2=1092150&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/url.c (original)
+++ subversion/trunk/subversion/libsvn_client/url.c Thu Apr 14 11:57:22 2011
@@ -136,8 +136,12 @@ svn_client__entry_location(const char **
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
- const char *copyfrom_url;
- svn_revnum_t copyfrom_rev;
+ svn_boolean_t is_copy;
+ const char *repos_root_url;
+ const char *repos_relpath;
+ svn_revnum_t origin_rev;
+
+ *url = NULL;
/* This function doesn't contact the repository, so error out if
asked to do so. */
@@ -145,58 +149,68 @@ svn_client__entry_location(const char **
|| peg_rev_kind == svn_opt_revision_head)
return svn_error_create(SVN_ERR_CLIENT_BAD_REVISION, NULL, NULL);
- SVN_ERR(svn_wc__node_get_copyfrom_info(NULL, NULL,
- ©from_url, ©from_rev,
- NULL, wc_ctx, local_abspath,
- result_pool, scratch_pool));
+ SVN_ERR(svn_wc__node_get_origin(&is_copy, &origin_rev, &repos_relpath,
+ &repos_root_url, NULL,
+ wc_ctx, local_abspath, TRUE,
+ scratch_pool, scratch_pool));
+
+ if (is_copy
+ /* ### Just && peg_rev_kind == svn_opt_revision_base ?? */
+ && peg_rev_kind != svn_opt_revision_working
+ && peg_rev_kind != svn_opt_revision_committed
+ && peg_rev_kind != svn_opt_revision_previous)
+ {
+ /* Obtain BASE url or future url */
+ SVN_ERR(svn_wc__node_get_url(url, wc_ctx, local_abspath,
+ result_pool, scratch_pool));
+ }
+ else if (repos_relpath)
+ {
+ *url = svn_path_url_add_component2(repos_root_url, repos_relpath,
+ result_pool);
+ }
- if (copyfrom_url && peg_rev_kind == svn_opt_revision_working)
+ if (! *url)
{
- *url = copyfrom_url;
- if (revnum)
- *revnum = copyfrom_rev;
+ return svn_error_createf(SVN_ERR_ENTRY_MISSING_URL, NULL,
+ _("Entry for '%s' has no URL"),
+ svn_dirent_local_style(local_abspath,
+ scratch_pool));
}
+
+ if (revnum)
+ *revnum = origin_rev;
else
+ return SVN_NO_ERROR;
+
+ switch (peg_rev_kind)
{
- const char *node_url;
+ case svn_opt_revision_committed:
+ case svn_opt_revision_previous:
+ SVN_ERR(svn_wc__node_get_changed_info(revnum, NULL, NULL,
+ wc_ctx, local_abspath,
+ scratch_pool, scratch_pool));
- SVN_ERR(svn_wc__node_get_url(&node_url, wc_ctx, local_abspath,
- result_pool, scratch_pool));
- if (node_url)
- {
- *url = node_url;
- if (revnum)
- {
- if ((peg_rev_kind == svn_opt_revision_committed) ||
- (peg_rev_kind == svn_opt_revision_previous))
- {
- SVN_ERR(svn_wc__node_get_changed_info(revnum, NULL, NULL,
- wc_ctx,
- local_abspath,
- result_pool,
- scratch_pool));
- if (peg_rev_kind == svn_opt_revision_previous)
- *revnum = *revnum - 1;
- }
- else
- {
- /* Local modifications are not relevant here, so consider
- svn_opt_revision_unspecified, svn_opt_revision_number,
- svn_opt_revision_base, and svn_opt_revision_working
- as the same. */
- SVN_ERR(svn_wc__node_get_base_rev(revnum,
- wc_ctx, local_abspath,
- scratch_pool));
- }
- }
- }
- else
- {
- return svn_error_createf(SVN_ERR_ENTRY_MISSING_URL, NULL,
- _("Entry for '%s' has no URL"),
- svn_dirent_local_style(local_abspath,
- scratch_pool));
- }
+ if (peg_rev_kind == svn_opt_revision_previous)
+ *revnum = *revnum - 1;
+ break;
+
+ case svn_opt_revision_base:
+ if (is_copy)
+ {
+ /* We really want to look at BASE below the origin */
+ SVN_ERR(svn_wc__node_get_base_rev(revnum, wc_ctx, local_abspath,
+ scratch_pool));
+ }
+
+ case svn_opt_revision_working:
+ /*case svn_opt_revision_unspecified:
+ case svn_opt_revision_number:
+ case svn_opt_revision_date:
+ case svn_opt_revision_head:*/
+ default:
+ /* Use the value we got from the origin */
+ break;
}
return SVN_NO_ERROR;