Author: pburba Date: Mon Nov 21 17:41:26 2011 New Revision: 1204617 URL: http://svn.apache.org/viewvc?rev=1204617&view=rev Log: Fix up some doc strings and consolidate two similar functions into one.
See http://svn.haxx.se/dev/archive-2011-11/0301.shtml * subversion/libsvn_client/merge.c (get_most_inclusive_start_rev, get_most_inclusive_end_rev): Remove both of these and replace with... (get_most_inclusive_rev): ...this. Note that the logic in get_most_inclusive_start_rev which checked for "dummy" ranges was removed in the new combined function; this logic has been unnecessary since r872890. (do_directory_merge): Replace calls to get_most_inclusive_*_rev with get_most_inclusive_rev. Correct a in-line comment before one of those calls. Modified: subversion/trunk/subversion/libsvn_client/merge.c Modified: subversion/trunk/subversion/libsvn_client/merge.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1204617&r1=1204616&r2=1204617&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_client/merge.c (original) +++ subversion/trunk/subversion/libsvn_client/merge.c Mon Nov 21 17:41:26 2011 @@ -5110,77 +5110,49 @@ drive_merge_report_editor(const char *ta } /* Iterate over each svn_client__merge_path_t * element in - CHILDREN_WITH_MERGEINFO and find the most inclusive start revision - among those element's first remaining_ranges element. - - If IS_ROLLBACK is true the youngest revision is considered the "most - inclusive" otherwise the oldest revision is. + CHILDREN_WITH_MERGEINFO and, if START_REV is true, find the most inclusive + start revision among those element's first remaining_ranges element. If + START_REV is false, then look for the most inclusive end revision. + + If IS_ROLLBACK is true the youngest start or end (as per START_REV) + revision is considered the "most inclusive" otherwise the oldest revision + is. If none of CHILDREN_WITH_MERGEINFO's elements have any remaining ranges return SVN_INVALID_REVNUM. */ static svn_revnum_t -get_most_inclusive_start_rev(const apr_array_header_t *children_with_mergeinfo, - svn_boolean_t is_rollback) +get_most_inclusive_rev(const apr_array_header_t *children_with_mergeinfo, + svn_boolean_t is_rollback, + svn_boolean_t start_rev) { int i; - svn_revnum_t start_rev = SVN_INVALID_REVNUM; + svn_revnum_t most_inclusive_rev = SVN_INVALID_REVNUM; for (i = 0; i < children_with_mergeinfo->nelts; i++) { svn_client__merge_path_t *child = APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *); - svn_merge_range_t *range; if ((! child) || child->absent) continue; - if (! child->remaining_ranges->nelts) - continue; - range = APR_ARRAY_IDX(child->remaining_ranges, 0, svn_merge_range_t *); - if ((i == 0) && (range->start == range->end)) - continue; - if ((start_rev == SVN_INVALID_REVNUM) - || (is_rollback && (range->start > start_rev)) - || ((! is_rollback) && (range->start < start_rev))) - start_rev = range->start; - } - return start_rev; -} - -/* Iterate over each svn_client__merge_path_t * element in - CHILDREN_WITH_MERGEINFO and find the most inclusive end revision - among those element's first remaining_ranges element. - - If IS_ROLLBACK is true the oldest revision is considered the "most - inclusive" otherwise the youngest revision is. - - If none of CHILDREN_WITH_MERGEINFO's elements have any remaining ranges - return SVN_INVALID_REVNUM. */ -static svn_revnum_t -get_most_inclusive_end_rev(const apr_array_header_t *children_with_mergeinfo, - svn_boolean_t is_rollback) -{ - int i; - svn_revnum_t end_rev = SVN_INVALID_REVNUM; - - for (i = 0; i < children_with_mergeinfo->nelts; i++) - { - svn_client__merge_path_t *child = - APR_ARRAY_IDX(children_with_mergeinfo, i, svn_client__merge_path_t *); - if (!child || child->absent) - continue; if (child->remaining_ranges->nelts > 0) { - svn_merge_range_t *range = APR_ARRAY_IDX(child->remaining_ranges, 0, - svn_merge_range_t *); - if ((end_rev == SVN_INVALID_REVNUM) - || (is_rollback && (range->end > end_rev)) - || ((! is_rollback) && (range->end < end_rev))) - end_rev = range->end; + svn_merge_range_t *range = + APR_ARRAY_IDX(child->remaining_ranges, 0, svn_merge_range_t *); + + /* Are we looking for the most inclusive start or end rev? */ + svn_revnum_t rev = start_rev ? range->start : range->end; + + if ((most_inclusive_rev == SVN_INVALID_REVNUM) + || (is_rollback && (rev > most_inclusive_rev)) + || ((! is_rollback) && (rev < most_inclusive_rev))) + most_inclusive_rev = rev; } } - return end_rev; + return most_inclusive_rev; } + /* If first item in each child of CHILDREN_WITH_MERGEINFO's remaining_ranges is inclusive of END_REV, Slice the first range in to two at END_REV. All the allocations are persistent and allocated @@ -8406,8 +8378,8 @@ do_directory_merge(svn_mergeinfo_catalog We'll do this twice, right now for the start of the mergeinfo we will ultimately record to describe this merge and then later for the start of the actual editor drive. */ - new_range_start = get_most_inclusive_start_rev( - notify_b->children_with_mergeinfo, is_rollback); + new_range_start = get_most_inclusive_rev( + notify_b->children_with_mergeinfo, is_rollback, TRUE); if (SVN_IS_VALID_REVNUM(new_range_start)) range.start = new_range_start; @@ -8429,18 +8401,18 @@ do_directory_merge(svn_mergeinfo_catalog may have further refined the starting revision for our editor drive. */ start_rev = - get_most_inclusive_start_rev(notify_b->children_with_mergeinfo, - is_rollback); + get_most_inclusive_rev(notify_b->children_with_mergeinfo, + is_rollback, TRUE); /* Is there anything to merge? */ if (SVN_IS_VALID_REVNUM(start_rev)) { - /* Now examine NOTIFY_B->CHILDREN_WITH_MERGEINFO to find the youngest + /* Now examine NOTIFY_B->CHILDREN_WITH_MERGEINFO to find the oldest ending revision that actually needs to be merged (for reverse - merges this is the oldest starting revision). */ + merges this is the youngest ending revision). */ svn_revnum_t end_rev = - get_most_inclusive_end_rev(notify_b->children_with_mergeinfo, - is_rollback); + get_most_inclusive_rev(notify_b->children_with_mergeinfo, + is_rollback, FALSE); /* While END_REV is valid, do the following: @@ -8583,8 +8555,8 @@ do_directory_merge(svn_mergeinfo_catalog remove_first_range_from_remaining_ranges( end_rev, notify_b->children_with_mergeinfo, scratch_pool); next_end_rev = - get_most_inclusive_end_rev(notify_b->children_with_mergeinfo, - is_rollback); + get_most_inclusive_rev(notify_b->children_with_mergeinfo, + is_rollback, FALSE); if ((next_end_rev != SVN_INVALID_REVNUM || abort_on_conflicts) && is_path_conflicted_by_merge(merge_b)) { @@ -8599,8 +8571,8 @@ do_directory_merge(svn_mergeinfo_catalog break; } start_rev = - get_most_inclusive_start_rev(notify_b->children_with_mergeinfo, - is_rollback); + get_most_inclusive_rev(notify_b->children_with_mergeinfo, + is_rollback, TRUE); end_rev = next_end_rev; } }
