subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1227601 - in /subversion/trunk/subversion/libsvn_client: client.h copy.c merge.c ra.c
Date Thu, 05 Jan 2012 14:13:34 GMT
Author: julianfoad
Date: Thu Jan  5 14:13:34 2012
New Revision: 1227601

URL: http://svn.apache.org/viewvc?rev=1227601&view=rev
Log:
Simplify use of svn_client__ensure_ra_session_url() by never allowing it to
return null for the old URL.  In fact its implementation never has been able
to return null, but its doc string said it could and most of its callers
made allowance for this.  I noticed that get_full_mergeinfo() didn't make
allowance and wondered why it didn't crash.

* subversion/libsvn_client/client.h
  (svn_client__ensure_ra_session_url): Don't say that the returned URL will
    ever be null.

* subversion/libsvn_client/copy.c
  (calculate_target_mergeinfo): Don't check for null. Remove redundant
    initialization.
  (repos_to_repos_copy): Remove redundant initialization. This caller
    already didn't check for null.

* subversion/libsvn_client/merge.c
  (get_full_mergeinfo): Rename and rescope the URL variable. This caller
    already didn't check for null.
  (filter_self_referential_mergeinfo, drive_merge_report_editor,
   single_file_merge_get_file, do_file_merge,
   record_mergeinfo_for_dir_merge, record_mergeinfo_for_added_subtrees,
   do_directory_merge): Don't check for null. Remove redundant
    initialization.
  (process_children_with_new_mergeinfo): Don't check for null. Move the
    reparenting into the same scope as svn_client__ensure_ra_session_url().

* subversion/libsvn_client/ra.c
  (svn_client__ensure_ra_session_url): Eliminate a redundant assignment.

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/copy.c
    subversion/trunk/subversion/libsvn_client/merge.c
    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=1227601&r1=1227600&r2=1227601&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Thu Jan  5 14:13:34 2012
@@ -249,11 +249,10 @@ svn_client__ra_session_from_path(svn_ra_
                                  apr_pool_t *pool);
 
 /* Ensure that RA_SESSION's session URL matches SESSION_URL,
-   reparenting that session if necessary.  If reparenting occurs,
-   store the previous session URL in *OLD_SESSION_URL (so that if the
+   reparenting that session if necessary.
+   Store the previous session URL in *OLD_SESSION_URL (so that if the
    reparenting is meant to be temporary, the caller can reparent the
-   session back to where it was); otherwise set *OLD_SESSION_URL to
-   NULL.
+   session back to where it was).
 
    If SESSION_URL is NULL, treat this as a magic value meaning "point
    the RA session to the root of the repository".
@@ -268,8 +267,7 @@ svn_client__ra_session_from_path(svn_ra_
 
        [...]
 
-       if (old_session_url)
-         SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
+       SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
 */
 svn_error_t *
 svn_client__ensure_ra_session_url(const char **old_session_url,

Modified: subversion/trunk/subversion/libsvn_client/copy.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/copy.c?rev=1227601&r1=1227600&r2=1227601&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/copy.c (original)
+++ subversion/trunk/subversion/libsvn_client/copy.c Thu Jan  5 14:13:34 2012
@@ -118,15 +118,14 @@ calculate_target_mergeinfo(svn_ra_sessio
          We could, as an alternative, first see if the target URL was a
          child of the session URL and use the relative "remainder",
          falling back to this reparenting as necessary.  */
-      const char *old_session_url = NULL;
+      const char *old_session_url;
       SVN_ERR(svn_client__ensure_ra_session_url(&old_session_url,
                                                 ra_session, src_url, pool));
       SVN_ERR(svn_client__get_repos_mergeinfo(&src_mergeinfo, ra_session,
                                               "", src_revnum,
                                               svn_mergeinfo_inherited,
                                               TRUE, pool));
-      if (old_session_url)
-        SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
+      SVN_ERR(svn_ra_reparent(ra_session, old_session_url, pool));
     }
 
   *target_mergeinfo = src_mergeinfo;
@@ -981,7 +980,7 @@ repos_to_repos_copy(const apr_array_head
         }
       else
         {
-          const char *old_url = NULL;
+          const char *old_url;
 
           src_rel = NULL;
           SVN_ERR_ASSERT(! is_move);

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1227601&r1=1227600&r2=1227601&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Thu Jan  5 14:13:34 2012
@@ -879,7 +879,7 @@ 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 = NULL;
+      const char *old_url;
       svn_error_t *err;
 
       if ((strcmp(prop->name, SVN_PROP_MERGEINFO) != 0)
@@ -913,8 +913,7 @@ filter_self_referential_mergeinfo(apr_ar
 
               /* If we reparented RA_SESSION above, put it back
                  to the original URL. */
-              if (old_url)
-                SVN_ERR(svn_ra_reparent(ra_session, old_url, iterpool));
+              SVN_ERR(svn_ra_reparent(ra_session, old_url, iterpool));
 
               continue;
             }
@@ -1080,10 +1079,8 @@ filter_self_referential_mergeinfo(apr_ar
                                         mergeinfo, TRUE, iterpool, iterpool));
         }
 
-      /* If we reparented RA_SESSION above, put it back
-         to the original URL. */
-      if (old_url)
-        SVN_ERR(svn_ra_reparent(ra_session, old_url, 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. */
@@ -3503,7 +3500,6 @@ get_full_mergeinfo(svn_mergeinfo_t *reco
     {
       const char *repos_root;
       const char *repos_relpath;
-      const char *session_url = NULL;
       svn_revnum_t target_rev;
 
       /* Assert that we have sane input. */
@@ -3535,6 +3531,7 @@ 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);
@@ -5056,8 +5053,7 @@ drive_merge_report_editor(const char *ta
   SVN_ERR(reporter->finish_report(report_baton, scratch_pool));
 
   /* Point the merge baton's second session back where it was. */
-  if (old_sess2_url)
-    SVN_ERR(svn_ra_reparent(merge_b->ra_session2, old_sess2_url, scratch_pool));
+  SVN_ERR(svn_ra_reparent(merge_b->ra_session2, old_sess2_url, scratch_pool));
 
   /* Caller must call svn_sleep_for_timestamps() */
   *(merge_b->use_sleep) = TRUE;
@@ -5229,8 +5225,7 @@ single_file_merge_get_file(const char **
                                             pool));
   SVN_ERR(svn_ra_get_file(ra_session, "", rev,
                           stream, NULL, props, pool));
-  if (old_sess_url)
-    SVN_ERR(svn_ra_reparent(ra_session, old_sess_url, pool));
+  SVN_ERR(svn_ra_reparent(ra_session, old_sess_url, pool));
 
   return svn_stream_close(stream);
 }
@@ -6767,9 +6762,8 @@ do_file_merge(svn_mergeinfo_catalog_t re
           SVN_ERR(remove_noop_merge_ranges(&ranges_to_merge,
                                            merge_b->ra_session1,
                                            remaining_ranges, scratch_pool));
-          if (old_sess_url)
-            SVN_ERR(svn_ra_reparent(merge_b->ra_session1, old_sess_url,
-                                    iterpool));
+          SVN_ERR(svn_ra_reparent(merge_b->ra_session1, old_sess_url,
+                                  iterpool));
         }
 
       for (i = 0; i < ranges_to_merge->nelts; i++)
@@ -7002,7 +6996,6 @@ 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 *old_session_url = NULL;
       const char *path_url;
       svn_mergeinfo_t path_inherited_mergeinfo;
       svn_mergeinfo_t path_explicit_mergeinfo;
@@ -7024,6 +7017,8 @@ 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,
@@ -7085,12 +7080,12 @@ 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));
         }
-      /* Return MERGE_B->RA_SESSION2 to its initial state if we
-         reparented it. */
-      if (old_session_url)
-        SVN_ERR(svn_ra_reparent(merge_b->ra_session2, old_session_url,
-                                iterpool));
     }
   svn_pool_destroy(iterpool);
 
@@ -7825,9 +7820,8 @@ record_mergeinfo_for_dir_merge(svn_merge
                                                    FALSE);
                 }
 
-              if (old_session_url)
-                SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
-                                        old_session_url, iterpool));
+              SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
+                                      old_session_url, iterpool));
             }
 
           apr_hash_set(child_merges, child->abspath, APR_HASH_KEY_STRING,
@@ -8002,9 +7996,8 @@ record_mergeinfo_for_added_subtrees(
             MIN(merged_range->start, merged_range->end),
             merge_b->ra_session2, merge_b->ctx, iterpool));
 
-          if (old_session_url)
-            SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
-                                    old_session_url, iterpool));
+          SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
+                                  old_session_url, iterpool));
 
           SVN_ERR(svn_mergeinfo_intersect2(&merge_mergeinfo,
                                            merge_mergeinfo,
@@ -8584,7 +8577,7 @@ do_directory_merge(svn_mergeinfo_catalog
             {
               svn_revnum_t next_end_rev;
               merge_source_t *real_source;
-              const char *old_sess1_url = NULL, *old_sess2_url = NULL;
+              const char *old_sess1_url, *old_sess2_url;
               svn_merge_range_t *first_target_range
                 = (target_merge_path->remaining_ranges->nelts == 0 ? NULL
                    : APR_ARRAY_IDX(target_merge_path->remaining_ranges, 0,
@@ -8635,12 +8628,10 @@ do_directory_merge(svn_mergeinfo_catalog
                 depth, notify_b,
                 merge_b,
                 iterpool));
-              if (old_sess1_url)
-                SVN_ERR(svn_ra_reparent(merge_b->ra_session1,
-                                        old_sess1_url, iterpool));
-              if (old_sess2_url)
-                SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
-                                        old_sess2_url, iterpool));
+              SVN_ERR(svn_ra_reparent(merge_b->ra_session1,
+                                      old_sess1_url, iterpool));
+              SVN_ERR(svn_ra_reparent(merge_b->ra_session2,
+                                      old_sess2_url, iterpool));
 
               /* If any paths picked up explicit mergeinfo as a result of
                  the merge we need to make sure any mergeinfo those paths

Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1227601&r1=1227600&r2=1227601&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Thu Jan  5 14:13:34 2012
@@ -501,7 +501,6 @@ svn_client__ensure_ra_session_url(const 
                                   const char *session_url,
                                   apr_pool_t *pool)
 {
-  *old_session_url = NULL;
   SVN_ERR(svn_ra_get_session_url(ra_session, old_session_url, pool));
   if (! session_url)
     SVN_ERR(svn_ra_get_repos_root2(ra_session, &session_url, pool));



Mime
View raw message