subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1645439 [3/8] - in /subversion/branches/1.7.x-issue4340-repos: ./ build/ac-macros/ build/generator/ build/generator/templates/ contrib/hook-scripts/ subversion/bindings/javahl/native/ subversion/bindings/javahl/src/org/apache/subversion/ja...
Date Sun, 14 Dec 2014 11:44:04 GMT
Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/externals.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/externals.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/externals.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/externals.c Sun Dec 14 11:44:03 2014
@@ -464,7 +464,10 @@ switch_file_external(const char *local_a
        ### information into the wrong working copy */
     const char *definition_abspath = svn_dirent_dirname(local_abspath,subpool);
 
-    /* Open an RA session to 'source' URL */
+    /* ### Why do we open a new session?  RA_SESSION is a valid
+       ### session -- the caller used it to call svn_ra_check_path on
+       ### this very URL, the caller also did the resolving and
+       ### reparenting that is repeated here. */
     SVN_ERR(svn_client__ra_session_from_path(&ra_session, &revnum,
                                              &switch_rev_url,
                                              url, dir_abspath,
@@ -497,7 +500,7 @@ switch_file_external(const char *local_a
     /* Tell RA to do an update of URL+TARGET to REVISION; if we pass an
      invalid revnum, that means RA will use the latest revision. */
   SVN_ERR(svn_ra_do_switch2(ra_session, &reporter, &report_baton, revnum,
-                            target, svn_depth_unknown, url,
+                            target, svn_depth_unknown, switch_rev_url,
                             switch_editor, switch_baton, subpool));
 
   SVN_ERR(svn_wc__crawl_file_external(ctx->wc_ctx, local_abspath,
@@ -916,7 +919,7 @@ handle_external_item_change(const struct
   switch (local_kind)
     {
       case svn_node_dir:
-        SVN_ERR(switch_dir_external(local_abspath, new_url,
+        SVN_ERR(switch_dir_external(local_abspath, ra_session_url,
                                     &(new_item->peg_revision),
                                     &(new_item->revision),
                                     parent_dir_abspath,
@@ -1302,17 +1305,19 @@ svn_client__do_external_status(svn_clien
                                svn_boolean_t get_all,
                                svn_boolean_t update,
                                svn_boolean_t no_ignore,
+                               const char *anchor_abspath,
+                               const char *anchor_relpath,
                                svn_client_status_func_t status_func,
                                void *status_baton,
-                               apr_pool_t *pool)
+                               apr_pool_t *scratch_pool)
 {
   apr_hash_index_t *hi;
-  apr_pool_t *iterpool = svn_pool_create(pool);
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
 
   /* Loop over the hash of new values (we don't care about the old
      ones).  This is a mapping of versioned directories to property
      values. */
-  for (hi = apr_hash_first(pool, external_map);
+  for (hi = apr_hash_first(scratch_pool, external_map);
        hi;
        hi = apr_hash_next(hi))
     {
@@ -1321,6 +1326,7 @@ svn_client__do_external_status(svn_clien
       const char *defining_abspath = svn__apr_hash_index_val(hi);
       svn_node_kind_t kind;
       svn_opt_revision_t opt_rev;
+      const char *status_path;
 
       svn_pool_clear(iterpool);
 
@@ -1351,8 +1357,17 @@ svn_client__do_external_status(svn_clien
                                     svn_wc_notify_status_external,
                                     iterpool), iterpool);
 
+      status_path = local_abspath;
+      if (anchor_abspath)
+        {
+          status_path = svn_dirent_join(anchor_relpath,
+                           svn_dirent_skip_ancestor(anchor_abspath,
+                                                    status_path),
+                           iterpool);
+        }
+
       /* And then do the status. */
-      SVN_ERR(svn_client_status5(NULL, ctx, local_abspath, &opt_rev, depth,
+      SVN_ERR(svn_client_status5(NULL, ctx, status_path, &opt_rev, depth,
                                  get_all, update, no_ignore, FALSE, FALSE,
                                  NULL, status_func, status_baton,
                                  iterpool));

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/merge.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/merge.c Sun Dec 14 11:44:03 2014
@@ -6598,6 +6598,7 @@ do_file_merge(svn_mergeinfo_catalog_t re
               svn_boolean_t sources_related,
               svn_boolean_t squelch_mergeinfo_notifications,
               notification_receiver_baton_t *notify_b,
+              svn_boolean_t abort_on_conflicts,
               merge_cmd_baton_t *merge_b,
               apr_pool_t *scratch_pool)
 {
@@ -6862,10 +6863,13 @@ do_file_merge(svn_mergeinfo_catalog_t re
           SVN_ERR(svn_io_remove_file2(tmpfile1, TRUE, iterpool));
           SVN_ERR(svn_io_remove_file2(tmpfile2, TRUE, iterpool));
 
-          if ((i < (ranges_to_merge->nelts - 1))
+          if ((i < (ranges_to_merge->nelts - 1) || abort_on_conflicts)
               && is_path_conflicted_by_merge(merge_b))
             {
               conflicted_range = svn_merge_range_dup(r, scratch_pool);
+              /* Only record partial mergeinfo if only a partial merge was
+                 performed before a conflict was encountered. */
+              range.end = r->end;
               break;
             }
         }
@@ -6887,7 +6891,8 @@ do_file_merge(svn_mergeinfo_catalog_t re
         &filtered_rangelist,
         mergeinfo_path,
         merge_target->implicit_mergeinfo,
-        &range, iterpool));
+        &range,
+        iterpool));
 
       /* Only record mergeinfo if there is something other than
          self-referential mergeinfo, but don't record mergeinfo if
@@ -8801,6 +8806,11 @@ do_merge(apr_hash_t **modified_subtrees,
         APR_ARRAY_IDX(merge_sources, i, merge_source_t *);
       const char *url1, *url2;
       svn_revnum_t rev1, rev2;
+      /* If conflicts occur while merging any but the very last
+       * revision range we want an error to be raised that aborts
+       * the merge operation. The user will be asked to resolve conflicts
+       * before merging subsequent revision ranges. */
+      svn_boolean_t abort_on_conflicts = (i < merge_sources->nelts - 1);
 
       svn_pool_clear(iterpool);
 
@@ -8854,16 +8864,11 @@ do_merge(apr_hash_t **modified_subtrees,
                                 sources_related,
                                 squelch_mergeinfo_notifications,
                                 &notify_baton,
+                                abort_on_conflicts,
                                 &merge_cmd_baton, iterpool));
         }
       else if (target_kind == svn_node_dir)
         {
-          /* If conflicts occur while merging any but the very last
-           * revision range we want an error to be raised that aborts
-           * the merge operation. The user will be asked to resolve conflicts
-           * before merging subsequent revision ranges. */
-          svn_boolean_t abort_on_conflicts = (i < merge_sources->nelts - 1);
-
           SVN_ERR(do_directory_merge(result_catalog,
                                      url1, rev1, url2, rev2, target_abspath,
                                      depth, squelch_mergeinfo_notifications,

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/repos_diff_summarize.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/repos_diff_summarize.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/repos_diff_summarize.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/repos_diff_summarize.c Sun Dec 14 11:44:03 2014
@@ -93,14 +93,11 @@ create_item_baton(struct edit_baton *edi
   struct item_baton *b = apr_pcalloc(pool, sizeof(*b));
 
   b->edit_baton = edit_baton;
-  /* Issue #2765: b->path is supposed to be relative to the target.
-     If the target is a file, just use an empty path.  This way the
-     receiver can just concatenate this path to the original path
-     without doing any extra checks. */
-  if (node_kind == svn_node_file && strcmp(path, edit_baton->target) == 0)
-    b->path =  "";
-  else
-    b->path = apr_pstrdup(pool, path);
+  /* Issues #2765 & #4408: b->path is supposed to be relative to the target.
+     This way the receiver can just concatenate this path to the original
+     path without doing any extra checks. */
+  b->path = apr_pstrdup(pool,
+                        svn_relpath_skip_ancestor(edit_baton->target, path));
   b->node_kind = node_kind;
   b->item_pool = pool;
 
@@ -130,12 +127,13 @@ ensure_summarize(struct item_baton *ib)
 
 /* An editor function. The root of the comparison hierarchy */
 static svn_error_t *
-open_root(void *edit_baton,
+open_root(void *eb,
           svn_revnum_t base_revision,
           apr_pool_t *pool,
           void **root_baton)
 {
-  struct item_baton *ib = create_item_baton(edit_baton, "",
+  struct edit_baton *b = eb;
+  struct item_baton *ib = create_item_baton(eb, b->target,
                                             svn_node_dir, pool);
 
   *root_baton = ib;
@@ -198,7 +196,8 @@ diff_deleted_dir(const char *dir,
 
       sum = apr_pcalloc(iterpool, sizeof(*sum));
       sum->summarize_kind = svn_client_diff_summarize_kind_deleted;
-      sum->path = path;
+      /* Issue #4408: sum->path should be relative to target. */
+      sum->path = svn_relpath_skip_ancestor(eb->target, path);
       sum->node_kind = kind;
 
       SVN_ERR(eb->summarize_func(sum,
@@ -240,7 +239,8 @@ delete_entry(const char *path,
 
   sum = apr_pcalloc(pool, sizeof(*sum));
   sum->summarize_kind = svn_client_diff_summarize_kind_deleted;
-  sum->path = path;
+  /* Issue #4408: sum->path should be relative to target. */
+  sum->path = svn_relpath_skip_ancestor(eb->target, path);
   sum->node_kind = kind;
 
   SVN_ERR(eb->summarize_func(sum, eb->summarize_func_baton, pool));

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/status.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/status.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/status.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/status.c Sun Dec 14 11:44:03 2014
@@ -519,6 +519,7 @@ svn_client_status5(svn_revnum_t *result_
       SVN_ERR(svn_client__do_external_status(ctx, external_map,
                                              depth, get_all,
                                              update, no_ignore,
+                                             sb.anchor_abspath, sb.anchor_relpath,
                                              status_func, status_baton, pool));
     }
 

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/update.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/update.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/update.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_client/update.c Sun Dec 14 11:44:03 2014
@@ -209,6 +209,7 @@ update_internal(svn_revnum_t *result_rev
   struct svn_client__dirent_fetcher_baton_t dfb;
   svn_boolean_t server_supports_depth;
   svn_boolean_t tree_conflicted;
+  svn_boolean_t cropping_target;
   svn_config_t *cfg = ctx->config ? apr_hash_get(ctx->config,
                                                  SVN_CONFIG_CATEGORY_CONFIG,
                                                  APR_HASH_KEY_STRING) : NULL;
@@ -268,7 +269,8 @@ update_internal(svn_revnum_t *result_rev
     }
 
   /* We may need to crop the tree if the depth is sticky */
-  if (depth_is_sticky && depth < svn_depth_infinity)
+  cropping_target = (depth_is_sticky && depth < svn_depth_infinity);
+  if (cropping_target)
     {
       svn_node_kind_t target_kind;
 
@@ -421,7 +423,8 @@ update_internal(svn_revnum_t *result_rev
   /* We handle externals after the update is complete, so that
      handling external items (and any errors therefrom) doesn't delay
      the primary operation.  */
-  if (SVN_DEPTH_IS_RECURSIVE(depth) && (! ignore_externals))
+  if ((SVN_DEPTH_IS_RECURSIVE(depth) || cropping_target)
+      && (! ignore_externals))
     {
       apr_hash_t *new_externals;
       apr_hash_t *new_depths;

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_delta/svndiff.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_delta/svndiff.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_delta/svndiff.c Sun Dec 14 11:44:03 2014
@@ -647,7 +647,13 @@ decode_window(svn_txdelta_window_t *wind
     }
   else
     {
-      new_data->data = (const char *) insend;
+      /* Copy the data because an svn_string_t must have the invariant
+         data[len]=='\0'. */
+      char *buf = apr_palloc(pool, newlen + 1);
+
+      memcpy(buf, insend, newlen);
+      buf[newlen] = '\0';
+      new_data->data = buf;
       new_data->len = newlen;
     }
 

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_diff/diff_file.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_diff/diff_file.c Sun Dec 14 11:44:03 2014
@@ -121,6 +121,9 @@ datasource_to_index(svn_diff_datasource_
  * whatsoever.  If there is a number someone comes up with that has some
  * argumentation, let's use that.
  */
+/* If you change this number, update test_norm_offset(),
+ * test_identical_suffix() and and test_token_compare()  in diff-diff3-test.c.
+ */
 #define CHUNK_SHIFT 17
 #define CHUNK_SIZE (1 << CHUNK_SHIFT)
 
@@ -430,7 +433,7 @@ find_identical_prefix(svn_boolean_t *rea
         }
 
       is_match = TRUE;
-      for (delta = 0; delta < max_delta && is_match; delta += sizeof(apr_uintptr_t))
+      for (delta = 0; delta < max_delta; delta += sizeof(apr_uintptr_t))
         {
           apr_uintptr_t chunk = *(const apr_size_t *)(file[0].curp + delta);
           if (contains_eol(chunk))
@@ -440,18 +443,25 @@ find_identical_prefix(svn_boolean_t *rea
             if (chunk != *(const apr_size_t *)(file[i].curp + delta))
               {
                 is_match = FALSE;
-                delta -= sizeof(apr_size_t);
                 break;
               }
+
+          if (! is_match)
+            break;
         }
 
-      /* We either found a mismatch or an EOL at or shortly behind curp+delta
-       * or we cannot proceed with chunky ops without exceeding endp.
-       * In any way, everything up to curp + delta is equal and not an EOL.
-       */
-      for (i = 0; i < file_len; i++)
-        file[i].curp += delta;
+      if (delta /* > 0*/)
+        {
+          /* We either found a mismatch or an EOL at or shortly behind curp+delta
+           * or we cannot proceed with chunky ops without exceeding endp.
+           * In any way, everything up to curp + delta is equal and not an EOL.
+           */
+          for (i = 0; i < file_len; i++)
+            file[i].curp += delta;
 
+          /* Skipped data without EOL markers, so last char was not a CR. */
+          had_cr = FALSE; 
+        }
 #endif
 
       *reached_one_eof = is_one_at_eof(file, file_len);
@@ -546,6 +556,13 @@ find_identical_suffix(apr_off_t *suffix_
       file_for_suffix[i].chunk =
         (int) offset_to_chunk(file_for_suffix[i].size); /* last chunk */
       length[i] = offset_in_chunk(file_for_suffix[i].size);
+      if (length[i] == 0)
+        {
+          /* last chunk is an empty chunk -> start at next-to-last chunk */
+          file_for_suffix[i].chunk = file_for_suffix[i].chunk - 1;
+          length[i] = CHUNK_SIZE;
+        }
+
       if (file_for_suffix[i].chunk == file[i].chunk)
         {
           /* Prefix ended in last chunk, so we can reuse the prefix buffer */
@@ -631,32 +648,41 @@ find_identical_suffix(apr_off_t *suffix_
         can_read_word = can_read_word
                         && (   file_for_suffix[i].curp - sizeof(apr_uintptr_t)
                             >= min_curp[i]);
-      if (can_read_word)
+      while (can_read_word)
         {
-          do
-            {
-              apr_uintptr_t chunk;
-              for (i = 0; i < file_len; i++)
-                file_for_suffix[i].curp -= sizeof(apr_uintptr_t);
+          apr_uintptr_t chunk;
 
-              chunk = *(const apr_uintptr_t *)(file_for_suffix[0].curp + 1);
-              if (contains_eol(chunk))
-                break;
+          /* For each file curp is positioned at the next byte to read, but we
+             want to examine the bytes before the current location. */
 
-              for (i = 0, can_read_word = TRUE; i < file_len; i++)
-                can_read_word = can_read_word
-                                && (   file_for_suffix[i].curp - sizeof(apr_uintptr_t)
-                                    >= min_curp[i]);
-              for (i = 1, is_match = TRUE; i < file_len; i++)
-                is_match = is_match
-                           && (   chunk
-                               == *(const apr_uintptr_t *)(file_for_suffix[i].curp + 1));
-            } while (can_read_word && is_match);
+          chunk = *(const apr_uintptr_t *)(file_for_suffix[0].curp + 1
+                                             - sizeof(apr_uintptr_t));
+          if (contains_eol(chunk))
+            break;
 
-            for (i = 0; i < file_len; i++)
-              file_for_suffix[i].curp += sizeof(apr_uintptr_t);
-        }
+          for (i = 1, is_match = TRUE; i < file_len; i++)
+            is_match = is_match
+                       && (   chunk
+                           == *(const apr_uintptr_t *)
+                                    (file_for_suffix[i].curp + 1
+                                       - sizeof(apr_uintptr_t)));
+
+          if (! is_match)
+            break;
 
+          for (i = 0; i < file_len; i++)
+            {
+              file_for_suffix[i].curp -= sizeof(apr_uintptr_t);
+              can_read_word = can_read_word
+                              && (   (file_for_suffix[i].curp
+                                        - sizeof(apr_uintptr_t))
+                                  >= min_curp[i]);
+            }
+
+          /* We skipped 4 bytes, so there are no closing EOLs */
+          had_nl = FALSE;
+          had_cr = FALSE;
+        }
 #endif
 
       reached_prefix = file_for_suffix[0].chunk == suffix_min_chunk0
@@ -841,17 +867,24 @@ datasource_get_next_token(apr_uint32_t *
 
   last_chunk = offset_to_chunk(file->size);
 
-  if (curp == endp
-      && last_chunk == file->chunk)
+  /* Are we already at the end of a chunk? */
+  if (curp == endp)
     {
-      return SVN_NO_ERROR;
+      /* Are we at EOF */
+      if (last_chunk == file->chunk)
+        return SVN_NO_ERROR; /* EOF */
+
+      /* Or right before an identical suffix in the next chunk? */
+      if (file->chunk + 1 == file->suffix_start_chunk
+          && file->suffix_offset_in_chunk == 0)
+        return SVN_NO_ERROR;
     }
 
   /* Stop when we encounter the identical suffix. If suffix scanning was not
    * performed, suffix_start_chunk will be -1, so this condition will never
    * be true. */
   if (file->chunk == file->suffix_start_chunk
-      && curp - file->buffer == file->suffix_offset_in_chunk)
+      && (curp - file->buffer) == file->suffix_offset_in_chunk)
     return SVN_NO_ERROR;
 
   /* Allocate a new token, or fetch one from the "reusable tokens" list. */
@@ -868,6 +901,7 @@ datasource_get_next_token(apr_uint32_t *
   file_token->datasource = datasource;
   file_token->offset = chunk_to_offset(file->chunk)
                        + (curp - file->buffer);
+  file_token->norm_offset = file_token->offset;
   file_token->raw_length = 0;
   file_token->length = 0;
 
@@ -896,11 +930,21 @@ datasource_get_next_token(apr_uint32_t *
 
       length = endp - curp;
       file_token->raw_length += length;
-      svn_diff__normalize_buffer(&curp, &length,
-                                 &file->normalize_state,
-                                 curp, file_baton->options);
-      file_token->length += length;
-      h = svn__adler32(h, curp, length);
+      {
+        char *c = curp;
+
+        svn_diff__normalize_buffer(&c, &length,
+                                   &file->normalize_state,
+                                   curp, file_baton->options);
+        if (file_token->length == 0)
+          {
+            /* When we are reading the first part of the token, move the
+               normalized offset past leading ignored characters, if any. */
+            file_token->norm_offset += (c - curp);
+          }
+        file_token->length += length;
+        h = svn__adler32(h, c, length);
+      }
 
       curp = endp = file->buffer;
       file->chunk++;
@@ -909,6 +953,14 @@ datasource_get_next_token(apr_uint32_t *
       endp += length;
       file->endp = endp;
 
+      /* Issue #4283: Normally we should have checked for reaching the skipped
+         suffix here, but because we assume that a suffix always starts on a
+         line and token boundary we rely on catching the suffix earlier in this
+         function.
+
+         When changing things here, make sure the whitespace settings are
+         applied, or we mught not reach the exact suffix boundary as token
+         boundary. */
       SVN_ERR(read_chunk(file->file, file->path,
                          curp, length,
                          chunk_to_offset(file->chunk),
@@ -939,11 +991,12 @@ datasource_get_next_token(apr_uint32_t *
       svn_diff__normalize_buffer(&c, &length,
                                  &file->normalize_state,
                                  curp, file_baton->options);
-
-      file_token->norm_offset = file_token->offset;
       if (file_token->length == 0)
-        /* move past leading ignored characters */
-        file_token->norm_offset += (c - curp);
+        {
+          /* When we are reading the first part of the token, move the
+             normalized offset past leading ignored characters, if any. */
+          file_token->norm_offset += (c - curp);
+        }
 
       file_token->length += length;
 
@@ -1015,8 +1068,15 @@ token_compare(void *baton, void *token1,
         }
       else
         {
+          apr_off_t skipped;
+
           length[i] = 0;
-          raw_length[i] = file_token[i]->raw_length;
+
+          /* When we skipped the first part of the token via the whitespace
+             normalization we must reduce the raw length of the token */
+          skipped = (file_token[i]->norm_offset - file_token[i]->offset);
+
+          raw_length[i] = file_token[i]->raw_length - skipped;
         }
     }
 
@@ -1052,6 +1112,8 @@ token_compare(void *baton, void *token1,
                  so, overwriting it isn't a problem */
               svn_diff__normalize_buffer(&bufp[i], &length[i], &state[i],
                                          bufp[i], file_baton->options);
+
+              /* assert(length[i] == file_token[i]->length); */
             }
         }
 

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs/fs-loader.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs/fs-loader.c Sun Dec 14 11:44:03 2014
@@ -671,19 +671,20 @@ svn_fs_commit_txn(const char **conflict_
 {
 #ifdef PACK_AFTER_EVERY_COMMIT
   svn_fs_root_t *txn_root;
-  svn_fs_t *fs;
-  const char *fs_path;
+#endif
 
   *new_rev = SVN_INVALID_REVNUM;
+
+#if defined(PACK_AFTER_EVERY_COMMIT)
   SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
-  fs = svn_fs_root_fs(txn_root);
-  fs_path = svn_fs_path(fs, pool);
 #endif
 
   SVN_ERR(txn->vtable->commit(conflict_p, new_rev, txn, pool));
 
 #ifdef PACK_AFTER_EVERY_COMMIT
   {
+    svn_fs_t *fs = svn_fs_root_fs(txn_root);
+    const char *fs_path = svn_fs_path(fs, pool);
     svn_error_t *err = svn_fs_pack(fs_path, NULL, NULL, NULL, NULL, pool);
     if (err && err->apr_err == SVN_ERR_UNSUPPORTED_FEATURE)
       /* Pre-1.6 filesystem. */

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/fs_fs.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/fs_fs.c Sun Dec 14 11:44:03 2014
@@ -78,6 +78,13 @@
 #define SVN_FS_FS_DEFAULT_MAX_FILES_PER_DIR 1000
 #endif
 
+/* Finding a deltification base takes operations proportional to the
+   number of changes being skipped. To prevent exploding runtime
+   during commits, limit the deltification range to this value.
+   Should be a power of 2 minus one.
+   Values < 1 disable deltification. */
+#define SVN_FS_FS_MAX_DELTIFICATION_WALK 1023
+
 /* Following are defines that specify the textual elements of the
    native filesystem directories and revision files. */
 
@@ -5483,6 +5490,16 @@ choose_delta_base(representation_t **rep
   count = noderev->predecessor_count;
   count = count & (count - 1);
 
+  /* Finding the delta base over a very long distance can become extremely
+     expensive for very deep histories, possibly causing client timeouts etc.
+     OTOH, this is a rare operation and its gains are minimal. Lets simply
+     start deltification anew close every other 1000 changes or so.  */
+  if (noderev->predecessor_count - count > SVN_FS_FS_MAX_DELTIFICATION_WALK)
+    {
+      *rep = NULL;
+      return SVN_NO_ERROR;
+    }
+
   /* Walk back a number of predecessors equal to the difference
      between count and the original predecessor count.  (For example,
      if noderev has ten predecessors and we want the eighth file rev,

Propchange: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/temp_serializer.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 14 11:44:03 2014
@@ -1,4 +1,6 @@
+/subversion/branches/1.7.x/subversion/libsvn_fs_fs/temp_serializer.c:1480943-1645438
 /subversion/branches/1.7.x-issue4087/subversion/libsvn_fs_fs/temp_serializer.c:1243707-1336073
+/subversion/branches/1.7.x-issue4153/subversion/libsvn_fs_fs/temp_serializer.c:1309894-1539233
 /subversion/branches/1.7.x-issue4169/subversion/libsvn_fs_fs/temp_serializer.c:1330537-1336116
 /subversion/branches/1.7.x-r1210147/subversion/libsvn_fs_fs/temp_serializer.c:1213310-1293110
 /subversion/branches/1.7.x-r1423646/subversion/libsvn_fs_fs/temp_serializer.c:1423647-1424282

Propchange: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/temp_serializer.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 14 11:44:03 2014
@@ -1,4 +1,6 @@
+/subversion/branches/1.7.x/subversion/libsvn_fs_fs/temp_serializer.h:1480943-1645438
 /subversion/branches/1.7.x-issue4087/subversion/libsvn_fs_fs/temp_serializer.h:1243707-1336073
+/subversion/branches/1.7.x-issue4153/subversion/libsvn_fs_fs/temp_serializer.h:1309894-1539233
 /subversion/branches/1.7.x-issue4169/subversion/libsvn_fs_fs/temp_serializer.h:1330537-1336116
 /subversion/branches/1.7.x-r1210147/subversion/libsvn_fs_fs/temp_serializer.h:1213310-1293110
 /subversion/branches/1.7.x-r1423646/subversion/libsvn_fs_fs/temp_serializer.h:1423647-1424282

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/tree.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_fs_fs/tree.c Sun Dec 14 11:44:03 2014
@@ -44,6 +44,7 @@
 #include "svn_private_config.h"
 #include "svn_pools.h"
 #include "svn_error.h"
+#include "svn_ctype.h"
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
 #include "svn_mergeinfo.h"
@@ -1806,6 +1807,78 @@ fs_dir_entries(apr_hash_t **table_p,
   return svn_fs_fs__dag_dir_entries(table_p, node, pool, pool);
 }
 
+/* Return a copy of PATH, allocated from POOL, for which control
+   characters have been escaped using the form \NNN (where NNN is the
+   octal representation of the byte's ordinal value).  */
+static const char *
+illegal_path_escape(const char *path, apr_pool_t *pool)
+{
+  svn_stringbuf_t *retstr;
+  apr_size_t i, copied = 0;
+  int c;
+
+  /* At least one control character:
+      strlen - 1 (control) + \ + N + N + N + null . */
+  retstr = svn_stringbuf_create_ensure(strlen(path) + 4, pool);
+  for (i = 0; path[i]; i++)
+    {
+      c = (unsigned char)path[i];
+      if (! svn_ctype_iscntrl(c))
+        continue;
+
+      /* If we got here, we're looking at a character that isn't
+         supported by the (or at least, our) URI encoding scheme.  We
+         need to escape this character.  */
+
+      /* First things first, copy all the good stuff that we haven't
+         yet copied into our output buffer. */
+      if (i - copied)
+        svn_stringbuf_appendbytes(retstr, path + copied,
+                                  i - copied);
+
+      /* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
+      svn_stringbuf_ensure(retstr, retstr->len + 5);
+      /*### The backslash separator doesn't work too great with Windows,
+         but it's what we'll use for consistency with invalid utf8
+         formatting (until someone has a better idea) */
+      apr_snprintf(retstr->data + retstr->len, 5, "\\%03o", (unsigned char)c);
+      retstr->len += 4;
+
+      /* Finally, update our copy counter. */
+      copied = i + 1;
+    }
+
+  /* If we didn't encode anything, we don't need to duplicate the string. */
+  if (retstr->len == 0)
+    return path;
+
+  /* Anything left to copy? */
+  if (i - copied)
+    svn_stringbuf_appendbytes(retstr, path + copied, i - copied);
+
+  /* retstr is null-terminated either by apr_snprintf or the svn_stringbuf
+     functions. */
+
+  return retstr->data;
+}
+
+/* Raise an error if PATH contains a newline because FSFS cannot handle
+ * such paths. See issue #4340. */
+static svn_error_t *
+check_newline(const char *path, apr_pool_t *pool)
+{
+  const char *c;
+
+  for (c = path; *c; c++)
+    {
+      if (*c == '\n')
+        return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
+           _("Invalid control character '0x%02x' in path '%s'"),
+           (unsigned char)*c, illegal_path_escape(path, pool));
+    }
+
+  return SVN_NO_ERROR;
+}
 
 /* Create a new directory named PATH in ROOT.  The new directory has
    no entries, and no properties.  ROOT must be the root of a
@@ -1820,6 +1893,8 @@ fs_make_dir(svn_fs_root_t *root,
   dag_node_t *sub_dir;
   const char *txn_id = root->txn;
 
+  SVN_ERR(check_newline(path, pool));
+
   SVN_ERR(open_path(&parent_path, root, path, open_path_last_optional,
                     txn_id, pool));
 
@@ -2082,6 +2157,8 @@ fs_copy(svn_fs_root_t *from_root,
         const char *to_path,
         apr_pool_t *pool)
 {
+  SVN_ERR(check_newline(to_path, pool));
+
   return svn_error_trace(copy_helper(from_root, from_path, to_root, to_path,
                                      TRUE, pool));
 }
@@ -2174,6 +2251,8 @@ fs_make_file(svn_fs_root_t *root,
   dag_node_t *child;
   const char *txn_id = root->txn;
 
+  SVN_ERR(check_newline(path, pool));
+
   SVN_ERR(open_path(&parent_path, root, path, open_path_last_optional,
                     txn_id, pool));
 

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_local/split_url.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_local/split_url.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_local/split_url.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_local/split_url.c Sun Dec 14 11:44:03 2014
@@ -39,6 +39,7 @@ svn_ra_local__split_URL(svn_repos_t **re
   const char *repos_dirent;
   const char *repos_root_dirent;
   svn_stringbuf_t *urlbuf;
+  apr_size_t root_end;
 
   SVN_ERR(svn_uri_get_dirent_from_file_url(&repos_dirent, URL, pool));
 
@@ -61,10 +62,17 @@ svn_ra_local__split_URL(svn_repos_t **re
     SVN_ERR(svn_repos_remember_client_capabilities(*repos, caps));
   }
 
-  *fs_path = &repos_dirent[strlen(repos_root_dirent)];
-
-  if (**fs_path == '\0')
+  root_end = strlen(repos_root_dirent);
+  if (! repos_dirent[root_end])
     *fs_path = "/";
+  else if (repos_dirent[root_end] == '/')
+    *fs_path = &repos_dirent[root_end];
+  else
+    {
+      /* On Windows "C:/" is the parent directory of "C:/dir" */
+      *fs_path = &repos_dirent[root_end-1];
+      SVN_ERR_ASSERT((*fs_path)[0] == '/');
+    }
 
   /* Remove the path components in *fs_path from the original URL, to get
      the URL to the repository root. */

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_neon/log.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_neon/log.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_neon/log.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_neon/log.c Sun Dec 14 11:44:03 2014
@@ -548,7 +548,7 @@ svn_error_t * svn_ra_neon__get_log(svn_r
      dav_get_resource() to choke on the server.  So instead, we pass a
      baseline-collection URL, which we get from the largest of the
      START and END revisions. */
-  use_rev = (start > end) ? start : end;
+  use_rev = (start == SVN_INVALID_REVNUM || start > end) ? start : end;
   SVN_ERR(svn_ra_neon__get_baseline_info(&bc_url, &bc_relative, NULL, ras,
                                          ras->url->data, use_rev, pool));
   final_bc_url = svn_path_url_add_component2(bc_url, bc_relative, pool);

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/log.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/log.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/log.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/log.c Sun Dec 14 11:44:03 2014
@@ -689,7 +689,7 @@ svn_ra_serf__get_log(svn_ra_session_t *r
   /* At this point, we may have a deleted file.  So, we'll match ra_neon's
    * behavior and use the larger of start or end as our 'peg' rev.
    */
-  peg_rev = (start > end) ? start : end;
+  peg_rev = (start == SVN_INVALID_REVNUM || start > end) ? start : end;
 
   SVN_ERR(svn_ra_serf__get_baseline_info(&basecoll_url, &relative_url, session,
                                          NULL, NULL, peg_rev, NULL, pool));

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/util.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_serf/util.c Sun Dec 14 11:44:03 2014
@@ -28,7 +28,6 @@
 #define APR_WANT_STRFUNC
 #include <apr.h>
 #include <apr_want.h>
-#include <apr_fnmatch.h>
 
 #include <serf.h>
 #include <serf_bucket_types.h>
@@ -40,6 +39,7 @@
 #include "svn_xml.h"
 #include "private/svn_dep_compat.h"
 #include "private/svn_fspath.h"
+#include "private/svn_cert.h"
 
 #include "ra_serf.h"
 
@@ -202,7 +202,10 @@ ssl_server_cert(void *baton, int failure
   apr_hash_t *issuer, *subject, *serf_cert;
   apr_array_header_t *san;
   void *creds;
-  int found_matching_hostname = 0;
+  svn_boolean_t found_matching_hostname = FALSE;
+  svn_boolean_t found_san_entry = FALSE;
+  svn_string_t *actual_hostname =
+      svn_string_create(conn->hostname, scratch_pool);
 
   /* Implicitly approve any non-server certs. */
   if (serf_ssl_cert_depth(cert) > 0)
@@ -237,29 +240,42 @@ ssl_server_cert(void *baton, int failure
                   | conn->server_cert_failures);
 
   /* Try to find matching server name via subjectAltName first... */
-  if (san) {
+  if (san)
+    {
       int i;
-      for (i = 0; i < san->nelts; i++) {
+      found_san_entry = san->nelts > 0;
+      for (i = 0; i < san->nelts; i++)
+        {
           char *s = APR_ARRAY_IDX(san, i, char*);
-          if (apr_fnmatch(s, conn->hostname,
-                          APR_FNM_PERIOD) == APR_SUCCESS) {
-              found_matching_hostname = 1;
+          svn_string_t *cert_hostname = svn_string_create(s, scratch_pool);
+
+          if (svn_cert__match_dns_identity(cert_hostname, actual_hostname))
+            {
+              found_matching_hostname = TRUE;
               cert_info.hostname = s;
               break;
-          }
-      }
-  }
+            }
+        }
+    }
 
-  /* Match server certificate CN with the hostname of the server */
-  if (!found_matching_hostname && cert_info.hostname)
+  /* Match server certificate CN with the hostname of the server iff
+   * we didn't find any subjectAltName fields and try to match them.
+   * Per RFC 2818 they are authoritative if present and CommonName
+   * should be ignored. */
+  if (!found_matching_hostname && !found_san_entry && cert_info.hostname)
     {
-      if (apr_fnmatch(cert_info.hostname, conn->hostname,
-                      APR_FNM_PERIOD) == APR_FNM_NOMATCH)
+      svn_string_t *cert_hostname = svn_string_create(cert_info.hostname,
+                                                      scratch_pool);
+
+      if (svn_cert__match_dns_identity(cert_hostname, actual_hostname))
         {
-          svn_failures |= SVN_AUTH_SSL_CNMISMATCH;
+          found_matching_hostname = TRUE;
         }
     }
 
+  if (!found_matching_hostname)
+    svn_failures |= SVN_AUTH_SSL_CNMISMATCH;
+
   svn_auth_set_parameter(conn->session->wc_callbacks->auth_baton,
                          SVN_AUTH_PARAM_SSL_SERVER_FAILURES,
                          &svn_failures);

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_svn/cyrus_auth.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_svn/cyrus_auth.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_svn/cyrus_auth.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_ra_svn/cyrus_auth.c Sun Dec 14 11:44:03 2014
@@ -858,12 +858,12 @@ svn_ra_svn__do_cyrus_auth(svn_ra_svn__se
 
   /* The username callback. */
   callbacks[0].id = SASL_CB_AUTHNAME;
-  callbacks[0].proc = get_username_cb;
+  callbacks[0].proc = (int (*)(void))get_username_cb;
   callbacks[0].context = &cred_baton;
 
   /* The password callback. */
   callbacks[1].id = SASL_CB_PASS;
-  callbacks[1].proc = get_password_cb;
+  callbacks[1].proc = (int (*)(void))get_password_cb;
   callbacks[1].context = &cred_baton;
 
   /* Mark the end of the array. */

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/dump.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/dump.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/dump.c Sun Dec 14 11:44:03 2014
@@ -212,6 +212,48 @@ make_dir_baton(const char *path,
   return new_db;
 }
 
+/* If the mergeinfo in MERGEINFO_STR refers to any revisions older than
+ * OLDEST_DUMPED_REV, issue a warning and set *FOUND_OLD_MERGEINFO to TRUE,
+ * otherwise leave *FOUND_OLD_MERGEINFO unchanged.
+ */
+static svn_error_t *
+verify_mergeinfo_revisions(svn_boolean_t *found_old_mergeinfo,
+                           const char *mergeinfo_str,
+                           svn_revnum_t oldest_dumped_rev,
+                           svn_repos_notify_func_t notify_func,
+                           void *notify_baton,
+                           apr_pool_t *pool)
+{
+  svn_mergeinfo_t mergeinfo, old_mergeinfo;
+
+  SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_str, pool));
+  SVN_ERR(svn_mergeinfo__filter_mergeinfo_by_ranges(
+            &old_mergeinfo, mergeinfo,
+            oldest_dumped_rev - 1, 0,
+            TRUE, pool, pool));
+
+  if (apr_hash_count(old_mergeinfo))
+    {
+      svn_repos_notify_t *notify =
+        svn_repos_notify_create(svn_repos_notify_warning, pool);
+
+      notify->warning = svn_repos_notify_warning_found_old_mergeinfo;
+      notify->warning_str = apr_psprintf(
+        pool,
+        _("Mergeinfo referencing revision(s) prior "
+          "to the oldest dumped revision (r%ld). "
+          "Loading this dump may result in invalid "
+          "mergeinfo."),
+        oldest_dumped_rev);
+
+      if (found_old_mergeinfo)
+        *found_old_mergeinfo = TRUE;
+      notify_func(notify_baton, notify, pool);
+    }
+
+  return SVN_NO_ERROR;
+}
+
 
 /* This helper is the main "meat" of the editor -- it does all the
    work of writing a node record.
@@ -473,31 +515,13 @@ dump_node(struct edit_baton *eb,
                                                      APR_HASH_KEY_STRING);
           if (mergeinfo_str)
             {
-              svn_mergeinfo_t mergeinfo, old_mergeinfo;
-
-              SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_str->data,
-                                          pool));
-              SVN_ERR(svn_mergeinfo__filter_mergeinfo_by_ranges(
-                &old_mergeinfo, mergeinfo,
-                eb->oldest_dumped_rev - 1, 0,
-                TRUE, pool, pool));
-              if (apr_hash_count(old_mergeinfo))
-                {
-                  svn_repos_notify_t *notify =
-                    svn_repos_notify_create(svn_repos_notify_warning, pool);
-
-                  notify->warning = svn_repos_notify_warning_found_old_mergeinfo;
-                  notify->warning_str = apr_psprintf(
-                    pool,
-                    _("Mergeinfo referencing revision(s) prior "
-                      "to the oldest dumped revision (r%ld). "
-                      "Loading this dump may result in invalid "
-                      "mergeinfo."),
-                    eb->oldest_dumped_rev);
-
-                  eb->found_old_mergeinfo = TRUE;
-                  eb->notify_func(eb->notify_baton, notify, pool);
-                }
+              /* An error in verifying the mergeinfo must not prevent dumping
+                 the data. Ignore any such error. */
+              svn_error_clear(verify_mergeinfo_revisions(
+                                &eb->found_old_mergeinfo,
+                                mergeinfo_str->data, eb->oldest_dumped_rev,
+                                eb->notify_func, eb->notify_baton,
+                                pool));
             }
         }
 

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/reporter.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/reporter.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_repos/reporter.c Sun Dec 14 11:44:03 2014
@@ -1026,7 +1026,8 @@ delta_dirs(report_baton_t *b, svn_revnum
   svn_fs_root_t *s_root;
   apr_hash_t *s_entries = NULL, *t_entries;
   apr_hash_index_t *hi;
-  apr_pool_t *subpool;
+  apr_pool_t *subpool = svn_pool_create(pool);
+  apr_pool_t *iterpool;
   const char *name, *s_fullpath, *t_fullpath, *e_fullpath;
   path_info_t *info;
 
@@ -1035,7 +1036,8 @@ delta_dirs(report_baton_t *b, svn_revnum
 
      When we support directory locks, we must pass the lock token here. */
   SVN_ERR(delta_proplists(b, s_rev, start_empty ? NULL : s_path, t_path,
-                          NULL, change_dir_prop, dir_baton, pool));
+                          NULL, change_dir_prop, dir_baton, subpool));
+  svn_pool_clear(subpool);
 
   if (requested_depth > svn_depth_empty
       || requested_depth == svn_depth_unknown)
@@ -1044,19 +1046,19 @@ delta_dirs(report_baton_t *b, svn_revnum
       if (s_path && !start_empty)
         {
           SVN_ERR(get_source_root(b, &s_root, s_rev));
-          SVN_ERR(svn_fs_dir_entries(&s_entries, s_root, s_path, pool));
+          SVN_ERR(svn_fs_dir_entries(&s_entries, s_root, s_path, subpool));
         }
-      SVN_ERR(svn_fs_dir_entries(&t_entries, b->t_root, t_path, pool));
+      SVN_ERR(svn_fs_dir_entries(&t_entries, b->t_root, t_path, subpool));
 
       /* Iterate over the report information for this directory. */
-      subpool = svn_pool_create(pool);
+      iterpool = svn_pool_create(pool);
 
       while (1)
         {
           const svn_fs_dirent_t *s_entry, *t_entry;
 
-          svn_pool_clear(subpool);
-          SVN_ERR(fetch_path_info(b, &name, &info, e_path, subpool));
+          svn_pool_clear(iterpool);
+          SVN_ERR(fetch_path_info(b, &name, &info, e_path, iterpool));
           if (!name)
             break;
 
@@ -1076,10 +1078,10 @@ delta_dirs(report_baton_t *b, svn_revnum
               continue;
             }
 
-          e_fullpath = svn_relpath_join(e_path, name, subpool);
-          t_fullpath = svn_fspath__join(t_path, name, subpool);
+          e_fullpath = svn_relpath_join(e_path, name, iterpool);
+          t_fullpath = svn_fspath__join(t_path, name, iterpool);
           t_entry = apr_hash_get(t_entries, name, APR_HASH_KEY_STRING);
-          s_fullpath = s_path ? svn_fspath__join(s_path, name, subpool) : NULL;
+          s_fullpath = s_path ? svn_fspath__join(s_path, name, iterpool) : NULL;
           s_entry = s_entries ?
             apr_hash_get(s_entries, name, APR_HASH_KEY_STRING) : NULL;
 
@@ -1099,7 +1101,7 @@ delta_dirs(report_baton_t *b, svn_revnum
                                  t_entry, dir_baton, e_fullpath, info,
                                  info ? info->depth
                                       : DEPTH_BELOW_HERE(wc_depth),
-                                 DEPTH_BELOW_HERE(requested_depth), subpool));
+                                 DEPTH_BELOW_HERE(requested_depth), iterpool));
 
           /* Don't revisit this name in the target or source entries. */
           apr_hash_set(t_entries, name, APR_HASH_KEY_STRING, NULL);
@@ -1119,13 +1121,13 @@ delta_dirs(report_baton_t *b, svn_revnum
          target, for graceful handling of case-only renames. */
       if (s_entries)
         {
-          for (hi = apr_hash_first(pool, s_entries);
+          for (hi = apr_hash_first(subpool, s_entries);
                hi;
                hi = apr_hash_next(hi))
             {
               const svn_fs_dirent_t *s_entry;
 
-              svn_pool_clear(subpool);
+              svn_pool_clear(iterpool);
               s_entry = svn__apr_hash_index_val(hi);
 
               if (apr_hash_get(t_entries, s_entry->name,
@@ -1143,27 +1145,29 @@ delta_dirs(report_baton_t *b, svn_revnum
                     continue;
 
                   /* There is no corresponding target entry, so delete. */
-                  e_fullpath = svn_relpath_join(e_path, s_entry->name, subpool);
+                  e_fullpath = svn_relpath_join(e_path, s_entry->name, iterpool);
                   SVN_ERR(svn_repos_deleted_rev(svn_fs_root_fs(b->t_root),
                                                 svn_fspath__join(t_path,
                                                                  s_entry->name,
-                                                                 subpool),
+                                                                 iterpool),
                                                 s_rev, b->t_rev,
-                                                &deleted_rev, subpool));
+                                                &deleted_rev, iterpool));
 
                   SVN_ERR(b->editor->delete_entry(e_fullpath,
                                                   deleted_rev,
-                                                  dir_baton, subpool));
+                                                  dir_baton, iterpool));
                 }
             }
         }
 
       /* Loop over the dirents in the target. */
-      for (hi = apr_hash_first(pool, t_entries); hi; hi = apr_hash_next(hi))
+      for (hi = apr_hash_first(subpool, t_entries);
+           hi;
+           hi = apr_hash_next(hi))
         {
           const svn_fs_dirent_t *s_entry, *t_entry;
 
-          svn_pool_clear(subpool);
+          svn_pool_clear(iterpool);
           t_entry = svn__apr_hash_index_val(hi);
 
           if (is_depth_upgrade(wc_depth, requested_depth, t_entry->kind))
@@ -1191,24 +1195,27 @@ delta_dirs(report_baton_t *b, svn_revnum
                   apr_hash_get(s_entries, t_entry->name, APR_HASH_KEY_STRING)
                   : NULL;
               s_fullpath = s_entry ?
-                  svn_fspath__join(s_path, t_entry->name, subpool) : NULL;
+                  svn_fspath__join(s_path, t_entry->name, iterpool) : NULL;
             }
 
           /* Compose the report, editor, and target paths for this entry. */
-          e_fullpath = svn_relpath_join(e_path, t_entry->name, subpool);
-          t_fullpath = svn_fspath__join(t_path, t_entry->name, subpool);
+          e_fullpath = svn_relpath_join(e_path, t_entry->name, iterpool);
+          t_fullpath = svn_fspath__join(t_path, t_entry->name, iterpool);
 
           SVN_ERR(update_entry(b, s_rev, s_fullpath, s_entry, t_fullpath,
                                t_entry, dir_baton, e_fullpath, NULL,
                                DEPTH_BELOW_HERE(wc_depth),
                                DEPTH_BELOW_HERE(requested_depth),
-                               subpool));
+                               iterpool));
         }
 
 
       /* Destroy iteration subpool. */
-      svn_pool_destroy(subpool);
+      svn_pool_destroy(iterpool);
     }
+
+  svn_pool_destroy(subpool);
+
   return SVN_NO_ERROR;
 }
 

Propchange: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/adler32.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 14 11:44:03 2014
@@ -1,4 +1,6 @@
+/subversion/branches/1.7.x/subversion/libsvn_subr/adler32.c:1480943-1645438
 /subversion/branches/1.7.x-issue4087/subversion/libsvn_subr/adler32.c:1243707-1336073
+/subversion/branches/1.7.x-issue4153/subversion/libsvn_subr/adler32.c:1309894-1539233
 /subversion/branches/1.7.x-issue4169/subversion/libsvn_subr/adler32.c:1330537-1336116
 /subversion/branches/1.7.x-r1210147/subversion/libsvn_subr/adler32.c:1213310-1293110
 /subversion/branches/1.7.x-r1423646/subversion/libsvn_subr/adler32.c:1423647-1424282

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/cmdline.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/cmdline.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/cmdline.c Sun Dec 14 11:44:03 2014
@@ -340,7 +340,7 @@ svn_cmdline_fputs(const char *string, FI
         {
           /* ### Issue #3014: Return a specific error for broken pipes,
            * ### with a single element in the error chain. */
-          if (APR_STATUS_IS_EPIPE(apr_get_os_error()))
+          if (SVN__APR_STATUS_IS_EPIPE(apr_get_os_error()))
             return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
           else
             return svn_error_wrap_apr(apr_get_os_error(), _("Write error"));
@@ -363,7 +363,7 @@ svn_cmdline_fflush(FILE *stream)
         {
           /* ### Issue #3014: Return a specific error for broken pipes,
            * ### with a single element in the error chain. */
-          if (APR_STATUS_IS_EPIPE(apr_get_os_error()))
+          if (SVN__APR_STATUS_IS_EPIPE(apr_get_os_error()))
             return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
           else
             return svn_error_wrap_apr(apr_get_os_error(), _("Write error"));

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/config_auth.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/config_auth.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/config_auth.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/config_auth.c Sun Dec 14 11:44:03 2014
@@ -90,6 +90,7 @@ svn_config_read_auth_data(apr_hash_t **h
   if (kind == svn_node_file)
     {
       svn_stream_t *stream;
+      svn_string_t *stored_realm;
 
       SVN_ERR_W(svn_stream_open_readonly(&stream, auth_path, pool, pool),
                 _("Unable to open auth file for reading"));
@@ -100,6 +101,12 @@ svn_config_read_auth_data(apr_hash_t **h
                 apr_psprintf(pool, _("Error parsing '%s'"),
                              svn_dirent_local_style(auth_path, pool)));
 
+      stored_realm = apr_hash_get(*hash, SVN_CONFIG_REALMSTRING_KEY,
+                                  APR_HASH_KEY_STRING);
+
+      if (!stored_realm || strcmp(stored_realm->data, realmstring) != 0)
+        *hash = NULL; /* Hash collision, or somebody tampering with storage */
+
       SVN_ERR(svn_stream_close(stream));
     }
 

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/dirent_uri.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/dirent_uri.c Sun Dec 14 11:44:03 2014
@@ -38,6 +38,7 @@
 
 #include "dirent_uri.h"
 #include "private/svn_fspath.h"
+#include "private/svn_cert.h"
 
 /* The canonical empty path.  Can this be changed?  Well, change the empty
    test below and the path library will work, not so sure about the fs/wc
@@ -1866,6 +1867,9 @@ svn_uri_is_canonical(const char *uri, ap
 #endif /* SVN_USE_DOS_PATHS */
 
   /* Now validate the rest of the URI. */
+  seg = ptr;
+  while (*ptr && (*ptr != '/'))
+    ptr++;
   while(1)
     {
       apr_size_t seglen = ptr - seg;
@@ -1884,9 +1888,8 @@ svn_uri_is_canonical(const char *uri, ap
 
       if (*ptr == '/')
         ptr++;
-      seg = ptr;
-
 
+      seg = ptr;
       while (*ptr && (*ptr != '/'))
         ptr++;
     }
@@ -2629,3 +2632,81 @@ svn_urlpath__canonicalize(const char *ur
     }
   return uri;
 }
+
+
+/* -------------- The cert API (see private/svn_cert.h) ------------- */
+
+svn_boolean_t
+svn_cert__match_dns_identity(svn_string_t *pattern, svn_string_t *hostname)
+{
+  apr_size_t pattern_pos = 0, hostname_pos = 0;
+
+  /* support leading wildcards that composed of the only character in the
+   * left-most label. */
+  if (pattern->len >= 2 &&
+      pattern->data[pattern_pos] == '*' &&
+      pattern->data[pattern_pos + 1] == '.')
+    {
+      while (hostname_pos < hostname->len &&
+             hostname->data[hostname_pos] != '.')
+        {
+          hostname_pos++;
+        }
+      /* Assume that the wildcard must match something.  Rule 2 says
+       * that *.example.com should not match example.com.  If the wildcard
+       * ends up not matching anything then it matches .example.com which
+       * seems to be essentially the same as just example.com */
+      if (hostname_pos == 0)
+        return FALSE;
+
+      pattern_pos++;
+    }
+
+  while (pattern_pos < pattern->len && hostname_pos < hostname->len)
+    {
+      char pattern_c = pattern->data[pattern_pos];
+      char hostname_c = hostname->data[hostname_pos];
+
+      /* fold case as described in RFC 4343.
+       * Note: We actually convert to lowercase, since our URI
+       * canonicalization code converts to lowercase and generally
+       * most certs are issued with lowercase DNS names, meaning
+       * this avoids the fold operation in most cases.  The RFC
+       * suggests the opposite transformation, but doesn't require
+       * any specific implementation in any case.  It is critical
+       * that this folding be locale independent so you can't use
+       * tolower(). */
+      pattern_c = canonicalize_to_lower(pattern_c);
+      hostname_c = canonicalize_to_lower(hostname_c);
+
+      if (pattern_c != hostname_c)
+        {
+          /* doesn't match */
+          return FALSE;
+        }
+      else
+        {
+          /* characters match so skip both */
+          pattern_pos++;
+          hostname_pos++;
+        }
+    }
+
+  /* ignore a trailing period on the hostname since this has no effect on the
+   * security of the matching.  See the following for the long explanation as
+   * to why:
+   * https://bugzilla.mozilla.org/show_bug.cgi?id=134402#c28
+   */
+  if (pattern_pos == pattern->len &&
+      hostname_pos == hostname->len - 1 &&
+      hostname->data[hostname_pos] == '.')
+    hostname_pos++;
+
+  if (pattern_pos != pattern->len || hostname_pos != hostname->len)
+    {
+      /* end didn't match */
+      return FALSE;
+    }
+
+  return TRUE;
+}

Propchange: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/hash.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 14 11:44:03 2014
@@ -1,5 +1,7 @@
 /subversion/branches/1.5.x-r30215/subversion/libsvn_subr/hash.c:870312
+/subversion/branches/1.7.x/subversion/libsvn_subr/hash.c:1480943-1645438
 /subversion/branches/1.7.x-issue4087/subversion/libsvn_subr/hash.c:1243707-1336073
+/subversion/branches/1.7.x-issue4153/subversion/libsvn_subr/hash.c:1309894-1539233
 /subversion/branches/1.7.x-issue4169/subversion/libsvn_subr/hash.c:1330537-1336116
 /subversion/branches/1.7.x-r1210147/subversion/libsvn_subr/hash.c:1213310-1293110
 /subversion/branches/1.7.x-r1423646/subversion/libsvn_subr/hash.c:1423647-1424282

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/io.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/io.c Sun Dec 14 11:44:03 2014
@@ -3066,7 +3066,7 @@ do_io_file_wrapper_cleanup(apr_file_t *f
 
   /* ### Issue #3014: Return a specific error for broken pipes,
    * ### with a single element in the error chain. */
-  if (APR_STATUS_IS_EPIPE(status))
+  if (SVN__APR_STATUS_IS_EPIPE(status))
     return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
 
   if (name)
@@ -3250,17 +3250,8 @@ svn_io_write_unique(const char **tmp_pat
 
   err = svn_io_file_write_full(new_file, buf, nbytes, NULL, pool);
 
-  /* ### BH: Windows doesn't have the race condition between the write and the
-     ###     rename that other operating systems might have. So allow windows
-     ###     to decide when it wants to perform the disk synchronization using
-     ###     the normal file locking and journaling filesystem rules.
-
-     ### Note that this function doesn't handle the rename, so we aren't even
-     ### sure that we really have to sync. */
-#ifndef WIN32
-  if (!err && nbytes > 0)
+  if (!err)
     err = svn_io_file_flush_to_disk(new_file, pool);
-#endif
 
   return svn_error_trace(
                   svn_error_compose_create(err,

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/nls.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/nls.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/nls.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/nls.c Sun Dec 14 11:44:03 2014
@@ -56,7 +56,6 @@ svn_nls_init(void)
       char* utf8_path;
       const char* internal_path;
       apr_pool_t* pool;
-      apr_status_t apr_err;
       apr_size_t inwords, outbytes, outlength;
 
       apr_pool_create(&pool, 0);
@@ -99,10 +98,10 @@ svn_nls_init(void)
 
           if (outbytes == 0)
             {
-              err = svn_error_createf(apr_err, NULL,
-                                      _("Can't convert module path "
-                                        "to UTF-8 from UCS-2: '%s'"),
-                                      ucs2_path);
+              err = svn_error_wrap_apr(apr_get_os_error(),
+                                       _("Can't convert module path "
+                                         "to UTF-8 from UCS-2: '%s'"),
+                                       ucs2_path);
             }
           else
             {

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/opt.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/opt.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/opt.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/opt.c Sun Dec 14 11:44:03 2014
@@ -1088,7 +1088,7 @@ svn_opt__print_version_info(const char *
                                      "   compiled %s, %s\n\n"), pgm_name,
                              SVN_VERSION, __DATE__, __TIME__));
   SVN_ERR(svn_cmdline_fputs(
-             _("Copyright (C) 2013 The Apache Software Foundation.\n"
+             _("Copyright (C) 2014 The Apache Software Foundation.\n"
                "This software consists of contributions made by many "
                "people; see the NOTICE\n"
                "file for more information.\n"

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/subst.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/subst.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/subst.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/subst.c Sun Dec 14 11:44:03 2014
@@ -1743,7 +1743,12 @@ svn_subst_copy_and_translate4(const char
     }
 
   /* Now that dst_tmp contains the translated data, do the atomic rename. */
-  return svn_error_trace(svn_io_file_rename(dst_tmp, dst, pool));
+  SVN_ERR(svn_io_file_rename(dst_tmp, dst, pool));
+
+  /* Preserve the source file's permission bits. */
+  SVN_ERR(svn_io_copy_perms(src, dst, pool));
+
+  return SVN_NO_ERROR;
 }
 
 

Propchange: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/svn_base64.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 14 11:44:03 2014
@@ -1,5 +1,6 @@
 /subversion/1.7.x-issue4059/subversion/libsvn_subr/svn_base64.c:1239661-1239744
 /subversion/branches/1.5.x-r30215/subversion/libsvn_subr/svn_base64.c:870312
+/subversion/branches/1.7.x/subversion/libsvn_subr/svn_base64.c:1480943-1645438
 /subversion/branches/1.7.x-JavaHL-pools/subversion/libsvn_subr/svn_base64.c:1158684-1158722
 /subversion/branches/1.7.x-issue3888/subversion/libsvn_subr/svn_base64.c:1148937-1149162
 /subversion/branches/1.7.x-issue3975/subversion/libsvn_subr/svn_base64.c:1160761-1161546
@@ -10,6 +11,7 @@
 /subversion/branches/1.7.x-issue4059/subversion/libsvn_subr/svn_base64.c:1239745-1242661
 /subversion/branches/1.7.x-issue4087/subversion/libsvn_subr/svn_base64.c:1243707-1336073
 /subversion/branches/1.7.x-issue4093/subversion/libsvn_subr/svn_base64.c:1229839-1230236
+/subversion/branches/1.7.x-issue4153/subversion/libsvn_subr/svn_base64.c:1309894-1539233
 /subversion/branches/1.7.x-issue4169/subversion/libsvn_subr/svn_base64.c:1330537-1336116
 /subversion/branches/1.7.x-issue4k/subversion/libsvn_subr/svn_base64.c:1166502-1167193
 /subversion/branches/1.7.x-neon-default/subversion/libsvn_subr/svn_base64.c:1148803-1158680

Modified: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/svn_cache_config.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/svn_cache_config.c?rev=1645439&r1=1645438&r2=1645439&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/svn_cache_config.c (original)
+++ subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/svn_cache_config.c Sun Dec 14 11:44:03 2014
@@ -23,6 +23,7 @@
 #include <apr_atomic.h>
 
 #include "svn_cache_config.h"
+#include "private/svn_atomic.h"
 #include "private/svn_cache.h"
 
 #include "svn_pools.h"
@@ -69,30 +70,27 @@ svn_cache_config_get(void)
   return &cache_settings;
 }
 
-/* Access the process-global (singleton) membuffer cache. The first call
- * will automatically allocate the cache using the current cache config.
- * NULL will be returned if the desired cache size is 0 or if the cache
- * could not be created for some reason.
+/* Initializer function as required by svn_atomic__init_once.  Allocate
+ * the process-global (singleton) membuffer cache and return it in the
+ * svn_membuffer_t * in *BATON.  UNUSED_POOL is unused and should be NULL.
  */
-svn_membuffer_t *
-svn_cache__get_global_membuffer_cache(void)
+static svn_error_t *
+initialize_cache(void *baton, apr_pool_t *unused_pool)
 {
-  static svn_membuffer_t * volatile cache = NULL;
+  svn_membuffer_t **cache_p = baton;
+  svn_membuffer_t *cache = NULL;
 
   apr_uint64_t cache_size = cache_settings.cache_size;
-  if (!cache && cache_size)
+  if (cache_size)
     {
       svn_error_t *err;
 
-      svn_membuffer_t *old_cache = NULL;
-      svn_membuffer_t *new_cache = NULL;
-
       /* auto-allocate cache */
       apr_allocator_t *allocator = NULL;
       apr_pool_t *pool = NULL;
 
       if (apr_allocator_create(&allocator))
-        return NULL;
+        return SVN_NO_ERROR;
 
       /* Ensure that we free partially allocated data if we run OOM
        * before the cache is complete: If the cache cannot be allocated
@@ -112,48 +110,55 @@ svn_cache__get_global_membuffer_cache(vo
        */
       apr_pool_create_ex(&pool, NULL, NULL, allocator);
       if (pool == NULL)
-        return NULL;
+        return SVN_NO_ERROR;
       apr_allocator_owner_set(allocator, pool);
 
       err = svn_cache__membuffer_cache_create(
-          &new_cache,
+          &cache,
           (apr_size_t)cache_size,
           (apr_size_t)(cache_size / 16),
           ! svn_cache_config_get()->single_threaded,
           pool);
 
-      /* Some error occured. Most likely it's an OOM error but we don't
+      /* Some error occurred. Most likely it's an OOM error but we don't
        * really care. Simply release all cache memory and disable caching
        */
       if (err)
         {
-          /* Memory and error cleanup */
-          svn_error_clear(err);
-          apr_pool_destroy(pool);
-
-          /* Prevent future attempts to create the cache. However, an
-           * existing cache instance (see next comment) remains valid.
-           */
+          /* Memory cleanup */
+          svn_pool_destroy(pool);
+
+          /* Document that we actually don't have a cache. */
           cache_settings.cache_size = 0;
 
-          /* The current caller won't get the cache object.
-           * However, a concurrent call might have succeeded in creating
-           * the cache object. That call and all following ones will then
-           * use the successfully created cache instance.
-           */
-          return NULL;
+          return svn_error_trace(err);
         }
 
-      /* Handle race condition: if we are the first to create a
-       * cache object, make it our global singleton. Otherwise,
-       * discard the new cache and keep the existing one.
-       *
-       * Cast is necessary because of APR bug:
-       * https://issues.apache.org/bugzilla/show_bug.cgi?id=50731
-       */
-      old_cache = apr_atomic_casptr((volatile void **)&cache, new_cache, NULL);
-      if (old_cache != NULL)
-        apr_pool_destroy(pool);
+      /* done */
+      *cache_p = cache;
+    }
+
+  return SVN_NO_ERROR;
+}
+
+/* Access the process-global (singleton) membuffer cache. The first call
+ * will automatically allocate the cache using the current cache config.
+ * NULL will be returned if the desired cache size is 0 or if the cache
+ * could not be created for some reason.
+ */
+svn_membuffer_t *
+svn_cache__get_global_membuffer_cache(void)
+{
+  static svn_membuffer_t *cache = NULL;
+  static svn_atomic_t initialized = 0;
+
+  svn_error_t *err
+    = svn_atomic__init_once(&initialized, initialize_cache, &cache, NULL);
+  if (err)
+    {
+      /* no caches today ... */
+      svn_error_clear(err);
+      return NULL;
     }
 
   return cache;

Propchange: subversion/branches/1.7.x-issue4340-repos/subversion/libsvn_subr/svn_cache_config.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 14 11:44:03 2014
@@ -1,6 +1,8 @@
 /subversion/1.7.x-issue4059/subversion/libsvn_subr/svn_cache_config.c:1239661-1239744
 /subversion/branches/1.5.x-r30215/subversion/libsvn_subr/svn_cache_config.c:870312
+/subversion/branches/1.7.x/subversion/libsvn_subr/svn_cache_config.c:1480943-1645438
 /subversion/branches/1.7.x-JavaHL-pools/subversion/libsvn_subr/svn_cache_config.c:1158684-1158722
+/subversion/branches/1.7.x-gssapi-solaris10/subversion/libsvn_subr/svn_cache_config.c:1453164-1515067
 /subversion/branches/1.7.x-issue3888/subversion/libsvn_subr/svn_cache_config.c:1148937-1149162
 /subversion/branches/1.7.x-issue3975/subversion/libsvn_subr/svn_cache_config.c:1160761-1161546
 /subversion/branches/1.7.x-issue3976/subversion/libsvn_subr/svn_cache_config.c:1161731-1165397
@@ -13,12 +15,21 @@
 /subversion/branches/1.7.x-issue4102/subversion/libsvn_subr/svn_cache_config.c:1292401-1295402
 /subversion/branches/1.7.x-issue4123/subversion/libsvn_subr/svn_cache_config.c:1293358-1293812
 /subversion/branches/1.7.x-issue4144/subversion/libsvn_subr/svn_cache_config.c:1305854-1306143
+/subversion/branches/1.7.x-issue4153/subversion/libsvn_subr/svn_cache_config.c:1309894-1539233
 /subversion/branches/1.7.x-issue4161/subversion/libsvn_subr/svn_cache_config.c:1330697-1331209
 /subversion/branches/1.7.x-issue4166/subversion/libsvn_subr/svn_cache_config.c:1330474-1336071
 /subversion/branches/1.7.x-issue4169/subversion/libsvn_subr/svn_cache_config.c:1330537-1336116
+/subversion/branches/1.7.x-issue4257/subversion/libsvn_subr/svn_cache_config.c:1454456-1461404
+/subversion/branches/1.7.x-issue4263/subversion/libsvn_subr/svn_cache_config.c:1423588-1434547
+/subversion/branches/1.7.x-issue4270/subversion/libsvn_subr/svn_cache_config.c:1433737-1485341
+/subversion/branches/1.7.x-issue4306/subversion/libsvn_subr/svn_cache_config.c:1438872-1514941
+/subversion/branches/1.7.x-issue4332/subversion/libsvn_subr/svn_cache_config.c:1453478-1460963
+/subversion/branches/1.7.x-issue4340/subversion/libsvn_subr/svn_cache_config.c:1461589-1485180
+/subversion/branches/1.7.x-issue4408/subversion/libsvn_subr/svn_cache_config.c:1512143-1514943
 /subversion/branches/1.7.x-issue4k/subversion/libsvn_subr/svn_cache_config.c:1166502-1167193
 /subversion/branches/1.7.x-log-diff/subversion/libsvn_subr/svn_cache_config.c:1295670-1295699
 /subversion/branches/1.7.x-neon-default/subversion/libsvn_subr/svn_cache_config.c:1148803-1158680
+/subversion/branches/1.7.x-neon-properr/subversion/libsvn_subr/svn_cache_config.c:1440619-1461944
 /subversion/branches/1.7.x-r1152189/subversion/libsvn_subr/svn_cache_config.c:1152759-1154249
 /subversion/branches/1.7.x-r1155160/subversion/libsvn_subr/svn_cache_config.c:1158704-1159223
 /subversion/branches/1.7.x-r1159093/subversion/libsvn_subr/svn_cache_config.c:1159097-1159230
@@ -34,6 +45,7 @@
 /subversion/branches/1.7.x-r1306111/subversion/libsvn_subr/svn_cache_config.c:1306301-1331207
 /subversion/branches/1.7.x-r1341012/subversion/libsvn_subr/svn_cache_config.c:1341013-1355629
 /subversion/branches/1.7.x-r1348822/subversion/libsvn_subr/svn_cache_config.c:1348878-1355700
+/subversion/branches/1.7.x-r1352031/subversion/libsvn_subr/svn_cache_config.c:1431725-1435017
 /subversion/branches/1.7.x-r1352068/subversion/libsvn_subr/svn_cache_config.c:1352087-1364232
 /subversion/branches/1.7.x-r1361007/subversion/libsvn_subr/svn_cache_config.c:1361110-1367853
 /subversion/branches/1.7.x-r1361341/subversion/libsvn_subr/svn_cache_config.c:1361342-1367855
@@ -45,7 +57,18 @@
 /subversion/branches/1.7.x-r1389878/subversion/libsvn_subr/svn_cache_config.c:1389879-1393126
 /subversion/branches/1.7.x-r1389928/subversion/libsvn_subr/svn_cache_config.c:1390384-1391747
 /subversion/branches/1.7.x-r1398325/subversion/libsvn_subr/svn_cache_config.c:1398353-1398633
+/subversion/branches/1.7.x-r1399174/subversion/libsvn_subr/svn_cache_config.c:1399176-1403964
+/subversion/branches/1.7.x-r1401915/subversion/libsvn_subr/svn_cache_config.c:1401934-1407349
+/subversion/branches/1.7.x-r1407131/subversion/libsvn_subr/svn_cache_config.c:1407164-1419607
 /subversion/branches/1.7.x-r1423646/subversion/libsvn_subr/svn_cache_config.c:1423647-1424282
+/subversion/branches/1.7.x-r1426752/subversion/libsvn_subr/svn_cache_config.c:1426753-1485335
+/subversion/branches/1.7.x-r1427278/subversion/libsvn_subr/svn_cache_config.c:1433724-1485338
+/subversion/branches/1.7.x-r1461743/subversion/libsvn_subr/svn_cache_config.c:1461745-1482189
+/subversion/branches/1.7.x-r1475724/subversion/libsvn_subr/svn_cache_config.c:1475743-1482192
+/subversion/branches/1.7.x-r1481010/subversion/libsvn_subr/svn_cache_config.c:1481034-1482194
+/subversion/branches/1.7.x-r1482759/subversion/libsvn_subr/svn_cache_config.c:1483584-1485046
+/subversion/branches/1.7.x-r1507044/subversion/libsvn_subr/svn_cache_config.c:1507300-1511568
+/subversion/branches/1.7.x-r1527103/subversion/libsvn_subr/svn_cache_config.c:1527110-1541378
 /subversion/branches/1.7.x-serf-server-root-segfaults/subversion/libsvn_subr/svn_cache_config.c:1383952-1392726
 /subversion/branches/1.7.x-svn-patch-eol-fixes/subversion/libsvn_subr/svn_cache_config.c:1207511-1235924
 /subversion/branches/atomic-revprop/subversion/libsvn_subr/svn_cache_config.c:965046-1000689
@@ -103,4 +126,4 @@
 /subversion/branches/tree-conflicts-notify/subversion/libsvn_subr/svn_cache_config.c:873926-874008
 /subversion/branches/uris-as-urls/subversion/libsvn_subr/svn_cache_config.c:1060426-1064427
 /subversion/trunk/subversion/libsvn_subr/cache_config.c:1398325
-/subversion/trunk/subversion/libsvn_subr/svn_cache_config.c:1146013,1146121,1146219,1146222,1146274,1146492,1146555,1146606,1146620,1146684,1146762,1146781,1146832,1146834,1146870,1146899,1146904,1147293,1147299,1147309,1147882,1148071,1148083,1148094,1148131,1148374,1148424,1148566,1148588,1148652,1148662,1148699,1148853,1148877,1148882,1148936,1149103,1149105,1149135,1149141,1149160,1149228,1149240,1149343,1149371-1149372,1149377,1149398,1149401,1149539,1149572,1149627,1149675,1149701,1149713,1150242,1150254,1150260-1150261,1150266,1150302,1150327,1150344,1150368,1150372,1150441,1150506,1150812,1150853,1151036,1151177,1151610,1151854,1151906,1151911,1152129,1152140,1152189-1152190,1152267,1152282,1152286,1152726,1152809,1153138,1153141,1153416,1153540,1153566,1153799,1153807,1153968,1154009,1154023,1154115,1154119,1154121,1154144,1154155,1154159,1154165,1154215,1154225,1154273,1154278,1154379,1154382,1154461,1154717-1154718,1154733,1154908,1154982,1155015,1155044,1155124,1155131,1
 155160,1155313,1155334,1155391,1155404,1156085,1156098,1156216,1156218,1156312,1156527,1156717,1156721,1156750,1156827,1156838,1157416,1158187,1158193-1158194,1158196,1158201,1158207,1158209-1158210,1158217,1158285,1158288,1158303,1158309,1158407,1158419,1158421,1158436,1158455,1158616-1158617,1158634,1158854,1158875,1158886,1158893,1158896,1158919,1158923-1158924,1158929,1158963,1159093,1159098,1159101,1159132,1159136,1159148,1159230,1159275,1159400,1159686,1159760,1159772,1160605,1160671,1160682,1160704-1160705,1160756,1161063,1161080,1161185,1161210,1161683,1161721,1162024,1162033,1162201,1162516,1162880,1162974,1162995,1163243,1163372,1163383,1163557,1163792,1163953,1164027,1164386,1164426,1164517,1164535,1164554,1164580,1164614,1164645,1164760,1164765,1164929,1166267,1166500,1166555,1166678,1167062,1167173,1167209,1167269,1167503,1167659,1167681,1169524,1169531,1169650,1171708,1173111,1173425,1173639,1174051,1174060,1174342,1174652,1174761,1174797-1174798,1174806,1175888,117691
 5,1176949,1177001,1177492,1177732,1178280,1178282,1178942,1179680,1179767,1179776,1180154,1181090,1181110,1181155,1181215,1181609,1181666,1182115,1182527,1182771,1182904,1182909,1183054,1183263,1183347,1185222,1185242,1185280,1185282,1185730,1185738,1185746,1185763,1185768,1185886,1185911,1185918,1186059,1186092,1186101,1186107,1186109,1186121,1186231,1186240,1186422,1186434,1186732,1186755,1186784,1186815,1186928,1186944,1186981,1186983,1187311,1187676,1187695,1188609,1188652,1188677,1188762,1188774,1189190,1189261,1189395,1189580,1189665,1190463,1195480,1197135,1197998,1199876,1199950,1200277,1200837,1200896,1201002,1201072,1201419,1201824,1202132,1202135,1202187,1202333,1202630,1202807,1203546,1203651,1203653,1203977,1204167,1204478,1204610,1204673,1205188,1205193,1205209,1205726,1205839,1205848,1205968,1206523,1206533,1206576,1206718-1206719,1206724,1206741,1206748,1207555,1207656,1207663,1207808,1207823,1207858,1207949,1208840,1209631,1209654,1210147,1210195,1210913,1211048,121
 1483,1211859,1211885,1212476,1212482,1212484,1213331,1213673,1213681,1213690,1213711,1213716,1214139,1215260,1215288,1215374-1215375,1215379,1220740,1220742,1220750,1220861,1221178,1221303,1221767,1221780,1221793,1222521,1222628,1222644,1222693,1222699,1225491,1226597,1227146,1227237,1227250,1227352,1227372,1227384-1227385,1227900,1228340,1229252,1229303,1229677,1229833,1229980,1230212,1230714,1231029,1231944-1231945,1232202,1232207,1232221-1232222,1232267,1232413,1233292,1235264,1235296,1235302,1235736,1236163,1236173,1236283,1236343,1237720,1238121,1239382,1239596,1239631,1239655,1239747,1240314,1240485,1240619,1240752,1241530,1241553,1241599,1241626,1241713,1241726,1242116,1242537,1242607,1242759,1242770,1242794,1243694,1243840,1243920,1243976,1244303,1244317,1244466,1244551,1245284-1245285,1245711,1245738,1245746,1245764,1245809,1245817,1245929,1245935,1291429,1291446,1291520,1291594,1291680,1291685,1291700,1291704,1291726,1291729,1291797,1291810,1291941,1292090,1292248,1292255,
 1292260,1292296,1292322,1292507,1292516,1292768,1292827,1292926,1293229,1293577,1293945,1293972,1293976,1293998,1294134,1294136,1294147,1294236,1294470,1294586,1295007,1295303,1295372,1296251,1296303,1296369,1296691,1297522,1298343,1300265,1302399,1302417,1302539,1302588,1302591,1302613,1305853,1306111,1306334,1307177,1309992,1310378,1310428,1310535,1310594,1311702,1311935,1325361,1327474,1327490,1327495,1327979,1328002,1328038,1328144,1328267-1328268,1328353,1328846-1328847,1328852,1328878,1329388,1329417,1329876,1330258,1330382,1330444,1330520,1335104,1335555,1337441,1338810,1339164,1340556,1341012,1341031,1341034,1341076,1342984,1344864-1344865,1344869,1345482,1346765,1348822,1349215,1349367,1349371,1349380,1349778,1351117,1351772,1352068,1353572,1354626,1354652,1354876,1354907,1355340,1361007,1361019,1361341,1362508,1365519,1365549,1365554,1365556,1365592,1367498,1368065,1368128,1368197-1368198,1371282,1374198,1374800,1374802,1375052,1375089,1376414,1378847,1380175,1380295,13806
 97,1382843,1383029,1383466,1383483,1383946,1387226,1387943,1388975,1389364,1389499,1389658,1389851,1389878,1389928,1390965,1391020,1391022,1391641,1391935,1392502,1392599,1393061,1393156,1393165,1393542,1393551,1393598,1396285,1423646
+/subversion/trunk/subversion/libsvn_subr/svn_cache_config.c:1146013,1146121,1146219,1146222,1146274,1146492,1146555,1146606,1146620,1146684,1146762,1146781,1146832,1146834,1146870,1146899,1146904,1147293,1147299,1147309,1147882,1148071,1148083,1148094,1148131,1148374,1148424,1148566,1148588,1148652,1148662,1148699,1148853,1148877,1148882,1148936,1149103,1149105,1149135,1149141,1149160,1149228,1149240,1149343,1149371-1149372,1149377,1149398,1149401,1149539,1149572,1149627,1149675,1149701,1149713,1150242,1150254,1150260-1150261,1150266,1150302,1150327,1150344,1150368,1150372,1150441,1150506,1150812,1150853,1151036,1151177,1151610,1151854,1151906,1151911,1152129,1152140,1152189-1152190,1152267,1152282,1152286,1152726,1152809,1153138,1153141,1153416,1153540,1153566,1153799,1153807,1153968,1154009,1154023,1154115,1154119,1154121,1154144,1154155,1154159,1154165,1154215,1154225,1154273,1154278,1154379,1154382,1154461,1154717-1154718,1154733,1154908,1154982,1155015,1155044,1155124,1155131,1
 155160,1155313,1155334,1155391,1155404,1156085,1156098,1156216,1156218,1156312,1156527,1156717,1156721,1156750,1156827,1156838,1157416,1158187,1158193-1158194,1158196,1158201,1158207,1158209-1158210,1158217,1158285,1158288,1158303,1158309,1158407,1158419,1158421,1158436,1158455,1158616-1158617,1158634,1158854,1158875,1158886,1158893,1158896,1158919,1158923-1158924,1158929,1158963,1159093,1159098,1159101,1159132,1159136,1159148,1159230,1159275,1159400,1159686,1159760,1159772,1160605,1160671,1160682,1160704-1160705,1160756,1161063,1161080,1161185,1161210,1161683,1161721,1162024,1162033,1162201,1162516,1162880,1162974,1162995,1163243,1163372,1163383,1163557,1163792,1163953,1164027,1164116,1164386,1164426,1164517,1164535,1164554,1164580,1164614,1164645,1164760,1164765,1164929,1166267,1166500,1166555,1166678,1167062,1167173,1167209,1167269,1167503,1167659,1167681,1169524,1169531,1169650,1171708,1173111,1173425,1173639,1174051,1174060,1174342,1174652,1174761,1174797-1174798,1174806,117588
 8,1176915,1176949,1177001,1177492,1177732,1178280,1178282,1178942,1179680,1179767,1179776,1180154,1181090,1181110,1181155,1181215,1181609,1181666,1182115,1182527,1182771,1182904,1182909,1183054,1183263,1183347,1185222,1185242,1185280,1185282,1185730,1185738,1185746,1185763,1185768,1185886,1185911,1185918,1186059,1186092,1186101,1186107,1186109,1186121,1186231,1186240,1186422,1186434,1186732,1186755,1186784,1186815,1186928,1186944,1186981,1186983,1187311,1187676,1187695,1188609,1188652,1188677,1188762,1188774,1189190,1189261,1189395,1189580,1189665,1190463,1195480,1197135,1197998,1199876,1199950,1200277,1200837,1200896,1201002,1201072,1201419,1201824,1202132,1202135,1202187,1202333,1202630,1202807,1203546,1203651,1203653,1203977,1204167,1204478,1204610,1204673,1205188,1205193,1205209,1205726,1205839,1205848,1205968,1206523,1206533,1206576,1206718-1206719,1206724,1206741,1206748,1207555,1207656,1207663,1207808,1207823,1207858,1207949,1208840,1209631,1209654,1210147,1210195,1210913,121
 1048,1211483,1211859,1211885,1212476,1212482,1212484,1213331,1213673,1213681,1213690,1213711,1213716,1214139,1215260,1215288,1215374-1215375,1215379,1220740,1220742,1220750,1220861,1221178,1221303,1221767,1221780,1221793,1222521,1222628,1222644,1222693,1222699,1225491,1226597,1227146,1227237,1227250,1227352,1227372,1227384-1227385,1227900,1228340,1229252,1229303,1229677,1229833,1229980,1230212,1230714,1230798,1231029,1231944-1231945,1232202,1232207,1232221-1232222,1232267,1232413,1233292,1235264,1235296,1235302,1235736,1236163,1236173,1236283,1236343,1237720,1237779,1238121,1239382,1239596,1239631,1239655,1239747,1240314,1240485,1240619,1240752,1241530,1241553,1241599,1241626,1241713,1241726,1242116,1242537,1242607,1242759,1242770,1242794,1243694,1243840,1243920,1243976,1244303,1244317,1244466,1244551,1245284-1245285,1245711,1245738,1245746,1245764,1245809,1245817,1245929,1245935,1291429,1291446,1291520,1291594,1291680,1291685,1291700,1291704,1291726,1291729,1291797,1291810,1291941,
 1292090,1292248,1292255,1292260,1292296,1292322,1292507,1292516,1292768,1292827,1292926,1293229,1293577,1293945,1293972,1293976,1293998,1294134,1294136,1294147,1294236,1294470,1294586,1295007,1295303,1295372,1295418,1296251,1296303,1296369,1296691,1297522,1298343,1300265,1302399,1302417,1302539,1302588,1302591,1302613,1305853,1306111,1306275,1306334,1307177,1309865,1309992,1310378,1310428,1310535,1310594,1311702,1311935,1325361,1327474,1327490,1327495,1327979,1328002,1328038,1328144,1328267-1328268,1328353,1328846-1328847,1328852,1328878,1329388,1329417,1329876,1330258,1330382,1330444,1330520,1335104,1335555,1337441,1338291,1338297,1338314,1338688,1338708,1338713,1338739,1338748,1338810,1339159,1339164,1340556,1341012,1341031,1341034,1341076,1341544,1341560,1342984,1344864-1344865,1344869,1345482,1345740,1346765,1348822,1349215,1349367,1349371,1349380,1349778,1351117,1351772,1352031,1352068,1353572,1354626,1354652,1354876,1354907,1355340,1361007,1361019,1361341,1362508,1365519,13655
 49,1365554,1365556,1365592,1367498,1368065,1368128,1368197-1368198,1371282,1374198,1374800,1374802,1375052,1375089,1376414,1378847,1380175,1380295,1380697,1382843,1383029,1383466,1383483,1383946,1387226,1387943,1388975,1389364,1389499,1389658,1389851,1389878,1389928,1390653,1390965,1391020,1391022,1391641,1391935,1392502,1392599,1393061,1393156,1393165,1393542,1393551,1393598,1394519,1396285,1398100,1399174,1401915,1402417,1402421,1403258,1403583,1403588,1403691,1403964,1403982,1405922,1407131,1407812,1408650,1409146,1409939,1410106,1410203,1419670-1419681,1421011,1421103,1421380,1421541,1422053,1422100,1423585,1423646,1423837,1423840,1423848,1424977,1425368,1426138,1426264,1426752,1426830,1427197,1427210,1427278,1429201,1434128,1434405,1434414,1434418,1434435,1434476,1434750,1435361,1438602,1438683,1441810,1443763,1443929,1445753,1451678,1452617,1452780,1452967,1453780,1454088,1454217,1455352,1458341,1459599,1461278,1461562,1461580,1461701,1461743,1462293,1462300,1462302,1462321,14
 62334,1465975,1476359,1477730,1481010,1481627,1482282,1483781,1485350,1490684,1503528,1507044,1512432,1512471-1512472,1513463,1513472,1514763,1515119,1515237,1515992,1515997,1516023-1516024,1516051-1516052,1516565



Mime
View raw message