subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1229547 - in /subversion/trunk/subversion/libsvn_client: client.h merge.c mergeinfo.c mergeinfo.h ra.c
Date Tue, 10 Jan 2012 14:12:42 GMT
Author: julianfoad
Date: Tue Jan 10 14:12:42 2012
New Revision: 1229547

URL: http://svn.apache.org/viewvc?rev=1229547&view=rev
Log:
Simplify the merge code by reparenting RA sessions in lower level functions
rather than in their callers.

* subversion/libsvn_client/client.h
  (svn_client__repos_location): Require only that the session be open to a
    URL in the right repository, not necessarily to the right URL.

* subversion/libsvn_client/mergeinfo.h
  (svn_client__get_history_as_mergeinfo): Same; and add an explicit target
    URL parameter.

* subversion/libsvn_client/merge.c
  (filter_self_referential_mergeinfo, get_full_mergeinfo,
   find_gaps_in_merge_source_history, record_mergeinfo_for_dir_merge,
   record_mergeinfo_for_added_subtrees): Taking advantage of the changes
    above, loosen the requirements on the incoming RA session and don't
    explicitly reparent it.
  (process_children_with_new_mergeinfo): Don't reparent the session here
    because the function being called already did not require it.

* subversion/libsvn_client/mergeinfo.c
  (svn_client__get_history_as_mergeinfo): See above.
  (svn_client_mergeinfo_log): Adjust calls accordingly.

* subversion/libsvn_client/ra.c
  (repos_locations): Clarify requirements for the session parameter.
  (svn_client__repos_location): See above.
  (svn_client__get_youngest_common_ancestor): Adjust calls to
    svn_client__get_history_as_mergeinfo().

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_client/mergeinfo.c
    subversion/trunk/subversion/libsvn_client/mergeinfo.h
    subversion/trunk/subversion/libsvn_client/ra.c

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1229547&r1=1229546&r2=1229547&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Tue Jan 10 14:12:42 2012
@@ -148,7 +148,9 @@ svn_client__repos_locations(const char *
  *
  * Set *OP_URL to the URL that the object PEG_URL@PEG_REVNUM had in
  * revision OP_REVNUM.
- * RA_SESSION is required. */
+ *
+ * RA_SESSION is an open RA session to the correct repository; it may be
+ * temporarily reparented inside this function. */
 svn_error_t *
 svn_client__repos_location(const char **start_url,
                            svn_ra_session_t *ra_session,

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1229547&r1=1229546&r2=1229547&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Tue Jan 10 14:12:42 2012
@@ -835,8 +835,11 @@ omit_mergeinfo_changes(apr_array_header_
    that range.  If the entire rangelist for a given path is filtered then
    filter out the path as well.
 
-   Use RA_SESSION for any communication to the repository, and CTX for any
-   further client operations.
+   If SAME_REPOS is true, RA_SESSION is an open RA session to the repository
+   in which both the source and target live, else RA_SESSION is not used. It
+   may be temporarily reparented as needed by this function.
+
+   Use CTX for any further client operations.
 
    If any filtering occurs, set outgoing *PROPS to a shallow copy (allocated
    in POOL) of incoming *PROPS minus the filtered mergeinfo. */
@@ -897,7 +900,6 @@ filter_self_referential_mergeinfo(apr_ar
       svn_mergeinfo_t mergeinfo, younger_mergeinfo;
       svn_mergeinfo_t filtered_mergeinfo = NULL;
       svn_mergeinfo_t filtered_younger_mergeinfo = NULL;
-      const char *old_url;
       svn_error_t *err;
 
       if ((strcmp(prop->name, SVN_PROP_MERGEINFO) != 0)
@@ -911,11 +913,6 @@ filter_self_referential_mergeinfo(apr_ar
       svn_pool_clear(iterpool);
 
       /* Non-empty mergeinfo; filter self-referential mergeinfo out. */
-      /* Temporarily reparent our RA session to the merge
-         target's URL. */
-      SVN_ERR(svn_client__ensure_ra_session_url(&old_url,
-                                                ra_session,
-                                                target_base_url, iterpool));
 
       /* Parse the incoming mergeinfo to allow easier manipulation. */
       err = svn_mergeinfo_parse(&mergeinfo, prop->value->data, iterpool);
@@ -928,11 +925,6 @@ filter_self_referential_mergeinfo(apr_ar
             {
               svn_error_clear(err);
               APR_ARRAY_PUSH(adjusted_props, svn_prop_t) = *prop;
-
-              /* If we reparented RA_SESSION above, put it back
-                 to the original URL. */
-              SVN_ERR(svn_ra_reparent(ra_session, old_url, iterpool));
-
               continue;
             }
           else
@@ -1085,11 +1077,9 @@ filter_self_referential_mergeinfo(apr_ar
           svn_mergeinfo_t implicit_mergeinfo;
 
           SVN_ERR(svn_client__get_history_as_mergeinfo(
-            &implicit_mergeinfo, NULL,
+            &implicit_mergeinfo, NULL, target_base_url,
             target_base_rev, target_base_rev, SVN_INVALID_REVNUM,
-            ra_session,
-            ctx,
-            iterpool));
+            ra_session, ctx, iterpool));
 
           /* Remove PATH's implicit mergeinfo from the incoming mergeinfo. */
           SVN_ERR(svn_mergeinfo_remove2(&filtered_mergeinfo,
@@ -1097,9 +1087,6 @@ filter_self_referential_mergeinfo(apr_ar
                                         mergeinfo, TRUE, iterpool, iterpool));
         }
 
-      /* If we reparented RA_SESSION above, put it back to the original URL. */
-      SVN_ERR(svn_ra_reparent(ra_session, old_url, iterpool));
-
       /* Combine whatever older and younger filtered mergeinfo exists
          into filtered_mergeinfo. */
       if (filtered_mergeinfo && filtered_younger_mergeinfo)
@@ -3484,8 +3471,8 @@ fix_deleted_subtree_ranges(const merge_s
    is older than START, then the base revision is used as the younger
    bound in place of START.
 
-   RA_SESSION is an open session that may be temporarily reparented as
-   needed by this function.
+   RA_SESSION is an open RA session to the repository in which SOURCE lives.
+   It may be temporarily reparented as needed by this function.
 
    Allocate *RECORDED_MERGEINFO and *IMPLICIT_MERGEINFO in RESULT_POOL.
    Use SCRATCH_POOL for any temporary allocations. */
@@ -3549,17 +3536,12 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
       else
         {
           const char *url;
-          const char *session_url;
 
           url = svn_path_url_add_component2(repos_root, repos_relpath,
                                             scratch_pool);
 
-          /* Temporarily point our RA_SESSION at our target URL so we can
-             fetch so-called "implicit mergeinfo" (that is, natural
+          /* Fetch so-called "implicit mergeinfo" (that is, natural
              history). */
-          SVN_ERR(svn_client__ensure_ra_session_url(&session_url,
-                                                    ra_session, url,
-                                                    scratch_pool));
 
           /* Do not ask for implicit mergeinfo from TARGET_ABSPATH's future.
              TARGET_ABSPATH might not even exist, and even if it does the
@@ -3571,13 +3553,10 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
           /* Fetch the implicit mergeinfo. */
           SVN_ERR(svn_client__get_history_as_mergeinfo(implicit_mergeinfo,
                                                        NULL,
-                                                       target_rev,
+                                                       url, target_rev,
                                                        start, end,
                                                        ra_session, ctx,
                                                        result_pool));
-
-          /* Return RA_SESSION back to where it was when we were called. */
-          SVN_ERR(svn_ra_reparent(ra_session, session_url, scratch_pool));
         }
     } /*if (implicit_mergeinfo) */
 
@@ -4119,8 +4098,7 @@ calculate_remaining_ranges(svn_client__m
 
 /* Helper for populate_remaining_ranges().
 
-   SOURCE, RA_SESSION,
-   and MERGE_B are all cascaded from the arguments of the same name in
+   SOURCE and MERGE_B are cascaded from the arguments of the same name in
    populate_remaining_ranges().
 
    Note: The following comments assume a forward merge, i.e. SOURCE->rev1
@@ -4140,7 +4118,10 @@ calculate_remaining_ranges(svn_client__m
    would indicate that trunk@7 was copied from trunk@2.  This function would
    return GAP_START:GAP_END of 2:6 in this case.  Note that a path 'trunk'
    might exist at r3-6, but it would not be on the same line of history as
-   trunk@9. */
+   trunk@9.
+
+   RA_SESSION is an open RA session to the repository in which SOURCE lives.
+*/
 static svn_error_t *
 find_gaps_in_merge_source_history(svn_revnum_t *gap_start,
                                   svn_revnum_t *gap_end,
@@ -4162,8 +4143,8 @@ find_gaps_in_merge_source_history(svn_re
 
   /* Get SOURCE as mergeinfo. */
   SVN_ERR(svn_client__get_history_as_mergeinfo(&implicit_src_mergeinfo, NULL,
-                                               young_rev, young_rev,
-                                               old_rev, ra_session,
+                                               primary_url, young_rev,
+                                               young_rev, old_rev, ra_session,
                                                merge_b->ctx, scratch_pool));
 
   SVN_ERR(svn_ra__get_fspath_relative_to_root(
@@ -7014,15 +6995,11 @@ process_children_with_new_mergeinfo(merg
        hi = apr_hash_next(hi))
     {
       const char *abspath_with_new_mergeinfo = svn__apr_hash_index_key(hi);
-      const char *path_url;
       svn_mergeinfo_t path_inherited_mergeinfo;
       svn_mergeinfo_t path_explicit_mergeinfo;
       svn_client__merge_path_t *new_child;
 
       apr_pool_clear(iterpool);
-      SVN_ERR(svn_wc__node_get_url(&path_url, merge_b->ctx->wc_ctx,
-                                   abspath_with_new_mergeinfo,
-                                   pool, pool));
 
       /* Get the path's new explicit mergeinfo... */
       SVN_ERR(svn_client__get_wc_mergeinfo(&path_explicit_mergeinfo, NULL,
@@ -7035,14 +7012,6 @@ process_children_with_new_mergeinfo(merg
          but you can't be too careful. */
       if (path_explicit_mergeinfo)
         {
-          const char *old_session_url;
-
-          /* Temporarily reparent MERGE_B->RA_SESSION2 in case we need to
-             contact the repository for inherited mergeinfo. */
-          SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
-                                                    merge_b->ra_session2,
-                                                    path_url,
-                                                    iterpool));
           /* Get the mergeinfo the path would have inherited before
              the merge. */
           SVN_ERR(svn_client__get_wc_or_repos_mergeinfo(
@@ -7098,11 +7067,6 @@ process_children_with_new_mergeinfo(merg
                  parent->remaining_ranges, pool);
               insert_child_to_merge(children_with_mergeinfo, new_child, pool);
             }
-
-          /* Return MERGE_B->RA_SESSION2 to its initial state if we
-             reparented it. */
-          SVN_ERR(svn_ra_reparent(merge_b->ra_session2, old_session_url,
-                                  iterpool));
         }
     }
   svn_pool_destroy(iterpool);
@@ -7785,7 +7749,6 @@ record_mergeinfo_for_dir_merge(svn_merge
               svn_error_t *err;
               svn_mergeinfo_t subtree_history_as_mergeinfo;
               apr_array_header_t *child_merge_src_rangelist;
-              const char *old_session_url;
               const char *subtree_mergeinfo_url =
                 svn_path_url_add_component2(merge_b->target->repos_root.url,
                                             child_merge_src_fspath + 1,
@@ -7797,15 +7760,10 @@ record_mergeinfo_for_dir_merge(svn_merge
                  history. */
               /* We know MERGED_RANGE->END is younger than MERGE_RANGE->START
                  because we only do this for forward merges. */
-              SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
-                                                        merge_b->ra_session2,
-                                                        subtree_mergeinfo_url,
-                                                        iterpool));
               err = svn_client__get_history_as_mergeinfo(
                 &subtree_history_as_mergeinfo, NULL,
-                merged_range->end,
-                merged_range->end,
-                merged_range->start,
+                subtree_mergeinfo_url, merged_range->end,
+                merged_range->end, merged_range->start,
                 merge_b->ra_session2, merge_b->ctx, iterpool);
 
               /* If CHILD is a subtree it may have been deleted prior to
@@ -7831,9 +7789,6 @@ record_mergeinfo_for_dir_merge(svn_merge
                     svn_rangelist__set_inheritance(child_merge_rangelist,
                                                    FALSE);
                 }
-
-              SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
-                                      old_session_url, iterpool));
             }
 
           apr_hash_set(child_merges, child->abspath, APR_HASH_KEY_STRING,
@@ -7955,7 +7910,6 @@ record_mergeinfo_for_added_subtrees(
           apr_array_header_t *rangelist;
           const char *rel_added_path;
           const char *added_path_mergeinfo_fspath;
-          const char *old_session_url;
           const char *added_path_mergeinfo_url;
 
           SVN_ERR(svn_wc_read_kind(&added_path_kind, merge_b->ctx->wc_ctx,
@@ -7998,19 +7952,14 @@ record_mergeinfo_for_added_subtrees(
             svn_path_url_add_component2(merge_b->target->repos_root.url,
                                         added_path_mergeinfo_fspath + 1,
                                         iterpool);
-          SVN_ERR(svn_client__ensure_ra_session_url(
-            &old_session_url, merge_b->ra_session2,
-            added_path_mergeinfo_url, iterpool));
           SVN_ERR(svn_client__get_history_as_mergeinfo(
             &adds_history_as_mergeinfo, NULL,
+            added_path_mergeinfo_url,
             MAX(merged_range->start, merged_range->end),
             MAX(merged_range->start, merged_range->end),
             MIN(merged_range->start, merged_range->end),
             merge_b->ra_session2, merge_b->ctx, iterpool));
 
-          SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
-                                  old_session_url, iterpool));
-
           SVN_ERR(svn_mergeinfo_intersect2(&merge_mergeinfo,
                                            merge_mergeinfo,
                                            adds_history_as_mergeinfo,

Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.c?rev=1229547&r1=1229546&r2=1229547&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.c Tue Jan 10 14:12:42 2012
@@ -757,6 +757,7 @@ svn_client__get_wc_or_repos_mergeinfo_ca
 svn_error_t *
 svn_client__get_history_as_mergeinfo(svn_mergeinfo_t *mergeinfo_p,
                                      svn_boolean_t *has_rev_zero_history,
+                                     const char *url,
                                      svn_revnum_t peg_revnum,
                                      svn_revnum_t range_youngest,
                                      svn_revnum_t range_oldest,
@@ -764,6 +765,7 @@ svn_client__get_history_as_mergeinfo(svn
                                      svn_client_ctx_t *ctx,
                                      apr_pool_t *pool)
 {
+  const char *old_session_url;
   apr_array_header_t *segments;
 
   /* Fetch the location segments for our URL@PEG_REVNUM. */
@@ -771,9 +773,13 @@ svn_client__get_history_as_mergeinfo(svn
     range_youngest = peg_revnum;
   if (! SVN_IS_VALID_REVNUM(range_oldest))
     range_oldest = 0;
+
+  SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url, ra_session,
+                                            url, pool));
   SVN_ERR(svn_client__repos_location_segments(&segments, ra_session, "",
                                               peg_revnum, range_youngest,
                                               range_oldest, ctx, pool));
+  SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
 
   if (has_rev_zero_history)
     {
@@ -1652,7 +1658,6 @@ svn_client_mergeinfo_log(svn_boolean_t f
                          apr_pool_t *scratch_pool)
 {
   apr_pool_t *sesspool = svn_pool_create(scratch_pool);
-  svn_ra_session_t *source_session, *target_session;
   const char *log_target = NULL;
   const char *repos_root;
   const char *target_repos_rel;
@@ -1728,38 +1733,34 @@ svn_client_mergeinfo_log(svn_boolean_t f
    * should share a single session, tracking the two URLs separately. */
   if (!finding_merged)
     {
-      svn_revnum_t target_peg_revnum;
-
-      SVN_ERR(svn_client__ra_session_from_path(&target_session,
-                                               &target_peg_revnum, NULL,
-                                               target_path_or_url, NULL,
-                                               target_peg_revision,
-                                               target_peg_revision,
-                                               ctx, sesspool));
-
-      SVN_ERR(svn_client__get_history_as_mergeinfo(&target_history, NULL,
-                                                   target_peg_revnum,
-                                                   SVN_INVALID_REVNUM,
-                                                   SVN_INVALID_REVNUM,
-                                                   target_session, ctx,
-                                                   scratch_pool));
+      svn_ra_session_t *target_session;
+      svn_revnum_t rev;
+      const char *url;
+
+      SVN_ERR(svn_client__ra_session_from_path(
+                &target_session, &rev, &url,
+                target_path_or_url, NULL,
+                target_peg_revision, target_peg_revision,
+                ctx, sesspool));
+      SVN_ERR(svn_client__get_history_as_mergeinfo(
+                &target_history, NULL,
+                url, rev, SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
+                target_session, ctx, scratch_pool));
     }
   {
-    svn_revnum_t source_peg_revnum;
-
-    SVN_ERR(svn_client__ra_session_from_path(&source_session,
-                                             &source_peg_revnum, NULL,
-                                             source_path_or_url, NULL,
-                                             source_peg_revision,
-                                             source_peg_revision,
-                                             ctx, sesspool));
-
-    SVN_ERR(svn_client__get_history_as_mergeinfo(&source_history, NULL,
-                                                 source_peg_revnum,
-                                                 SVN_INVALID_REVNUM,
-                                                 SVN_INVALID_REVNUM,
-                                                 source_session, ctx,
-                                                 scratch_pool));
+    svn_ra_session_t *source_session;
+    svn_revnum_t rev;
+    const char *url;
+
+    SVN_ERR(svn_client__ra_session_from_path(
+              &source_session, &rev, &url,
+              source_path_or_url, NULL,
+              source_peg_revision, source_peg_revision,
+              ctx, sesspool));
+    SVN_ERR(svn_client__get_history_as_mergeinfo(
+              &source_history, NULL,
+              url, rev, SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
+              source_session, ctx, scratch_pool));
   }
   /* Close the source and target sessions. */
   svn_pool_destroy(sesspool);

Modified: subversion/trunk/subversion/libsvn_client/mergeinfo.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/mergeinfo.h?rev=1229547&r1=1229546&r2=1229547&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/mergeinfo.h (original)
+++ subversion/trunk/subversion/libsvn_client/mergeinfo.h Tue Jan 10 14:12:42 2012
@@ -286,7 +286,7 @@ svn_client__get_wc_or_repos_mergeinfo_ca
   apr_pool_t *scratch_pool);
 
 /* Set *MERGEINFO_P to a mergeinfo constructed solely from the
-   natural history of RA_SESSION's session URL at PEG_REVNUM.
+   natural history of URL at PEG_REVNUM.
 
    If RANGE_YOUNGEST and RANGE_OLDEST are valid, use them to bound the
    revision ranges of returned mergeinfo.  They are governed by the same
@@ -294,10 +294,15 @@ svn_client__get_wc_or_repos_mergeinfo_ca
    svn_ra_get_location_segments().
 
    If HAS_REV_ZERO_HISTORY is not NULL, then set *HAS_REV_ZERO_HISTORY to
-   TRUE if the natural history includes revision 0, else to FALSE. */
+   TRUE if the natural history includes revision 0, else to FALSE.
+
+   RA_SESSION is an open RA session to the repository in which URL lives;
+   it may be temporarily reparented by this function.
+*/
 svn_error_t *
 svn_client__get_history_as_mergeinfo(svn_mergeinfo_t *mergeinfo_p,
                                      svn_boolean_t *has_rev_zero_history,
+                                     const char *url,
                                      svn_revnum_t peg_revnum,
                                      svn_revnum_t range_youngest,
                                      svn_revnum_t range_oldest,

Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1229547&r1=1229546&r2=1229547&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Tue Jan 10 14:12:42 2012
@@ -578,7 +578,9 @@ svn_client__repos_location_segments(apr_
  *
  * START_URL and/or END_URL may be NULL if not wanted.  START_REVNUM and
  * END_REVNUM must be valid revision numbers except that END_REVNUM may
- * be SVN_INVALID_REVNUM if END_URL is NULL.  RA_SESSION is required.
+ * be SVN_INVALID_REVNUM if END_URL is NULL.
+ *
+ * RA_SESSION is an open RA session parented at URL.
  */
 static svn_error_t *
 repos_locations(const char **start_url,
@@ -660,10 +662,15 @@ svn_client__repos_location(const char **
                            apr_pool_t *result_pool,
                            apr_pool_t *scratch_pool)
 {
+  const char *old_session_url;
+
+  SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url, ra_session,
+                                            peg_url, scratch_pool));
   SVN_ERR(repos_locations(op_url, NULL,
                           ra_session, peg_url, peg_revnum,
                           op_revnum, SVN_INVALID_REVNUM,
                           result_pool, scratch_pool));
+  SVN_ERR(svn_ra_reparent(ra_session, old_session_url, scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -833,14 +840,13 @@ svn_client__get_youngest_common_ancestor
      saves us a bunch of annoying custom data comparisons and such. */
   SVN_ERR(svn_client__get_history_as_mergeinfo(&history1,
                                                &has_rev_zero_history1,
-                                               rev1,
+                                               url1, rev1,
                                                SVN_INVALID_REVNUM,
                                                SVN_INVALID_REVNUM,
                                                session, ctx, pool));
-  SVN_ERR(svn_ra_reparent(session, url2, pool));
   SVN_ERR(svn_client__get_history_as_mergeinfo(&history2,
                                                &has_rev_zero_history2,
-                                               rev2,
+                                               url2, rev2,
                                                SVN_INVALID_REVNUM,
                                                SVN_INVALID_REVNUM,
                                                session, ctx, pool));



Mime
View raw message