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 2012/03/21 17:54:35 UTC

svn commit: r1303465 - /subversion/trunk/subversion/libsvn_client/merge.c

Author: julianfoad
Date: Wed Mar 21 16:54:35 2012
New Revision: 1303465

URL: http://svn.apache.org/viewvc?rev=1303465&view=rev
Log:
Teach symmetric merge to find the other base, so it will choose whichever
base is younger.  Now it can merge back and forth between two branches.
(The implementation doesn't yet cope with renames in the history of
the branch, but that's a relatively SMOP.)

* subversion/libsvn_client/merge.c
  (find_base_on_source): Fill in a rough implementation.

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=1303465&r1=1303464&r2=1303465&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Wed Mar 21 16:54:35 2012
@@ -10933,7 +10933,7 @@ close_source_and_target(source_and_targe
 /* Find a merge base location on the target branch, like in a sync
  * merge.
  *
- *          (Source-left) (Source-right)
+ *          (Source-left) (Source-right = S_T->source)
  *                BASE        RIGHT
  *          o-------o-----------o---
  *         /         \           \
@@ -10950,7 +10950,45 @@ find_base_on_source(repo_location_t **ba
                     apr_pool_t *result_pool,
                     apr_pool_t *scratch_pool)
 {
-  *base_p = NULL;
+  svn_mergeinfo_t target_mergeinfo;
+  svn_client__merge_path_t *merge_target;
+  svn_boolean_t inherited;
+  merge_source_t source;
+  svn_merge_range_t *r;
+  repo_location_t *base;
+
+  merge_target = svn_client__merge_path_create(s_t->target->abspath,
+                                               scratch_pool);
+
+  /* Fetch target mergeinfo (all the way back to revision 1). */
+  SVN_ERR(get_full_mergeinfo(&target_mergeinfo,
+                             &merge_target->implicit_mergeinfo,
+                             &inherited, svn_mergeinfo_inherited,
+                             s_t->target_ra_session, s_t->target->abspath,
+                             s_t->source->rev, 1,
+                             ctx, scratch_pool, scratch_pool));
+
+  /* In order to find the first unmerged change in the source, set
+   * MERGE_TARGET->remaining_ranges to the ranges left to merge,
+   * and look at the start revision of the first such range. */
+  source.url1 = s_t->source->url;  /* ### WRONG: need historical URL/REV */
+  source.rev1 = 1;
+  source.url2 = s_t->source->url;
+  source.rev2 = s_t->source->rev;
+  SVN_ERR(calculate_remaining_ranges(NULL, merge_target,
+                                     &source,
+                                     target_mergeinfo,
+                                     NULL /*merge_b->implicit_src_gap*/,
+                                     FALSE /*child_inherits_implicit*/,
+                                     s_t->source_ra_session,
+                                     ctx, scratch_pool, scratch_pool));
+
+  r = APR_ARRAY_IDX(merge_target->remaining_ranges, 0, svn_merge_range_t *);
+  base = apr_palloc(result_pool, sizeof(*base));
+  base->url = s_t->source->url;  /* ### WRONG: need historical URL */
+  base->rev = r->start;
+
+  *base_p = base;
   return SVN_NO_ERROR;
 }