You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by pb...@apache.org on 2012/06/26 21:28:22 UTC

svn commit: r1354186 [19/33] - in /subversion/branches/inheritable-props: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ build/win32/ contrib/client-side/emacs/ contrib/server-side/ notes/ notes/api-errata/1.8/ notes/directory-i...

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/config_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/config_file.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/config_file.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/config_file.c Tue Jun 26 19:26:49 2012
@@ -60,15 +60,19 @@ typedef struct parse_context_t
   /* The current line in the file */
   int line;
 
-  /* Cached ungotten character  - streams don't support ungetc()
-     [emulate it] */
+  /* Emulate an ungetc */
   int ungotten_char;
-  svn_boolean_t have_ungotten_char;
 
-  /* Temporary strings, allocated from the temp pool */
+  /* Temporary strings */
   svn_stringbuf_t *section;
   svn_stringbuf_t *option;
   svn_stringbuf_t *value;
+
+  /* Parser buffer for getc() to avoid call overhead into several libraries
+     for every character */
+  char parser_buffer[SVN_STREAM_CHUNK_SIZE]; /* Larger than most config files */
+  size_t buffer_pos; /* Current position within parser_buffer */
+  size_t buffer_size; /* parser_buffer contains this many bytes */
 } parse_context_t;
 
 
@@ -82,27 +86,61 @@ typedef struct parse_context_t
 static APR_INLINE svn_error_t *
 parser_getc(parse_context_t *ctx, int *c)
 {
-  if (ctx->have_ungotten_char)
-    {
-      *c = ctx->ungotten_char;
-      ctx->have_ungotten_char = FALSE;
-    }
-  else
+  do
     {
-      char char_buf;
-      apr_size_t readlen = 1;
+      if (ctx->ungotten_char != EOF)
+        {
+          *c = ctx->ungotten_char;
+          ctx->ungotten_char = EOF;
+        }
+      else if (ctx->buffer_pos < ctx->buffer_size)
+        {
+          *c = ctx->parser_buffer[ctx->buffer_pos];
+          ctx->buffer_pos++;
+        }
+      else
+        {
+          ctx->buffer_pos = 0;
+          ctx->buffer_size = sizeof(ctx->parser_buffer);
 
-      SVN_ERR(svn_stream_read(ctx->stream, &char_buf, &readlen));
+          SVN_ERR(svn_stream_read(ctx->stream, ctx->parser_buffer,
+                                  &(ctx->buffer_size)));
 
-      if (readlen == 1)
-        *c = char_buf;
-      else
-        *c = EOF;
+          if (ctx->buffer_pos < ctx->buffer_size)
+            {
+              *c = ctx->parser_buffer[ctx->buffer_pos];
+              ctx->buffer_pos++;
+            }
+          else
+            *c = EOF;
+        }
     }
+  while (*c == '\r');
 
   return SVN_NO_ERROR;
 }
 
+/* Simplified version of parser_getc() to be used inside skipping loops.
+ * It will not check for 'ungotton' chars and may or may not ignore '\r'.
+ *
+ * In a 'while(cond) getc();' loop, the first iteration must call
+ * parser_getc to handle all the special cases.  Later iterations should
+ * use parser_getc_plain for maximum performance.
+ */
+static APR_INLINE svn_error_t *
+parser_getc_plain(parse_context_t *ctx, int *c)
+{
+  if (ctx->buffer_pos < ctx->buffer_size)
+    {
+      *c = ctx->parser_buffer[ctx->buffer_pos];
+      ctx->buffer_pos++;
+
+      return SVN_NO_ERROR;
+    }
+
+  return parser_getc(ctx, c);
+}
+
 /* Emulate ungetc() because streams don't support it.
  *
  * Use CTX to store the ungotten character C.
@@ -111,7 +149,6 @@ static APR_INLINE svn_error_t *
 parser_ungetc(parse_context_t *ctx, int c)
 {
   ctx->ungotten_char = c;
-  ctx->have_ungotten_char = TRUE;
 
   return SVN_NO_ERROR;
 }
@@ -127,10 +164,10 @@ skip_whitespace(parse_context_t *ctx, in
   int count = 0;
 
   SVN_ERR(parser_getc(ctx, &ch));
-  while (ch != EOF && ch != '\n' && svn_ctype_isspace(ch))
+  while (svn_ctype_isspace(ch) && ch != '\n' && ch != EOF)
     {
       ++count;
-      SVN_ERR(parser_getc(ctx, &ch));
+      SVN_ERR(parser_getc_plain(ctx, &ch));
     }
   *pcount = count;
   *c = ch;
@@ -146,8 +183,8 @@ skip_to_eoln(parse_context_t *ctx, int *
   int ch;
 
   SVN_ERR(parser_getc(ctx, &ch));
-  while (ch != EOF && ch != '\n')
-    SVN_ERR(parser_getc(ctx, &ch));
+  while (ch != '\n' && ch != EOF)
+    SVN_ERR(parser_getc_plain(ctx, &ch));
 
   *c = ch;
   return SVN_NO_ERROR;
@@ -241,7 +278,7 @@ parse_value(int *pch, parse_context_t *c
 
 /* Parse a single option */
 static svn_error_t *
-parse_option(int *pch, parse_context_t *ctx, apr_pool_t *pool)
+parse_option(int *pch, parse_context_t *ctx, apr_pool_t *scratch_pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
   int ch;
@@ -260,7 +297,7 @@ parse_option(int *pch, parse_context_t *
       ch = EOF;
       err = svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                               "%s:%d: Option must end with ':' or '='",
-                              svn_dirent_local_style(ctx->file, pool),
+                              svn_dirent_local_style(ctx->file, scratch_pool),
                               ctx->line);
     }
   else
@@ -284,7 +321,8 @@ parse_option(int *pch, parse_context_t *
  * starts a section name.
  */
 static svn_error_t *
-parse_section_name(int *pch, parse_context_t *ctx, apr_pool_t *pool)
+parse_section_name(int *pch, parse_context_t *ctx,
+                   apr_pool_t *scratch_pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
   int ch;
@@ -303,7 +341,7 @@ parse_section_name(int *pch, parse_conte
       ch = EOF;
       err = svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                               "%s:%d: Section header must end with ']'",
-                              svn_dirent_local_style(ctx->file, pool),
+                              svn_dirent_local_style(ctx->file, scratch_pool),
                               ctx->line);
     }
   else
@@ -363,91 +401,101 @@ svn_config__sys_config_path(const char *
 
 svn_error_t *
 svn_config__parse_file(svn_config_t *cfg, const char *file,
-                       svn_boolean_t must_exist, apr_pool_t *pool)
+                       svn_boolean_t must_exist, apr_pool_t *result_pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
-  parse_context_t ctx;
+  parse_context_t *ctx;
   int ch, count;
   svn_stream_t *stream;
+  apr_pool_t *scratch_pool = svn_pool_create(result_pool);
 
-  err = svn_stream_open_readonly(&stream, file, pool, pool);
+  err = svn_stream_open_readonly(&stream, file, scratch_pool, scratch_pool);
 
   if (! must_exist && err && APR_STATUS_IS_ENOENT(err->apr_err))
     {
       svn_error_clear(err);
+      svn_pool_destroy(scratch_pool);
       return SVN_NO_ERROR;
     }
   else
     SVN_ERR(err);
 
-  ctx.cfg = cfg;
-  ctx.file = file;
-  ctx.stream = svn_subst_stream_translated(stream, "\n", TRUE, NULL, FALSE,
-                                           pool);
-  ctx.line = 1;
-  ctx.have_ungotten_char = FALSE;
-  ctx.section = svn_stringbuf_create_empty(pool);
-  ctx.option = svn_stringbuf_create_empty(pool);
-  ctx.value = svn_stringbuf_create_empty(pool);
+  ctx = apr_palloc(scratch_pool, sizeof(*ctx));
+
+  ctx->cfg = cfg;
+  ctx->file = file;
+  ctx->stream = stream;
+  ctx->line = 1;
+  ctx->ungotten_char = EOF;
+  ctx->section = svn_stringbuf_create_empty(scratch_pool);
+  ctx->option = svn_stringbuf_create_empty(scratch_pool);
+  ctx->value = svn_stringbuf_create_empty(scratch_pool);
+  ctx->buffer_pos = 0;
+  ctx->buffer_size = 0;
 
   do
     {
-      SVN_ERR(skip_whitespace(&ctx, &ch, &count));
+      SVN_ERR(skip_whitespace(ctx, &ch, &count));
 
       switch (ch)
         {
         case '[':               /* Start of section header */
           if (count == 0)
-            SVN_ERR(parse_section_name(&ch, &ctx, pool));
+            SVN_ERR(parse_section_name(&ch, ctx, scratch_pool));
           else
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Section header"
                                      " must start in the first column",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           break;
 
         case '#':               /* Comment */
           if (count == 0)
             {
-              SVN_ERR(skip_to_eoln(&ctx, &ch));
-              ++ctx.line;
+              SVN_ERR(skip_to_eoln(ctx, &ch));
+              ++(ctx->line);
             }
           else
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Comment"
                                      " must start in the first column",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           break;
 
         case '\n':              /* Empty line */
-          ++ctx.line;
+          ++(ctx->line);
           break;
 
         case EOF:               /* End of file or read error */
           break;
 
         default:
-          if (svn_stringbuf_isempty(ctx.section))
+          if (svn_stringbuf_isempty(ctx->section))
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Section header expected",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           else if (count != 0)
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Option expected",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           else
-            SVN_ERR(parse_option(&ch, &ctx, pool));
+            SVN_ERR(parse_option(&ch, ctx, scratch_pool));
           break;
         }
     }
   while (ch != EOF);
 
   /* Close the streams (and other cleanup): */
-  return svn_stream_close(ctx.stream);
+  svn_pool_destroy(scratch_pool);
+  return SVN_NO_ERROR;
 }
 
 
@@ -749,9 +797,6 @@ svn_config_ensure(const char *config_dir
                                                                              NL
         "###   http-compression           Whether to compress HTTP requests" NL
         "###   neon-debug-mask            Debug mask for Neon HTTP library"  NL
-#ifdef SVN_NEON_0_26
-        "###   http-auth-types            Auth types to use for HTTP library"NL
-#endif
         "###   ssl-authority-files        List of files, each of a trusted CA"
                                                                              NL
         "###   ssl-trust-default-ca       Trust the system 'default' CAs"    NL
@@ -761,7 +806,7 @@ svn_config_ensure(const char *config_dir
         "###   ssl-pkcs11-provider        Name of PKCS#11 provider to use."  NL
         "###   http-library               Which library to use for http/https"
                                                                              NL
-        "###                              connections (neon or serf)"        NL
+        "###                              connections."                      NL
         "###   store-passwords            Specifies whether passwords used"  NL
         "###                              to authenticate against a"         NL
         "###                              Subversion server may be cached"   NL
@@ -839,6 +884,13 @@ svn_config_ensure(const char *config_dir
         "### HTTP timeouts, if given, are specified in seconds.  A timeout"  NL
         "### of 0, i.e. zero, causes a builtin default to be used."          NL
         "###"                                                                NL
+        "### Most users will not need to explicitly set the http-library"    NL
+        "### option, but valid values for the option include:"               NL
+        "###    'serf': Serf-based module (Subversion 1.5 - present)"        NL
+        "###    'neon': Neon-based module (Subversion 1.0 - 1.7)"            NL
+        "### Availability of these modules may depend on your specific"      NL
+        "### Subversion distribution."                                       NL
+        "###"                                                                NL
         "### The commented-out examples below are intended only to"          NL
         "### demonstrate how to use this file; any resemblance to actual"    NL
         "### servers, living or dead, is entirely coincidental."             NL
@@ -860,9 +912,6 @@ svn_config_ensure(const char *config_dir
         "# http-proxy-username = blah"                                       NL
         "# http-proxy-password = doubleblah"                                 NL
         "# http-timeout = 60"                                                NL
-#ifdef SVN_NEON_0_26
-        "# http-auth-types = basic;digest;negotiate"                         NL
-#endif
         "# neon-debug-mask = 130"                                            NL
 #ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
         "# store-plaintext-passwords = no"                                   NL
@@ -903,9 +952,6 @@ svn_config_ensure(const char *config_dir
         "# http-proxy-username = defaultusername"                            NL
         "# http-proxy-password = defaultpassword"                            NL
         "# http-compression = no"                                            NL
-#ifdef SVN_NEON_0_26
-        "# http-auth-types = basic;digest;negotiate"                         NL
-#endif
         "# No http-timeout, so just use the builtin default."                NL
         "# No neon-debug-mask, so neon debugging is disabled."               NL
         "# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem"   NL

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/dirent_uri.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/dirent_uri.c Tue Jun 26 19:26:49 2012
@@ -104,7 +104,7 @@ canonicalize_to_lower(char c)
   if (c < 'A' || c > 'Z')
     return c;
   else
-    return c - 'A' + 'a';
+    return (char)(c - 'A' + 'a');
 }
 
 /* Locale insensitive toupper() for converting parts of dirents and urls
@@ -115,7 +115,7 @@ canonicalize_to_upper(char c)
   if (c < 'a' || c > 'z')
     return c;
   else
-    return c - 'a' + 'A';
+    return (char)(c - 'a' + 'A');
 }
 
 /* Calculates the length of the dirent absolute or non absolute root in

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/error.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/error.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/error.c Tue Jun 26 19:26:49 2012
@@ -218,6 +218,28 @@ svn_error_quick_wrap(svn_error_t *child,
 
 
 svn_error_t *
+svn_error__trace(const char *file, long line, svn_error_t *err)
+{
+#ifndef SVN_DEBUG
+
+  /* We shouldn't even be here, but whatever. Just return the error as-is.  */
+  return err;
+
+#else
+
+  /* Only do the work when an error occurs.  */
+  if (err)
+    {
+      svn_error__locate(file, line);
+      return svn_error_quick_wrap(err, SVN_ERR__TRACED);
+    }
+  return SVN_NO_ERROR;
+
+#endif
+}
+
+
+svn_error_t *
 svn_error_compose_create(svn_error_t *err1,
                          svn_error_t *err2)
 {

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/hash.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/hash.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/hash.c Tue Jun 26 19:26:49 2012
@@ -40,6 +40,7 @@
 #include "svn_pools.h"
 
 #include "private/svn_dep_compat.h"
+#include "private/svn_subr_private.h"
 
 #include "svn_private_config.h"
 
@@ -237,7 +238,7 @@ hash_write(apr_hash_t *hash, apr_hash_t 
                                 valstr->len));
       len = valstr->len;
       SVN_ERR(svn_stream_write(stream, valstr->data, &len));
-      SVN_ERR(svn_stream_printf(stream, subpool, "\n"));
+      SVN_ERR(svn_stream_puts(stream, "\n"));
     }
 
   if (oldhash)
@@ -495,7 +496,7 @@ svn_hash_from_cstring_keys(apr_hash_t **
                            apr_pool_t *pool)
 {
   int i;
-  apr_hash_t *hash = apr_hash_make(pool);
+  apr_hash_t *hash = svn_hash__make(pool);
   for (i = 0; i < keys->nelts; i++)
     {
       const char *key =
@@ -560,3 +561,71 @@ svn_hash__get_bool(apr_hash_t *hash, con
   return default_value;
 }
 
+
+
+/*** Optimized hash function ***/
+
+/* Optimized version of apr_hashfunc_default in APR 1.4.5 and earlier.
+ * It assumes that the CPU has 32-bit multiplications with high throughput
+ * of at least 1 operation every 3 cycles. Latency is not an issue. Another
+ * optimization is a mildly unrolled main loop and breaking the dependency
+ * chain within the loop.
+ *
+ * Note that most CPUs including Intel Atom, VIA Nano, ARM feature the
+ * assumed pipelined multiplication circuitry. They can do one MUL every
+ * or every other cycle.
+ *
+ * The performance is ultimately limited by the fact that most CPUs can
+ * do only one LOAD and only one BRANCH operation per cycle. The best we
+ * can do is to process one character per cycle - provided the processor
+ * is wide enough to do 1 LOAD, COMPARE, BRANCH, MUL and ADD per cycle.
+ */
+static unsigned int
+hashfunc_compatible(const char *char_key, apr_ssize_t *klen)
+{
+    unsigned int hash = 0;
+    const unsigned char *key = (const unsigned char *)char_key;
+    const unsigned char *p;
+    apr_ssize_t i;
+
+    if (*klen == APR_HASH_KEY_STRING)
+      {
+        for (p = key; ; p+=4)
+          {
+            unsigned int new_hash = hash * 33 * 33 * 33 * 33;
+            if (!p[0]) break;
+            new_hash += p[0] * 33 * 33 * 33;
+            if (!p[1]) break;
+            new_hash += p[1] * 33 * 33;
+            if (!p[2]) break;
+            new_hash += p[2] * 33;
+            if (!p[3]) break;
+            hash = new_hash + p[3];
+          }
+        for (; *p; p++)
+            hash = hash * 33 + *p;
+
+        *klen = p - key;
+      }
+    else
+      {
+        for (p = key, i = *klen; i >= 4; i-=4, p+=4)
+          {
+            hash = hash * 33 * 33 * 33 * 33
+                 + p[0] * 33 * 33 * 33
+                 + p[1] * 33 * 33
+                 + p[2] * 33
+                 + p[3];
+          }
+        for (; i; i--, p++)
+            hash = hash * 33 + *p;
+      }
+
+    return hash;
+}
+
+apr_hash_t *
+svn_hash__make(apr_pool_t *pool)
+{
+  return apr_hash_make_custom(pool, hashfunc_compatible);
+}

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/internal_statements.sql
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/internal_statements.sql?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/internal_statements.sql (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/internal_statements.sql Tue Jun 26 19:26:49 2012
@@ -21,5 +21,27 @@
  * ====================================================================
  */
 
--- STMT_DUMMY_SELECT_FOR_BACKUP
-SELECT * FROM SQLITE_MASTER;
+-- STMT_INTERNAL_SAVEPOINT_SVN
+SAVEPOINT svn
+
+-- STMT_INTERNAL_RELEASE_SAVEPOINT_SVN
+RELEASE SAVEPOINT svn
+
+-- STMT_INTERNAL_ROLLBACK_TO_SAVEPOINT_SVN
+ROLLBACK TO SAVEPOINT svn
+
+-- STMT_INTERNAL_BEGIN_TRANSACTION
+BEGIN TRANSACTION
+
+-- STMT_INTERNAL_BEGIN_IMMEDIATE_TRANSACTION
+BEGIN IMMEDIATE TRANSACTION
+
+-- STMT_INTERNAL_COMMIT_TRANSACTION
+COMMIT TRANSACTION
+
+-- STMT_INTERNAL_ROLLBACK_TRANSACTION
+ROLLBACK TRANSACTION
+
+/* Dummmy statement to determine the number of internal statements */
+-- STMT_INTERNAL_LAST
+;

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/io.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/io.c Tue Jun 26 19:26:49 2012
@@ -168,6 +168,41 @@ cstring_from_utf8(const char **path_apr,
 #endif
 }
 
+/* Helper function that allows to convert an APR-level PATH to something
+ * that we can pass the svn_error_wrap_apr. Since we use it in context
+ * of error reporting, having *some* path info may be more useful than
+ * having none.  Therefore, we use a best effort approach here.
+ *
+ * This is different from svn_io_file_name_get in that it uses a different
+ * signature style and will never fail.
+ */
+static const char *
+try_utf8_from_internal_style(const char *path, apr_pool_t *pool)
+{
+  svn_error_t *error;
+  const char *path_utf8;
+
+  /* Special case. */
+  if (path == NULL)
+    return "(NULL)";
+  
+  /* (try to) convert PATH to UTF-8. If that fails, continue with the plain
+   * PATH because it is the best we have. It may actually be UTF-8 already.
+   */
+  error = cstring_to_utf8(&path_utf8, path, pool);
+  if (error)
+    {
+      /* fallback to best representation we have */
+
+      svn_error_clear(error);
+      path_utf8 = path;
+    }
+
+  /* Toggle (back-)slashes etc. as necessary.
+   */
+  return svn_dirent_local_style(path_utf8, pool);
+}
+
 
 /* Set *NAME_P to the UTF-8 representation of directory entry NAME.
  * NAME is in the internal encoding used by APR; PARENT is in
@@ -193,6 +228,10 @@ entry_name_to_utf8(const char **name_p,
                    const char *parent,
                    apr_pool_t *pool)
 {
+#if defined(WIN32) || defined(DARWIN)
+  *name_p = apr_pstrdup(pool, name);
+  return SVN_NO_ERROR;
+#else
   svn_error_t *err = svn_path_cstring_to_utf8(name_p, name, pool);
   if (err && err->apr_err == APR_EINVAL)
     {
@@ -202,6 +241,7 @@ entry_name_to_utf8(const char **name_p,
                                svn_dirent_local_style(parent, pool));
     }
   return err;
+#endif
 }
 
 
@@ -851,10 +891,10 @@ file_perms_set(const char *fname, apr_fi
 
 /* Set permissions PERMS on the FILE. This is a cheaper variant of the
  * file_perms_set wrapper() function because no locale-dependent string
- * conversion is required.
+ * conversion is required. POOL will be used for allocations.
  */
 static svn_error_t *
-file_perms_set2(apr_file_t* file, apr_fileperms_t perms)
+file_perms_set2(apr_file_t* file, apr_fileperms_t perms, apr_pool_t *pool)
 {
   const char *fname_apr;
   apr_status_t status;
@@ -866,7 +906,7 @@ file_perms_set2(apr_file_t* file, apr_fi
   status = apr_file_perms_set(fname_apr, perms);
   if (status)
     return svn_error_wrap_apr(status, _("Can't set permissions on '%s'"),
-                              fname_apr);
+                              try_utf8_from_internal_style(fname_apr, pool));
   else
     return SVN_NO_ERROR;
 }
@@ -1351,28 +1391,32 @@ get_default_file_perms(apr_fileperms_t *
     {
       apr_finfo_t finfo;
       apr_file_t *fd;
+      const char *fname_base, *fname;
+      apr_uint32_t randomish;
+      svn_error_t *err;
 
       /* Get the perms for a newly created file to find out what bits
         should be set.
 
-        Normally del_on_close can be problematic because APR might
-        delete the file if we spawned any child processes. In this
-        case, the lifetime of this file handle is about 3 lines of
-        code, so we can safely use del_on_close here.
-
-        Not so fast! If some other thread forks off a child, then the
-        APR cleanups run, and the file will disappear. So use
-        del_on_pool_cleanup instead.
+        Explictly delete the file because we want this file to be as
+        short-lived as possible since its presence means other
+        processes may have to try multiple names.
 
         Using svn_io_open_uniquely_named() here because other tempfile
         creation functions tweak the permission bits of files they create.
       */
-      SVN_ERR(svn_io_open_uniquely_named(&fd, NULL, NULL, "default-perms", NULL,
-                                         svn_io_file_del_on_pool_cleanup,
-                                         scratch_pool, scratch_pool));
-      SVN_ERR(svn_io_file_info_get(&finfo, APR_FINFO_PROT, fd, scratch_pool));
-      SVN_ERR(svn_io_file_close(fd, scratch_pool));
+      randomish = ((apr_uint32_t)(apr_uintptr_t)scratch_pool
+                   + (apr_uint32_t)apr_time_now());
+      fname_base = apr_psprintf(scratch_pool, "svn-%08x", randomish);
 
+      SVN_ERR(svn_io_open_uniquely_named(&fd, &fname, NULL, fname_base,
+                                         NULL, svn_io_file_del_none,
+                                         scratch_pool, scratch_pool));
+      err = svn_io_file_info_get(&finfo, APR_FINFO_PROT, fd, scratch_pool);
+      err = svn_error_compose_create(err, svn_io_file_close(fd, scratch_pool));
+      err = svn_error_compose_create(err, svn_io_remove_file2(fname, TRUE,
+                                                              scratch_pool));
+      SVN_ERR(err);
       *perms = finfo.protection;
       default_perms = finfo.protection;
     }
@@ -1911,11 +1955,11 @@ svn_io_lock_open_file(apr_file_t *lockfi
         case APR_FLOCK_SHARED:
           return svn_error_wrap_apr(apr_err,
                                     _("Can't get shared lock on file '%s'"),
-                                    fname);
+                                    try_utf8_from_internal_style(fname, pool));
         case APR_FLOCK_EXCLUSIVE:
           return svn_error_wrap_apr(apr_err,
                                     _("Can't get exclusive lock on file '%s'"),
-                                    fname);
+                                    try_utf8_from_internal_style(fname, pool));
         default:
           SVN_ERR_MALFUNCTION();
         }
@@ -1948,7 +1992,8 @@ svn_io_unlock_open_file(apr_file_t *lock
   /* The actual unlock attempt. */
   apr_err = apr_file_unlock(lockfile_handle);
   if (apr_err)
-    return svn_error_wrap_apr(apr_err, _("Can't unlock file '%s'"), fname);
+    return svn_error_wrap_apr(apr_err, _("Can't unlock file '%s'"),
+                              try_utf8_from_internal_style(fname, pool));
   
 /* On Windows and OS/2 file locks are automatically released when
    the file handle closes */
@@ -2085,7 +2130,7 @@ stringbuf_from_aprfile(svn_stringbuf_t *
         {
           apr_finfo_t finfo;
           if (! (status = apr_stat(&finfo, filename, APR_FINFO_MIN, pool)))
-            res_initial_len = finfo.size;
+            res_initial_len = (apr_size_t)finfo.size;
         }
     }
 
@@ -3131,7 +3176,7 @@ do_io_file_wrapper_cleanup(apr_file_t *f
 
   if (name)
     return svn_error_wrap_apr(status, _(msg),
-                              svn_dirent_local_style(name, pool));
+                              try_utf8_from_internal_style(name, pool));
   else
     return svn_error_wrap_apr(status, "%s", _(msg_no_name));
 }
@@ -3140,33 +3185,30 @@ do_io_file_wrapper_cleanup(apr_file_t *f
 svn_error_t *
 svn_io_file_close(apr_file_t *file, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_close(file),
-     N_("Can't close file '%s'"),
-     N_("Can't close stream"),
-      pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_close(file),
+                                    N_("Can't close file '%s'"),
+                                    N_("Can't close stream"),
+                                    pool);
 }
 
 
 svn_error_t *
 svn_io_file_getc(char *ch, apr_file_t *file, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_getc(ch, file),
-     N_("Can't read file '%s'"),
-     N_("Can't read stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_getc(ch, file),
+                                    N_("Can't read file '%s'"),
+                                    N_("Can't read stream"),
+                                    pool);
 }
 
 
 svn_error_t *
 svn_io_file_putc(char ch, apr_file_t *file, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_putc(ch, file),
-     N_("Can't write file '%s'"),
-     N_("Can't write stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_putc(ch, file),
+                                    N_("Can't write file '%s'"),
+                                    N_("Can't write stream"),
+                                    pool);
 }
 
 
@@ -3177,11 +3219,11 @@ svn_io_file_info_get(apr_finfo_t *finfo,
   /* Quoting APR: On NT this request is incredibly expensive, but accurate. */
   wanted &= ~SVN__APR_FINFO_MASK_OUT;
 
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_info_get(finfo, wanted, file),
-     N_("Can't get attribute information from file '%s'"),
-     N_("Can't get attribute information from stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(
+             file, apr_file_info_get(finfo, wanted, file),
+             N_("Can't get attribute information from file '%s'"),
+             N_("Can't get attribute information from stream"),
+             pool);
 }
 
 
@@ -3189,11 +3231,10 @@ svn_error_t *
 svn_io_file_read(apr_file_t *file, void *buf,
                  apr_size_t *nbytes, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_read(file, buf, nbytes),
-     N_("Can't read file '%s'"),
-     N_("Can't read stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_read(file, buf, nbytes),
+                                    N_("Can't read file '%s'"),
+                                    N_("Can't read stream"),
+                                    pool);
 }
 
 
@@ -3215,11 +3256,10 @@ svn_io_file_read_full2(apr_file_t *file,
         *hit_eof = FALSE;
     }
 
-  return do_io_file_wrapper_cleanup
-    (file, status,
-     N_("Can't read file '%s'"),
-     N_("Can't read stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, status,
+                                    N_("Can't read file '%s'"),
+                                    N_("Can't read stream"),
+                                    pool);
 }
 
 
@@ -3227,11 +3267,11 @@ svn_error_t *
 svn_io_file_seek(apr_file_t *file, apr_seek_where_t where,
                  apr_off_t *offset, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_seek(file, where, offset),
-     N_("Can't set position pointer in file '%s'"),
-     N_("Can't set position pointer in stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(
+             file, apr_file_seek(file, where, offset),
+             N_("Can't set position pointer in file '%s'"),
+             N_("Can't set position pointer in stream"),
+             pool);
 }
 
 
@@ -3334,17 +3374,15 @@ svn_io_file_trunc(apr_file_t *file, apr_
   /* 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. */
-  SVN_ERR(do_io_file_wrapper_cleanup
-    (file, apr_file_flush(file),
-     N_("Can't flush file '%s'"),
-     N_("Can't flush stream"),
-     pool));
+  SVN_ERR(do_io_file_wrapper_cleanup(file, apr_file_flush(file),
+                                     N_("Can't flush file '%s'"),
+                                     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);
+  return do_io_file_wrapper_cleanup(file, apr_file_trunc(file, offset),
+                                    N_("Can't truncate file '%s'"),
+                                    N_("Can't truncate stream"),
+                                    pool);
 }
 
 
@@ -3986,8 +4024,8 @@ contents_identical_p(svn_boolean_t *iden
   apr_size_t bytes_read1, bytes_read2;
   char *buf1 = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
   char *buf2 = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
-  apr_file_t *file1_h = NULL;
-  apr_file_t *file2_h = NULL;
+  apr_file_t *file1_h;
+  apr_file_t *file2_h;
   svn_boolean_t eof1 = FALSE;
   svn_boolean_t eof2 = FALSE;
 
@@ -4050,16 +4088,16 @@ svn_io_files_contents_same_p(svn_boolean
 
   if (q)
     {
-      *same = 0;
+      *same = FALSE;
       return SVN_NO_ERROR;
     }
 
   SVN_ERR(contents_identical_p(&q, file1, file2, pool));
 
   if (q)
-    *same = 1;
+    *same = TRUE;
   else
-    *same = 0;
+    *same = FALSE;
 
   return SVN_NO_ERROR;
 }
@@ -4296,7 +4334,7 @@ svn_io_open_unique_file3(apr_file_t **fi
   if (!using_system_temp_dir)
     {
       SVN_ERR(merge_default_file_perms(tempfile, &perms, scratch_pool));
-      SVN_ERR(file_perms_set2(tempfile, perms));
+      SVN_ERR(file_perms_set2(tempfile, perms, scratch_pool));
     }
 #endif
 

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/lock.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/lock.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/lock.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/lock.c Tue Jun 26 19:26:49 2012
@@ -54,8 +54,7 @@ svn_lock_dup(const svn_lock_t *lock, apr
   new_l->path = apr_pstrdup(pool, new_l->path);
   new_l->token = apr_pstrdup(pool, new_l->token);
   new_l->owner = apr_pstrdup(pool, new_l->owner);
-  if (new_l->comment)
-    new_l->comment = apr_pstrdup(pool, new_l->comment);
+  new_l->comment = apr_pstrdup(pool, new_l->comment);
 
   return new_l;
 }

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/named_atomic.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/named_atomic.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/named_atomic.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/named_atomic.c Tue Jun 26 19:26:49 2012
@@ -341,6 +341,36 @@ return_atomic(svn_named_atomic__t **atom
 /* Implement API */
 
 svn_boolean_t
+svn_named_atomic__is_supported(void)
+{
+#ifdef _WIN32
+  static svn_tristate_t result = svn_tristate_unknown;
+
+  if (result == svn_tristate_unknown)
+    {
+      /* APR SHM implementation requires the creation of global objects */
+      HANDLE handle = CreateFileMappingA(INVALID_HANDLE_VALUE,
+                                         NULL,
+                                         PAGE_READONLY,
+                                         0,
+                                         1,
+                                         "Global\\__RandomXZY_svn");
+      if (handle != NULL)
+        {
+          CloseHandle(handle);
+          result = svn_tristate_true;
+        }
+      else
+        result = svn_tristate_false;
+    }
+
+  return result == svn_tristate_true ? TRUE : FALSE;
+#else
+  return TRUE;
+#endif
+}
+
+svn_boolean_t
 svn_named_atomic__is_efficient(void)
 {
   return NA_SYNCHRONIZE_IS_FAST;

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/opt.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/opt.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/opt.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/opt.c Tue Jun 26 19:26:49 2012
@@ -1041,6 +1041,20 @@ svn_opt__arg_canonicalize_url(const char
   /* Auto-escape some ASCII characters. */
   target = svn_path_uri_autoescape(target, pool);
 
+#if '/' != SVN_PATH_LOCAL_SEPARATOR
+  /* Allow using file:///C:\users\me/repos on Windows, like we did in 1.6 */
+  if (strchr(target, SVN_PATH_LOCAL_SEPARATOR))
+    {
+      char *p = apr_pstrdup(pool, target);
+      target = p;
+
+      /* Convert all local-style separators to the canonical ones. */
+      for (; *p != '\0'; ++p)
+        if (*p == SVN_PATH_LOCAL_SEPARATOR)
+          *p = '/';
+    }
+#endif
+
   /* Verify that no backpaths are present in the URL. */
   if (svn_path_is_backpath_present(target))
     return svn_error_createf(SVN_ERR_BAD_URL, 0,

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/path.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/path.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/path.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/path.c Tue Jun 26 19:26:49 2012
@@ -399,8 +399,8 @@ svn_path_compare_paths(const char *path1
   apr_size_t min_len = ((path1_len < path2_len) ? path1_len : path2_len);
   apr_size_t i = 0;
 
-  assert(is_canonical(path1, strlen(path1)));
-  assert(is_canonical(path2, strlen(path2)));
+  assert(is_canonical(path1, path1_len));
+  assert(is_canonical(path2, path2_len));
 
   /* Skip past common prefix. */
   while (i < min_len && path1[i] == path2[i])
@@ -1102,15 +1102,19 @@ svn_path_cstring_from_utf8(const char **
                            const char *path_utf8,
                            apr_pool_t *pool)
 {
+#if !defined(WIN32) && !defined(DARWIN)
   svn_boolean_t path_is_utf8;
   SVN_ERR(get_path_encoding(&path_is_utf8, pool));
   if (path_is_utf8)
+#endif
     {
       *path_apr = apr_pstrdup(pool, path_utf8);
       return SVN_NO_ERROR;
     }
+#if !defined(WIN32) && !defined(DARWIN)
   else
     return svn_utf_cstring_from_utf8(path_apr, path_utf8, pool);
+#endif
 }
 
 
@@ -1119,15 +1123,19 @@ svn_path_cstring_to_utf8(const char **pa
                          const char *path_apr,
                          apr_pool_t *pool)
 {
+#if !defined(WIN32) && !defined(DARWIN)
   svn_boolean_t path_is_utf8;
   SVN_ERR(get_path_encoding(&path_is_utf8, pool));
   if (path_is_utf8)
+#endif
     {
       *path_utf8 = apr_pstrdup(pool, path_apr);
       return SVN_NO_ERROR;
     }
+#if !defined(WIN32) && !defined(DARWIN)
   else
     return svn_utf_cstring_to_utf8(path_utf8, path_apr, pool);
+#endif
 }
 
 
@@ -1160,8 +1168,8 @@ illegal_path_escape(const char *path, ap
         svn_stringbuf_appendbytes(retstr, path + copied,
                                   i - copied);
 
-      /* Make sure buffer is big enough for '\' 'N' 'N' 'N' null */
-      svn_stringbuf_ensure(retstr, retstr->len + 5);
+      /* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
+      svn_stringbuf_ensure(retstr, retstr->len + 4);
       /*### 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) */

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/pool.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/pool.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/pool.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/pool.c Tue Jun 26 19:26:49 2012
@@ -53,6 +53,7 @@ abort_on_pool_failure(int retcode)
      And we don't have any of it... */
   printf("Out of memory - terminating application.\n");
   abort();
+  return 0; /* not reached */
 }
 
 

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/properties.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/properties.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/properties.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/properties.c Tue Jun 26 19:26:49 2012
@@ -122,7 +122,7 @@ svn_categorize_props(const apr_array_hea
       enum svn_prop_kind kind;
 
       prop = &APR_ARRAY_IDX(proplist, i, svn_prop_t);
-      kind = svn_property_kind(NULL, prop->name);
+      kind = svn_property_kind2(prop->name);
       newprop = NULL;
 
       if (kind == svn_prop_regular_kind)
@@ -305,7 +305,7 @@ svn_prop_hash_dup(apr_hash_t *hash,
       void *prop;
 
       apr_hash_this(hi, &key, &klen, &prop);
-      apr_hash_set(new_hash, apr_pstrdup(pool, key), klen,
+      apr_hash_set(new_hash, apr_pstrmemdup(pool, key, klen), klen,
                    svn_string_dup(prop, pool));
     }
   return new_hash;

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/quoprint.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/quoprint.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/quoprint.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/quoprint.c Tue Jun 26 19:26:49 2012
@@ -233,7 +233,7 @@ decode_bytes(svn_stringbuf_t *str, const
           find2 = strchr(hextab, inbuf[2]);
           if (find1 != NULL && find2 != NULL)
             {
-              c = ((find1 - hextab) << 4) | (find2 - hextab);
+              c = (char)(((find1 - hextab) << 4) | (find2 - hextab));
               svn_stringbuf_appendbyte(str, c);
             }
           *inbuflen = 0;

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/skel.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/skel.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/skel.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/skel.c Tue Jun 26 19:26:49 2012
@@ -136,41 +136,6 @@ getsize(const char *data, apr_size_t len
     }
 }
 
-/* Store the ASCII decimal representation of VALUE at DATA.  Return
-   the length of the representation if all goes well; return zero if
-   the result doesn't fit in LEN bytes.  */
-static apr_size_t
-putsize(char *data, apr_size_t len, apr_size_t value)
-{
-  apr_size_t i = 0;
-
-  /* Generate the digits, least-significant first.  */
-  do
-    {
-      if (i >= len)
-        return 0;
-
-      data[i] = (value % 10) + '0';
-      value /= 10;
-      i++;
-    }
-  while (value > 0);
-
-  /* Put the digits in most-significant-first order.  */
-  {
-    apr_size_t left, right;
-
-    for (left = 0, right = i-1; left < right; left++, right--)
-      {
-        char t = data[left];
-        data[left] = data[right];
-        data[right] = t;
-      }
-  }
-
-  return i;
-}
-
 
 /* Checking validity of skels. */
 static svn_error_t *
@@ -434,7 +399,7 @@ estimate_unparsed_size(const svn_skel_t 
     }
   else
     {
-      int total_len;
+      apr_size_t total_len;
       svn_skel_t *child;
 
       /* Allow space for opening and closing parens, and a space
@@ -491,17 +456,18 @@ unparse(const svn_skel_t *skel, svn_stri
         svn_stringbuf_appendbytes(str, skel->data, skel->len);
       else
         {
-          /* Append the length to STR.  */
-          char buf[200];
+          /* Append the length to STR.  Ensure enough space for at least
+           * one 64 bit int. */
+          char buf[200 + SVN_INT64_BUFFER_SIZE];
           apr_size_t length_len;
 
-          length_len = putsize(buf, sizeof(buf), skel->len);
+          length_len = svn__ui64toa(buf, skel->len);
 
           SVN_ERR_ASSERT_NO_RETURN(length_len > 0);
 
           /* Make sure we have room for the length, the space, and the
              atom's contents.  */
-          svn_stringbuf_ensure(str, str->len + length_len + 1 + skel->len + 1);
+          svn_stringbuf_ensure(str, str->len + length_len + 1 + skel->len);
           svn_stringbuf_appendbytes(str, buf, length_len);
           svn_stringbuf_appendbyte(str, ' ');
           svn_stringbuf_appendbytes(str, skel->data, skel->len);

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/spillbuf.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/spillbuf.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/spillbuf.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/spillbuf.c Tue Jun 26 19:26:49 2012
@@ -291,7 +291,7 @@ read_data(struct memblock_t **mem,
   /* NOTE: mem's size/next are uninitialized.  */
 
   if (buf->spill_size < buf->blocksize)
-    (*mem)->size = buf->spill_size;
+    (*mem)->size = (apr_size_t)buf->spill_size;
   else
     (*mem)->size = buf->blocksize;  /* The size of (*mem)->data  */
   (*mem)->next = NULL;

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/sqlite.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/sqlite.c Tue Jun 26 19:26:49 2012
@@ -50,8 +50,8 @@
   #include <sqlite3.h>
 #endif
 
-#if !SQLITE_VERSION_AT_LEAST(3,6,18)
-#error SQLite is too old -- version 3.6.18 is the minimum required version
+#if !SQLITE_VERSION_AT_LEAST(3,7,12)
+#error SQLite is too old -- version 3.7.12 is the minimum required version
 #endif
 
 INTERNAL_STATEMENTS_SQL_DECLARE_STATEMENTS(internal_statements);
@@ -84,7 +84,6 @@ struct svn_sqlite__db_t
   int nbr_statements;
   svn_sqlite__stmt_t **prepared_stmts;
   apr_pool_t *state_pool;
-  unsigned savepoint_nr;
 };
 
 struct svn_sqlite__stmt_t
@@ -204,6 +203,29 @@ svn_sqlite__get_statement(svn_sqlite__st
   return SVN_NO_ERROR;
 }
 
+/* Like svn_sqlite__get_statement but gets an internal statement.
+
+   All internal statements that use this api are executed with step_done(),
+   so we don't need the fallback reset handling here or in the pool cleanup */
+static svn_error_t *
+get_internal_statement(svn_sqlite__stmt_t **stmt, svn_sqlite__db_t *db,
+                       int stmt_idx)
+{
+  /* The internal statements are stored after the registered statements */
+  int prep_idx = db->nbr_statements + stmt_idx;
+  SVN_ERR_ASSERT(stmt_idx < STMT_INTERNAL_LAST);
+
+  if (db->prepared_stmts[prep_idx] == NULL)
+    SVN_ERR(prepare_statement(&db->prepared_stmts[prep_idx], db,
+                              internal_statements[stmt_idx],
+                              db->state_pool));
+
+  *stmt = db->prepared_stmts[prep_idx];
+
+  return SVN_NO_ERROR;
+}
+
+
 static svn_error_t *
 step_with_expectation(svn_sqlite__stmt_t* stmt,
                       svn_boolean_t expecting_row)
@@ -300,7 +322,13 @@ vbindf(svn_sqlite__stmt_t *stmt, const c
                                           va_arg(ap, const char *)));
             break;
 
+          case 'd':
+            SVN_ERR(svn_sqlite__bind_int(stmt, count,
+                                         va_arg(ap, int)));
+            break;
+
           case 'i':
+          case 'L':
             SVN_ERR(svn_sqlite__bind_int64(stmt, count,
                                            va_arg(ap, apr_int64_t)));
             break;
@@ -657,16 +685,14 @@ internal_open(sqlite3 **db3, const char 
     else
       SVN_ERR_MALFUNCTION();
 
-    /* If this flag is defined (3.6.x), then let's turn off SQLite's mutexes.
-       All svn objects are single-threaded, so we can already guarantee that
-       our use of the SQLite handle will be serialized properly.
+    /* Turn off SQLite's mutexes. All svn objects are single-threaded,
+       so we can already guarantee that our use of the SQLite handle
+       will be serialized properly.
 
        Note: in 3.6.x, we've already config'd SQLite into MULTITHREAD mode,
        so this is probably redundant, but if we are running in a process where
        somebody initialized SQLite before us it is needed anyway.  */
-#ifdef SQLITE_OPEN_NOMUTEX
     flags |= SQLITE_OPEN_NOMUTEX;
-#endif
 
     /* Open the database. Note that a handle is returned, even when an error
        occurs (except for out-of-memory); thus, we can safely use it to
@@ -736,6 +762,15 @@ close_apr(void *data)
                         svn_sqlite__finalize(db->prepared_stmts[i]), err);
         }
     }
+  /* And finalize any used internal statements */
+  for (; i < db->nbr_statements + STMT_INTERNAL_LAST; i++)
+    {
+      if (db->prepared_stmts[i])
+        {
+          err = svn_error_compose_create(
+                        svn_sqlite__finalize(db->prepared_stmts[i]), err);
+        }
+    }
 
   result = sqlite3_close(db->db3);
 
@@ -776,23 +811,9 @@ svn_sqlite__open(svn_sqlite__db_t **db, 
   sqlite3_profile((*db)->db3, sqlite_profiler, (*db)->db3);
 #endif
 
-  /* Work around a bug in SQLite 3.7.7.  The bug was fixed in SQLite 3.7.7.1.
-
-     See:
-
-       Date: Sun, 26 Jun 2011 18:52:14 -0400
-       From: Richard Hipp <dr...@sqlite.org>
-       To: General Discussion of SQLite Database <sq...@sqlite.org>
-       Cc: dev@subversion.apache.org
-       Subject: Re: [sqlite] PRAGMA bug in 3.7.7 (but fine in 3.7.6.3)
-       Message-ID: <BA...@mail.gmail.com>
-   */
+  /* ### simplify this. remnants of some old SQLite compat code.  */
   {
     int ignored_err = SQLITE_OK;
-#if !SQLITE_VERSION_AT_LEAST(3,7,8) && defined(SQLITE_SCHEMA)
-    if (!strcmp(sqlite3_libversion(), "3.7.7"))
-      ignored_err = SQLITE_SCHEMA;
-#endif
 
     SVN_ERR(exec_sql2(*db, "PRAGMA case_sensitive_like=1;", ignored_err));
   }
@@ -816,7 +837,7 @@ svn_sqlite__open(svn_sqlite__db_t **db, 
                  Requires SQLite >= 3.6.18  */
               "PRAGMA recursive_triggers=ON;"));
 
-#if SQLITE_VERSION_AT_LEAST(3,6,19) && defined(SVN_DEBUG)
+#if defined(SVN_DEBUG)
   /* When running in debug mode, enable the checking of foreign key
      constraints.  This has possible performance implications, so we don't
      bother to do it for production...for now. */
@@ -838,11 +859,19 @@ svn_sqlite__open(svn_sqlite__db_t **db, 
           statements++;
           (*db)->nbr_statements++;
         }
-      (*db)->prepared_stmts = apr_pcalloc(result_pool, (*db)->nbr_statements
+
+      (*db)->prepared_stmts = apr_pcalloc(
+                                  result_pool,
+                                  ((*db)->nbr_statements + STMT_INTERNAL_LAST)
                                                 * sizeof(svn_sqlite__stmt_t *));
     }
   else
-    (*db)->nbr_statements = 0;
+    {
+      (*db)->nbr_statements = 0;
+      (*db)->prepared_stmts = apr_pcalloc(result_pool,
+                                          (0 + STMT_INTERNAL_LAST)
+                                                * sizeof(svn_sqlite__stmt_t *));
+    }
 
   (*db)->state_pool = result_pool;
   apr_pool_cleanup_register(result_pool, *db, close_apr, apr_pool_cleanup_null);
@@ -891,6 +920,7 @@ with_transaction(svn_sqlite__db_t *db,
                  void *cb_baton,
                  apr_pool_t *scratch_pool /* NULL allowed */)
 {
+  svn_sqlite__stmt_t *stmt;
   svn_error_t *err;
 
   err = cb_func(cb_baton, db, scratch_pool);
@@ -898,7 +928,12 @@ with_transaction(svn_sqlite__db_t *db,
   /* Commit or rollback the sqlite transaction. */
   if (err)
     {
-      svn_error_t *err2 = exec_sql(db, "ROLLBACK TRANSACTION;");
+      svn_error_t *err2;
+
+      err2 = get_internal_statement(&stmt, db,
+                                    STMT_INTERNAL_ROLLBACK_TRANSACTION);
+      if (!err2)
+        err2 = svn_sqlite__step_done(stmt);
 
       if (err2 && err2->apr_err == SVN_ERR_SQLITE_BUSY)
         {
@@ -923,7 +958,7 @@ with_transaction(svn_sqlite__db_t *db,
 
           err2 = reset_all_statements(db, err2);
           err2 = svn_error_compose_create(
-                      exec_sql(db, "ROLLBACK TRANSACTION;"),
+                      svn_sqlite__step_done(stmt),
                       err2);
         }
 
@@ -931,7 +966,8 @@ with_transaction(svn_sqlite__db_t *db,
                                       err2);
     }
 
-  return svn_error_trace(exec_sql(db, "COMMIT TRANSACTION;"));
+  SVN_ERR(get_internal_statement(&stmt, db, STMT_INTERNAL_COMMIT_TRANSACTION));
+  return svn_error_trace(svn_sqlite__step_done(stmt));
 }
 
 svn_error_t *
@@ -940,7 +976,10 @@ svn_sqlite__with_transaction(svn_sqlite_
                              void *cb_baton,
                              apr_pool_t *scratch_pool /* NULL allowed */)
 {
-  SVN_ERR(exec_sql(db, "BEGIN TRANSACTION;"));
+  svn_sqlite__stmt_t *stmt;
+  SVN_ERR(get_internal_statement(&stmt, db,
+                                 STMT_INTERNAL_BEGIN_TRANSACTION));
+  SVN_ERR(svn_sqlite__step_done(stmt));
   return svn_error_trace(with_transaction(db, cb_func, cb_baton,
                                           scratch_pool));
 }
@@ -952,7 +991,10 @@ svn_sqlite__with_immediate_transaction(
   void *cb_baton,
   apr_pool_t *scratch_pool /* NULL allowed */)
 {
-  SVN_ERR(exec_sql(db, "BEGIN IMMEDIATE TRANSACTION;"));
+  svn_sqlite__stmt_t *stmt;
+  SVN_ERR(get_internal_statement(&stmt, db,
+                                 STMT_INTERNAL_BEGIN_IMMEDIATE_TRANSACTION));
+  SVN_ERR(svn_sqlite__step_done(stmt));
   return svn_error_trace(with_transaction(db, cb_func, cb_baton,
                                           scratch_pool));
 }
@@ -964,20 +1006,21 @@ svn_sqlite__with_lock(svn_sqlite__db_t *
                       apr_pool_t *scratch_pool)
 {
   svn_error_t *err;
-  int savepoint = db->savepoint_nr++;
-  /* This buffer is plenty big to hold the SAVEPOINT and RELEASE commands. */
-  char buf[32];
+  svn_sqlite__stmt_t *stmt;
 
-  snprintf(buf, sizeof(buf), "SAVEPOINT s%u", savepoint);
-  SVN_ERR(exec_sql(db, buf));
+  SVN_ERR(get_internal_statement(&stmt, db, STMT_INTERNAL_SAVEPOINT_SVN));
+  SVN_ERR(svn_sqlite__step_done(stmt));
   err = cb_func(cb_baton, db, scratch_pool);
 
   if (err)
     {
       svn_error_t *err2;
 
-      snprintf(buf, sizeof(buf), "ROLLBACK TO s%u", savepoint);
-      err2 = exec_sql(db, buf);
+      err2 = get_internal_statement(&stmt, db,
+                                    STMT_INTERNAL_ROLLBACK_TO_SAVEPOINT_SVN);
+
+      if (!err2)
+        err2 = svn_sqlite__step_done(stmt);
 
       if (err2 && err2->apr_err == SVN_ERR_SQLITE_BUSY)
         {
@@ -988,17 +1031,23 @@ svn_sqlite__with_lock(svn_sqlite__db_t *
                  further details */
 
           err2 = reset_all_statements(db, err2);
-          err2 = svn_error_compose_create(exec_sql(db, buf), err2);
+          err2 = svn_error_compose_create(svn_sqlite__step_done(stmt), err2);
         }
 
-      snprintf(buf, sizeof(buf), "RELEASE   s%u", savepoint);
-      err2 = svn_error_compose_create(exec_sql(db, buf), err2);
+      err = svn_error_compose_create(err, err2);
+      err2 = get_internal_statement(&stmt, db,
+                                    STMT_INTERNAL_RELEASE_SAVEPOINT_SVN);
+
+      if (!err2)
+        err2 = svn_sqlite__step_done(stmt);
 
       return svn_error_trace(svn_error_compose_create(err, err2));
     }
 
-  snprintf(buf, sizeof(buf), "RELEASE   s%u", savepoint);
-  return svn_error_trace(exec_sql(db, buf));
+  SVN_ERR(get_internal_statement(&stmt, db,
+                                 STMT_INTERNAL_RELEASE_SAVEPOINT_SVN));
+
+  return svn_error_trace(svn_sqlite__step_done(stmt));
 }
 
 svn_error_t *
@@ -1009,7 +1058,7 @@ svn_sqlite__hotcopy(const char *src_path
   svn_sqlite__db_t *src_db;
 
   SVN_ERR(svn_sqlite__open(&src_db, src_path, svn_sqlite__mode_readonly,
-                           internal_statements, 0, NULL,
+                           NULL, 0, NULL,
                            scratch_pool, scratch_pool));
 
   {
@@ -1067,13 +1116,15 @@ wrapped_func(sqlite3_context *context,
              sqlite3_value *values[])
 {
   struct function_wrapper_baton_t *fwb = sqlite3_user_data(context);
-  svn_sqlite__context_t sctx = { context };
+  svn_sqlite__context_t sctx;
   svn_sqlite__value_t **local_vals =
                             apr_palloc(fwb->scratch_pool,
                                        sizeof(svn_sqlite__value_t *) * argc);
   svn_error_t *err;
   int i;
 
+  sctx.context = context;
+
   for (i = 0; i < argc; i++)
     {
       local_vals[i] = apr_palloc(fwb->scratch_pool, sizeof(*local_vals[i]));

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/stream.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/stream.c Tue Jun 26 19:26:49 2012
@@ -140,7 +140,7 @@ svn_error_t *
 svn_stream_read(svn_stream_t *stream, char *buffer, apr_size_t *len)
 {
   SVN_ERR_ASSERT(stream->read_fn != NULL);
-  return stream->read_fn(stream->baton, buffer, len);
+  return svn_error_trace(stream->read_fn(stream->baton, buffer, len));
 }
 
 
@@ -148,9 +148,10 @@ svn_error_t *
 svn_stream_skip(svn_stream_t *stream, apr_size_t len)
 {
   if (stream->skip_fn == NULL)
-    return skip_default_handler(stream->baton, len, stream->read_fn);
+    return svn_error_trace(
+            skip_default_handler(stream->baton, len, stream->read_fn));
 
-  return stream->skip_fn(stream->baton, len);
+  return svn_error_trace(stream->skip_fn(stream->baton, len));
 }
 
 
@@ -158,7 +159,7 @@ svn_error_t *
 svn_stream_write(svn_stream_t *stream, const char *data, apr_size_t *len)
 {
   SVN_ERR_ASSERT(stream->write_fn != NULL);
-  return stream->write_fn(stream->baton, data, len);
+  return svn_error_trace(stream->write_fn(stream->baton, data, len));
 }
 
 
@@ -182,7 +183,7 @@ svn_stream_mark(svn_stream_t *stream, sv
   if (stream->mark_fn == NULL)
     return svn_error_create(SVN_ERR_STREAM_SEEK_NOT_SUPPORTED, NULL, NULL);
 
-  return stream->mark_fn(stream->baton, mark, pool);
+  return svn_error_trace(stream->mark_fn(stream->baton, mark, pool));
 }
 
 svn_error_t *
@@ -191,7 +192,7 @@ svn_stream_seek(svn_stream_t *stream, co
   if (stream->seek_fn == NULL)
     return svn_error_create(SVN_ERR_STREAM_SEEK_NOT_SUPPORTED, NULL, NULL);
 
-  return stream->seek_fn(stream->baton, mark);
+  return svn_error_trace(stream->seek_fn(stream->baton, mark));
 }
 
 svn_boolean_t
@@ -208,9 +209,17 @@ svn_stream_close(svn_stream_t *stream)
 {
   if (stream->close_fn == NULL)
     return SVN_NO_ERROR;
-  return stream->close_fn(stream->baton);
+  return svn_error_trace(stream->close_fn(stream->baton));
 }
 
+svn_error_t *
+svn_stream_puts(svn_stream_t *stream,
+                const char *str)
+{
+  apr_size_t len;
+  len = strlen(str);
+  return svn_error_trace(svn_stream_write(stream, str, &len));
+}
 
 svn_error_t *
 svn_stream_printf(svn_stream_t *stream,
@@ -220,20 +229,12 @@ svn_stream_printf(svn_stream_t *stream,
 {
   const char *message;
   va_list ap;
-  apr_size_t len;
 
-  /* any format controls or is this a static string? */
-  if (strchr(fmt, '%'))
-    {
-      va_start(ap, fmt);
-      message = apr_pvsprintf(pool, fmt, ap);
-      va_end(ap);
-    }
-  else
-    message = fmt;
+  va_start(ap, fmt);
+  message = apr_pvsprintf(pool, fmt, ap);
+  va_end(ap);
 
-  len = strlen(message);
-  return svn_stream_write(stream, message, &len);
+  return svn_error_trace(svn_stream_puts(stream, message));
 }
 
 
@@ -246,7 +247,6 @@ svn_stream_printf_from_utf8(svn_stream_t
 {
   const char *message, *translated;
   va_list ap;
-  apr_size_t len;
 
   va_start(ap, fmt);
   message = apr_pvsprintf(pool, fmt, ap);
@@ -255,9 +255,7 @@ svn_stream_printf_from_utf8(svn_stream_t
   SVN_ERR(svn_utf_cstring_from_utf8_ex2(&translated, message, encoding,
                                         pool));
 
-  len = strlen(translated);
-
-  return svn_stream_write(stream, translated, &len);
+  return svn_error_trace(svn_stream_puts(stream, translated));
 }
 
 /* Size that 90% of the lines we encounter will be not longer than.
@@ -382,7 +380,7 @@ stream_readline_chunky(svn_stringbuf_t *
       {
         /* Append the next chunk to the string read so far.
          */
-        svn_stringbuf_ensure(str, str->len + LINE_CHUNK_SIZE + 1);
+        svn_stringbuf_ensure(str, str->len + LINE_CHUNK_SIZE);
         numbytes = LINE_CHUNK_SIZE;
         SVN_ERR(svn_stream_read(stream, str->data + str->len, &numbytes));
         str->len += numbytes;
@@ -417,7 +415,7 @@ stream_readline_chunky(svn_stringbuf_t *
   /* Move the stream read pointer to the first position behind the EOL.
    */
   SVN_ERR(svn_stream_seek(stream, mark));
-  return svn_stream_skip(stream, total_parsed);
+  return svn_error_trace(svn_stream_skip(stream, total_parsed));
 }
 
 /* Guts of svn_stream_readline().
@@ -686,31 +684,31 @@ svn_stream_tee(svn_stream_t *out1,
 static svn_error_t *
 read_handler_disown(void *baton, char *buffer, apr_size_t *len)
 {
-  return svn_stream_read(baton, buffer, len);
+  return svn_error_trace(svn_stream_read(baton, buffer, len));
 }
 
 static svn_error_t *
 skip_handler_disown(void *baton, apr_size_t len)
 {
-  return svn_stream_skip(baton, len);
+  return svn_error_trace(svn_stream_skip(baton, len));
 }
 
 static svn_error_t *
 write_handler_disown(void *baton, const char *buffer, apr_size_t *len)
 {
-  return svn_stream_write(baton, buffer, len);
+  return svn_error_trace(svn_stream_write(baton, buffer, len));
 }
 
 static svn_error_t *
 mark_handler_disown(void *baton, svn_stream_mark_t **mark, apr_pool_t *pool)
 {
-  return svn_stream_mark(baton, mark, pool);
+  return svn_error_trace(svn_stream_mark(baton, mark, pool));
 }
 
 static svn_error_t *
 seek_handler_disown(void *baton, const svn_stream_mark_t *mark)
 {
-  return svn_stream_seek(baton, mark);
+  return svn_error_trace(svn_stream_seek(baton, mark));
 }
 
 static svn_boolean_t
@@ -771,7 +769,7 @@ read_handler_apr(void *baton, char *buff
     err = svn_io_file_read_full2(btn->file, buffer, *len, len,
                                  &eof, btn->pool);
 
-  return err;
+  return svn_error_trace(err);
 }
 
 static svn_error_t *
@@ -780,7 +778,8 @@ skip_handler_apr(void *baton, apr_size_t
   struct baton_apr *btn = baton;
   apr_off_t offset = len;
 
-  return svn_io_file_seek(btn->file, APR_CUR, &offset, btn->pool);
+  return svn_error_trace(
+            svn_io_file_seek(btn->file, APR_CUR, &offset, btn->pool));
 }
 
 static svn_error_t *
@@ -798,7 +797,7 @@ write_handler_apr(void *baton, const cha
   else
     err = svn_io_file_write_full(btn->file, data, *len, len, btn->pool);
 
-  return err;
+  return svn_error_trace(err);
 }
 
 static svn_error_t *
@@ -806,7 +805,7 @@ close_handler_apr(void *baton)
 {
   struct baton_apr *btn = baton;
 
-  return svn_io_file_close(btn->file, btn->pool);
+  return svn_error_trace(svn_io_file_close(btn->file, btn->pool));
 }
 
 static svn_error_t *
@@ -1133,7 +1132,7 @@ close_handler_gz(void *baton)
     }
 
   if (btn->close != NULL)
-    return btn->close(btn->subbaton);
+    return svn_error_trace(btn->close(btn->subbaton));
   else
     return SVN_NO_ERROR;
 }
@@ -1208,7 +1207,7 @@ write_handler_checksum(void *baton, cons
   if (btn->write_checksum && *len > 0)
     SVN_ERR(svn_checksum_update(btn->write_ctx, buffer, *len));
 
-  return svn_stream_write(btn->proxy, buffer, len);
+  return svn_error_trace(svn_stream_write(btn->proxy, buffer, len));
 }
 
 
@@ -1237,7 +1236,7 @@ close_handler_checksum(void *baton)
   if (btn->write_ctx)
     SVN_ERR(svn_checksum_final(btn->write_checksum, btn->write_ctx, btn->pool));
 
-  return svn_stream_close(btn->proxy);
+  return svn_error_trace(svn_stream_close(btn->proxy));
 }
 
 
@@ -1293,21 +1292,21 @@ static svn_error_t *
 read_handler_md5(void *baton, char *buffer, apr_size_t *len)
 {
   struct md5_stream_baton *btn = baton;
-  return svn_stream_read(btn->proxy, buffer, len);
+  return svn_error_trace(svn_stream_read(btn->proxy, buffer, len));
 }
 
 static svn_error_t *
 skip_handler_md5(void *baton, apr_size_t len)
 {
   struct md5_stream_baton *btn = baton;
-  return svn_stream_skip(btn->proxy, len);
+  return svn_error_trace(svn_stream_skip(btn->proxy, len));
 }
 
 static svn_error_t *
 write_handler_md5(void *baton, const char *buffer, apr_size_t *len)
 {
   struct md5_stream_baton *btn = baton;
-  return svn_stream_write(btn->proxy, buffer, len);
+  return svn_error_trace(svn_stream_write(btn->proxy, buffer, len));
 }
 
 static svn_error_t *
@@ -1662,3 +1661,147 @@ svn_stream_buffered(apr_pool_t *result_p
   return svn_stream__from_spillbuf(BUFFER_BLOCK_SIZE, BUFFER_MAX_SIZE,
                                    result_pool);
 }
+
+
+
+/*** Lazyopen Streams ***/
+
+/* Custom baton for lazyopen-style wrapper streams. */
+typedef struct lazyopen_baton_t {
+
+  /* Callback function and baton for opening the wrapped stream. */
+  svn_stream_lazyopen_func_t open_func;
+  void *open_baton;
+
+  /* The wrapped stream, or NULL if the stream hasn't yet been
+     opened. */
+  svn_stream_t *real_stream;
+  apr_pool_t *pool;
+
+} lazyopen_baton_t;
+
+
+/* Use B->open_func/baton to create and set B->real_stream iff it
+   isn't already set. */
+static svn_error_t *
+lazyopen_if_unopened(lazyopen_baton_t *b)
+{
+  if (b->real_stream == NULL)
+    {
+      svn_stream_t *stream;
+      apr_pool_t *scratch_pool = svn_pool_create(b->pool);
+
+      SVN_ERR(b->open_func(&stream, b->open_baton,
+                           b->pool, scratch_pool));
+
+      svn_pool_destroy(scratch_pool);
+
+      b->real_stream = stream;
+    }
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_read_fn_t */
+static svn_error_t *
+read_handler_lazyopen(void *baton,
+                      char *buffer,
+                      apr_size_t *len)
+{
+  lazyopen_baton_t *b = baton;
+
+  SVN_ERR(lazyopen_if_unopened(b));
+  SVN_ERR(svn_stream_read(b->real_stream, buffer, len));
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_stream_skip_fn_t */
+static svn_error_t *
+skip_handler_lazyopen(void *baton,
+                      apr_size_t len)
+{
+  lazyopen_baton_t *b = baton;
+
+  SVN_ERR(lazyopen_if_unopened(b));
+  SVN_ERR(svn_stream_skip(b->real_stream, len));
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_write_fn_t */
+static svn_error_t *
+write_handler_lazyopen(void *baton,
+                       const char *data,
+                       apr_size_t *len)
+{
+  lazyopen_baton_t *b = baton;
+
+  SVN_ERR(lazyopen_if_unopened(b));
+  SVN_ERR(svn_stream_write(b->real_stream, data, len));
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_close_fn_t */
+static svn_error_t *
+close_handler_lazyopen(void *baton)
+{
+  lazyopen_baton_t *b = baton;
+
+  if (b->real_stream != NULL)
+    SVN_ERR(svn_stream_close(b->real_stream));
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_stream_mark_fn_t */
+static svn_error_t *
+mark_handler_lazyopen(void *baton,
+                      svn_stream_mark_t **mark,
+                      apr_pool_t *pool)
+{
+  lazyopen_baton_t *b = baton;
+
+  SVN_ERR(lazyopen_if_unopened(b));
+  SVN_ERR(svn_stream_mark(b->real_stream, mark, pool));
+
+  return SVN_NO_ERROR;
+}
+
+/* Implements svn_stream_seek_fn_t */
+static svn_error_t *
+seek_handler_lazyopen(void *baton,
+                      const svn_stream_mark_t *mark)
+{
+  lazyopen_baton_t *b = baton;
+
+  SVN_ERR(lazyopen_if_unopened(b));
+  SVN_ERR(svn_stream_seek(b->real_stream, mark));
+
+  return SVN_NO_ERROR;
+}
+
+svn_stream_t *
+svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func,
+                           void *open_baton,
+                           apr_pool_t *result_pool)
+{
+  lazyopen_baton_t *lob = apr_pcalloc(result_pool, sizeof(*lob));
+  svn_stream_t *stream;
+
+  lob->open_func = open_func;
+  lob->open_baton = open_baton;
+  lob->real_stream = NULL;
+  lob->pool = result_pool;
+
+  stream = svn_stream_create(lob, result_pool);
+  svn_stream_set_read(stream, read_handler_lazyopen);
+  svn_stream_set_skip(stream, skip_handler_lazyopen);
+  svn_stream_set_write(stream, write_handler_lazyopen);
+  svn_stream_set_close(stream, close_handler_lazyopen);
+  svn_stream_set_mark(stream, mark_handler_lazyopen);
+  svn_stream_set_seek(stream, seek_handler_lazyopen);
+  
+  return stream;
+}

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/string.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/string.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/string.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/string.c Tue Jun 26 19:26:49 2012
@@ -1,6 +1,6 @@
 /*
- * svn_string.c:  routines to manipulate counted-length strings
- *                (svn_stringbuf_t and svn_string_t) and C strings.
+ * string.c:  routines to manipulate counted-length strings
+ *            (svn_stringbuf_t and svn_string_t) and C strings.
  *
  *
  * ====================================================================
@@ -407,7 +407,7 @@ svn_stringbuf_set(svn_stringbuf_t *str, 
 {
   apr_size_t amt = strlen(value);
 
-  svn_stringbuf_ensure(str, amt + 1);
+  svn_stringbuf_ensure(str, amt);
   memcpy(str->data, value, amt + 1);
   str->len = amt;
 }
@@ -549,8 +549,8 @@ svn_stringbuf_appendbytes(svn_stringbuf_
 
   total_len = str->len + count;  /* total size needed */
 
-  /* +1 for null terminator. */
-  svn_stringbuf_ensure(str, (total_len + 1));
+  /* svn_stringbuf_ensure adds 1 for null terminator. */
+  svn_stringbuf_ensure(str, total_len);
 
   /* get address 1 byte beyond end of original bytestring */
   start_address = (str->data + str->len);
@@ -937,16 +937,8 @@ static const char decimal_table[100][4]
       , "90", "91", "92", "93", "94", "95", "96", "97", "98", "99"};
 
 /* Copy the two bytes at SOURCE[0] and SOURCE[1] to DEST[0] and DEST[1] */
-#if SVN_UNALIGNED_ACCESS_IS_OK
-#  define COPY_TWO_BYTES(dest,source)\
-      *(apr_uint16_t*)(dest) = *(apr_uint16_t*)(source);
-#else
-#  define COPY_TWO_BYTES(dest,source) \
-    do { \
-      (dest)[0] = (source)[0]; \
-      (dest)[1] = (source)[1]; \
-    } while (0)
-#endif
+#define COPY_TWO_BYTES(dest,source)\
+  memcpy((dest), (source), 2)
 
 apr_size_t
 svn__ui64toa(char * dest, apr_uint64_t number)
@@ -984,7 +976,7 @@ svn__ui64toa(char * dest, apr_uint64_t n
       /* Number is larger than 100^4, i.e. we can write 4x2 chars.
        * Also, use 32 bit DIVs as these are about twice as fast.
        */
-      reduced = number % 100000000;
+      reduced = (apr_uint32_t)(number % 100000000);
       number /= 100000000;
 
       COPY_TWO_BYTES(target - 0, decimal_table[reduced % 100]);

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/temp_serializer.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/temp_serializer.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/temp_serializer.c Tue Jun 26 19:26:49 2012
@@ -72,7 +72,7 @@ struct svn_temp_serializer__context_t
   source_stack_t *source;
 };
 
-/* Mmake sure the serialized data len is a multiple of the default alignment,
+/* Make sure the serialized data len is a multiple of the default alignment,
  * i.e. structures may be appended without violating member alignment
  * guarantees.
  */
@@ -83,7 +83,7 @@ align_buffer_end(svn_temp_serializer__co
   apr_size_t aligned_len = APR_ALIGN_DEFAULT(current_len);
   if (aligned_len != current_len)
     {
-      svn_stringbuf_ensure(context->buffer, aligned_len+1);
+      svn_stringbuf_ensure(context->buffer, aligned_len);
       context->buffer->len = aligned_len;
     }
 }

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crashrpt.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crashrpt.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crashrpt.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crashrpt.c Tue Jun 26 19:26:49 2012
@@ -257,10 +257,10 @@ format_basic_type(char *buf, DWORD basic
   switch(length)
     {
       case 1:
-        sprintf(buf, "%x", *(unsigned char *)address);
+        sprintf(buf, "0x%02x", (int)*(unsigned char *)address);
         break;
       case 2:
-        sprintf(buf, "%x", *(unsigned short *)address);
+        sprintf(buf, "0x%04x", (int)*(unsigned short *)address);
         break;
       case 4:
         switch(basic_type)
@@ -270,7 +270,7 @@ format_basic_type(char *buf, DWORD basic
                 if (!IsBadStringPtr(*(PSTR*)address, 32))
                   sprintf(buf, "\"%.31s\"", *(unsigned long *)address);
                 else
-                  sprintf(buf, "%x", *(unsigned long *)address);
+                  sprintf(buf, "0x%08x", (int)*(unsigned long *)address);
               }
             case 6:  /* btInt */
               sprintf(buf, "%d", *(int *)address);
@@ -279,7 +279,7 @@ format_basic_type(char *buf, DWORD basic
               sprintf(buf, "%f", *(float *)address);
               break;
             default:
-              sprintf(buf, "%x", *(unsigned long *)address);
+              sprintf(buf, "0x%08x", *(unsigned long *)address);
               break;
           }
         break;
@@ -287,7 +287,10 @@ format_basic_type(char *buf, DWORD basic
         if (basic_type == 8) /* btFloat */
           sprintf(buf, "%lf", *(double *)address);
         else
-          sprintf(buf, "%I64X", *(unsigned __int64 *)address);
+          sprintf(buf, "0x%016I64X", *(unsigned __int64 *)address);
+        break;
+      default:
+        sprintf(buf, "[unhandled type 0x%08x of length 0x%08x]", basic_type, length);
         break;
     }
 }
@@ -297,7 +300,7 @@ format_basic_type(char *buf, DWORD basic
 static void
 format_value(char *value_str, DWORD64 mod_base, DWORD type, void *value_addr)
 {
-  DWORD tag;
+  DWORD tag = 0;
   int ptr = 0;
   HANDLE proc = GetCurrentProcess();
 
@@ -332,10 +335,12 @@ format_value(char *value_str, DWORD64 mo
                         type_name, *(DWORD *)value_addr);
               else
                 sprintf(value_str, "(%s **) 0x%08x",
-                        type_name, (DWORD *)value_addr);
+                        type_name, *(DWORD *)value_addr);
 
               free(type_name);
             }
+          else
+            sprintf(value_str, "[no symbol tag]");
         }
         break;
       case 16: /* SymTagBaseType */
@@ -349,17 +354,14 @@ format_value(char *value_str, DWORD64 mo
             {
               sprintf(value_str, "0x%08x \"%s\"",
                       *(DWORD *)value_addr, (char *)*(DWORD*)value_addr);
-              break;
             }
-          if (ptr >= 1)
+          else if (ptr >= 1)
             {
               sprintf(value_str, "0x%08x", *(DWORD *)value_addr);
-              break;
             }
-          if (SymGetTypeInfo_(proc, mod_base, type, TI_GET_BASETYPE, &bt))
+          else if (SymGetTypeInfo_(proc, mod_base, type, TI_GET_BASETYPE, &bt))
             {
               format_basic_type(value_str, bt, length, value_addr);
-              break;
             }
         }
         break;
@@ -369,7 +371,9 @@ format_value(char *value_str, DWORD64 mo
       case 13: /* SymTagFunctionType */
           sprintf(value_str, "0x%08x", *(DWORD *)value_addr);
           break;
-      default: break;
+      default:
+          sprintf(value_str, "[unhandled tag: %d]", tag);
+          break;
     }
 }
 

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crypto.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crypto.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crypto.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/win32_crypto.c Tue Jun 26 19:26:49 2012
@@ -64,7 +64,8 @@ encrypt_data(const svn_string_t *orig,
   if (CryptProtectData(&blobin, description, NULL, NULL, NULL,
                        CRYPTPROTECT_UI_FORBIDDEN, &blobout))
     {
-      crypted = svn_string_ncreate(blobout.pbData, blobout.cbData, pool);
+      crypted = svn_string_ncreate((const char *)blobout.pbData,
+                                   blobout.cbData, pool);
       LocalFree(blobout.pbData);
     }
   return crypted;
@@ -87,7 +88,8 @@ decrypt_data(const svn_string_t *crypted
                          CRYPTPROTECT_UI_FORBIDDEN, &blobout))
     {
       if (0 == lstrcmpW(descr, description))
-        orig = svn_string_ncreate(blobout.pbData, blobout.cbData, pool);
+        orig = svn_string_ncreate((const char *)blobout.pbData,
+                                  blobout.cbData, pool);
       LocalFree(blobout.pbData);
       LocalFree(descr);
     }

Modified: subversion/branches/inheritable-props/subversion/libsvn_subr/xml.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_subr/xml.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_subr/xml.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_subr/xml.c Tue Jun 26 19:26:49 2012
@@ -455,7 +455,7 @@ void svn_xml_signal_bailout(svn_error_t 
 /*** Attribute walking. ***/
 
 const char *
-svn_xml_get_attr_value(const char *name, const char **atts)
+svn_xml_get_attr_value(const char *name, const char *const *atts)
 {
   while (atts && (*atts))
     {

Modified: subversion/branches/inheritable-props/subversion/libsvn_wc/adm_crawler.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_wc/adm_crawler.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_wc/adm_crawler.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_wc/adm_crawler.c Tue Jun 26 19:26:49 2012
@@ -1206,7 +1206,10 @@ svn_wc__internal_transmit_prop_deltas(sv
   apr_array_header_t *propmods;
   svn_kind_t kind;
 
-  SVN_ERR(svn_wc__db_read_kind(&kind, db, local_abspath, FALSE, iterpool));
+  SVN_ERR(svn_wc__db_read_kind(&kind, db, local_abspath,
+                               FALSE /* allow_missing */,
+                               FALSE /* show_hidden */,
+                               iterpool));
 
   /* Get an array of local changes by comparing the hashes. */
   SVN_ERR(svn_wc__internal_propdiff(&propmods, NULL, db, local_abspath,

Modified: subversion/branches/inheritable-props/subversion/libsvn_wc/adm_files.c
URL: http://svn.apache.org/viewvc/subversion/branches/inheritable-props/subversion/libsvn_wc/adm_files.c?rev=1354186&r1=1354185&r2=1354186&view=diff
==============================================================================
--- subversion/branches/inheritable-props/subversion/libsvn_wc/adm_files.c (original)
+++ subversion/branches/inheritable-props/subversion/libsvn_wc/adm_files.c Tue Jun 26 19:26:49 2012
@@ -56,7 +56,7 @@ static const char default_adm_dir_name[]
 
 /* The name that is actually used for the WC admin directory.  The
    commonest case where this won't be the default is in Windows
-   ASP.NET development environments, which choke on ".svn". */
+   ASP.NET development environments, which used to choke on ".svn". */
 static const char *adm_dir_name = default_adm_dir_name;
 
 
@@ -108,43 +108,19 @@ svn_wc_set_adm_dir(const char *name, apr
 }
 
 
-static const char *
-simple_extend(const char *adm_path,  /* ### adm_abspath?  */
-              svn_boolean_t use_tmp,
-              const char *subdir,
-              const char *child,
-              const char *extension,
-              apr_pool_t *result_pool)
-{
-  if (subdir)
-    child = svn_dirent_join(subdir, child, result_pool);
-  if (extension)
-    child = apr_pstrcat(result_pool, child, extension, (char *)NULL);
-
-  if (use_tmp)
-    return svn_dirent_join_many(result_pool,
-                                adm_path,
-                                adm_dir_name,
-                                SVN_WC__ADM_TMP,
-                                child,
-                                NULL);
-
+const char *
+svn_wc__adm_child(const char *path,
+                  const char *child,
+                  apr_pool_t *result_pool)
+{
   return svn_dirent_join_many(result_pool,
-                              adm_path,
+                              path,
                               adm_dir_name,
                               child,
                               NULL);
 }
 
 
-const char *svn_wc__adm_child(const char *path,
-                              const char *child,
-                              apr_pool_t *result_pool)
-{
-  return simple_extend(path, FALSE, NULL, child, NULL, result_pool);
-}
-
-
 svn_boolean_t
 svn_wc__adm_area_exists(const char *adm_abspath,
                         apr_pool_t *pool)
@@ -173,12 +149,11 @@ svn_wc__adm_area_exists(const char *adm_
 static svn_error_t *
 make_adm_subdir(const char *path,
                 const char *subdir,
-                svn_boolean_t tmp,
                 apr_pool_t *pool)
 {
   const char *fullpath;
 
-  fullpath = simple_extend(path, tmp, NULL, subdir, NULL, pool);
+  fullpath = svn_wc__adm_child(path, subdir, pool);
 
   return svn_io_dir_make(fullpath, APR_OS_DEFAULT, pool);
 }
@@ -360,7 +335,7 @@ static svn_error_t *
 init_adm_tmp_area(const char *path, apr_pool_t *pool)
 {
   /* SVN_WC__ADM_TMP */
-  SVN_ERR(make_adm_subdir(path, SVN_WC__ADM_TMP, FALSE, pool));
+  SVN_ERR(make_adm_subdir(path, SVN_WC__ADM_TMP, pool));
 
   return SVN_NO_ERROR;
 }
@@ -387,7 +362,7 @@ init_adm(svn_wc__db_t *db,
   /** Make subdirectories. ***/
 
   /* SVN_WC__ADM_PRISTINE */
-  SVN_ERR(make_adm_subdir(local_abspath, SVN_WC__ADM_PRISTINE, FALSE, pool));
+  SVN_ERR(make_adm_subdir(local_abspath, SVN_WC__ADM_PRISTINE, pool));
 
   /* ### want to add another directory? do a format bump to ensure that
      ### all existing working copies get the new directories. or maybe
@@ -634,3 +609,16 @@ svn_wc_create_tmp_file2(apr_file_t **fp,
 
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_wc__get_tmpdir(const char **tmpdir_abspath,
+                   svn_wc_context_t *wc_ctx,
+                   const char *wri_abspath,
+                   apr_pool_t *result_pool,
+                   apr_pool_t *scratch_pool)
+{
+  SVN_ERR(svn_wc__db_temp_wcroot_tempdir(tmpdir_abspath,
+                                         wc_ctx->db, wri_abspath,
+                                         result_pool, scratch_pool));
+  return SVN_NO_ERROR;
+}