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 2013/06/25 15:32:16 UTC
svn commit: r1496468 - /subversion/trunk/subversion/libsvn_client/ra.c
Author: rhuijben
Date: Tue Jun 25 13:32:16 2013
New Revision: 1496468
URL: http://svn.apache.org/r1496468
Log:
Use a cheaper ra operation for a common libsvn_client calculation.
* subversion/libsvn_client/ra.c
(repos_locations): Optimize common diff ra request for diff for the old
location of the repository root.
Modified:
subversion/trunk/subversion/libsvn_client/ra.c
Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1496468&r1=1496467&r2=1496468&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Tue Jun 25 13:32:16 2013
@@ -668,9 +668,9 @@ repos_locations(const char **start_url,
apr_array_header_t *revs;
apr_hash_t *rev_locs;
- SVN_ERR_ASSERT(peg_revnum != SVN_INVALID_REVNUM);
- SVN_ERR_ASSERT(start_revnum != SVN_INVALID_REVNUM);
- SVN_ERR_ASSERT(end_revnum != SVN_INVALID_REVNUM || end_url == NULL);
+ SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(peg_revnum));
+ SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(start_revnum));
+ SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(end_revnum) || end_url == NULL);
/* Avoid a network request in the common easy case. */
if (start_revnum == peg_revnum
@@ -685,6 +685,26 @@ repos_locations(const char **start_url,
SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_url, scratch_pool));
+ /* Handle another common case: The repository root can't move */
+ if (! strcmp(repos_url, url))
+ {
+ svn_revnum_t latest_revnum;
+ SVN_ERR(svn_ra_get_latest_revnum(ra_session, &latest_revnum,
+ scratch_pool));
+
+ if (start_revnum > latest_revnum || end_revnum > latest_revnum)
+ return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
+ _("No such revision %ld"),
+ (start_revnum > latest_revnum)
+ ? start_revnum : end_revnum);
+
+ if (start_url)
+ *start_url = apr_pstrdup(result_pool, repos_url);
+ if (end_url)
+ *end_url = apr_pstrdup(result_pool, repos_url);
+ return SVN_NO_ERROR;
+ }
+
revs = apr_array_make(scratch_pool, 2, sizeof(svn_revnum_t));
APR_ARRAY_PUSH(revs, svn_revnum_t) = start_revnum;
if (end_revnum != start_revnum && end_revnum != SVN_INVALID_REVNUM)
Re: svn commit: r1496468 - /subversion/trunk/subversion/libsvn_client/ra.c
Posted by Ivan Zhakov <iv...@visualsvn.com>.
On Tue, Jun 25, 2013 at 5:32 PM, <rh...@apache.org> wrote:
> Author: rhuijben
> Date: Tue Jun 25 13:32:16 2013
> New Revision: 1496468
>
> URL: http://svn.apache.org/r1496468
> Log:
> Use a cheaper ra operation for a common libsvn_client calculation.
>
> * subversion/libsvn_client/ra.c
> (repos_locations): Optimize common diff ra request for diff for the old
> location of the repository root.
>
[...]
======
> --- subversion/trunk/subversion/libsvn_client/ra.c (original)
> +++ subversion/trunk/subversion/libsvn_client/ra.c Tue Jun 25 13:32:16 2013
> @@ -668,9 +668,9 @@ repos_locations(const char **start_url,
> apr_array_header_t *revs;
> apr_hash_t *rev_locs;
>
> - SVN_ERR_ASSERT(peg_revnum != SVN_INVALID_REVNUM);
> - SVN_ERR_ASSERT(start_revnum != SVN_INVALID_REVNUM);
> - SVN_ERR_ASSERT(end_revnum != SVN_INVALID_REVNUM || end_url == NULL);
> + SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(peg_revnum));
> + SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(start_revnum));
> + SVN_ERR_ASSERT(SVN_IS_VALID_REVNUM(end_revnum) || end_url == NULL);
>
> /* Avoid a network request in the common easy case. */
> if (start_revnum == peg_revnum
> @@ -685,6 +685,26 @@ repos_locations(const char **start_url,
>
> SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_url, scratch_pool));
>
> + /* Handle another common case: The repository root can't move */
> + if (! strcmp(repos_url, url))
> + {
> + svn_revnum_t latest_revnum;
> + SVN_ERR(svn_ra_get_latest_revnum(ra_session, &latest_revnum,
> + scratch_pool));
> +
> + if (start_revnum > latest_revnum || end_revnum > latest_revnum)
end_revnum can be SVN_INVALID_REVNUM if end_url is NULL. So this
condition should be fixed.
Also it probably makes sense to move this optimization to caller
(svn_client__repos_locations) since most likely youngest is already
known at this layer.
--
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com