Kamesh, I think we should keep this routine Subversion-private, as
svn_rangelist__parse(), defined in include/private/svn_mergeinfo_private.h.
- Dan
On Tue, 04 Dec 2007, kameshj@tigris.org wrote:
> Author: kameshj
> Date: Tue Dec 4 03:48:20 2007
> New Revision: 28231
>
> Log:
> On the issue-2897 branch:
>
> Expose svn_rangelist_parse and consume it whereever needed.
>
> * subversion/include/svn_mergeinfo.h
> (svn_rangelist_parse): New Prototype.
>
> * subversion/libsvn_subr/mergeinfo.c
> (svn_rangelist_parse): New function.
>
> * subversion/mod_dav_svn/reports/mergeinfo.c
> (dav_svn__get_commit_revs_for_merge_ranges_report):
> * subversion/svnserve/serve.c
> (get_commit_revs_for_merge_ranges):
> Use 'svn_rangelist_parse' to parse the rangelist rather than
> svn_mergeinfo_parse with a dummy merge source.
>
>
> Modified:
> branches/issue-2897/subversion/include/svn_mergeinfo.h
> branches/issue-2897/subversion/libsvn_subr/mergeinfo.c
> branches/issue-2897/subversion/mod_dav_svn/reports/mergeinfo.c
> branches/issue-2897/subversion/svnserve/serve.c
>
> Modified: branches/issue-2897/subversion/include/svn_mergeinfo.h
> URL: http://svn.collab.net/viewvc/svn/branches/issue-2897/subversion/include/svn_mergeinfo.h?pathrev=28231&r1=28230&r2=28231
> ==============================================================================
> --- branches/issue-2897/subversion/include/svn_mergeinfo.h (original)
> +++ branches/issue-2897/subversion/include/svn_mergeinfo.h Tue Dec 4 03:48:20 2007
> @@ -108,6 +108,24 @@
> svn_mergeinfo_parse(apr_hash_t **mergeinfo, const char *input,
> apr_pool_t *pool);
>
> +/** Parse the rangelist from @a input into @a *rangelist
> + * of @c svn_merge_range_t* elements. If no rangelist is available,
> + * return an empty list (never @c NULL). Perform temporary allocations
> + * in @a pool.
> + *
> + * If @a input is not a grammatically correct 'rangelist' token
> + * described in @c SVN_PROP_MERGEINFO section above then return
> + * @c SVN_ERR_MERGEINFO_PARSE_ERROR.
> + *
> + * Note: @a *rangelist is guaranteed to be sorted (ordered by smallest
> + * revision ranges to largest).
> + * @since New in 1.5.
> + */
> +svn_error_t *
> +svn_rangelist_parse(apr_array_header_t **rangelist,
> + const char *input,
> + apr_pool_t *pool);
> +
> /** Calculate the delta between two hashes of mergeinfo (with
> * rangelists sorted in ascending order), @a mergefrom and @a mergeto
> * (which may be @c NULL), and place the result in @a deleted and @a
>
> Modified: branches/issue-2897/subversion/libsvn_subr/mergeinfo.c
> URL: http://svn.collab.net/viewvc/svn/branches/issue-2897/subversion/libsvn_subr/mergeinfo.c?pathrev=28231&r1=28230&r2=28231
> ==============================================================================
> --- branches/issue-2897/subversion/libsvn_subr/mergeinfo.c (original)
> +++ branches/issue-2897/subversion/libsvn_subr/mergeinfo.c Tue Dec 4 03:48:20 2007
> @@ -583,6 +583,19 @@
> return parse_top(&input, input + strlen(input), *mergeinfo, pool);
> }
>
> +/* Parse rangelist. */
> +svn_error_t *
> +svn_rangelist_parse(apr_array_header_t **rangelist,
> + const char *input,
> + apr_pool_t *pool)
> +{
> + *rangelist = apr_array_make(pool, 0, sizeof(svn_merge_range_t *));
> + SVN_ERR(parse_revlist(&input, input + strlen(input), *rangelist, pool));
> + qsort((*rangelist)->elts, (*rangelist)->nelts, (*rangelist)->elt_size,
> + svn_sort_compare_ranges);
> + return SVN_NO_ERROR;
> +}
> +
>
> /* Merge revision list RANGELIST into *MERGEINFO, doing some trivial
> attempts to combine ranges as we go. */
>
> Modified: branches/issue-2897/subversion/mod_dav_svn/reports/mergeinfo.c
> URL: http://svn.collab.net/viewvc/svn/branches/issue-2897/subversion/mod_dav_svn/reports/mergeinfo.c?pathrev=28231&r1=28230&r2=28231
> ==============================================================================
> --- branches/issue-2897/subversion/mod_dav_svn/reports/mergeinfo.c (original)
> +++ branches/issue-2897/subversion/mod_dav_svn/reports/mergeinfo.c Tue Dec 4 03:48:20 2007
> @@ -288,30 +288,18 @@
>
> /* else unknown element; skip it */
> }
> - {
> - /* We lack svn_rangelist_parse(), so create a dummy mergeinfo
> - and parse it with the help of svn_mergeinfo_parse().
> -
> - ### Might be better to write svn_rangelist_parse()? Could
> - ### other places use it too? -Karl */
> - apr_hash_t *dummy_mergeinfo;
> - char *dummy_mergeinfo_str = apr_pstrcat(resource->pool, merge_source, ":",
> - merge_ranges_string, NULL);
> - serr = svn_mergeinfo_parse(&dummy_mergeinfo, dummy_mergeinfo_str,
> - resource->pool);
> - /* ### This error-handling code is repeated all over the place.
> - ### It would be nice to abstract it out; in fact, I think there
> - ### may already be an abstraction ready and waiting... -Karl */
> - if (serr)
> - {
> - derr = dav_svn__convert_err(serr, HTTP_BAD_REQUEST, NULL,
> - resource->pool);
> - goto cleanup;
> - }
> - merge_rangelist = apr_hash_get(dummy_mergeinfo, merge_source,
> - APR_HASH_KEY_STRING);
> - }
>
> + serr = svn_rangelist_parse(&merge_rangelist, merge_ranges_string,
> + resource->pool);
> + /* ### This error-handling code is repeated all over the place.
> + ### It would be nice to abstract it out; in fact, I think there
> + ### may already be an abstraction ready and waiting... -Karl */
> + if (serr)
> + {
> + derr = dav_svn__convert_err(serr, HTTP_BAD_REQUEST, NULL,
> + resource->pool);
> + goto cleanup;
> + }
>
> /* Build authz read baton */
> arb.r = resource->info->r;
>
> Modified: branches/issue-2897/subversion/svnserve/serve.c
> URL: http://svn.collab.net/viewvc/svn/branches/issue-2897/subversion/svnserve/serve.c?pathrev=28231&r1=28230&r2=28231
> ==============================================================================
> --- branches/issue-2897/subversion/svnserve/serve.c (original)
> +++ branches/issue-2897/subversion/svnserve/serve.c Tue Dec 4 03:48:20 2007
> @@ -1557,16 +1557,7 @@
> merge_source_abs_path = svn_path_join(b->fs_path->data, merge_source, pool);
> inherit = svn_inheritance_from_word(inherit_word);
>
> - {
> - /* We lack svn_rangelist_parse, so creating a dummy mergeinfo
> - and parse with the help of svn_mergeinfo_parse. */
> - apr_hash_t *dummy_mergeinfo;
> - char *dummy_mergeinfo_str = apr_pstrcat(pool, merge_source, ":",
> - merge_ranges_string, NULL);
> - SVN_ERR(svn_mergeinfo_parse(&dummy_mergeinfo, dummy_mergeinfo_str, pool));
> - merge_rangelist = apr_hash_get(dummy_mergeinfo, merge_source,
> - APR_HASH_KEY_STRING);
> - }
> + SVN_ERR(svn_rangelist_parse(&merge_rangelist, merge_ranges_string, pool));
>
> SVN_ERR(trivial_auth_request(conn, pool, b));
> SVN_CMD_ERR(svn_repos_get_commit_revs_for_merge_ranges(
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: svn-help@subversion.tigris.org
--
Daniel Rall
- application/pgp-signature attachment: stored
Received on Wed Dec 5 08:32:53 2007