Modified: subversion/branches/authzperf/subversion/libsvn_client/merge.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_client/merge.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_client/merge.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_client/merge.c Thu Oct 13 
15:25:15 2016
@@ -1210,7 +1210,7 @@ struct merge_file_baton_t
 
   /* If a tree conflict will be installed once edited, it's reason. If a skip
      should be produced its reason. Some special values are defined. See the
-     merge_tree_baton_t for an explanation. */
+     merge_dir_baton_t for an explanation. */
   svn_wc_conflict_reason_t tree_conflict_reason;
   svn_wc_conflict_action_t tree_conflict_action;
   svn_node_kind_t tree_conflict_local_node_kind;

Modified: subversion/branches/authzperf/subversion/libsvn_client/patch.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_client/patch.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_client/patch.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_client/patch.c Thu Oct 13 
15:25:15 2016
@@ -1224,11 +1224,11 @@ init_patch_target(patch_target_t **patch
 
       /* Open a temporary file to write the patched result to. */
       SVN_ERR(svn_io_open_unique_file3(&target->patched_file,
-                                        &target->patched_path, NULL,
-                                        remove_tempfiles ?
-                                          svn_io_file_del_on_pool_cleanup :
-                                          svn_io_file_del_none,
-                                        result_pool, scratch_pool));
+                                       &target->patched_path, NULL,
+                                       remove_tempfiles ?
+                                         svn_io_file_del_on_pool_cleanup :
+                                         svn_io_file_del_none,
+                                       result_pool, scratch_pool));
 
       /* Put the write callback in place. */
       content->write = write_file;

Modified: subversion/branches/authzperf/subversion/libsvn_fs/fs-loader.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs/fs-loader.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs/fs-loader.c Thu Oct 13 
15:25:15 2016
@@ -1501,15 +1501,11 @@ svn_fs_file_checksum(svn_checksum_t **ch
 
   if (force && (*checksum == NULL || (*checksum)->kind != kind))
     {
-      svn_stream_t *contents, *checksum_contents;
+      svn_stream_t *contents;
 
       SVN_ERR(svn_fs_file_contents(&contents, root, path, pool));
-      checksum_contents = svn_stream_checksummed2(contents, checksum, NULL,
-                                                  kind, TRUE, pool);
-
-      /* This will force a read of any remaining data (which is all of it in
-         this case) and dump the checksum into checksum->digest. */
-      SVN_ERR(svn_stream_close(checksum_contents));
+      SVN_ERR(svn_stream_contents_checksum(checksum, contents, kind,
+                                           pool, pool));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/cached_data.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/cached_data.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/cached_data.c 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/cached_data.c Thu Oct 
13 15:25:15 2016
@@ -3379,8 +3379,8 @@ read_item(svn_stream_t **stream,
                  _("Low-level checksum mismatch while reading\n"
                    "%s bytes of meta data at offset %s "
                    "for item %s in revision %ld"),
-                 apr_psprintf(pool, "%" APR_OFF_T_FMT, entry->size),
-                 apr_psprintf(pool, "%" APR_OFF_T_FMT, entry->offset),
+                 apr_off_t_toa(pool, entry->size),
+                 apr_off_t_toa(pool, entry->offset),
                  apr_psprintf(pool, "%" APR_UINT64_T_FMT, entry->item.number),
                  entry->item.revision);
 }

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/caching.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/caching.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/caching.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/caching.c Thu Oct 13 
15:25:15 2016
@@ -383,7 +383,7 @@ svn_fs_fs__initialize_caches(svn_fs_t *f
   /* General rules for assigning cache priorities:
    *
    * - Data that can be reconstructed from other elements has low prio
-   *   (e.g. fulltexts, directories etc.)
+   *   (e.g. fulltexts etc.)
    * - Index data required to find any of the other data has high prio
    *   (e.g. noderevs, L2P and P2L index pages)
    * - everthing else should use default prio

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.c Thu Oct 13 
15:25:15 2016
@@ -475,7 +475,7 @@ fs_pack(svn_fs_t *fs,
         apr_pool_t *common_pool)
 {
   SVN_ERR(fs_open(fs, path, common_pool_lock, pool, common_pool));
-  return svn_fs_fs__pack(fs, notify_func, notify_baton,
+  return svn_fs_fs__pack(fs, 0, notify_func, notify_baton,
                          cancel_func, cancel_baton, pool);
 }
 

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.h?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/fs.h Thu Oct 13 
15:25:15 2016
@@ -530,7 +530,7 @@ typedef struct representation_t
   /* Revision where this representation is located. */
   svn_revnum_t revision;
 
-  /* Item index with the the revision. */
+  /* Item index with the revision. */
   apr_uint64_t item_index;
 
   /* The size of the representation in bytes as seen in the revision

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/low_level.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/low_level.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/low_level.c Thu Oct 
13 15:25:15 2016
@@ -800,7 +800,11 @@ svn_fs_fs__parse_representation(represen
 
   SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_md5, str,
                                  scratch_pool));
-  memcpy(rep->md5_digest, checksum->digest, sizeof(rep->md5_digest));
+
+  /* If STR is a all-zero checksum, CHECKSUM will be NULL and REP already
+     contains the correct value. */
+  if (checksum)
+    memcpy(rep->md5_digest, checksum->digest, sizeof(rep->md5_digest));
 
   /* The remaining fields are only used for formats >= 4, so check that. */
   str = svn_cstring_tokenize(" ", &string);
@@ -814,8 +818,16 @@ svn_fs_fs__parse_representation(represen
 
   SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_sha1, str,
                                  scratch_pool));
+
+  /* We do have a valid SHA1 but it might be all 0.
+     We cannot be sure where that came from (Alas! legacy), so let's not
+     claim we know the SHA1 in that case. */
   rep->has_sha1 = checksum != NULL;
-  memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest));
+
+  /* If STR is a all-zero checksum, CHECKSUM will be NULL and REP already
+     contains the correct value. */
+  if (checksum)
+    memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest));
 
   /* Read the uniquifier. */
   str = svn_cstring_tokenize("/", &string);

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.c Thu Oct 13 
15:25:15 2016
@@ -221,7 +221,7 @@ typedef struct pack_context_t
    * to NULL that we already processed. */
   apr_array_header_t *reps;
 
-  /* array of int, marking for each revision, the which offset their items
+  /* array of int, marking for each revision, at which offset their items
    * begin in REPS.  Will be filled in phase 2 and be cleared after
    * each revision range. */
   apr_array_header_t *rev_offsets;
@@ -341,21 +341,40 @@ static svn_error_t *
 reset_pack_context(pack_context_t *context,
                    apr_pool_t *pool)
 {
+  const char *temp_dir;
+
   apr_array_clear(context->changes);
-  SVN_ERR(svn_io_file_trunc(context->changes_file, 0, pool));
+  SVN_ERR(svn_io_file_close(context->changes_file, pool));
   apr_array_clear(context->file_props);
-  SVN_ERR(svn_io_file_trunc(context->file_props_file, 0, pool));
+  SVN_ERR(svn_io_file_close(context->file_props_file, pool));
   apr_array_clear(context->dir_props);
-  SVN_ERR(svn_io_file_trunc(context->dir_props_file, 0, pool));
+  SVN_ERR(svn_io_file_close(context->dir_props_file, pool));
 
   apr_array_clear(context->rev_offsets);
   apr_array_clear(context->path_order);
   apr_array_clear(context->references);
   apr_array_clear(context->reps);
-  SVN_ERR(svn_io_file_trunc(context->reps_file, 0, pool));
+  SVN_ERR(svn_io_file_close(context->reps_file, pool));
 
   svn_pool_clear(context->info_pool);
 
+  /* The new temporary files must live at least as long as any other info
+   * object in CONTEXT. */
+  SVN_ERR(svn_io_temp_dir(&temp_dir, pool));
+  SVN_ERR(svn_io_open_unique_file3(&context->changes_file, NULL, temp_dir,
+                                   svn_io_file_del_on_close,
+                                   context->info_pool, pool));
+  SVN_ERR(svn_io_open_unique_file3(&context->file_props_file, NULL, temp_dir,
+                                   svn_io_file_del_on_close,
+                                   context->info_pool, pool));
+  SVN_ERR(svn_io_open_unique_file3(&context->dir_props_file, NULL, temp_dir,
+                                   svn_io_file_del_on_close,
+                                   context->info_pool, pool));
+  SVN_ERR(svn_io_open_unique_file3(&context->reps_file, NULL, temp_dir,
+                                   svn_io_file_del_on_close,
+                                   context->info_pool, pool));
+  context->paths = svn_prefix_tree__create(context->info_pool);
+
   return SVN_NO_ERROR;
 }
 
@@ -670,7 +689,7 @@ svn_fs_fs__order_dir_entries(svn_fs_t *f
   return result;
 }
 
-/* Return a duplicate of the the ORIGINAL path and with special sub-strins
+/* Return a duplicate of the ORIGINAL path and with special sub-strings
  * (e.g. "trunk") modified in such a way that have a lower lexicographic
  * value than any other "normal" file name.
  */
@@ -707,7 +726,7 @@ tweak_path_for_ordering(const char *orig
  */
 static svn_error_t *
 copy_node_to_temp(pack_context_t *context,
-                  apr_file_t *rev_file,
+                  svn_fs_fs__revision_file_t *rev_file,
                   svn_fs_fs__p2l_entry_t *entry,
                   apr_pool_t *pool)
 {
@@ -715,13 +734,10 @@ copy_node_to_temp(pack_context_t *contex
                                          sizeof(*path_order));
   node_revision_t *noderev;
   const char *sort_path;
-  svn_stream_t *stream;
   apr_off_t source_offset = entry->offset;
 
   /* read & parse noderev */
-  stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
-  SVN_ERR(svn_fs_fs__read_noderev(&noderev, stream, pool, pool));
-  SVN_ERR(svn_stream_close(stream));
+  SVN_ERR(svn_fs_fs__read_noderev(&noderev, rev_file->stream, pool, pool));
 
   /* create a copy of ENTRY, make it point to the copy destination and
    * store it in CONTEXT */
@@ -731,9 +747,9 @@ copy_node_to_temp(pack_context_t *contex
   add_item_rep_mapping(context, entry);
 
   /* copy the noderev to our temp file */
-  SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &source_offset, pool));
-  SVN_ERR(copy_file_data(context, context->reps_file, rev_file, entry->size,
-                         pool));
+  SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, pool));
+  SVN_ERR(copy_file_data(context, context->reps_file, rev_file->file,
+                         entry->size, pool));
 
   /* if the node has a data representation, make that the node's "base".
    * This will (often) cause the noderev to be placed right in front of
@@ -1391,7 +1407,7 @@ pack_range(pack_context_t *context,
                     SVN_ERR(copy_rep_to_temp(context, rev_file->file, entry,
                                              iterpool2));
                   else if (entry->type == SVN_FS_FS__ITEM_TYPE_NODEREV)
-                    SVN_ERR(copy_node_to_temp(context, rev_file->file, entry,
+                    SVN_ERR(copy_node_to_temp(context, rev_file, entry,
                                               iterpool2));
                   else
                     SVN_ERR_ASSERT(entry->type == SVN_FS_FS__ITEM_TYPE_UNUSED);
@@ -1450,17 +1466,19 @@ append_revision(pack_context_t *context,
   apr_off_t offset = 0;
   apr_pool_t *iterpool = svn_pool_create(pool);
   svn_fs_fs__revision_file_t *rev_file;
-  svn_filesize_t revfile_size;
+  svn_filesize_t revdata_size;
 
-  /* Copy all the bits from the rev file to the end of the pack file. */
+  /* Copy all non-index contents the rev file to the end of the pack file. */
   SVN_ERR(svn_fs_fs__open_pack_or_rev_file(&rev_file, context->fs,
                                            context->start_rev, pool,
                                            iterpool));
-  /* Get the size of the file. */
-  SVN_ERR(svn_io_file_size_get(&revfile_size, rev_file->file, pool));
+  SVN_ERR(svn_fs_fs__auto_read_footer(rev_file));
+  revdata_size = rev_file->l2p_offset;
 
+  SVN_ERR(svn_io_file_aligned_seek(rev_file->file, ffd->block_size, NULL, 0,
+                                   iterpool));
   SVN_ERR(copy_file_data(context, context->pack_file, rev_file->file,
-                         revfile_size, iterpool));
+                         revdata_size, iterpool));
 
   /* mark the start of a new revision */
   SVN_ERR(svn_fs_fs__l2p_proto_index_add_revision(context->proto_l2p_index,
@@ -1468,7 +1486,7 @@ append_revision(pack_context_t *context,
 
   /* read the phys-to-log index file until we covered the whole rev file.
    * That index contains enough info to build both target indexes from it. */
-  while (offset < revfile_size)
+  while (offset < revdata_size)
     {
       /* read one cluster */
       int i;
@@ -1492,7 +1510,7 @@ append_revision(pack_context_t *context,
 
           /* process entry while inside the rev file */
           offset = entry->offset;
-          if (offset < revfile_size)
+          if (offset < revdata_size)
             {
               entry->offset += context->pack_offset;
               offset += entry->size;
@@ -1506,7 +1524,7 @@ append_revision(pack_context_t *context,
     }
 
   svn_pool_destroy(iterpool);
-  context->pack_offset += revfile_size;
+  context->pack_offset += revdata_size;
 
   SVN_ERR(svn_fs_fs__close_revision_file(rev_file));
 
@@ -1573,6 +1591,7 @@ pack_log_addressed(svn_fs_t *fs,
     if (   APR_ARRAY_IDX(max_ids, i, apr_uint64_t)
         <= (apr_uint64_t)max_items - item_count)
       {
+        item_count += APR_ARRAY_IDX(max_ids, i, apr_uint64_t);
         context.end_rev++;
       }
     else
@@ -1731,6 +1750,7 @@ pack_phys_addressed(const char *pack_fil
       svn_stream_t *rev_stream;
       const char *path;
       apr_off_t offset;
+      apr_file_t *rev_file;
 
       svn_pool_clear(iterpool);
 
@@ -1744,10 +1764,15 @@ pack_phys_addressed(const char *pack_fil
       SVN_ERR(svn_stream_printf(manifest_stream, iterpool,
                                 "%" APR_OFF_T_FMT "\n", offset));
 
-      /* Copy all the bits from the rev file to the end of the pack file. */
-      SVN_ERR(svn_stream_open_readonly(&rev_stream, path, iterpool, iterpool));
+      /* Copy all the bits from the rev file to the end of the pack file.
+       * Use unbuffered apr_file_t since we're going to write using 16kb
+       * chunks. */
+      SVN_ERR(svn_io_file_open(&rev_file, path, APR_READ, APR_OS_DEFAULT,
+                               iterpool));
+      rev_stream = svn_stream_from_aprfile2(rev_file, FALSE, iterpool);
       SVN_ERR(svn_stream_copy3(rev_stream,
-                               svn_stream_from_aprfile2(pack_file, TRUE, pool),
+                               svn_stream_from_aprfile2(pack_file, TRUE,
+                                                        iterpool),
                                cancel_func, cancel_baton, iterpool));
     }
 
@@ -1836,6 +1861,7 @@ struct pack_baton
   void *notify_baton;
   svn_cancel_func_t cancel_func;
   void *cancel_baton;
+  size_t max_mem;
 
   /* Additional entries valid when entering pack_shard(). */
   const char *revs_dir;
@@ -1960,7 +1986,7 @@ pack_shard(struct pack_baton *baton,
   /* pack the revision content */
   SVN_ERR(pack_rev_shard(baton->fs, rev_pack_file_dir, baton->rev_shard_path,
                          baton->shard, ffd->max_files_per_dir,
-                         DEFAULT_MAX_MEM, ffd->flush_to_disk,
+                         baton->max_mem, ffd->flush_to_disk,
                          baton->cancel_func, baton->cancel_baton, pool));
 
   /* For newer repo formats, we only acquired the pack lock so far.
@@ -2070,6 +2096,7 @@ pack_body(void *baton,
 
 svn_error_t *
 svn_fs_fs__pack(svn_fs_t *fs,
+                apr_size_t max_mem,
                 svn_fs_pack_notify_t notify_func,
                 void *notify_baton,
                 svn_cancel_func_t cancel_func,
@@ -2115,6 +2142,7 @@ svn_fs_fs__pack(svn_fs_t *fs,
   pb.notify_baton = notify_baton;
   pb.cancel_func = cancel_func;
   pb.cancel_baton = cancel_baton;
+  pb.max_mem = max_mem ? max_mem : DEFAULT_MAX_MEM;
 
   if (ffd->format >= SVN_FS_FS__MIN_PACK_LOCK_FORMAT)
     {

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.h?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.h (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/pack.h Thu Oct 13 
15:25:15 2016
@@ -26,13 +26,19 @@
 #include "fs.h"
 
 /* Possibly pack the repository at PATH.  This just take full shards, and
-   combines all the revision files into a single one, with a manifest header.
+   combines all the revision files into a single one, with a manifest header
+   when required by the repository format.
+
+   MAX_MEM limits the size of in-memory data structures needed for reordering
+   items in format 7 repositories.  0 means use the built-in default.
+
    If given, NOTIFY_FUNC will be called with NOTIFY_BATON to report progress.
    Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
 
    Existing filesystem references need not change.  */
 svn_error_t *
 svn_fs_fs__pack(svn_fs_t *fs,
+                apr_size_t max_mem,
                 svn_fs_pack_notify_t notify_func,
                 void *notify_baton,
                 svn_cancel_func_t cancel_func,

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/revprops.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/revprops.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/revprops.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/revprops.c Thu Oct 13 
15:25:15 2016
@@ -836,7 +836,7 @@ serialize_revprops_header(svn_stream_t *
     }
 
   /* the double newline char indicates the end of the header */
-  SVN_ERR(svn_stream_printf(stream, iterpool, "\n"));
+  SVN_ERR(svn_stream_puts(stream, "\n"));
 
   svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
@@ -933,7 +933,7 @@ repack_file_open(apr_file_t **file,
 {
   apr_int64_t tag;
   const char *tag_string;
-  svn_string_t *new_filename;
+  const char *new_filename;
   int i;
   int manifest_offset
     = (int)(revprops->start_revision - revprops->manifest_start);
@@ -957,18 +957,18 @@ repack_file_open(apr_file_t **file,
                              old_filename);
 
   SVN_ERR(svn_cstring_atoi64(&tag, tag_string + 1));
-  new_filename = svn_string_createf(pool, "%ld.%" APR_INT64_T_FMT,
-                                    revprops->start_revision + start,
-                                    ++tag);
+  new_filename = apr_psprintf(pool, "%ld.%" APR_INT64_T_FMT,
+                              revprops->start_revision + start,
+                              ++tag);
 
   /* update the manifest to point to the new file */
   for (i = start; i < end; ++i)
     APR_ARRAY_IDX(revprops->manifest, i + manifest_offset, const char*)
-      = new_filename->data;
+      = new_filename;
 
   /* open the file */
   SVN_ERR(svn_io_file_open(file, svn_dirent_join(revprops->folder,
-                                                 new_filename->data,
+                                                 new_filename,
                                                  pool),
                            APR_WRITE | APR_CREATE, APR_OS_DEFAULT, pool));
 
@@ -1286,6 +1286,7 @@ svn_fs_fs__copy_revprops(const char *pac
     {
       const char *path;
       svn_stream_t *stream;
+      apr_file_t *file;
 
       svn_pool_clear(iterpool);
 
@@ -1294,8 +1295,11 @@ svn_fs_fs__copy_revprops(const char *pac
                              iterpool);
 
       /* Copy all the bits from the non-packed revprop file to the end of
-       * the pack file. */
-      SVN_ERR(svn_stream_open_readonly(&stream, path, iterpool, iterpool));
+       * the pack file.  Use unbuffered apr_file_t since we're going to
+       * write using 16kb chunks. */
+      SVN_ERR(svn_io_file_open(&file, path, APR_READ, APR_OS_DEFAULT,
+                               iterpool));
+      stream = svn_stream_from_aprfile2(file, FALSE, iterpool);
       SVN_ERR(svn_stream_copy3(stream, pack_stream,
                                cancel_func, cancel_baton, iterpool));
     }

Modified: 
subversion/branches/authzperf/subversion/libsvn_fs_fs/temp_serializer.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/temp_serializer.h?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/temp_serializer.h 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/temp_serializer.h Thu 
Oct 13 15:25:15 2016
@@ -51,7 +51,7 @@ svn_fs_fs__noderev_deserialize(void *buf
 
 
 /**
- * Adds position information to the the raw window data in WINDOW.
+ * Adds position information to the raw window data in WINDOW.
  */
 typedef struct
 {

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/transaction.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/transaction.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/transaction.c 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/transaction.c Thu Oct 
13 15:25:15 2016
@@ -442,7 +442,7 @@ get_writable_proto_rev(apr_file_t **file
   /* Now open the prototype revision file and seek to the end. */
   err = svn_io_file_open(file,
                          svn_fs_fs__path_txn_proto_rev(fs, txn_id, pool),
-                         APR_READ | APR_WRITE | APR_BUFFERED, APR_OS_DEFAULT,
+                         APR_WRITE | APR_BUFFERED, APR_OS_DEFAULT,
                          pool);
 
   /* You might expect that we could dispense with the following seek
@@ -1731,9 +1731,11 @@ svn_fs_fs__add_change(svn_fs_t *fs,
   return svn_io_file_close(file, pool);
 }
 
-/* If the transaction TXN_ID in FS uses logical addressing, store the
- * (ITEM_INDEX, OFFSET) pair in the txn's log-to-phys proto index file.
+/* Store the (ITEM_INDEX, OFFSET) pair in the txn's log-to-phys proto
+ * index file.
  * Use POOL for allocations.
+ * This function assumes that transaction TXN_ID in FS uses logical
+ * addressing.
  */
 static svn_error_t *
 store_l2p_index_entry(svn_fs_t *fs,
@@ -1742,37 +1744,40 @@ store_l2p_index_entry(svn_fs_t *fs,
                       apr_uint64_t item_index,
                       apr_pool_t *pool)
 {
-  if (svn_fs_fs__use_log_addressing(fs))
-    {
-      const char *path = svn_fs_fs__path_l2p_proto_index(fs, txn_id, pool);
-      apr_file_t *file;
-      SVN_ERR(svn_fs_fs__l2p_proto_index_open(&file, path, pool));
-      SVN_ERR(svn_fs_fs__l2p_proto_index_add_entry(file, offset,
-                                                   item_index, pool));
-      SVN_ERR(svn_io_file_close(file, pool));
-    }
+  const char *path;
+  apr_file_t *file;
+
+  SVN_ERR_ASSERT(svn_fs_fs__use_log_addressing(fs));
+
+  path = svn_fs_fs__path_l2p_proto_index(fs, txn_id, pool);
+  SVN_ERR(svn_fs_fs__l2p_proto_index_open(&file, path, pool));
+  SVN_ERR(svn_fs_fs__l2p_proto_index_add_entry(file, offset,
+                                               item_index, pool));
+  SVN_ERR(svn_io_file_close(file, pool));
 
   return SVN_NO_ERROR;
 }
 
-/* If the transaction TXN_ID in FS uses logical addressing, store ENTRY
- * in the phys-to-log proto index file of transaction TXN_ID.
+/* Store ENTRY in the phys-to-log proto index file of transaction TXN_ID.
  * Use POOL for allocations.
+ * This function assumes that transaction TXN_ID in FS uses logical
+ * addressing.
  */
 static svn_error_t *
 store_p2l_index_entry(svn_fs_t *fs,
                       const svn_fs_fs__id_part_t *txn_id,
-                      svn_fs_fs__p2l_entry_t *entry,
+                      const svn_fs_fs__p2l_entry_t *entry,
                       apr_pool_t *pool)
 {
-  if (svn_fs_fs__use_log_addressing(fs))
-    {
-      const char *path = svn_fs_fs__path_p2l_proto_index(fs, txn_id, pool);
-      apr_file_t *file;
-      SVN_ERR(svn_fs_fs__p2l_proto_index_open(&file, path, pool));
-      SVN_ERR(svn_fs_fs__p2l_proto_index_add_entry(file, entry, pool));
-      SVN_ERR(svn_io_file_close(file, pool));
-    }
+  const char *path;
+  apr_file_t *file;
+
+  SVN_ERR_ASSERT(svn_fs_fs__use_log_addressing(fs));
+
+  path = svn_fs_fs__path_p2l_proto_index(fs, txn_id, pool);
+  SVN_ERR(svn_fs_fs__p2l_proto_index_open(&file, path, pool));
+  SVN_ERR(svn_fs_fs__p2l_proto_index_add_entry(file, entry, pool));
+  SVN_ERR(svn_io_file_close(file, pool));
 
   return SVN_NO_ERROR;
 }
@@ -2191,10 +2196,10 @@ rep_write_get_baton(struct rep_write_bat
                                  b->scratch_pool));
 
   b->file = file;
-  b->rep_stream = fnv1a_wrap_stream(&b->fnv1a_checksum_ctx,
-                                    svn_stream_from_aprfile2(file, TRUE,
-                                                             b->scratch_pool),
-                                    b->scratch_pool);
+  b->rep_stream = svn_stream_from_aprfile2(file, TRUE, b->scratch_pool);
+  if (svn_fs_fs__use_log_addressing(fs))
+    b->rep_stream = fnv1a_wrap_stream(&b->fnv1a_checksum_ctx, b->rep_stream,
+                                      b->scratch_pool);
 
   SVN_ERR(svn_io_file_get_offset(&b->rep_offset, file, b->scratch_pool));
 
@@ -2471,7 +2476,7 @@ rep_write_contents_close(void *baton)
   /* Write out the new node-rev information. */
   SVN_ERR(svn_fs_fs__put_node_revision(b->fs, b->noderev->id, b->noderev,
                                        FALSE, b->scratch_pool));
-  if (!old_rep)
+  if (!old_rep && svn_fs_fs__use_log_addressing(b->fs))
     {
       svn_fs_fs__p2l_entry_t entry;
 
@@ -2485,12 +2490,17 @@ rep_write_contents_close(void *baton)
                                       b->fnv1a_checksum_ctx,
                                       b->scratch_pool));
 
-      SVN_ERR(store_sha1_rep_mapping(b->fs, b->noderev, b->scratch_pool));
       SVN_ERR(store_p2l_index_entry(b->fs, &rep->txn_id, &entry,
                                     b->scratch_pool));
     }
 
   SVN_ERR(svn_io_file_close(b->file, b->scratch_pool));
+
+  /* Write the sha1->rep mapping *after* we successfully written node
+   * revision to disk. */
+  if (!old_rep)
+    SVN_ERR(store_sha1_rep_mapping(b->fs, b->noderev, b->scratch_pool));
+
   SVN_ERR(unlock_proto_rev(b->fs, &rep->txn_id, b->lockcookie,
                            b->scratch_pool));
   svn_pool_destroy(b->scratch_pool);
@@ -2693,10 +2703,12 @@ write_container_rep(representation_t *re
 
   whb = apr_pcalloc(scratch_pool, sizeof(*whb));
 
-  whb->stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx,
-                                  svn_stream_from_aprfile2(file, TRUE,
-                                                           scratch_pool),
-                                  scratch_pool);
+  whb->stream = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
+  if (svn_fs_fs__use_log_addressing(fs))
+    whb->stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx, whb->stream,
+                                    scratch_pool);
+  else
+    fnv1a_checksum_ctx = NULL;
   whb->size = 0;
   whb->md5_ctx = svn_checksum_ctx_create(svn_checksum_md5, scratch_pool);
   if (item_type != SVN_FS_FS__ITEM_TYPE_DIR_REP)
@@ -2725,16 +2737,18 @@ write_container_rep(representation_t *re
 
       /* Use the old rep for this content. */
       memcpy(rep, old_rep, sizeof (*rep));
+      return SVN_NO_ERROR;
     }
-  else
-    {
-      svn_fs_fs__p2l_entry_t entry;
 
-      /* Write out our cosmetic end marker. */
-      SVN_ERR(svn_stream_puts(whb->stream, "ENDREP\n"));
+  /* Write out our cosmetic end marker. */
+  SVN_ERR(svn_stream_puts(whb->stream, "ENDREP\n"));
 
-      SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
-                                  offset, scratch_pool));
+  SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
+                              offset, scratch_pool));
+
+  if (svn_fs_fs__use_log_addressing(fs))
+    {
+      svn_fs_fs__p2l_entry_t entry;
 
       entry.offset = offset;
       SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
@@ -2747,11 +2761,11 @@ write_container_rep(representation_t *re
                                       scratch_pool));
 
       SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
-
-      /* update the representation */
-      rep->size = whb->size;
     }
 
+  /* update the representation */
+  rep->size = whb->size;
+
   return SVN_NO_ERROR;
 }
 
@@ -2819,10 +2833,12 @@ write_container_delta_rep(representation
       header.type = svn_fs_fs__rep_self_delta;
     }
 
-  file_stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx,
-                                  svn_stream_from_aprfile2(file, TRUE,
-                                                           scratch_pool),
-                                  scratch_pool);
+  file_stream = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
+  if (svn_fs_fs__use_log_addressing(fs))
+    file_stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx, file_stream,
+                                    scratch_pool);
+  else
+    fnv1a_checksum_ctx = NULL;
   SVN_ERR(svn_fs_fs__write_rep_header(&header, file_stream, scratch_pool));
   SVN_ERR(svn_io_file_get_offset(&delta_start, file, scratch_pool));
 
@@ -2865,17 +2881,19 @@ write_container_delta_rep(representation
 
       /* Use the old rep for this content. */
       memcpy(rep, old_rep, sizeof (*rep));
+      return SVN_NO_ERROR;
     }
-  else
-    {
-      svn_fs_fs__p2l_entry_t entry;
 
-      /* Write out our cosmetic end marker. */
-      SVN_ERR(svn_io_file_get_offset(&rep_end, file, scratch_pool));
-      SVN_ERR(svn_stream_puts(file_stream, "ENDREP\n"));
+  /* Write out our cosmetic end marker. */
+  SVN_ERR(svn_io_file_get_offset(&rep_end, file, scratch_pool));
+  SVN_ERR(svn_stream_puts(file_stream, "ENDREP\n"));
 
-      SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
-                                  offset, scratch_pool));
+  SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
+                              offset, scratch_pool));
+
+  if (svn_fs_fs__use_log_addressing(fs))
+    {
+      svn_fs_fs__p2l_entry_t entry;
 
       entry.offset = offset;
       SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
@@ -2888,11 +2906,11 @@ write_container_delta_rep(representation
                                       scratch_pool));
 
       SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));
-
-      /* update the representation */
-      rep->size = rep_end - delta_start;
     }
 
+  /* update the representation */
+  rep->size = rep_end - delta_start;
+
   return SVN_NO_ERROR;
 }
 
@@ -3223,9 +3241,12 @@ write_final_rev(const svn_fs_id_t **new_
   if (at_root)
     SVN_ERR(validate_root_noderev(fs, noderev, rev, pool));
 
-  file_stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx,
-                                  svn_stream_from_aprfile2(file, TRUE, pool),
-                                  pool);
+  file_stream = svn_stream_from_aprfile2(file, TRUE, pool);
+  if (svn_fs_fs__use_log_addressing(fs))
+    file_stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx, file_stream, pool);
+  else
+    fnv1a_checksum_ctx = NULL;
+
   SVN_ERR(svn_fs_fs__write_noderev(file_stream, noderev, ffd->format,
                                    svn_fs_fs__fs_supports_mergeinfo(fs),
                                    pool));
@@ -3272,10 +3293,13 @@ write_final_changed_path_info(apr_off_t
 
   SVN_ERR(svn_io_file_get_offset(&offset, file, pool));
 
-  /* write to target file & calculate checksum */
-  stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx,
-                             svn_stream_from_aprfile2(file, TRUE, pool),
-                             pool);
+  /* write to target file & calculate checksum if needed */
+  stream = svn_stream_from_aprfile2(file, TRUE, pool);
+  if (svn_fs_fs__use_log_addressing(fs))
+    stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx, stream, pool);
+  else
+    fnv1a_checksum_ctx = NULL;
+
   SVN_ERR(svn_fs_fs__write_changes(stream, fs, changed_paths, TRUE, pool));
 
   *offset_p = offset;

Modified: subversion/branches/authzperf/subversion/libsvn_fs_fs/tree.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_fs/tree.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_fs/tree.c Thu Oct 13 
15:25:15 2016
@@ -2314,7 +2314,7 @@ svn_fs_fs__commit_txn(const char **confl
 
   if (ffd->pack_after_commit)
     {
-      SVN_ERR(svn_fs_fs__pack(fs, NULL, NULL, NULL, NULL, pool));
+      SVN_ERR(svn_fs_fs__pack(fs, 0, NULL, NULL, NULL, NULL, pool));
     }
 
   return SVN_NO_ERROR;

Propchange: subversion/branches/authzperf/subversion/libsvn_fs_x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 13 15:25:15 2016
@@ -95,4 +95,4 @@
 
/subversion/branches/verify-keep-going/subversion/libsvn_fs_x:1439280-1492639,1546002-1546110
 /subversion/branches/wc-collate-path/subversion/libsvn_fs_x:1402685-1480384
 
/subversion/trunk/subversion/libsvn_fs_fs:1415133-1596500,1596567,1597414,1597989,1598273,1599140,1600872,1601633,1603485-1603487,1603499,1603605,1604128,1604188,1604413-1604414,1604416-1604417,1604421,1604442,1604700,1604717,1604720,1604726,1604755,1604794,1604802,1604824,1604836,1604844,1604902-1604903,1604911,1604925,1604933,1604947,1605059-1605060,1605064-1605065,1605068,1605071-1605073,1605075,1605123,1605188-1605189,1605191,1605197,1605444,1605633,1606132,1606142,1606144,1606514,1606526,1606528,1606551,1606554,1606564,1606598-1606599,1606656,1606658,1606662,1606744,1606840,1607085,1607572,1612407,1612810,1613339,1613872,1614611,1615348,1615351-1615352,1615356,1616338-1616339,1616613,1617586,1617688,1618138,1618151,1618153,1618226,1618641,1618653,1618662,1619068,1619358,1619413,1619769,1619774,1620602,1620909,1620912,1620928,1620930,1621275,1621635,1622931,1622937,1622942,1622946,1622959-1622960,1622963,1622987,1623007,1623368,1623373,1623377,1623379,1623381,1623398,1623402,162
 
4011,1624265,1624512,1626246,1626871,1626873,1626886,1627497-1627498,1627502,1627947-1627949,1627966,1628083,1628093,1628158-1628159,1628161,1628392-1628393,1628415,1628427,1628676,1628738,1628762,1628764,1629854-1629855,1629857,1629865,1629873,1629875,1629879,1630067,1630070,1631049-1631051,1631075,1631115,1631171,1631180,1631185-1631186,1631196-1631197,1631239-1631240,1631548,1631550,1631563,1631567,1631588,1631598,1632646,1632776,1632849,1632851-1632853,1632856-1632857,1632868,1632908,1632926,1633232,1633617-1633618,1634872,1634875,1634879-1634880,1634920,1636478,1636483,1636629,1636644,1637184,1637186,1637330,1637358,1637363,1637393,1639319,1639322,1639335,1639348,1639352,1639355,1639358,1639414,1639419,1639426,1639430,1639436,1639440,1639549,1640061-1640062,1640197,1640915,1640966,1641013,1643139,1643233,1645567,1646021,1646712,1646716,1647537,1647540-1647541,1647820,1647905,1648230,1648238,1648241-1648243,1648253,1648272,1648532,1648537-1648539,1648542,1648591,1648612,1649590,
 
1651567,1652068,1652076,1652441,1652451,1653608,1654932,1654934,1654937,1655635,1655649,1655651,1655664,1656176,1657525,1657972,1657978,1658482,1659212,1659217,1659314,1659509,1662668,1665318,1665854,1665894,1667090,1667101,1667538,1669743,1669746,1669749,1669945,1670139,1670953,1673170,1673197,1673202,1673204,1673445,1673454,1673685,1673689,1673875,1674165,1674341,1674400,1674404,1674631,1674669,1674673,1675396,1676667,1677431,1678149,1678151,1678718,1678725,1679169,1679907,1679920-1679924,1679926,1680347,1680460,1680464,1680476,1680819,1681949,1681966,1681974,1681994,1682008,1682076,1682086,1682093,1682259,1682265,1682739,1682864,1683311,1683330,1683378,1683544,1683553,1684047,1686232,1686542,1686546,1686554,1686557,1687061,1687064,1687070-1687071,1687074,1687078-1687079,1688270,1688425,1692650,1693886,1694489,1694848,1696171,1696185,1696627-1696628,1696630,1696758,1697372,1697381,1697387,1697393,1697403,1697405,1701017,1701053,1702600,1702922,1703069,1703142,1703237,1703240,17052
 
66,1705638,1705643,1705646,1705724,1705730,1705739,1706612,1706615,1706617,1706619,1706675-1706676,1706679,1706979-1706980,1707308,1707971-1707973,1707986,1707988-1707989,1708004,1709388,1709799,1710017,1710359,1710368,1710370,1711507,1711582,1711672,1712927,1715793,1715947,1716047,1716067,1716784,1716973-1716974,1717332,1717334,1717864,1719269,1719336,1719413,1719730,1720015,1721285,1723715,1723720,1723834,1723839,1725179-1725180,1726004,1726099,1726116,1726897,1726995,1727006-1727007,1727028,1727040,1727707,1727822,1730491,1735916,1736357,1736359,1737355-1737356,1740721-1740722,1741096,1741200,1741206,1741214,1741224,1742540,1745055,1745107,1745852,1746006,1746012,1746026
-/subversion/trunk/subversion/libsvn_fs_x:1414756-1509914,1613053-1746926
+/subversion/trunk/subversion/libsvn_fs_x:1414756-1509914,1613053-1764704

Modified: subversion/branches/authzperf/subversion/libsvn_fs_x/batch_fsync.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_x/batch_fsync.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_x/batch_fsync.c 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_x/batch_fsync.c Thu Oct 
13 15:25:15 2016
@@ -332,8 +332,9 @@ internal_open_file(apr_file_t **file,
   svn_error_t *err;
   apr_pool_t *pool;
   to_sync_t *to_sync;
-  svn_node_kind_t kind;
+#ifdef SVN_ON_POSIX
   svn_boolean_t is_new_file;
+#endif
 
   /* If we already have a handle for PATH, return that. */
   to_sync = svn_hash_gets(batch->files, path);
@@ -356,6 +357,7 @@ internal_open_file(apr_file_t **file,
   is_new_file = FALSE;
   if (flags & APR_CREATE)
     {
+      svn_node_kind_t kind;
       /* We might actually be about to create a new file.
        * Check whether the file already exists. */
       SVN_ERR(svn_io_check_path(path, &kind, scratch_pool));

Modified: subversion/branches/authzperf/subversion/libsvn_fs_x/pack.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_x/pack.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_fs_x/pack.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_fs_x/pack.c Thu Oct 13 
15:25:15 2016
@@ -640,7 +640,7 @@ svn_fs_x__order_dir_entries(svn_fs_t *fs
   return result;
 }
 
-/* Return a duplicate of the the ORIGINAL path and with special sub-strins
+/* Return a duplicate of the ORIGINAL path and with special sub-strings
  * (e.g. "trunk") modified in such a way that have a lower lexicographic
  * value than any other "normal" file name.
  */

Modified: subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/config_pool.c Thu Oct 
13 15:25:15 2016
@@ -199,10 +199,8 @@ auto_parse(svn_config_t **cfg,
   apr_pool_t *cfg_pool;
 
   /* calculate SHA1 over the whole file contents */
-  SVN_ERR(svn_stream_close
-              (svn_stream_checksummed2
-                  (svn_stream_from_stringbuf(contents, scratch_pool),
-                   &checksum, NULL, svn_checksum_sha1, TRUE, scratch_pool)));
+  SVN_ERR(svn_checksum(&checksum, svn_checksum_sha1,
+                       contents->data, contents->len, scratch_pool));
 
   /* return reference to suitable config object if that already exists */
   *key = checksum_as_key(checksum, result_pool);

Modified: subversion/branches/authzperf/subversion/libsvn_repos/reporter.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/reporter.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/reporter.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/reporter.c Thu Oct 13 
15:25:15 2016
@@ -918,7 +918,7 @@ update_entry(report_baton_t *b, svn_revn
              const char *e_path, path_info_t *info, svn_depth_t wc_depth,
              svn_depth_t requested_depth, apr_pool_t *pool)
 {
-  svn_fs_root_t *s_root;
+  svn_fs_root_t *s_root = NULL;
   svn_boolean_t allowed, related;
   void *new_baton;
   svn_checksum_t *checksum;
@@ -961,7 +961,26 @@ update_entry(report_baton_t *b, svn_revn
   if (s_entry && t_entry && s_entry->kind == t_entry->kind)
     {
       int distance = svn_fs_compare_ids(s_entry->id, t_entry->id);
-      if (distance == 0 && !any_path_info(b, e_path)
+      svn_boolean_t changed = TRUE;
+
+      /* Check related files for content changes to avoid reporting
+       * unchanged copies of files to the client as an open_file() call
+       * and change_file_prop()/apply_textdelta() calls with no-op changes.
+       * The client will otherwise raise unnecessary tree conflicts. */
+      if (!b->ignore_ancestry && t_entry->kind == svn_node_file &&
+          distance == 1)
+        {
+          if (s_root == NULL)
+            SVN_ERR(get_source_root(b, &s_root, s_rev));
+
+          SVN_ERR(svn_fs_props_different(&changed, s_root, s_path,
+                                         b->t_root, t_path, pool));
+          if (!changed)
+            SVN_ERR(svn_fs_contents_different(&changed, s_root, s_path,
+                                              b->t_root, t_path, pool));
+        }
+
+      if ((distance == 0 || !changed) && !any_path_info(b, e_path)
           && (requested_depth <= wc_depth || t_entry->kind == svn_node_file))
         {
           if (!info)

Modified: subversion/branches/authzperf/subversion/libsvn_repos/repos.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/repos.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/repos.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/repos.c Thu Oct 13 
15:25:15 2016
@@ -712,7 +712,7 @@ create_hooks(svn_repos_t *repos, apr_poo
 "# Because the locks have already been created and cannot be undone,"        NL
 "# the exit code of the hook program is ignored.  The hook program"          NL
 "# can use the 'svnlook' utility to examine the paths in the repository"     NL
-"# but since the hook is invoked asyncronously the newly-created locks"      NL
+"# but since the hook is invoked asynchronously the newly-created locks"     NL
 "# may no longer be present."                                                
NL;
   script =
 "REPOS=\"$1\""                                                               NL

Modified: subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/cmdline.c Thu Oct 13 
15:25:15 2016
@@ -822,7 +822,7 @@ most_similar(const char *needle_cstr,
              apr_size_t haystack_len,
              apr_pool_t *scratch_pool)
 {
-  const char *max_similar;
+  const char *max_similar = NULL;
   apr_size_t max_score = 0;
   apr_size_t i;
   svn_membuf_t membuf;
@@ -847,10 +847,7 @@ most_similar(const char *needle_cstr,
         }
     }
 
-  if (max_score)
-    return max_similar;
-  else
-    return NULL;
+  return max_similar;
 }
 
 /* Verify that NEEDLE is in HAYSTACK, which contains HAYSTACK_LEN elements. */
@@ -1210,11 +1207,7 @@ svn_cmdline__be_interactive(svn_boolean_
    * If --force-interactive was passed, always be interactive. */
   if (!force_interactive && !non_interactive)
     {
-#ifdef WIN32
-      return (_isatty(STDIN_FILENO) != 0);
-#else
-      return (isatty(STDIN_FILENO) != 0);
-#endif
+      return svn_cmdline__stdin_is_a_terminal();
     }
   else if (force_interactive)
     return TRUE;

Modified: subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/deprecated.c Thu Oct 
13 15:25:15 2016
@@ -1521,7 +1521,11 @@ void
 svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t **provider,
                                       apr_pool_t *pool)
 {
+#ifdef SVN_HAVE_KEYCHAIN_SERVICES
   svn_auth__get_keychain_simple_provider(provider, pool);
+#else
+  svn_auth__get_dummmy_simple_provider(provider, pool);
+#endif
 }
 
 void
@@ -1529,7 +1533,13 @@ svn_auth_get_keychain_ssl_client_cert_pw
   (svn_auth_provider_object_t **provider,
    apr_pool_t *pool)
 {
+#ifdef SVN_HAVE_KEYCHAIN_SERVICES
   svn_auth__get_keychain_ssl_client_cert_pw_provider(provider, pool);
+#else
+  /* Not really the right type of dummy provider, but doesn't throw NULL
+     errors as just returning NULL would */
+  svn_auth__get_dummmy_simple_provider(provider, pool);
+#endif
 }
 #endif /* DARWIN */
 

Modified: subversion/branches/authzperf/subversion/libsvn_subr/io.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/io.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/io.c Thu Oct 13 
15:25:15 2016
@@ -1478,18 +1478,14 @@ svn_io_file_checksum2(svn_checksum_t **c
                       apr_pool_t *pool)
 {
   svn_stream_t *file_stream;
-  svn_stream_t *checksum_stream;
   apr_file_t* f;
 
   SVN_ERR(svn_io_file_open(&f, file, APR_READ, APR_OS_DEFAULT, pool));
   file_stream = svn_stream_from_aprfile2(f, FALSE, pool);
-  checksum_stream = svn_stream_checksummed2(file_stream, checksum, NULL, kind,
-                                            TRUE, pool);
+  SVN_ERR(svn_stream_contents_checksum(checksum, file_stream, kind,
+                                       pool, pool));
 
-  /* Because the checksummed stream will force the reading (and
-     checksumming) of all the file's bytes, we can just close the stream
-     and let its magic work. */
-  return svn_stream_close(checksum_stream);
+  return SVN_NO_ERROR;
 }
 
 
@@ -1778,7 +1774,7 @@ svn_io__utf8_to_unicode_longpath(const W
      * than the original number of utf-8 narrow chars.
      */
     const WCHAR *prefix = NULL;
-    const int srclen = strlen(source);
+    const size_t srclen = strlen(source);
     WCHAR *buffer;
 
     if (srclen > 248)
@@ -1894,7 +1890,7 @@ io_win_file_attrs_set(const char *fname,
 
 static svn_error_t *win_init_dynamic_imports(void *baton, apr_pool_t *pool)
 {
-  HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
+  HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
 
   if (kernel32)
     {
@@ -2655,9 +2651,6 @@ svn_io_remove_file2(const char *path,
          allow us to delete when path is read-only */
       SVN_ERR(svn_io_set_file_read_write(path, ignore_enoent, scratch_pool));
       apr_err = apr_file_remove(path_apr, scratch_pool);
-
-      if (!apr_err)
-        return SVN_NO_ERROR;
     }
 
   /* Check to make sure we aren't trying to delete a directory */
@@ -4071,6 +4064,26 @@ svn_io_write_atomic2(const char *final_p
 svn_error_t *
 svn_io_file_trunc(apr_file_t *file, apr_off_t offset, apr_pool_t *pool)
 {
+  /* Workaround for yet another APR issue with trunc.
+
+     If the APR file internally is in read mode, the current buffer pointer
+     will not be clipped to the valid data range. get_file_offset may then
+     return an invalid position *after* new data was written to it.
+
+     To prevent this, write 1 dummy byte just after the OFFSET at which we
+     will trunc it.  That will force the APR file into write mode
+     internally and the flush() work-around below becomes affective. */
+  apr_off_t position = 0;
+
+  /* A frequent usage is OFFSET==0, in which case we don't need to preserve
+     any file content or file pointer. */
+  if (offset)
+    {
+      SVN_ERR(svn_io_file_seek(file, APR_CUR, &position, pool));
+      SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, pool));
+    }
+  SVN_ERR(svn_io_file_putc(0, file, pool));
+
   /* This is a work-around. APR would flush the write buffer
      _after_ truncating the file causing now invalid buffered
      data to be written behind OFFSET. */
@@ -4079,10 +4092,17 @@ svn_io_file_trunc(apr_file_t *file, apr_
                                      N_("Can't flush stream"),
                                      pool));
 
-  return do_io_file_wrapper_cleanup(file, apr_file_trunc(file, offset),
-                                    N_("Can't truncate file '%s'"),
-                                    N_("Can't truncate stream"),
-                                    pool);
+  SVN_ERR(do_io_file_wrapper_cleanup(file, apr_file_trunc(file, offset),
+                                     N_("Can't truncate file '%s'"),
+                                     N_("Can't truncate stream"),
+                                     pool));
+
+  /* Restore original file pointer, if necessary.
+     It's currently at OFFSET. */
+  if (position < offset)
+    SVN_ERR(svn_io_file_seek(file, APR_SET, &position, pool));
+
+  return SVN_NO_ERROR;
 }
 
 

Modified: subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/prefix_string.c Thu 
Oct 13 15:25:15 2016
@@ -49,7 +49,7 @@ struct svn_prefix_string__t
   /* mandatory prefix */
   node_t *prefix;
 
-  /* 0 ..7 chars to add the the prefix.
+  /* 0 ..7 chars to add the prefix.
    *
    * NUL-terminated, if this is indeed a tree leaf.  We use the same struct
    * within node_t for inner tree nodes, too.  There, DATA[7] is not NUL,

Modified: subversion/branches/authzperf/subversion/libsvn_subr/stream.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/stream.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/stream.c Thu Oct 13 
15:25:15 2016
@@ -61,7 +61,7 @@ struct svn_stream_t {
   svn_stream_mark_fn_t mark_fn;
   svn_stream_seek_fn_t seek_fn;
   svn_stream_data_available_fn_t data_available_fn;
-  svn_stream__is_buffered_fn_t is_buffered_fn;
+  svn_stream_readline_fn_t readline_fn;
   apr_file_t *file; /* Maybe NULL */
 };
 
@@ -139,10 +139,10 @@ svn_stream_set_data_available(svn_stream
 }
 
 void
-svn_stream__set_is_buffered(svn_stream_t *stream,
-                            svn_stream__is_buffered_fn_t is_buffered_fn)
+svn_stream_set_readline(svn_stream_t *stream,
+                        svn_stream_readline_fn_t readline_fn)
 {
-  stream->is_buffered_fn = is_buffered_fn;
+  stream->readline_fn = readline_fn;
 }
 
 /* Standard implementation for svn_stream_read_full() based on
@@ -265,15 +265,6 @@ svn_stream_data_available(svn_stream_t *
                                                    data_available));
 }
 
-svn_boolean_t
-svn_stream__is_buffered(svn_stream_t *stream)
-{
-  if (stream->is_buffered_fn == NULL)
-    return FALSE;
-
-  return stream->is_buffered_fn(stream->baton);
-}
-
 svn_error_t *
 svn_stream_close(svn_stream_t *stream)
 {
@@ -328,11 +319,9 @@ svn_stream_printf_from_utf8(svn_stream_t
   return svn_error_trace(svn_stream_puts(stream, translated));
 }
 
-/* Guts of svn_stream_readline().
+/* Default implementation for svn_stream_readline().
  * Returns the line read from STREAM in *STRINGBUF, and indicates
- * end-of-file in *EOF.  If DETECT_EOL is TRUE, the end-of-line indicator
- * is detected automatically and returned in *EOL.
- * If DETECT_EOL is FALSE, *EOL must point to the desired end-of-line
+ * end-of-file in *EOF.  EOL must point to the desired end-of-line
  * indicator.  STRINGBUF is allocated in POOL. */
 static svn_error_t *
 stream_readline_bytewise(svn_stringbuf_t **stringbuf,
@@ -381,161 +370,27 @@ stream_readline_bytewise(svn_stringbuf_t
   return SVN_NO_ERROR;
 }
 
-static svn_error_t *
-stream_readline_chunky(svn_stringbuf_t **stringbuf,
-                       svn_boolean_t *eof,
-                       const char *eol,
-                       svn_stream_t *stream,
-                       apr_pool_t *pool)
+svn_error_t *
+svn_stream_readline(svn_stream_t *stream,
+                    svn_stringbuf_t **stringbuf,
+                    const char *eol,
+                    svn_boolean_t *eof,
+                    apr_pool_t *pool)
 {
-  /* Read larger chunks of data at once into this buffer and scan
-   * that for EOL. A good chunk size should be about 80 chars since
-   * most text lines will be shorter. However, don't use a much
-   * larger value because filling the buffer from the stream takes
-   * time as well.
-   */
-  char buffer[SVN__LINE_CHUNK_SIZE+1];
-
-  /* variables */
-  svn_stream_mark_t *mark;
-  apr_size_t numbytes;
-  const char *eol_pos;
-  apr_size_t total_parsed = 0;
-
-  /* invariant for this call */
-  const size_t eol_len = strlen(eol);
-
-  /* Remember the line start so this plus the line length will be
-   * the position to move to at the end of this function.
-   */
-  SVN_ERR(svn_stream_mark(stream, &mark, pool));
-
-  /* Read the first chunk. */
-  numbytes = SVN__LINE_CHUNK_SIZE;
-  SVN_ERR(svn_stream_read_full(stream, buffer, &numbytes));
-  buffer[numbytes] = '\0';
-
-  /* Look for the EOL in this first chunk. If we find it, we are done here.
-   */
-  eol_pos = strstr(buffer, eol);
-  if (eol_pos != NULL)
-    {
-      *stringbuf = svn_stringbuf_ncreate(buffer, eol_pos - buffer, pool);
-      total_parsed = eol_pos - buffer + eol_len;
-    }
-  else if (numbytes < SVN__LINE_CHUNK_SIZE)
-    {
-      /* We hit EOF but not EOL.
-       */
-      *stringbuf = svn_stringbuf_ncreate(buffer, numbytes, pool);
-      *eof = TRUE;
-      return SVN_NO_ERROR;
-     }
-  else
+  if (stream->readline_fn)
     {
-      /* A larger buffer for the string is needed. */
-      svn_stringbuf_t *str;
-      str = svn_stringbuf_create_ensure(2*SVN__LINE_CHUNK_SIZE, pool);
-      svn_stringbuf_appendbytes(str, buffer, numbytes);
-      *stringbuf = str;
-
-      /* Loop reading chunks until an EOL was found. If we hit EOF, fall
-       * back to the standard implementation. */
-      do
-      {
-        /* Append the next chunk to the string read so far.
-         */
-        svn_stringbuf_ensure(str, str->len + SVN__LINE_CHUNK_SIZE);
-        numbytes = SVN__LINE_CHUNK_SIZE;
-        SVN_ERR(svn_stream_read_full(stream, str->data + str->len, &numbytes));
-        str->len += numbytes;
-        str->data[str->len] = '\0';
-
-        /* Look for the EOL in the new data plus the last part of the
-         * previous chunk because the EOL may span over the boundary
-         * between both chunks.
-         */
-        eol_pos = strstr(str->data + str->len - numbytes - (eol_len-1), eol);
-
-        if ((numbytes < SVN__LINE_CHUNK_SIZE) && (eol_pos == NULL))
-        {
-          /* We hit EOF instead of EOL. */
-          *eof = TRUE;
-          return SVN_NO_ERROR;
-        }
-      }
-      while (eol_pos == NULL);
-
-      /* Number of bytes we actually consumed (i.e. line + EOF).
-       * We need to "return" the rest to the stream by moving its
-       * read pointer.
-       */
-      total_parsed = eol_pos - str->data + eol_len;
-
-      /* Terminate the string at the EOL postion and return it. */
-      str->len = eol_pos - str->data;
-      str->data[str->len] = 0;
-    }
-
-  /* Move the stream read pointer to the first position behind the EOL.
-   */
-  SVN_ERR(svn_stream_seek(stream, mark));
-  return svn_error_trace(svn_stream_skip(stream, total_parsed));
-}
-
-/* Guts of svn_stream_readline().
- * Returns the line read from STREAM in *STRINGBUF, and indicates
- * end-of-file in *EOF.  EOL must point to the desired end-of-line
- * indicator.  STRINGBUF is allocated in POOL. */
-static svn_error_t *
-stream_readline(svn_stringbuf_t **stringbuf,
-                svn_boolean_t *eof,
-                const char *eol,
-                svn_stream_t *stream,
-                apr_pool_t *pool)
-{
-  *eof = FALSE;
-
-  /* Often, we operate on APR file or string-based streams and know what
-   * EOL we are looking for. Optimize that common case.
-   */
-  if (svn_stream_supports_mark(stream) &&
-      svn_stream__is_buffered(stream))
-    {
-      /* We can efficiently read chunks speculatively and reposition the
-       * stream pointer to the end of the line once we found that.
-       */
-      SVN_ERR(stream_readline_chunky(stringbuf,
-                                     eof,
-                                     eol,
-                                     stream,
-                                     pool));
+      /* Use the specific implementation when it's available. */
+      SVN_ERR(stream->readline_fn(stream->baton, stringbuf, eol, eof, pool));
     }
   else
     {
-      /* Use the standard byte-byte implementation.
-       */
-      SVN_ERR(stream_readline_bytewise(stringbuf,
-                                       eof,
-                                       eol,
-                                       stream,
-                                       pool));
+      /* Use the default implementation. */
+      SVN_ERR(stream_readline_bytewise(stringbuf, eof, eol, stream, pool));
     }
 
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_stream_readline(svn_stream_t *stream,
-                    svn_stringbuf_t **stringbuf,
-                    const char *eol,
-                    svn_boolean_t *eof,
-                    apr_pool_t *pool)
-{
-  return svn_error_trace(stream_readline(stringbuf, eof, eol, stream,
-                                         pool));
-}
-
 svn_error_t *svn_stream_copy3(svn_stream_t *from, svn_stream_t *to,
                               svn_cancel_func_t cancel_func,
                               void *cancel_baton,
@@ -664,11 +519,6 @@ seek_handler_empty(void *baton, const sv
   return SVN_NO_ERROR;
 }
 
-static svn_boolean_t
-is_buffered_handler_empty(void *baton)
-{
-  return FALSE;
-}
 
 
 svn_stream_t *
@@ -681,7 +531,6 @@ svn_stream_empty(apr_pool_t *pool)
   svn_stream_set_write(stream, write_handler_empty);
   svn_stream_set_mark(stream, mark_handler_empty);
   svn_stream_set_seek(stream, seek_handler_empty);
-  svn_stream__set_is_buffered(stream, is_buffered_handler_empty);
   return stream;
 }
 
@@ -788,10 +637,15 @@ data_available_disown(void *baton, svn_b
   return svn_error_trace(svn_stream_data_available(baton, data_available));
 }
 
-static svn_boolean_t
-is_buffered_handler_disown(void *baton)
+static svn_error_t *
+readline_handler_disown(void *baton,
+                        svn_stringbuf_t **stringbuf,
+                        const char *eol,
+                        svn_boolean_t *eof,
+                        apr_pool_t *pool)
 {
-  return svn_stream__is_buffered(baton);
+  return svn_error_trace(svn_stream_readline(baton, stringbuf, eol,
+                                             eof, pool));
 }
 
 svn_stream_t *
@@ -805,7 +659,7 @@ svn_stream_disown(svn_stream_t *stream,
   svn_stream_set_mark(s, mark_handler_disown);
   svn_stream_set_seek(s, seek_handler_disown);
   svn_stream_set_data_available(s, data_available_disown);
-  svn_stream__set_is_buffered(s, is_buffered_handler_disown);
+  svn_stream_set_readline(s, readline_handler_disown);
 
   return s;
 }
@@ -997,11 +851,146 @@ data_available_handler_apr(void *baton,
 #endif
 }
 
-static svn_boolean_t
-is_buffered_handler_apr(void *baton)
+static svn_error_t *
+readline_apr_lf(apr_file_t *file,
+                svn_stringbuf_t **stringbuf,
+                svn_boolean_t *eof,
+                apr_pool_t *pool)
+{
+  svn_stringbuf_t *buf;
+
+  buf = svn_stringbuf_create_ensure(SVN__LINE_CHUNK_SIZE, pool);
+  while (1)
+  {
+    apr_status_t status;
+
+    status = apr_file_gets(buf->data + buf->len,
+                           (int) (buf->blocksize - buf->len),
+                           file);
+    buf->len += strlen(buf->data + buf->len);
+
+    if (APR_STATUS_IS_EOF(status))
+      {
+        /* apr_file_gets() keeps the newline; strip it if necessary. */
+        if (buf->len > 0 && buf->data[buf->len - 1] == '\n')
+          svn_stringbuf_chop(buf, 1);
+
+        *eof = TRUE;
+        *stringbuf = buf;
+        return SVN_NO_ERROR;
+      }
+    else if (status != APR_SUCCESS)
+      {
+        const char *fname;
+        svn_error_t *err = svn_io_file_name_get(&fname, file, pool);
+        if (err)
+          fname = NULL;
+        svn_error_clear(err);
+
+        if (fname)
+          return svn_error_wrap_apr(status,
+                                    _("Can't read a line from file '%s'"),
+                                    svn_dirent_local_style(fname, pool));
+        else
+          return svn_error_wrap_apr(status,
+                                    _("Can't read a line from stream"));
+      }
+
+    /* Do we have the EOL?  If yes, strip it and return. */
+    if (buf->len > 0 && buf->data[buf->len - 1] == '\n')
+      {
+        svn_stringbuf_chop(buf, 1);
+        *eof = FALSE;
+        *stringbuf = buf;
+        return SVN_NO_ERROR;
+      }
+
+    /* Otherwise, prepare to read the next chunk. */
+    svn_stringbuf_ensure(buf, buf->blocksize + SVN__LINE_CHUNK_SIZE);
+  }
+}
+
+static svn_error_t *
+readline_apr_generic(apr_file_t *file,
+                     svn_stringbuf_t **stringbuf,
+                     const char *eol,
+                     svn_boolean_t *eof,
+                     apr_pool_t *pool)
+{
+  apr_size_t eol_len = strlen(eol);
+  apr_off_t offset;
+  svn_stringbuf_t *buf;
+
+  SVN_ERR(svn_io_file_get_offset(&offset, file, pool));
+
+  buf = svn_stringbuf_create_ensure(SVN__LINE_CHUNK_SIZE, pool);
+  while (1)
+    {
+      apr_size_t bytes_read;
+      svn_boolean_t hit_eof;
+      const char *search_start;
+      const char *eol_pos;
+
+      /* We look for the EOL in the new data plus the last part of the
+         previous chunk because the EOL may span over the boundary
+         between both chunks. */
+      if (buf->len < eol_len)
+        search_start = buf->data;
+      else
+        search_start = buf->data + buf->len - eol_len;
+
+      SVN_ERR(svn_io_file_read_full2(file, buf->data + buf->len,
+                                     buf->blocksize - buf->len - 1,
+                                     &bytes_read, &hit_eof, pool));
+      buf->len += bytes_read;
+      buf->data[buf->len] = '\0';
+
+      /* Do we have the EOL now? */
+      eol_pos = strstr(search_start, eol);
+      if (eol_pos)
+        {
+          svn_stringbuf_chop(buf, buf->data + buf->len - eol_pos);
+          /* Seek to the first position behind the EOL. */
+          offset += (buf->len + eol_len);
+          SVN_ERR(svn_io_file_seek(file, APR_SET, &offset, pool));
+
+          *eof = FALSE;
+          *stringbuf = buf;
+          return SVN_NO_ERROR;
+        }
+      else if (eol_pos == NULL && hit_eof)
+        {
+          *eof = TRUE;
+          *stringbuf = buf;
+          return SVN_NO_ERROR;
+        }
+
+      /* Prepare to read the next chunk. */
+      svn_stringbuf_ensure(buf, buf->blocksize + SVN__LINE_CHUNK_SIZE);
+    }
+}
+
+static svn_error_t *
+readline_handler_apr(void *baton,
+                     svn_stringbuf_t **stringbuf,
+                     const char *eol,
+                     svn_boolean_t *eof,
+                     apr_pool_t *pool)
 {
   struct baton_apr *btn = baton;
-  return (apr_file_flags_get(btn->file) & APR_BUFFERED) != 0;
+
+  if (eol[0] == '\n' && eol[1] == '\0')
+    {
+      /* Optimize the common case when we're looking for an LF ("\n")
+         end-of-line sequence by using apr_file_gets(). */
+      return svn_error_trace(readline_apr_lf(btn->file, stringbuf,
+                                             eof, pool));
+    }
+  else
+    {
+      return svn_error_trace(readline_apr_generic(btn->file, stringbuf,
+                                                  eol, eof, pool));
+    }
 }
 
 svn_error_t *
@@ -1083,10 +1072,10 @@ make_stream_from_apr_file(apr_file_t *fi
       svn_stream_set_skip(stream, skip_handler_apr);
       svn_stream_set_mark(stream, mark_handler_apr);
       svn_stream_set_seek(stream, seek_handler_apr);
+      svn_stream_set_readline(stream, readline_handler_apr);
     }
 
   svn_stream_set_data_available(stream, data_available_handler_apr);
-  svn_stream__set_is_buffered(stream, is_buffered_handler_apr);
   stream->file = file;
 
   if (! disown)
@@ -1478,6 +1467,51 @@ svn_stream_checksummed2(svn_stream_t *st
   return s;
 }
 
+/* Helper for svn_stream_contents_checksum() to compute checksum of
+ * KIND of STREAM. This function doesn't close source stream. */
+static svn_error_t *
+compute_stream_checksum(svn_checksum_t **checksum,
+                        svn_stream_t *stream,
+                        svn_checksum_kind_t kind,
+                        apr_pool_t *result_pool,
+                        apr_pool_t *scratch_pool)
+{
+  svn_checksum_ctx_t *ctx = svn_checksum_ctx_create(kind, scratch_pool);
+  char *buf = apr_palloc(scratch_pool, SVN__STREAM_CHUNK_SIZE);
+
+  while (1)
+    {
+      apr_size_t len = SVN__STREAM_CHUNK_SIZE;
+
+      SVN_ERR(svn_stream_read_full(stream, buf, &len));
+
+      if (len > 0)
+        SVN_ERR(svn_checksum_update(ctx, buf, len));
+
+      if (len != SVN__STREAM_CHUNK_SIZE)
+          break;
+    }
+  SVN_ERR(svn_checksum_final(checksum, ctx, result_pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_stream_contents_checksum(svn_checksum_t **checksum,
+                             svn_stream_t *stream,
+                             svn_checksum_kind_t kind,
+                             apr_pool_t *result_pool,
+                             apr_pool_t *scratch_pool)
+{
+  svn_error_t *err;
+
+  err = compute_stream_checksum(checksum, stream, kind,
+                                result_pool, scratch_pool);
+
+  /* Close source stream in all cases. */
+  return svn_error_compose_create(err, svn_stream_close(stream));
+}
+
 /* Miscellaneous stream functions. */
 
 /*
@@ -1606,10 +1640,35 @@ data_available_handler_stringbuf(void *b
   return SVN_NO_ERROR;
 }
 
-static svn_boolean_t
-is_buffered_handler_stringbuf(void *baton)
+static svn_error_t *
+readline_handler_stringbuf(void *baton,
+                           svn_stringbuf_t **stringbuf,
+                           const char *eol,
+                           svn_boolean_t *eof,
+                           apr_pool_t *pool)
 {
-  return TRUE;
+  struct stringbuf_stream_baton *btn = baton;
+  const char *pos = btn->str->data + btn->amt_read;
+  const char *eol_pos;
+
+  eol_pos = strstr(pos, eol);
+  if (eol_pos)
+    {
+      apr_size_t eol_len = strlen(eol);
+
+      *eof = FALSE;
+      *stringbuf = svn_stringbuf_ncreate(pos, eol_pos - pos, pool);
+      btn->amt_read += (eol_pos - pos + eol_len);
+    }
+  else
+    {
+      *eof = TRUE;
+      *stringbuf = svn_stringbuf_ncreate(pos, btn->str->len - btn->amt_read,
+                                         pool);
+      btn->amt_read = btn->str->len;
+    }
+
+  return SVN_NO_ERROR;
 }
 
 svn_stream_t *
@@ -1632,7 +1691,7 @@ svn_stream_from_stringbuf(svn_stringbuf_
   svn_stream_set_mark(stream, mark_handler_stringbuf);
   svn_stream_set_seek(stream, seek_handler_stringbuf);
   svn_stream_set_data_available(stream, data_available_handler_stringbuf);
-  svn_stream__set_is_buffered(stream, is_buffered_handler_stringbuf);
+  svn_stream_set_readline(stream, readline_handler_stringbuf);
   return stream;
 }
 
@@ -1711,10 +1770,35 @@ data_available_handler_string(void *bato
   return SVN_NO_ERROR;
 }
 
-static svn_boolean_t
-is_buffered_handler_string(void *baton)
+static svn_error_t *
+readline_handler_string(void *baton,
+                        svn_stringbuf_t **stringbuf,
+                        const char *eol,
+                        svn_boolean_t *eof,
+                        apr_pool_t *pool)
 {
-  return TRUE;
+  struct string_stream_baton *btn = baton;
+  const char *pos = btn->str->data + btn->amt_read;
+  const char *eol_pos;
+
+  eol_pos = strstr(pos, eol);
+  if (eol_pos)
+    {
+      apr_size_t eol_len = strlen(eol);
+
+      *eof = FALSE;
+      *stringbuf = svn_stringbuf_ncreate(pos, eol_pos - pos, pool);
+      btn->amt_read += (eol_pos - pos + eol_len);
+    }
+  else
+    {
+      *eof = TRUE;
+      *stringbuf = svn_stringbuf_ncreate(pos, btn->str->len - btn->amt_read,
+                                         pool);
+      btn->amt_read = btn->str->len;
+    }
+
+  return SVN_NO_ERROR;
 }
 
 svn_stream_t *
@@ -1736,7 +1820,7 @@ svn_stream_from_string(const svn_string_
   svn_stream_set_seek(stream, seek_handler_string);
   svn_stream_set_skip(stream, skip_handler_string);
   svn_stream_set_data_available(stream, data_available_handler_string);
-  svn_stream__set_is_buffered(stream, is_buffered_handler_string);
+  svn_stream_set_readline(stream, readline_handler_string);
   return stream;
 }
 
@@ -1985,17 +2069,19 @@ data_available_handler_lazyopen(void *ba
                                                    data_available));
 }
 
-/* Implements svn_stream__is_buffered_fn_t */
-static svn_boolean_t
-is_buffered_lazyopen(void *baton)
+/* Implements svn_stream_readline_fn_t */
+static svn_error_t *
+readline_handler_lazyopen(void *baton,
+                          svn_stringbuf_t **stringbuf,
+                          const char *eol,
+                          svn_boolean_t *eof,
+                          apr_pool_t *pool)
 {
   lazyopen_baton_t *b = baton;
 
-  /* No lazy open as we cannot handle an open error. */
-  if (!b->real_stream)
-    return FALSE;
-
-  return svn_stream__is_buffered(b->real_stream);
+  SVN_ERR(lazyopen_if_unopened(b));
+  return svn_error_trace(svn_stream_readline(b->real_stream, stringbuf,
+                                             eol, eof, pool));
 }
 
 svn_stream_t *
@@ -2022,7 +2108,7 @@ svn_stream_lazyopen_create(svn_stream_la
   svn_stream_set_mark(stream, mark_handler_lazyopen);
   svn_stream_set_seek(stream, seek_handler_lazyopen);
   svn_stream_set_data_available(stream, data_available_handler_lazyopen);
-  svn_stream__set_is_buffered(stream, is_buffered_lazyopen);
+  svn_stream_set_readline(stream, readline_handler_lazyopen);
 
   return stream;
 }

Modified: subversion/branches/authzperf/subversion/libsvn_subr/string.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/string.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/string.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/string.c Thu Oct 13 
15:25:15 2016
@@ -479,7 +479,7 @@ svn_stringbuf_set(svn_stringbuf_t *str,
 {
   apr_size_t amt = strlen(value);
 
-  svn_stringbuf_ensure(str, amt);
+  membuf_ensure((void**) &str->data, &str->blocksize, amt + 1, str->pool);
   memcpy(str->data, value, amt + 1);
   str->len = amt;
 }

Modified: subversion/branches/authzperf/subversion/libsvn_subr/subst.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/subst.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/subst.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/subst.c Thu Oct 13 
15:25:15 2016
@@ -1431,14 +1431,6 @@ translated_stream_seek(void *baton, cons
   return SVN_NO_ERROR;
 }
 
-/* Implements svn_stream__is_buffered_fn_t. */
-static svn_boolean_t
-translated_stream_is_buffered(void *baton)
-{
-  struct translated_stream_baton *b = baton;
-  return svn_stream__is_buffered(b->stream);
-}
-
 svn_error_t *
 svn_subst_read_specialfile(svn_stream_t **stream,
                            const char *path,
@@ -1546,9 +1538,11 @@ stream_translated(svn_stream_t *stream,
                        translated_stream_read);
   svn_stream_set_write(s, translated_stream_write);
   svn_stream_set_close(s, translated_stream_close);
-  svn_stream_set_mark(s, translated_stream_mark);
-  svn_stream_set_seek(s, translated_stream_seek);
-  svn_stream__set_is_buffered(s, translated_stream_is_buffered);
+  if (svn_stream_supports_mark(stream))
+    {
+      svn_stream_set_mark(s, translated_stream_mark);
+      svn_stream_set_seek(s, translated_stream_seek);
+    }
 
   return s;
 }

Modified: subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/sysinfo.c Thu Oct 13 
15:25:15 2016
@@ -666,7 +666,7 @@ system_info(SYSTEM_INFO *sysinfo,
             SYSTEM_INFO *local_sysinfo)
 {
   FNGETNATIVESYSTEMINFO GetNativeSystemInfo_ = (FNGETNATIVESYSTEMINFO)
-    GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetNativeSystemInfo");
+    GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetNativeSystemInfo");
 
   memset(sysinfo, 0, sizeof *sysinfo);
   if (local_sysinfo)
@@ -875,12 +875,12 @@ enum_loaded_modules(apr_pool_t *pool)
   DWORD size;
   FNENUMPROCESSMODULES EnumProcessModules_;
 
-  psapi_dll = GetModuleHandleA("psapi.dll");
+  psapi_dll = GetModuleHandleW(L"psapi.dll");
 
   if (!psapi_dll)
     {
       /* Load and never unload, just like static linking */
-      psapi_dll = LoadLibraryA("psapi.dll");
+      psapi_dll = LoadLibraryW(L"psapi.dll");
     }
 
   if (!psapi_dll)
@@ -1144,6 +1144,7 @@ release_name_from_version(const char *os
     case  9: return "Mavericks";
     case 10: return "Yosemite";
     case 11: return "El Capitan";
+    case 12: return "Sierra";
     }
 
   return NULL;

Modified: subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt.c Thu 
Oct 13 15:25:15 2016
@@ -380,7 +380,7 @@ write_value(FILE *log_file, DWORD64 mod_
         }
         break;
       case 12: /* SymTagEnum */
-          fprintf(log_file, "%d", *(DWORD_PTR *)value_addr);
+          fprintf(log_file, "%Id", *(DWORD_PTR *)value_addr);
           break;
       case 13: /* SymTagFunctionType */
           fprintf(log_file, FORMAT_PTR, *(DWORD_PTR *)value_addr);
@@ -599,20 +599,7 @@ write_stacktrace(CONTEXT *context, FILE
 static BOOL
 is_debugger_present()
 {
-  HANDLE kernel32_dll = LoadLibrary("kernel32.dll");
-  BOOL result;
-
-  ISDEBUGGERPRESENT IsDebuggerPresent_ =
-          (ISDEBUGGERPRESENT)GetProcAddress(kernel32_dll, "IsDebuggerPresent");
-
-  if (IsDebuggerPresent_ && IsDebuggerPresent_())
-    result = TRUE;
-  else
-    result = FALSE;
-
-  FreeLibrary(kernel32_dll);
-
-  return result;
+  return IsDebuggerPresent();
 }
 
 /* Load the dbghelp.dll file, try to find a version that matches our
@@ -621,7 +608,7 @@ static BOOL
 load_dbghelp_dll()
 {
   dbghelp_dll = LoadLibrary(DBGHELP_DLL);
-  if (dbghelp_dll != INVALID_HANDLE_VALUE)
+  if (dbghelp_dll != NULL)
     {
       DWORD opts;
 

Modified: 
subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt_dll.h
URL: 
http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt_dll.h?rev=1764707&r1=1764706&r2=1764707&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt_dll.h 
(original)
+++ subversion/branches/authzperf/subversion/libsvn_subr/win32_crashrpt_dll.h 
Thu Oct 13 15:25:15 2016
@@ -69,9 +69,6 @@ typedef PVOID (WINAPI * SYMFUNCTIONTABLE
 
 typedef DWORD64 (WINAPI * SYMGETMODULEBASE64)(HANDLE hProcess, DWORD64 dwAddr);
 
-/* public functions in kernel32.dll */
-typedef BOOL  (WINAPI * ISDEBUGGERPRESENT)(VOID);
-
 /* function pointers */
 MINIDUMPWRITEDUMP        MiniDumpWriteDump_;
 SYMINITIALIZE            SymInitialize_;


Reply via email to