You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/10/26 12:13:42 UTC
svn commit: r1189107 - in
/subversion/branches/showing-merge-info/subversion/svn: cl.h util.c
Author: julianfoad
Date: Wed Oct 26 10:13:41 2011
New Revision: 1189107
URL: http://svn.apache.org/viewvc?rev=1189107&view=rev
Log:
On the 'showing-merge-info' branch: Add a function to abbreviate a rangelist.
* subversion/svn/cl.h,
subversion/svn/util.c
(svn_cl__rangelist_to_string_elided): New function.
Modified:
subversion/branches/showing-merge-info/subversion/svn/cl.h
subversion/branches/showing-merge-info/subversion/svn/util.c
Modified: subversion/branches/showing-merge-info/subversion/svn/cl.h
URL: http://svn.apache.org/viewvc/subversion/branches/showing-merge-info/subversion/svn/cl.h?rev=1189107&r1=1189106&r2=1189107&view=diff
==============================================================================
--- subversion/branches/showing-merge-info/subversion/svn/cl.h (original)
+++ subversion/branches/showing-merge-info/subversion/svn/cl.h Wed Oct 26 10:13:41 2011
@@ -846,6 +846,16 @@ svn_cl__find_merge_source_branch(svn_cli
svn_client_ctx_t *ctx,
apr_pool_t *pool);
+/* Pretty-print the rangelist RANGES. If the number N of ranges is more than
+ * MAX_RANGES, print the first few ranges, an ellipsis "...", and the last
+ * range, such that the total number of ranges printed is MAX_RANGES-1. */
+svn_error_t *
+svn_cl__rangelist_to_string_elided(const char **ranges_string,
+ apr_array_header_t *ranges,
+ int max_ranges,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Modified: subversion/branches/showing-merge-info/subversion/svn/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/showing-merge-info/subversion/svn/util.c?rev=1189107&r1=1189106&r2=1189107&view=diff
==============================================================================
--- subversion/branches/showing-merge-info/subversion/svn/util.c (original)
+++ subversion/branches/showing-merge-info/subversion/svn/util.c Wed Oct 26 10:13:41 2011
@@ -1471,3 +1471,37 @@ svn_cl__find_merge_source_branch(svn_cli
return SVN_NO_ERROR;
}
+
+svn_error_t *
+svn_cl__rangelist_to_string_elided(const char **ranges_string,
+ apr_array_header_t *ranges,
+ int max_ranges,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ if (ranges->nelts <= max_ranges)
+ {
+ svn_string_t *str;
+
+ SVN_ERR(svn_rangelist_to_string(&str, ranges, result_pool));
+ *ranges_string = str->data;
+ }
+ else
+ {
+ /* Print in the form "FIRST,SECOND,...,LAST" */
+ int n_ranges = ranges->nelts;
+ svn_string_t *str1, *str2;
+
+ ranges = svn_rangelist_dup(ranges, scratch_pool);
+ ranges->nelts = max_ranges - 2;
+ SVN_ERR(svn_rangelist_to_string(&str1, ranges, scratch_pool));
+
+ APR_ARRAY_IDX(ranges, 0, svn_merge_range_t *)
+ = APR_ARRAY_IDX(ranges, n_ranges - 1, svn_merge_range_t *);
+ ranges->nelts = 1;
+ SVN_ERR(svn_rangelist_to_string(&str2, ranges, scratch_pool));
+ *ranges_string = apr_psprintf(result_pool, "%s,...,%s",
+ str1->data, str2->data);
+ }
+ return SVN_NO_ERROR;
+}