[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] [merge-tracking]Fix for svn merge reversal bug

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-07-07 21:39:01 CEST

Hi All,
Find the attached patch to the defect explained in the log message.

With regards
Kamesh Jayachandran

[[[
Patch by: Kamesh Jayachandran <kamesh@collab.net>

Assuming we have already merged 155-156 of /branches/b1 to wc.
'svn merge -r156:154 file:///path/to/repos/branches/b1' should remove
155-156
from the svn:mergeinfo property for '/branches/b1' after merging.
Without this
fix it does not.
The cause is rangelist api's are capable of handling forward paths not the
reverse paths.

* subversion/include/svn_mergeinfo.h
  Made svn_range_swap_endpoints public, this function was originally a
  static function in subversion/libsvn_subr/mergeinfo.c

* subversion/libsvn_subr/mergeinfo.c
  (svn_range_swap_endpoints): Renamed function 'range_swap_endpoints'
  'svn_range_swap_endpoints' as we want this function to be public.
  (svn_rangelist_reverse): Calls 'svn_range_swap_endpoints.

* subversion/libsvn_client/diff.c
  (update_wc_merge_info):
   Reverse the merge ranges(a.k.a eraser) before passing to
   svn_rangelist_remove().
]]]

Index: subversion/include/svn_mergeinfo.h
===================================================================
--- subversion/include/svn_mergeinfo.h (revision 20465)
+++ subversion/include/svn_mergeinfo.h (working copy)
@@ -131,6 +131,12 @@
                         apr_array_header_t *rangelist2,
                         apr_pool_t *pool);
 
+/** Swap @a range's @c start and @c end fields .
+ * @since New in 1.5.
+ */
+svn_error_t *
+svn_range_swap_endpoints(svn_merge_range_t *range);
+
 /** Reverse @a rangelist, and the @c start and @c end fields of each
  * range in @a rangelist, in place.
  * @since New in 1.5.
Index: subversion/libsvn_subr/mergeinfo.c
===================================================================
--- subversion/libsvn_subr/mergeinfo.c (revision 20465)
+++ subversion/libsvn_subr/mergeinfo.c (working copy)
@@ -356,12 +356,13 @@
 }
 
 /* Swap start and end fields of RANGE. */
-static void
-range_swap_endpoints(svn_merge_range_t *range)
+svn_error_t *
+svn_range_swap_endpoints(svn_merge_range_t *range)
 {
   svn_revnum_t swap = range->start;
   range->start = range->end;
   range->end = swap;
+ return SVN_NO_ERROR;
 }
 
 svn_error_t *
@@ -376,15 +377,15 @@
       *APR_ARRAY_IDX(rangelist, i, svn_merge_range_t *) =
         *APR_ARRAY_IDX(rangelist, swap_index, svn_merge_range_t *);
       *APR_ARRAY_IDX(rangelist, swap_index, svn_merge_range_t *) = range;
- range_swap_endpoints(APR_ARRAY_IDX(rangelist, swap_index,
+ svn_range_swap_endpoints(APR_ARRAY_IDX(rangelist, swap_index,
                                          svn_merge_range_t *));
- range_swap_endpoints(APR_ARRAY_IDX(rangelist, i, svn_merge_range_t *));
+ svn_range_swap_endpoints(APR_ARRAY_IDX(rangelist, i, svn_merge_range_t *));
     }
 
   /* If there's an odd number of elements, we still need to swap the
      end points of the remaining range. */
   if (rangelist->nelts % 2 == 1)
- range_swap_endpoints(APR_ARRAY_IDX(rangelist, rangelist->nelts / 2,
+ svn_range_swap_endpoints(APR_ARRAY_IDX(rangelist, rangelist->nelts / 2,
                                        svn_merge_range_t *));
 
   return SVN_NO_ERROR;
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 20465)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -1735,11 +1735,26 @@
   apr_hash_t *mergeinfo = apr_hash_copy(pool, target_mergeinfo);
   apr_array_header_t *rangelist = apr_hash_get(target_mergeinfo, rel_path,
                                                APR_HASH_KEY_STRING);
+ apr_array_header_t *reversed_ranges =
+ apr_array_make(pool, 0, sizeof(svn_merge_range_t *));
+ int i = 0;
+
   if (rangelist == NULL)
     rangelist = apr_array_make(pool, 0, sizeof(svn_merge_range_t *));
 
+ for (i = 0; i < ranges->nelts; i++)
+ {
+ svn_merge_range_t *reversed_range;
+ svn_merge_range_t *range =
+ (APR_ARRAY_IDX(ranges, i, svn_merge_range_t *));
+ reversed_range = svn_range_dup(range, pool);
+ svn_range_swap_endpoints(reversed_range);
+ APR_ARRAY_PUSH(reversed_ranges, svn_merge_range_t *) = reversed_range;
+ }
+
   if (is_revert)
- SVN_ERR(svn_rangelist_remove(&rangelist, ranges, rangelist, pool));
+ SVN_ERR(svn_rangelist_remove(&rangelist, reversed_ranges,
+ rangelist, pool));
   else
     SVN_ERR(svn_rangelist_merge(&rangelist, rangelist, ranges, pool));
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jul 7 21:38:30 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.