You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/09/09 17:59:02 UTC

svn commit: r995478 [1/2] - in /subversion/branches/performance: ./ subversion/bindings/javahl/native/ subversion/bindings/javahl/src/org/apache/subversion/javahl/ subversion/bindings/javahl/src/org/tigris/subversion/javahl/ subversion/bindings/javahl/...

Author: hwright
Date: Thu Sep  9 15:59:00 2010
New Revision: 995478

URL: http://svn.apache.org/viewvc?rev=995478&view=rev
Log:
On the performance branch:
Bring up-to-date with trunk.

Added:
    subversion/branches/performance/tools/dev/wc-format.py
      - copied unchanged from r995454, subversion/trunk/tools/dev/wc-format.py
Modified:
    subversion/branches/performance/   (props changed)
    subversion/branches/performance/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/branches/performance/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommitItem.java
    subversion/branches/performance/subversion/bindings/javahl/src/org/tigris/subversion/javahl/CommitItem.java
    subversion/branches/performance/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java
    subversion/branches/performance/subversion/include/private/svn_dep_compat.h
    subversion/branches/performance/subversion/include/private/svn_file_handle_cache.h   (props changed)
    subversion/branches/performance/subversion/include/private/svn_skel.h
    subversion/branches/performance/subversion/include/private/svn_temp_serializer.h   (props changed)
    subversion/branches/performance/subversion/include/svn_string.h
    subversion/branches/performance/subversion/libsvn_client/patch.c
    subversion/branches/performance/subversion/libsvn_diff/parse-diff.c
    subversion/branches/performance/subversion/libsvn_fs_base/util/fs_skels.c
    subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c
    subversion/branches/performance/subversion/libsvn_fs_fs/id.c
    subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c   (props changed)
    subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.h   (props changed)
    subversion/branches/performance/subversion/libsvn_fs_util/caching.c   (props changed)
    subversion/branches/performance/subversion/libsvn_ra_neon/util.c
    subversion/branches/performance/subversion/libsvn_ra_serf/serf.c
    subversion/branches/performance/subversion/libsvn_ra_serf/util.c
    subversion/branches/performance/subversion/libsvn_repos/reporter.c
    subversion/branches/performance/subversion/libsvn_subr/hash.c
    subversion/branches/performance/subversion/libsvn_subr/io.c
    subversion/branches/performance/subversion/libsvn_subr/skel.c
    subversion/branches/performance/subversion/libsvn_subr/svn_file_handle_cache.c   (props changed)
    subversion/branches/performance/subversion/libsvn_subr/svn_string.c
    subversion/branches/performance/subversion/libsvn_subr/svn_temp_serializer.c   (props changed)
    subversion/branches/performance/subversion/libsvn_wc/copy.c
    subversion/branches/performance/subversion/libsvn_wc/upgrade.c
    subversion/branches/performance/subversion/libsvn_wc/wc-queries.sql
    subversion/branches/performance/subversion/libsvn_wc/wc.h
    subversion/branches/performance/subversion/libsvn_wc/wc_db.c
    subversion/branches/performance/subversion/libsvn_wc/workqueue.c
    subversion/branches/performance/subversion/libsvn_wc/workqueue.h
    subversion/branches/performance/subversion/mod_dav_svn/reports/log.c
    subversion/branches/performance/subversion/mod_dav_svn/reports/replay.c
    subversion/branches/performance/subversion/svn/main.c
    subversion/branches/performance/subversion/tests/cmdline/copy_tests.py
    subversion/branches/performance/subversion/tests/cmdline/patch_tests.py
    subversion/branches/performance/subversion/tests/cmdline/revert_tests.py
    subversion/branches/performance/subversion/tests/cmdline/update_tests.py
    subversion/branches/performance/subversion/tests/cmdline/upgrade_tests.py
    subversion/branches/performance/tools/dev/unix-build/Makefile.svn
    subversion/branches/performance/tools/dev/wc-ng/bump-to-19.py

Propchange: subversion/branches/performance/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -36,4 +36,4 @@
 /subversion/branches/tc_url_rev:874351-874483
 /subversion/branches/tree-conflicts:868291-873154
 /subversion/branches/tree-conflicts-notify:873926-874008
-/subversion/trunk:962911-993127
+/subversion/trunk:962911-995462

Modified: subversion/branches/performance/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/bindings/javahl/native/CreateJ.cpp?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/branches/performance/subversion/bindings/javahl/native/CreateJ.cpp Thu Sep  9 15:59:00 2010
@@ -871,21 +871,8 @@ CreateJ::CommitItem(svn_client_commit_it
       midConstructor = env->GetMethodID(clazz, "<init>",
                                         "(Ljava/lang/String;"
                                         "L"JAVA_PACKAGE"/NodeKind;"
-                                        "ILjava/net/URI;"
-                                        "Ljava/net/URI;J)V");
-      if (JNIUtil::isExceptionThrown())
-        POP_AND_RETURN_NULL;
-    }
-
-  jclass clazz2 = env->FindClass("java/net/URI");
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN_NULL;
-
-  static jmethodID mid2 = 0;
-  if (mid2 == 0)
-    {
-      mid2 = env->GetMethodID(clazz2, "<init>",
-                              "(Ljava/lang/String;)V");
+                                        "ILjava/lang/String;"
+                                        "Ljava/lang/String;J)V");
       if (JNIUtil::isExceptionThrown())
         POP_AND_RETURN_NULL;
     }
@@ -913,23 +900,13 @@ CreateJ::CommitItem(svn_client_commit_it
     jstateFlags |=
       org_apache_subversion_javahl_CommitItemStateFlags_IsCopy;
 
-  jobject jurl = NULL;
-  if (item->url != NULL)
-    {
-      jurl = env->NewObject(clazz2, mid2,
-                            JNIUtil::makeJString(item->url));
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-    }
+  jstring jurl = JNIUtil::makeJString(item->url);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
 
-  jobject jcopyUrl = NULL;
-  if (item->copyfrom_url != NULL)
-    {
-      jcopyUrl = env->NewObject(clazz2, mid2,
-                                JNIUtil::makeJString(item->copyfrom_url));
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN_NULL;
-    }
+  jstring jcopyUrl = JNIUtil::makeJString(item->copyfrom_url);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
 
   jlong jcopyRevision = item->revision;
 

Modified: subversion/branches/performance/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommitItem.java
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommitItem.java?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommitItem.java (original)
+++ subversion/branches/performance/subversion/bindings/javahl/src/org/apache/subversion/javahl/CommitItem.java Thu Sep  9 15:59:00 2010
@@ -23,8 +23,6 @@
 
 package org.apache.subversion.javahl;
 
-import java.net.URI;
-
 /**
  * This class describes a item which will be commited.
  */
@@ -57,12 +55,12 @@ public class CommitItem implements java.
     /**
      * the url of the item
      */
-    URI url;
+    String url;
 
     /**
      * the source of the copy
      */
-    URI copyUrl;
+    String copyUrl;
 
     /**
      * the revision
@@ -78,7 +76,7 @@ public class CommitItem implements java.
      * @param cu    copy source url
      * @param r     revision number
      */
-    public CommitItem(String p, NodeKind nk, int sf, URI u, URI cu, long r)
+    public CommitItem(String p, NodeKind nk, int sf, String u, String cu, long r)
     {
         path = p;
         nodeKind = nk;
@@ -127,7 +125,7 @@ public class CommitItem implements java.
      * Returns the url of the item
      * @return url
      */
-    public URI getUrl()
+    public String getUrl()
     {
         return url;
     }
@@ -136,7 +134,7 @@ public class CommitItem implements java.
      * Returns the source url if the item is copied
      * @return source url
      */
-    public URI getCopyUrl()
+    public String getCopyUrl()
     {
         return copyUrl;
     }

Modified: subversion/branches/performance/subversion/bindings/javahl/src/org/tigris/subversion/javahl/CommitItem.java
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/bindings/javahl/src/org/tigris/subversion/javahl/CommitItem.java?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/bindings/javahl/src/org/tigris/subversion/javahl/CommitItem.java (original)
+++ subversion/branches/performance/subversion/bindings/javahl/src/org/tigris/subversion/javahl/CommitItem.java Thu Sep  9 15:59:00 2010
@@ -92,9 +92,7 @@ public class CommitItem implements java.
     public CommitItem(org.apache.subversion.javahl.CommitItem aItem)
     {
         this(aItem.getPath(), NodeKind.fromApache(aItem.getNodeKind()),
-             aItem.getStateFlags(),
-             aItem.getUrl() != null ? aItem.getUrl().toString() : null,
-             aItem.getCopyUrl() != null ? aItem.getCopyUrl().toString() : null,
+             aItem.getStateFlags(), aItem.getUrl(), aItem.getCopyUrl(),
              aItem.getRevision());
     }
 

Modified: subversion/branches/performance/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java (original)
+++ subversion/branches/performance/subversion/bindings/javahl/tests/org/apache/subversion/javahl/SVNTests.java Thu Sep  9 15:59:00 2010
@@ -806,7 +806,7 @@ class SVNTests extends TestCase
                 // path
                 String key;
                 if (commitItem.getUrl() != null)
-                    key = commitItem.getUrl().toString();
+                    key = commitItem.getUrl();
                 else
                     key = commitItem.getPath();
 

Modified: subversion/branches/performance/subversion/include/private/svn_dep_compat.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/include/private/svn_dep_compat.h?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/include/private/svn_dep_compat.h (original)
+++ subversion/branches/performance/subversion/include/private/svn_dep_compat.h Thu Sep  9 15:59:00 2010
@@ -62,6 +62,16 @@ extern "C" {
 #define apr_array_clear(arr)         (arr)->nelts = 0
 #endif
 
+#if !APR_VERSION_AT_LEAST(1,3,0)
+#define APR_UINT32_MAX 0xFFFFFFFFU
+#define APR_INT32_MAX  0x7FFFFFFF
+#define APR_INT32_MIN (-APR_INT32_MAX-1)
+#define APR_UINT64_MAX APR_UINT64_C(0xFFFFFFFFFFFFFFFF)
+#define APR_INT64_MAX   APR_INT64_C(0x7FFFFFFFFFFFFFFF)
+#define APR_INT64_MIN (-APR_INT64_MAX-1)
+#define APR_SIZE_MAX (~(apr_size_t)0)
+#endif
+
 /**
  * Check at compile time if the Serf version is at least a certain
  * level.

Propchange: subversion/branches/performance/subversion/include/private/svn_file_handle_cache.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -1 +1 @@
-/subversion/trunk/subversion/include/private/svn_file_handle_cache.h:962911-993127
+/subversion/trunk/subversion/include/private/svn_file_handle_cache.h:962911-995462

Modified: subversion/branches/performance/subversion/include/private/svn_skel.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/include/private/svn_skel.h?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/include/private/svn_skel.h (original)
+++ subversion/branches/performance/subversion/include/private/svn_skel.h Thu Sep  9 15:59:00 2010
@@ -163,11 +163,11 @@ void svn_skel__prepend_str(const char *v
                            apr_pool_t *result_pool);
 
 
-/* Parse SKEL as an integer. SCRATCH_POOL is used for temporary memory.
-   NOTE: this function assumes the input is valid -- there is no way to
-   return an error.  */
-apr_int64_t svn_skel__parse_int(const svn_skel_t *skel,
-                                apr_pool_t *scratch_pool);
+/* Parse SKEL as an integer and return the result in *N.
+ * SCRATCH_POOL is used for temporary memory.  */
+svn_error_t *
+svn_skel__parse_int(apr_int64_t *n, const svn_skel_t *skel,
+                    apr_pool_t *scratch_pool);
 
 
 /* Return a string whose contents are a concrete representation of

Propchange: subversion/branches/performance/subversion/include/private/svn_temp_serializer.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -1 +1 @@
-/subversion/trunk/subversion/include/private/svn_temp_serializer.h:962911-993127
+/subversion/trunk/subversion/include/private/svn_temp_serializer.h:962911-995462

Modified: subversion/branches/performance/subversion/include/svn_string.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/include/svn_string.h?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/include/svn_string.h (original)
+++ subversion/branches/performance/subversion/include/svn_string.h Thu Sep  9 15:59:00 2010
@@ -402,6 +402,71 @@ svn_cstring_join(const apr_array_header_
 int
 svn_cstring_casecmp(const char *str1, const char *str2);
 
+/**
+ * Parse the C string @a str into a 64 bit number, and return it in @a *n.
+ * Assume that the number is represented in base @a base.
+ * Raise an error if conversion fails (e.g. due to overflow), or if the
+ * converted number is smaller than @a minval or larger than @a maxval. 
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_cstring_strtoi64(apr_int64_t *n, const char *str,
+                     apr_int64_t minval, apr_int64_t maxval,
+                     int base);
+
+/**
+ * Parse the C string @a str into a 64 bit number, and return it in @a *n.
+ * Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_cstring_atoi64(apr_int64_t *n, const char *str);
+
+/**
+ * Parse the C string @a str into a 32 bit number, and return it in @a *n.
+ * Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_cstring_atoi(int *n, const char *str);
+
+/**
+ * Parse the C string @a str into an unsigned 64 bit number, and return
+ * it in @a *n. Assume that the number is represented in base @a base.
+ * Raise an error if conversion fails (e.g. due to overflow), or if the
+ * converted number is smaller than @a minval or larger than @a maxval. 
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_cstring_strtoui64(apr_uint64_t *n, const char *str,
+                      apr_uint64_t minval, apr_uint64_t maxval,
+                      int base);
+
+/**
+ * Parse the C string @a str into an unsigned 64 bit number, and return
+ * it in @a *n. Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_cstring_atoui64(apr_uint64_t *n, const char *str);
+
+/**
+ * Parse the C string @a str into an unsigned 32 bit number, and return
+ * it in @a *n. Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_cstring_atoui(unsigned int *n, const char *str);
 
 /** @} */
 

Modified: subversion/branches/performance/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_client/patch.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_client/patch.c (original)
+++ subversion/branches/performance/subversion/libsvn_client/patch.c Thu Sep  9 15:59:00 2010
@@ -1599,6 +1599,45 @@ send_patch_notification(const patch_targ
   return SVN_NO_ERROR;
 }
 
+/* Close the streams of the TARGET so that their content is flushed
+ * to disk. This will also close underlying streams and files. Use POOL for
+ * temporary allocations. */
+static svn_error_t *
+close_target_streams(const patch_target_t *target,
+                     apr_pool_t *pool)
+{
+  apr_hash_index_t *hi;
+  target_content_info_t *prop_content_info;
+
+   /* First the streams belonging to properties .. */
+      for (hi = apr_hash_first(pool, target->prop_targets);
+           hi;
+           hi = apr_hash_next(hi))
+        {
+          prop_patch_target_t *prop_target;
+          prop_target = svn__apr_hash_index_val(hi);
+          prop_content_info = prop_target->content_info;
+
+          /* ### If the prop did not exist pre-patching we'll not have a
+           * ### stream to read from. Find a better way to store info on
+           * ### the existence of the target prop. */
+          if (prop_content_info->stream)
+            SVN_ERR(svn_stream_close(prop_content_info->stream));
+
+          SVN_ERR(svn_stream_close(prop_content_info->patched));
+        }
+
+
+   /* .. And then streams associted with the file. The reject stream is
+    * shared between all target_content_info structures. */
+  if (target->kind_on_disk == svn_node_file)
+    SVN_ERR(svn_stream_close(target->content_info->stream));
+  SVN_ERR(svn_stream_close(target->content_info->patched));
+  SVN_ERR(svn_stream_close(target->content_info->reject));
+
+  return SVN_NO_ERROR;
+}
+
 /* Apply a PATCH to a working copy at ABS_WC_PATH and put the result
  * into temporary files, to be installed in the working copy later.
  * Return information about the patch target in *PATCH_TARGET, allocated
@@ -1721,16 +1760,13 @@ apply_one_patch(patch_target_t **patch_t
       svn_prop_patch_t *prop_patch;
       const char *prop_name;
       prop_patch_target_t *prop_target;
-      target_content_info_t *prop_content_info;
         
       prop_name = svn__apr_hash_index_key(hash_index);
       prop_patch = svn__apr_hash_index_val(hash_index);
 
-      /* We'll store matched hunks in prop_content_info.
-       * ### Just use prop_target->content_info? */
+      /* We'll store matched hunks in prop_content_info. */
       prop_target = apr_hash_get(target->prop_targets, prop_name, 
                                  APR_HASH_KEY_STRING);
-      prop_content_info = prop_target->content_info;
 
       for (i = 0; i < prop_patch->hunks->nelts; i++)
         {
@@ -1749,7 +1785,8 @@ apply_one_patch(patch_target_t **patch_t
            * If no match is found initially, try with fuzz. */
           do
             {
-              SVN_ERR(get_hunk_info(&hi, target, prop_content_info, hunk, fuzz,
+              SVN_ERR(get_hunk_info(&hi, target, prop_target->content_info, 
+                                    hunk, fuzz,
                                     ignore_whitespace,
                                     TRUE /* is_prop_hunk */,
                                     cancel_func, cancel_baton,
@@ -1758,7 +1795,7 @@ apply_one_patch(patch_target_t **patch_t
             }
           while (hi->rejected && fuzz <= MAX_FUZZ && ! hi->already_applied);
 
-          APR_ARRAY_PUSH(prop_content_info->hunks, hunk_info_t *) = hi;
+          APR_ARRAY_PUSH(prop_target->content_info->hunks, hunk_info_t *) = hi;
         }
     }
 
@@ -1768,52 +1805,40 @@ apply_one_patch(patch_target_t **patch_t
        hash_index = apr_hash_next(hash_index))
     {
       prop_patch_target_t *prop_target;
-      target_content_info_t *prop_content_info;
-      const char *prop_patched_path;
 
       prop_target = svn__apr_hash_index_val(hash_index);
-      /* ### Just use prop_target->content_info? */
-      prop_content_info = prop_target->content_info;
-      /* ### Just use prop_target->patched_path? */
-      prop_patched_path = prop_target->patched_path;
 
-      for (i = 0; i < prop_content_info->hunks->nelts; i++)
+      for (i = 0; i < prop_target->content_info->hunks->nelts; i++)
         {
           hunk_info_t *hi;
 
           svn_pool_clear(iterpool);
 
-          hi = APR_ARRAY_IDX(prop_content_info->hunks, i, hunk_info_t *);
+          hi = APR_ARRAY_IDX(prop_target->content_info->hunks, i, 
+                             hunk_info_t *);
           if (hi->already_applied)
             continue;
           else if (hi->rejected)
-            SVN_ERR(reject_hunk(target, prop_content_info, hi,
+            SVN_ERR(reject_hunk(target, prop_target->content_info, hi,
                                 prop_target->name,
                                 iterpool));
           else
-            SVN_ERR(apply_hunk(target, prop_content_info, hi, 
+            SVN_ERR(apply_hunk(target, prop_target->content_info, hi, 
                                prop_target->name,
                                iterpool));
         }
 
-        if (prop_content_info->stream)
+        if (prop_target->content_info->stream)
           {
             /* Copy any remaining lines to target. */
-            SVN_ERR(copy_lines_to_target(prop_content_info, 0,
-                                         prop_patched_path, scratch_pool));
-            if (! prop_content_info->eof)
+            SVN_ERR(copy_lines_to_target(prop_target->content_info, 0,
+                                         prop_target->patched_path, 
+                                         scratch_pool));
+            if (! prop_target->content_info->eof)
               {
                 /* We could not copy the entire target property to the
                  * temporary file, and would truncate the target if we
-                 * copied the temporary file on top of it. Skip this target. 
-                 *
-                 * ### dannas: Do we really want to skip an entire target
-                 * ### if one of the properties does not apply cleanly,
-                 * ### e.g. both text changes and all prop changes will not be
-                 * ### installed.
-                 * ### stsp: This is a "should never happen" situation.
-                 * ### It means we've run out of disk space or something
-                 * ### like that, so skipping is appropriate. */
+                 * copied the temporary file on top of it. Skip this target.  */
                 target->skipped = TRUE;
               }
           }
@@ -1821,40 +1846,7 @@ apply_one_patch(patch_target_t **patch_t
 
   svn_pool_destroy(iterpool);
 
-  /* ### Move this a separate function? apply_one_patch() has gotten quite
-   * ### big. We should consider splitting it up into several pieces. */
-    {
-      apr_hash_index_t *hi;
-      target_content_info_t *prop_content_info;
-
-      /* Close the streams of the target so that their content is flushed
-       * to disk. This will also close underlying streams and files. 
-       * First the streams belonging to properties .. */
-          for (hi = apr_hash_first(result_pool, target->prop_targets);
-               hi;
-               hi = apr_hash_next(hi))
-            {
-              prop_patch_target_t *prop_target;
-              prop_target = svn__apr_hash_index_val(hi);
-              prop_content_info = prop_target->content_info;
-
-              /* ### If the prop did not exist pre-patching we'll not have a
-               * ### stream to read from. Find a better way to store info on
-               * ### the existence of the target prop. */
-              if (prop_content_info->stream)
-                SVN_ERR(svn_stream_close(prop_content_info->stream));
-
-              SVN_ERR(svn_stream_close(prop_content_info->patched));
-            }
-
-
-       /* .. And then streams associted with the file. The reject stream is
-        * shared between all target_content_info structures. */
-      if (target->kind_on_disk == svn_node_file)
-        SVN_ERR(svn_stream_close(target->content_info->stream));
-      SVN_ERR(svn_stream_close(target->content_info->patched));
-      SVN_ERR(svn_stream_close(target->content_info->reject));
-    }
+  SVN_ERR(close_target_streams(target, scratch_pool));
 
   if (! target->skipped)
     {

Modified: subversion/branches/performance/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_diff/parse-diff.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/branches/performance/subversion/libsvn_diff/parse-diff.c Thu Sep  9 15:59:00 2010
@@ -28,6 +28,7 @@
 #include "svn_error.h"
 #include "svn_io.h"
 #include "svn_pools.h"
+#include "svn_string.h"
 #include "svn_utf.h"
 #include "svn_dirent_uri.h"
 #include "svn_diff.h"
@@ -119,20 +120,18 @@ svn_diff_hunk_get_trailing_context(const
 static svn_boolean_t
 parse_offset(svn_linenum_t *offset, const char *number)
 {
-  apr_int64_t parsed_offset;
+  svn_error_t *err;
+  apr_uint64_t val;
 
-  errno = 0; /* apr_atoi64() in APR-0.9 does not always set errno */
-  parsed_offset = apr_atoi64(number);
-  if (errno == ERANGE || parsed_offset < 0)
-    return FALSE;
+  err = svn_cstring_strtoui64(&val, number, 0, SVN_LINENUM_MAX_VALUE, 10);
+  if (err)
+    {
+      svn_error_clear(err);
+      return FALSE;
+    }
 
-  /* In case we cannot fit 64 bits into an svn_linenum_t,
-   * check for overflow. */
-  if (sizeof(svn_linenum_t) < sizeof(parsed_offset) &&
-      parsed_offset > SVN_LINENUM_MAX_VALUE)
-    return FALSE;
+  *offset = (svn_linenum_t)val;
 
-  *offset = parsed_offset;
   return TRUE;
 }
 

Modified: subversion/branches/performance/subversion/libsvn_fs_base/util/fs_skels.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_base/util/fs_skels.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_base/util/fs_skels.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_base/util/fs_skels.c Thu Sep  9 15:59:00 2010
@@ -31,6 +31,7 @@
 #include "svn_time.h"
 
 #include "private/svn_skel.h"
+#include "private/svn_dep_compat.h"
 
 #include "svn_checksum.h"
 #include "fs_skels.h"
@@ -550,32 +551,38 @@ svn_fs_base__parse_representation_skel(r
         {
           svn_skel_t *window_skel = chunk_skel->children->next;
           svn_skel_t *diff_skel = window_skel->children;
+          apr_int64_t val;
+          apr_uint64_t uval;
+          const char *str;
 
           /* Allocate a chunk and its window */
           chunk = apr_palloc(pool, sizeof(*chunk));
 
           /* Populate the window */
-          chunk->version
-            = (apr_byte_t)atoi(apr_pstrmemdup
-                               (pool,
-                                diff_skel->children->next->data,
-                                diff_skel->children->next->len));
+          str = apr_pstrmemdup(pool, diff_skel->children->next->data,
+                               diff_skel->children->next->len);
+          SVN_ERR(svn_cstring_strtoui64(&uval, str, 0, 255, 10));
+          chunk->version = (apr_byte_t)uval;
+
           chunk->string_key
             = apr_pstrmemdup(pool,
                              diff_skel->children->next->next->data,
                              diff_skel->children->next->next->len);
-          chunk->size
-            = atoi(apr_pstrmemdup(pool,
-                                  window_skel->children->next->data,
-                                  window_skel->children->next->len));
+
+          str = apr_pstrmemdup(pool, window_skel->children->next->data,
+                               window_skel->children->next->len);
+          SVN_ERR(svn_cstring_strtoui64(&uval, str, 0, APR_SIZE_MAX, 10));
+          chunk->size = (apr_size_t)uval;
+
           chunk->rep_key
             = apr_pstrmemdup(pool,
                              window_skel->children->next->next->data,
                              window_skel->children->next->next->len);
-          chunk->offset =
-            svn__atoui64(apr_pstrmemdup(pool,
-                                        chunk_skel->children->data,
-                                        chunk_skel->children->len));
+
+          str = apr_pstrmemdup(pool, chunk_skel->children->data,
+                               chunk_skel->children->len);
+          SVN_ERR(svn_cstring_strtoi64(&val, str, 0, APR_INT64_MAX, 10));
+          chunk->offset = (svn_filesize_t)val;
 
           /* Add this chunk to the array. */
           APR_ARRAY_PUSH(chunks, rep_delta_chunk_t *) = chunk;
@@ -633,24 +640,28 @@ svn_fs_base__parse_node_revision_skel(no
       noderev->predecessor_count = -1;
       if (cur_skel->next)
         {
+          const char *str;
+
           cur_skel = cur_skel->next;
           if (cur_skel->len)
-            noderev->predecessor_count = atoi(apr_pstrmemdup(pool,
-                                                             cur_skel->data,
-                                                             cur_skel->len));
+            {
+              str = apr_pstrmemdup(pool, cur_skel->data, cur_skel->len);
+              SVN_ERR(svn_cstring_atoi(&noderev->predecessor_count, str));
+            }
 
           /* HAS-MERGEINFO and MERGEINFO-COUNT */
           if (cur_skel->next)
             {
+              int val;
+
               cur_skel = cur_skel->next;
-              noderev->has_mergeinfo = atoi(apr_pstrmemdup(pool,
-                                                           cur_skel->data,
-                                                           cur_skel->len))
-                                         != 0;
-              noderev->mergeinfo_count =
-                apr_atoi64(apr_pstrmemdup(pool,
-                                          cur_skel->next->data,
-                                          cur_skel->next->len));
+              str = apr_pstrmemdup(pool, cur_skel->data, cur_skel->len);
+              SVN_ERR(svn_cstring_atoi(&val, str));
+              noderev->has_mergeinfo = (val != 0);
+
+              str = apr_pstrmemdup(pool, cur_skel->next->data,
+                                   cur_skel->next->len);
+              SVN_ERR(svn_cstring_atoi64(&noderev->mergeinfo_count, str));
             }
         }
     }

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/fs_fs.c Thu Sep  9 15:59:00 2010
@@ -44,6 +44,7 @@
 #include "svn_hash.h"
 #include "svn_props.h"
 #include "svn_sorts.h"
+#include "svn_string.h"
 #include "svn_time.h"
 #include "svn_mergeinfo.h"
 #include "svn_config.h"
@@ -1005,7 +1006,7 @@ read_format(int *pformat, int *max_files
 
   /* Check that the first line contains only digits. */
   SVN_ERR(check_format_file_buffer_numeric(buf, 0, path, pool));
-  *pformat = atoi(buf);
+  SVN_ERR(svn_cstring_atoi(pformat, buf));
 
   /* Set the default values for anything that can be set via an option. */
   *max_files_per_dir = 0;
@@ -1036,7 +1037,7 @@ read_format(int *pformat, int *max_files
             {
               /* Check that the argument is numeric. */
               SVN_ERR(check_format_file_buffer_numeric(buf, 15, path, pool));
-              *max_files_per_dir = atoi(buf+15);
+              SVN_ERR(svn_cstring_atoi(max_files_per_dir, buf + 15));
               continue;
             }
         }
@@ -1999,18 +2000,20 @@ get_packed_offset(apr_off_t *rev_offset,
     {
       svn_stringbuf_t *sb;
       svn_boolean_t eof;
+      apr_int64_t val;
+      svn_error_t *err;
 
       svn_pool_clear(iterpool);
       SVN_ERR(svn_stream_readline(manifest_stream, &sb, "\n", &eof, iterpool));
       if (eof)
         break;
 
-      errno = 0; /* apr_atoi64() in APR-0.9 does not always set errno */
-      APR_ARRAY_PUSH(manifest, apr_off_t) =
-                apr_atoi64(svn_string_create_from_buf(sb, iterpool)->data);
-      if (errno == ERANGE)
-        return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                                "Manifest offset too large");
+      err = svn_cstring_atoi64(&val, sb->data);
+      if (err)
+        return svn_error_return(
+                 svn_error_create(SVN_ERR_FS_CORRUPT, err,
+                                  _("Manifest offset too large")));
+      APR_ARRAY_PUSH(manifest, apr_off_t) = (apr_off_t)val;
     }
   svn_pool_destroy(iterpool);
 
@@ -2111,6 +2114,7 @@ read_rep_offsets(representation_t **rep_
 {
   representation_t *rep;
   char *str, *last_str;
+  apr_int64_t val;
 
   rep = apr_pcalloc(pool, sizeof(*rep));
   *rep_p = rep;
@@ -2134,21 +2138,24 @@ read_rep_offsets(representation_t **rep_
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Malformed text representation offset line in node-rev"));
 
-  rep->offset = apr_atoi64(str);
+  SVN_ERR(svn_cstring_atoi64(&val, str));
+  rep->offset = (apr_off_t)val;
 
   str = apr_strtok(NULL, " ", &last_str);
   if (str == NULL)
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Malformed text representation offset line in node-rev"));
 
-  rep->size = apr_atoi64(str);
+  SVN_ERR(svn_cstring_atoi64(&val, str));
+  rep->size = (svn_filesize_t)val;
 
   str = apr_strtok(NULL, " ", &last_str);
   if (str == NULL)
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Malformed text representation offset line in node-rev"));
 
-  rep->expanded_size = apr_atoi64(str);
+  SVN_ERR(svn_cstring_atoi64(&val, str));
+  rep->expanded_size = (svn_filesize_t)val;
 
   /* Read in the MD5 hash. */
   str = apr_strtok(NULL, " ", &last_str);
@@ -2343,7 +2350,10 @@ svn_fs_fs__read_noderev(node_revision_t 
 
   /* Read the 'count' field. */
   value = apr_hash_get(headers, HEADER_COUNT, APR_HASH_KEY_STRING);
-  noderev->predecessor_count = (value == NULL) ? 0 : atoi(value);
+  if (value)
+    SVN_ERR(svn_cstring_atoi(&noderev->predecessor_count, value));
+  else
+    noderev->predecessor_count = 0;
 
   /* Get the properties location. */
   value = apr_hash_get(headers, HEADER_PROPS, APR_HASH_KEY_STRING);
@@ -2434,7 +2444,10 @@ svn_fs_fs__read_noderev(node_revision_t 
 
   /* Get the mergeinfo count. */
   value = apr_hash_get(headers, HEADER_MINFO_CNT, APR_HASH_KEY_STRING);
-  noderev->mergeinfo_count = (value == NULL) ? 0 : apr_atoi64(value);
+  if (value)
+    SVN_ERR(svn_cstring_atoi64(&noderev->mergeinfo_count, value));
+  else
+    noderev->mergeinfo_count = 0;
 
   /* Get whether *this* node has mergeinfo. */
   value = apr_hash_get(headers, HEADER_MINFO_HERE, APR_HASH_KEY_STRING);
@@ -2624,6 +2637,7 @@ read_rep_line(struct rep_args **rep_args
   apr_size_t limit;
   struct rep_args *rep_args;
   char *str, *last_str;
+  apr_int64_t val;
 
   limit = sizeof(buffer);
   SVN_ERR(svn_io_read_length_line(file, buffer, &limit, pool));
@@ -2651,24 +2665,30 @@ read_rep_line(struct rep_args **rep_args
 
   /* We have hopefully a DELTA vs. a non-empty base revision. */
   str = apr_strtok(buffer, " ", &last_str);
-  if (! str || (strcmp(str, REP_DELTA) != 0)) goto err;
+  if (! str || (strcmp(str, REP_DELTA) != 0))
+    goto error;
 
   str = apr_strtok(NULL, " ", &last_str);
-  if (! str) goto err;
+  if (! str)
+    goto error;
   rep_args->base_revision = SVN_STR_TO_REV(str);
 
   str = apr_strtok(NULL, " ", &last_str);
-  if (! str) goto err;
-  rep_args->base_offset = (apr_off_t) apr_atoi64(str);
+  if (! str)
+    goto error;
+  SVN_ERR(svn_cstring_atoi64(&val, str));
+  rep_args->base_offset = (apr_off_t)val;
 
   str = apr_strtok(NULL, " ", &last_str);
-  if (! str) goto err;
-  rep_args->base_length = (apr_size_t) apr_atoi64(str);
+  if (! str)
+    goto error;
+  SVN_ERR(svn_cstring_atoi64(&val, str));
+  rep_args->base_length = (apr_size_t)val;
 
   *rep_args_p = rep_args;
   return SVN_NO_ERROR;
 
- err:
+ error:
   return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                           _("Malformed representation header"));
 }
@@ -2798,7 +2818,12 @@ get_root_changes_offset(apr_off_t *root_
   i++;
 
   if (root_offset)
-    *root_offset = rev_offset + apr_atoi64(&buf[i]);
+    {
+      apr_int64_t val;
+
+      SVN_ERR(svn_cstring_atoi64(&val, &buf[i]));
+      *root_offset = rev_offset + (apr_off_t)val;
+    }
 
   /* find the next space */
   for ( ; i < (num_bytes - 2) ; i++)
@@ -2810,10 +2835,16 @@ get_root_changes_offset(apr_off_t *root_
 
   i++;
 
-  /* note that apr_atoi64() will stop reading as soon as it encounters
-     the final newline. */
+  /* note that svn_cstring_atoi64() (actually, apr_atoi64()) will stop
+   * reading as soon as it encounters the final newline.
+   * ### Is it OK to rely on this APR implementation detail? */
   if (changes_offset)
-    *changes_offset = rev_offset + apr_atoi64(&buf[i]);
+    {
+      apr_int64_t val;
+
+      SVN_ERR(svn_cstring_atoi64(&val, &buf[i]));
+      *changes_offset = rev_offset + (apr_off_t)val;
+    }
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/performance/subversion/libsvn_fs_fs/id.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_fs_fs/id.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_fs_fs/id.c (original)
+++ subversion/branches/performance/subversion/libsvn_fs_fs/id.c Thu Sep  9 15:59:00 2010
@@ -275,6 +275,9 @@ svn_fs_fs__id_parse(const char *data,
 
   if (str[0] == 'r')
     {
+      apr_int64_t val;
+      svn_error_t *err;
+
       /* This is a revision type ID */
       pvt->txn_id = NULL;
 
@@ -286,7 +289,13 @@ svn_fs_fs__id_parse(const char *data,
       str = apr_strtok(NULL, "/", &last_str);
       if (str == NULL)
         return NULL;
-      pvt->offset = apr_atoi64(str);
+      err = svn_cstring_atoi64(&val, str);
+      if (err)
+        {
+          svn_error_clear(err);
+          return NULL;
+        }
+      pvt->offset = (apr_off_t)val;
     }
   else if (str[0] == 't')
     {

Propchange: subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -1 +1 @@
-/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c:962911-993127
+/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c:962911-995462

Propchange: subversion/branches/performance/subversion/libsvn_fs_fs/temp_serializer.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -34,4 +34,4 @@
 /subversion/branches/tc_url_rev/subversion/libsvn_fs_fs/fs_fs.h:874351-874483
 /subversion/branches/tree-conflicts/subversion/libsvn_fs_fs/fs_fs.h:868291-873154
 /subversion/branches/tree-conflicts-notify/subversion/libsvn_fs_fs/fs_fs.h:873926-874008
-/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h:962911-993127
+/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h:962911-995462

Propchange: subversion/branches/performance/subversion/libsvn_fs_util/caching.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -34,4 +34,4 @@
 /subversion/branches/tc_url_rev/subversion/libsvn_fs/caching.c:874351-874483
 /subversion/branches/tree-conflicts/subversion/libsvn_fs/caching.c:868291-873154
 /subversion/branches/tree-conflicts-notify/subversion/libsvn_fs/caching.c:873926-874008
-/subversion/trunk/subversion/libsvn_fs_util/caching.c:962911-993127
+/subversion/trunk/subversion/libsvn_fs_util/caching.c:962911-995462

Modified: subversion/branches/performance/subversion/libsvn_ra_neon/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_ra_neon/util.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_ra_neon/util.c (original)
+++ subversion/branches/performance/subversion/libsvn_ra_neon/util.c Thu Sep  9 15:59:00 2010
@@ -775,7 +775,12 @@ start_err_element(void *baton, int paren
                                  atts);
 
         if (errcode_str && *err)
-          (*err)->apr_err = atoi(errcode_str);
+          {
+            apr_int64_t val;
+
+            SVN_ERR(svn_cstring_atoi64(&val, errcode_str));
+            (*err)->apr_err = (apr_status_t)val;
+          }
 
         break;
       }

Modified: subversion/branches/performance/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_ra_serf/serf.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/branches/performance/subversion/libsvn_ra_serf/serf.c Thu Sep  9 15:59:00 2010
@@ -721,7 +721,7 @@ dirent_walker(void *baton,
         }
       else if (strcmp(name, "getcontentlength") == 0)
         {
-          entry->size = apr_atoi64(val->data);
+          SVN_ERR(svn_cstring_atoi64(&entry->size, val->data));
         }
       else if (strcmp(name, "resourcetype") == 0)
         {

Modified: subversion/branches/performance/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_ra_serf/util.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/branches/performance/subversion/libsvn_ra_serf/util.c Thu Sep  9 15:59:00 2010
@@ -36,6 +36,7 @@
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
 #include "svn_private_config.h"
+#include "svn_string.h"
 #include "svn_xml.h"
 #include "private/svn_dep_compat.h"
 
@@ -736,7 +737,10 @@ start_error(svn_ra_serf__xml_parser_t *p
       err_code = svn_xml_get_attr_value("errcode", attrs);
       if (err_code)
         {
-          ctx->error->apr_err = apr_atoi64(err_code);
+          apr_int64_t val;
+          
+          SVN_ERR(svn_cstring_atoi64(&val, err_code));
+          ctx->error->apr_err = (apr_status_t)val;
         }
       else
         {

Modified: subversion/branches/performance/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_repos/reporter.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_repos/reporter.c (original)
+++ subversion/branches/performance/subversion/libsvn_repos/reporter.c Thu Sep  9 15:59:00 2010
@@ -32,6 +32,7 @@
 #include "svn_props.h"
 #include "repos.h"
 #include "svn_private_config.h"
+#include "private/svn_dep_compat.h"
 
 #define NUM_CACHED_SOURCE_ROOTS 4
 
@@ -171,11 +172,6 @@ read_number(apr_uint64_t *num, apr_file_
   return SVN_NO_ERROR;
 }
 
-#ifndef APR_SIZE_MAX
-/* APR 0.9 doesn't define APR_SIZE_MAX */
-#define APR_SIZE_MAX    (~((apr_size_t)0))
-#endif
-
 static svn_error_t *
 read_string(const char **str, apr_file_t *temp, apr_pool_t *pool)
 {

Modified: subversion/branches/performance/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/hash.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/hash.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/hash.c Thu Sep  9 15:59:00 2010
@@ -344,11 +344,16 @@ svn_hash_read(apr_hash_t *hash,
         }
       else if ((buf[0] == 'K') && (buf[1] == ' '))
         {
+          size_t keylen;
+          int parsed_len;
+          void *keybuf;
+          
           /* Get the length of the key */
-          size_t keylen = (size_t) atoi(buf + 2);
+          SVN_ERR(svn_cstring_atoi(&parsed_len, buf + 2));
+          keylen = parsed_len;
 
           /* Now read that much into a buffer, + 1 byte for null terminator */
-          void *keybuf = apr_palloc(pool, keylen + 1);
+          keybuf = apr_palloc(pool, keylen + 1);
           SVN_ERR(svn_io_file_read_full2(srcfile,
                                          keybuf, keylen,
                                          &num_read, FALSE, pool));
@@ -366,12 +371,15 @@ svn_hash_read(apr_hash_t *hash,
           if ((buf[0] == 'V') && (buf[1] == ' '))
             {
               svn_string_t *value = apr_palloc(pool, sizeof(*value));
+              apr_size_t vallen;
+              void *valbuf;
 
               /* Get the length of the value */
-              apr_size_t vallen = atoi(buf + 2);
+              SVN_ERR(svn_cstring_atoi(&parsed_len, buf + 2));
+              vallen = parsed_len;
 
               /* Again, 1 extra byte for the null termination. */
-              void *valbuf = apr_palloc(pool, vallen + 1);
+              valbuf = apr_palloc(pool, vallen + 1);
               SVN_ERR(svn_io_file_read_full2(srcfile,
                                              valbuf, vallen,
                                              &num_read, FALSE, pool));

Modified: subversion/branches/performance/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/io.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/io.c Thu Sep  9 15:59:00 2010
@@ -1076,14 +1076,19 @@ svn_error_t *svn_io_file_create(const ch
 {
   apr_file_t *f;
   apr_size_t written;
+  svn_error_t *err;
 
   SVN_ERR(svn_io_file_open(&f, file,
                            (APR_WRITE | APR_CREATE | APR_EXCL),
                            APR_OS_DEFAULT,
                            pool));
-  SVN_ERR(svn_io_file_write_full(f, contents, strlen(contents),
-                                 &written, pool));
-  return svn_io_file_close(f, pool);
+  err= svn_io_file_write_full(f, contents, strlen(contents),
+                              &written, pool);
+
+
+  return svn_error_return(
+                        svn_error_compose_create(err,
+                                                 svn_io_file_close(f, pool)));
 }
 
 svn_error_t *svn_io_dir_file_copy(const char *src_path,
@@ -2952,12 +2957,19 @@ svn_io_write_unique(const char **tmp_pat
                     apr_pool_t *pool)
 {
   apr_file_t *new_file;
+  svn_error_t *err;
 
   SVN_ERR(svn_io_open_unique_file3(&new_file, tmp_path, dirpath,
                                    delete_when, pool, pool));
-  SVN_ERR(svn_io_file_write_full(new_file, buf, nbytes, NULL, pool));
-  SVN_ERR(svn_io_file_flush_to_disk(new_file, pool));
-  return svn_io_file_close(new_file, pool);
+
+  err = svn_io_file_write_full(new_file, buf, nbytes, NULL, pool);
+
+  if (!err)
+    err = svn_io_file_flush_to_disk(new_file, pool);
+
+  return svn_error_return(
+                  svn_error_compose_create(err,
+                                           svn_io_file_close(new_file, pool)));
 }
 
 
@@ -3521,15 +3533,17 @@ svn_io_read_version_file(int *version,
   apr_file_t *format_file;
   char buf[80];
   apr_size_t len;
+  svn_error_t *err;
 
   /* Read a chunk of data from PATH */
   SVN_ERR(svn_io_file_open(&format_file, path, APR_READ,
                            APR_OS_DEFAULT, pool));
   len = sizeof(buf);
-  SVN_ERR(svn_io_file_read(format_file, buf, &len, pool));
+  err = svn_io_file_read(format_file, buf, &len, pool);
 
   /* Close the file. */
-  SVN_ERR(svn_io_file_close(format_file, pool));
+  SVN_ERR(svn_error_compose_create(err,
+                                   svn_io_file_close(format_file, pool)));
 
   /* If there was no data in PATH, return an error. */
   if (len == 0)
@@ -3556,7 +3570,7 @@ svn_io_read_version_file(int *version,
   }
 
   /* Convert to integer. */
-  *version = atoi(buf);
+  SVN_ERR(svn_cstring_atoi(version, buf));
 
   return SVN_NO_ERROR;
 }
@@ -3570,40 +3584,65 @@ contents_identical_p(svn_boolean_t *iden
                      const char *file2,
                      apr_pool_t *pool)
 {
+  svn_error_t *err;
   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;
+  svn_boolean_t done1 = FALSE;
+  svn_boolean_t done2 = FALSE;
 
   SVN_ERR(svn_io_file_open(&file1_h, file1, APR_READ, APR_OS_DEFAULT,
                            pool));
-  SVN_ERR(svn_io_file_open(&file2_h, file2, APR_READ, APR_OS_DEFAULT,
-                           pool));
+
+  err = svn_io_file_open(&file2_h, file2, APR_READ, APR_OS_DEFAULT,
+                         pool);
+
+  if (err)
+    return svn_error_return(
+               svn_error_compose_create(err,
+                                        svn_io_file_close(file1_h, pool)));
 
   *identical_p = TRUE;  /* assume TRUE, until disproved below */
-  do
+  while (! (done1 || done2))
     {
-      SVN_ERR(svn_io_file_read_full2(file1_h, buf1,
-                                     SVN__STREAM_CHUNK_SIZE, &bytes_read1, 
-                                     TRUE, pool));
-      SVN_ERR(svn_io_file_read_full2(file2_h, buf2,
-                                     SVN__STREAM_CHUNK_SIZE, &bytes_read2, 
-                                     TRUE, pool));
+      err = svn_io_file_read_full(file1_h, buf1,
+                                  SVN__STREAM_CHUNK_SIZE, &bytes_read1, pool);
+      if (err && APR_STATUS_IS_EOF(err->apr_err))
+        {
+          svn_error_clear(err);
+          err = NULL;
+          done1 = TRUE;
+        }
+      else if (err)
+        break;
+
+      err = svn_io_file_read_full(file2_h, buf2,
+                                  SVN__STREAM_CHUNK_SIZE, &bytes_read2, pool);
+      if (err && APR_STATUS_IS_EOF(err->apr_err))
+        {
+          svn_error_clear(err);
+          err = NULL;
+          done2 = TRUE;
+        }
+      else if (err)
+        break;
 
       if ((bytes_read1 != bytes_read2)
+          || (done1 != done2)
           || (memcmp(buf1, buf2, bytes_read1)))
         {
           *identical_p = FALSE;
           break;
         }
-      /* The read_full functions are supposed to read until either the
-         buffer has been completely filled or EOF has been accountered.
-         Hence, the following check reliably tests for EOF. */
-    } while (bytes_read1 == SVN__STREAM_CHUNK_SIZE);
+    }
 
-  SVN_ERR(svn_io_file_close(file1_h, pool));
-  return svn_io_file_close(file2_h, pool);
+  return svn_error_return(
+           svn_error_compose_create(
+                err,
+                svn_error_compose_create(svn_io_file_close(file1_h, pool),
+                                         svn_io_file_close(file2_h, pool))));
 }
 
 

Modified: subversion/branches/performance/subversion/libsvn_subr/skel.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/skel.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/skel.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/skel.c Thu Sep  9 15:59:00 2010
@@ -666,12 +666,16 @@ svn_skel__list_length(const svn_skel_t *
 
 /* Parsing and unparsing into high-level types. */
 
-apr_int64_t svn_skel__parse_int(const svn_skel_t *skel,
-                                apr_pool_t *scratch_pool)
+svn_error_t *
+svn_skel__parse_int(apr_int64_t *n, const svn_skel_t *skel,
+                    apr_pool_t *scratch_pool)
 {
+  const char *str;
+
   /* We need to duplicate the SKEL contents in order to get a NUL-terminated
      version of it. The SKEL may not have valid memory at DATA[LEN].  */
-  return apr_atoi64(apr_pstrmemdup(scratch_pool, skel->data, skel->len));
+  str = apr_pstrmemdup(scratch_pool, skel->data, skel->len);
+  return svn_error_return(svn_cstring_atoi64(n, str));
 }
 
 

Propchange: subversion/branches/performance/subversion/libsvn_subr/svn_file_handle_cache.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -1 +1 @@
-/subversion/trunk/subversion/libsvn_subr/svn_file_handle_cache.c:962911-993127
+/subversion/trunk/subversion/libsvn_subr/svn_file_handle_cache.c:962911-995462

Modified: subversion/branches/performance/subversion/libsvn_subr/svn_string.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_subr/svn_string.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_subr/svn_string.c (original)
+++ subversion/branches/performance/subversion/libsvn_subr/svn_string.c Thu Sep  9 15:59:00 2010
@@ -25,11 +25,15 @@
 
 
 
+#include <apr.h>
+
 #include <string.h>      /* for memcpy(), memcmp(), strlen() */
 #include <apr_fnmatch.h>
 #include "svn_string.h"  /* loads "svn_types.h" and <apr_pools.h> */
 #include "svn_ctype.h"
+#include "private/svn_dep_compat.h"
 
+#include "svn_private_config.h"
 
 
 /* Our own realloc, since APR doesn't have one.  Note: this is a
@@ -634,3 +638,88 @@ svn_cstring_casecmp(const char *str1, co
         return cmp;
     }
 }
+
+svn_error_t *
+svn_cstring_strtoui64(apr_uint64_t *n, const char *str,
+                      apr_uint64_t minval, apr_uint64_t maxval,
+                      int base)
+{
+  apr_int64_t parsed;
+
+  /* We assume errno is thread-safe. */
+  errno = 0; /* APR-0.9 doesn't always set errno */
+
+  /* ### We're throwing away half the number range here.
+   * ### Maybe implement our own number parser? */
+  parsed = apr_strtoi64(str, NULL, base);
+  if (errno != 0)
+    return svn_error_return(
+             svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
+                               _("Could not convert '%s' into a number"),
+                               str));
+  if (parsed < 0 || parsed < minval || parsed > maxval)
+    return svn_error_return(
+             svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
+                               _("Number '%s' is out of range"), str));
+  *n = parsed;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_cstring_atoui64(apr_uint64_t *n, const char *str)
+{
+  return svn_error_return(svn_cstring_strtoui64(n, str, 0,
+                                                APR_UINT64_MAX, 10));
+}
+
+svn_error_t *
+svn_cstring_atoui(unsigned int *n, const char *str)
+{
+  apr_uint64_t parsed;
+
+  SVN_ERR(svn_cstring_strtoui64(&parsed, str, 0, APR_UINT32_MAX, 10));
+  *n = (unsigned int)parsed;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_cstring_strtoi64(apr_int64_t *n, const char *str,
+                     apr_int64_t minval, apr_int64_t maxval,
+                     int base)
+{
+  apr_int64_t parsed;
+
+  /* We assume errno is thread-safe. */
+  errno = 0; /* APR-0.9 doesn't always set errno */
+
+  parsed = apr_strtoi64(str, NULL, base);
+  if (errno != 0)
+    return svn_error_return(
+             svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
+                               _("Could not convert '%s' into a number"),
+                               str));
+  if (parsed < minval || parsed > maxval)
+    return svn_error_return(
+             svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
+                               _("Number '%s' is out of range"), str));
+  *n = parsed;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_cstring_atoi64(apr_int64_t *n, const char *str)
+{
+  return svn_error_return(svn_cstring_strtoi64(n, str, APR_INT64_MIN,
+                                               APR_INT64_MAX, 10));
+}
+
+svn_error_t *
+svn_cstring_atoi(int *n, const char *str)
+{
+  apr_int64_t parsed;
+
+  SVN_ERR(svn_cstring_strtoi64(&parsed, str, APR_INT32_MIN,
+                               APR_INT32_MAX, 10));
+  *n = (int)parsed;
+  return SVN_NO_ERROR;
+}

Propchange: subversion/branches/performance/subversion/libsvn_subr/svn_temp_serializer.c
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  9 15:59:00 2010
@@ -1 +1 @@
-/subversion/trunk/subversion/libsvn_subr/svn_temp_serializer.c:962911-993127
+/subversion/trunk/subversion/libsvn_subr/svn_temp_serializer.c:962911-995462

Modified: subversion/branches/performance/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/copy.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/copy.c (original)
+++ subversion/branches/performance/subversion/libsvn_wc/copy.c Thu Sep  9 15:59:00 2010
@@ -263,120 +263,6 @@ copy_versioned_dir(svn_wc__db_t *db,
                                              tmp_dst_abspath, dst_abspath,
                                              scratch_pool, scratch_pool));
           work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
-
-#ifndef SVN_WC__SINGLE_DB
-          if (kind == svn_node_dir)
-            {
-              /* Create the per-directory db in the copied directory.  The
-                 copy is not yet connected to the parent so we don't need
-                 to use a workqueue.  This will be removed when we
-                 centralise. */
-              const char *dst_parent_abspath, *name;
-              const char *repos_root_url, *repos_uuid;
-              svn_revnum_t revision;
-              svn_depth_t depth;
-              svn_wc__db_status_t status;
-              svn_boolean_t have_base;
-
-              svn_dirent_split(&dst_parent_abspath, &name, dst_abspath,
-                               scratch_pool);
-
-              SVN_ERR(svn_wc__db_read_info(&status,
-                                           NULL, /* kind */
-                                           &revision,
-                                           NULL, /* repos_relpath */
-                                           &repos_root_url,
-                                           &repos_uuid,
-                                           NULL, /* changed_rev */
-                                           NULL, /* changed_date */
-                                           NULL, /* changed_author */
-                                           NULL, /* last_mod_time */
-                                           &depth,
-                                           NULL, /* checksum */
-                                           NULL, /* translated_size */
-                                           NULL, /* target */
-                                           NULL, /* changelist */
-                                           NULL, /* original_repos_relpath */
-                                           NULL, /* original_root_url */
-                                           NULL, /* original_uuid */
-                                           NULL, /* original_revision */
-                                           NULL, /* props_mod */
-                                           &have_base,
-                                           NULL, /* have_work */
-                                           NULL, /* conflicted */
-                                           NULL, /* lock */
-                                           db, src_abspath,
-                                           scratch_pool, scratch_pool));
-
-              if (!repos_root_url)
-                {
-                  if (status == svn_wc__db_status_deleted)
-                    {
-                      const char *work_del_abspath;
-
-                      SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL, NULL,
-                                                       &work_del_abspath,
-                                                       db, src_abspath,
-                                                       scratch_pool,
-                                                       scratch_pool));
-                      if (work_del_abspath)
-                        {
-                          const char *parent_del_abspath
-                            = svn_dirent_dirname(work_del_abspath,
-                                                 scratch_pool);
-
-                          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL,
-                                                           &repos_root_url,
-                                                           &repos_uuid,
-                                                           NULL, NULL, NULL,
-                                                           NULL,
-                                                           db,
-                                                           parent_del_abspath,
-                                                           scratch_pool,
-                                                           scratch_pool));
-                        }
-                      else
-                        SVN_ERR(svn_wc__db_scan_base_repos(NULL,
-                                                           &repos_root_url,
-                                                           &repos_uuid,
-                                                           db, src_abspath,
-                                                           scratch_pool,
-                                                           scratch_pool));
-                    }
-                  else if (status == svn_wc__db_status_added || !have_base)
-                    SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL,
-                                                     &repos_root_url,
-                                                     &repos_uuid,
-                                                     NULL, NULL, NULL, NULL,
-                                                     db, src_abspath,
-                                                     scratch_pool,
-                                                     scratch_pool));
-                  else
-                    SVN_ERR(svn_wc__db_scan_base_repos(NULL, &repos_root_url,
-                                                       &repos_uuid,
-                                                       db, src_abspath,
-                                                       scratch_pool,
-                                                       scratch_pool));
-                }
-
-              /* Use the repos_root as root node url, because we are going to
-                 remove the node directly anyway. */
-              SVN_ERR(svn_wc__internal_ensure_adm(db, tmp_dst_abspath,
-                                                  repos_root_url,
-                                                  repos_root_url,
-                                                  repos_uuid, revision, depth,
-                                                  scratch_pool));
-
-              /* That creates a base node which we do not want so delete it. */
-              SVN_ERR(svn_wc__db_base_remove(db, tmp_dst_abspath,
-                                             scratch_pool));
-
-              /* ### Need to close the database so that Windows can move
-                 ### the directory. */
-              SVN_ERR(svn_wc__db_temp_forget_directory(db, tmp_dst_abspath,
-                                                       scratch_pool));
-            }
-#endif
         }
     }
 
@@ -385,17 +271,6 @@ copy_versioned_dir(svn_wc__db_t *db,
   SVN_ERR(svn_wc__wq_run(db, dir_abspath,
                          cancel_func, cancel_baton, scratch_pool));
 
-#ifndef SVN_WC__SINGLE_DB
-  if (kind == svn_node_dir)
-    {
-      /* The first copy only does the parent stub, this second copy
-         does the full node but can only happen after the workqueue
-         has moved the destination into place. */
-      SVN_ERR(svn_wc__db_op_copy(db, src_abspath, dst_abspath,
-                                 NULL, scratch_pool));
-    }
-#endif
-
   if (notify_func)
     {
       svn_wc_notify_t *notify
@@ -642,9 +517,6 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
                      svn_dirent_local_style(dst_abspath, scratch_pool));
 
           case svn_wc__db_status_deleted:
-#ifndef SVN_WC__SINGLE_DB
-          case svn_wc__db_status_obstructed_delete:
-#endif
           case svn_wc__db_status_not_present:
             break; /* OK to add */
 
@@ -658,14 +530,7 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
 
   SVN_ERR(svn_io_check_path(src_abspath, &src_kind, scratch_pool));
 
-#ifndef SINGLE_DB
-  if (src_kind == svn_node_file ||
-      (src_kind == svn_node_none
-        && (src_db_kind == svn_wc__db_kind_file
-            || src_db_kind == svn_wc__db_kind_symlink)))
-#else
   if (!metadata_only)
-#endif
     {
       svn_node_kind_t dst_kind;
 

Modified: subversion/branches/performance/subversion/libsvn_wc/upgrade.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/upgrade.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/branches/performance/subversion/libsvn_wc/upgrade.c Thu Sep  9 15:59:00 2010
@@ -35,6 +35,7 @@
 #include "wc_db.h"
 #include "tree_conflicts.h"
 #include "wc-queries.h"  /* for STMT_*  */
+#include "workqueue.h"
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
@@ -495,6 +496,54 @@ wipe_obsolete_files(const char *wcroot_a
                     TRUE, scratch_pool));
 }
 
+svn_error_t *
+svn_wc__wipe_postupgrade(const char *dir_abspath,
+                         svn_boolean_t whole_admin,
+                         svn_cancel_func_t cancel_func,
+                         void *cancel_baton,
+                         apr_pool_t *scratch_pool)
+{
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+  apr_array_header_t *subdirs;
+  svn_error_t *err;
+  int i;
+
+  if (cancel_func)
+    SVN_ERR((*cancel_func)(cancel_baton));
+
+  err = get_versioned_subdirs(&subdirs, dir_abspath, scratch_pool, iterpool);
+  if (err)
+    {
+      if (APR_STATUS_IS_ENOENT(err->apr_err))
+        {
+          /* An unversioned dir is obstructing a versioned dir */
+          svn_error_clear(err);
+          err = NULL;
+        }
+      svn_pool_destroy(iterpool);
+      return err;
+    }
+  for (i = 0; i < subdirs->nelts; ++i)
+    {
+      const char *child_abspath = APR_ARRAY_IDX(subdirs, i, const char *);
+
+      svn_pool_clear(iterpool);
+      SVN_ERR(svn_wc__wipe_postupgrade(child_abspath, TRUE,
+                                       cancel_func, cancel_baton, iterpool));
+    }
+
+  /* ### Should we really be ignoring errors here? */
+  if (whole_admin)
+    svn_error_clear(svn_io_remove_dir2(svn_wc__adm_child(dir_abspath, "",
+                                                         iterpool),
+                                       TRUE, NULL, NULL, iterpool));
+  else
+    wipe_obsolete_files(dir_abspath, scratch_pool);
+
+  svn_pool_destroy(iterpool);
+
+  return SVN_NO_ERROR;
+}
 
 /* Ensure that ENTRY has its REPOS and UUID fields set. These will be
    used to establish the REPOSITORY row in the new database, and then
@@ -1252,13 +1301,15 @@ upgrade_to_wcng(svn_wc__db_t *db,
     {
       const char *root_adm_abspath;
 
-      /* In root wc construst path to temporary root wc/.svn/wcng/.svn
+      /* In root wc construst path to temporary root wc/.svn/tmp/wcng/.svn */
 
-         ### This should really be in tmp so that 1.6 can cleanup if
-             interrupted, i.e. wc/.svn/tmp/wcng/.svn */
-      data->root_abspath = svn_wc__adm_child(dir_abspath, "wcng", result_pool);
+      data->root_abspath = svn_dirent_join(svn_wc__adm_child(dir_abspath, "tmp",
+                                                             scratch_pool),
+                                           "wcng", result_pool);
       root_adm_abspath = svn_wc__adm_child(data->root_abspath, "",
                                            scratch_pool);
+      SVN_ERR(svn_io_remove_dir2(root_adm_abspath, TRUE, NULL, NULL,
+                                 scratch_pool));
       SVN_ERR(svn_wc__ensure_directory(root_adm_abspath, scratch_pool));
 
       /* Create an empty sqlite database for this directory. */
@@ -1323,20 +1374,6 @@ upgrade_to_wcng(svn_wc__db_t *db,
   /* All done. DB should finalize the upgrade process now.  */
   SVN_ERR(svn_wc__db_upgrade_finish(dir_abspath, data->sdb, scratch_pool));
 
-  /* Zap all the obsolete files. This removes the old-style lock file.
-     In single-db we should postpone this until we have processed all
-     entries files into the single-db, otherwise an interrupted
-     upgrade is nasty.  Perhaps add a wq item?  If we do postpone then
-     perhaps we should still remove the lock otherwise the user has to
-     use 1.6 to cleanup. */
-  wipe_obsolete_files(dir_abspath, scratch_pool);
-
-  /* Remove the admin dir in subdirectories of the root. */
-  if (!svn_dirent_is_ancestor(dir_abspath, data->root_abspath))
-    svn_error_clear(svn_io_remove_dir2(svn_wc__adm_child(dir_abspath, NULL,
-                                                         scratch_pool),
-                                       FALSE, NULL, NULL, scratch_pool));
-
   return SVN_NO_ERROR;
 }
 
@@ -1494,9 +1531,9 @@ upgrade_working_copy(svn_wc__db_t *db,
   int old_format;
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_array_header_t *subdirs;
+  svn_error_t *err;
   int i;
 
-  /* Check cancellation; note that this catches recursive calls too. */
   if (cancel_func)
     SVN_ERR(cancel_func(cancel_baton));
 
@@ -1510,13 +1547,28 @@ upgrade_working_copy(svn_wc__db_t *db,
                     svn_wc_create_notify(dir_abspath, svn_wc_notify_skip,
                                          iterpool),
                 iterpool);
+      svn_pool_destroy(iterpool);
       return SVN_NO_ERROR;
     }
 
-  /* At present upgrade_to_wcng removes the entries file so get the
-     children before calling it. */
-  SVN_ERR(get_versioned_subdirs(&subdirs, dir_abspath,
-                                scratch_pool, iterpool));
+  err = get_versioned_subdirs(&subdirs, dir_abspath, scratch_pool, iterpool);
+  if (err)
+    {
+      if (APR_STATUS_IS_ENOENT(err->apr_err))
+        {
+          /* An unversioned dir is obstructing a versioned dir */
+          svn_error_clear(err);
+          err = NULL;
+          if (notify_func)
+            notify_func(notify_baton,
+                        svn_wc_create_notify(dir_abspath, svn_wc_notify_skip,
+                                             iterpool),
+                        iterpool);
+        }
+      svn_pool_destroy(iterpool);
+      return err;
+    }
+
 
   SVN_ERR(upgrade_to_wcng(db, dir_abspath, old_format,
                           repos_info_func, repos_info_baton,
@@ -1599,12 +1651,8 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
 {
   svn_wc__db_t *db;
   struct upgrade_data_t data = { NULL };
-
-  /* We need a DB that does not attempt an auto-upgrade, nor require
-     running a stale work queue. We'll handle everything manually.  */
-  SVN_ERR(svn_wc__db_open(&db, svn_wc__db_openmode_readwrite,
-                          NULL /* ### config */, FALSE, FALSE,
-                          scratch_pool, scratch_pool));
+  svn_skel_t *work_item, *work_items = NULL;
+  const char *pristine_from, *pristine_to, *db_from, *db_to;
 
   if (!is_old_wcroot(local_abspath, scratch_pool))
     return svn_error_createf(
@@ -1612,7 +1660,20 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
       _("Cannot upgrade '%s' as it is not a pre-1.7 working copy root"),
       svn_dirent_local_style(local_abspath, scratch_pool));
 
-  /* Upgrade this directory and/or its subdirectories.  */
+  /* Given a pre-wcng root some/wc we create a temporary wcng in
+     some/wc/.svn/tmp/wcng/wc.db and copy the metadata from one to the
+     other, then the temporary wc.db file gets moved into the original
+     root.  Until the wc.db file is moved the original working copy
+     remains a pre-wcng and 'cleanup' with an old client will remove
+     the partial upgrade.  Moving the wc.db file creates a wcng, and
+     'cleanup' with a new client will complete any outstanding
+     upgrade. */
+
+  SVN_ERR(svn_wc__db_open(&db, svn_wc__db_openmode_readwrite,
+                          NULL /* ### config */, FALSE, FALSE,
+                          scratch_pool, scratch_pool));
+
+  /* Upgrade the pre-wcng into a wcng in a temporary location. */
   SVN_ERR(upgrade_working_copy(db, local_abspath,
                                repos_info_func, repos_info_baton,
                                apr_hash_make(scratch_pool), &data,
@@ -1620,32 +1681,42 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
                                notify_func, notify_baton,
                                scratch_pool));
 
+  /* A workqueue item to move the pristine dir into place */
+  pristine_from = svn_wc__adm_child(data.root_abspath, PRISTINE_STORAGE_RELPATH,
+                                    scratch_pool);
+  pristine_to = svn_wc__adm_child(local_abspath, PRISTINE_STORAGE_RELPATH,
+                                  scratch_pool);
+  SVN_ERR(svn_wc__wq_build_file_move(&work_item, db,
+                                     pristine_from, pristine_to,
+                                     scratch_pool, scratch_pool));
+  work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+
+  /* A workqueue item to remove pre-wcng metadata */
+  SVN_ERR(svn_wc__wq_build_postupgrade(&work_item, scratch_pool));
+  work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+  SVN_ERR(svn_wc__db_wq_add(db, data.root_abspath, work_items, scratch_pool));
+
   SVN_ERR(svn_wc__db_wclock_release(db, data.root_abspath, scratch_pool));
-  SVN_ERR(svn_wc__db_drop_root(db, data.root_abspath, scratch_pool));
   SVN_ERR(svn_sqlite__close(data.sdb));
-  {
-    const char *pristine_from = svn_wc__adm_child(data.root_abspath,
-                                                  PRISTINE_STORAGE_RELPATH,
-                                                  scratch_pool);
-    const char *pristine_to = svn_wc__adm_child(local_abspath,
-                                                PRISTINE_STORAGE_RELPATH,
-                                                scratch_pool);
-    SVN_ERR(svn_io_file_rename(pristine_from, pristine_to, scratch_pool));
-  }
-  {
-    const char *db_from = svn_wc__adm_child(data.root_abspath, SDB_FILE,
-                                            scratch_pool);
-    const char *db_to = svn_wc__adm_child(local_abspath, SDB_FILE,
-                                          scratch_pool);
-    SVN_ERR(svn_io_file_rename(db_from, db_to, scratch_pool));
-  }
-  {
-    SVN_ERR(svn_io_remove_dir2(data.root_abspath, FALSE, NULL, NULL,
-                               scratch_pool));
-  }
+  SVN_ERR(svn_wc__db_close(db));
 
+  /* Renaming the db file is what makes the pre-wcng into a wcng */
+  db_from = svn_wc__adm_child(data.root_abspath, SDB_FILE, scratch_pool);
+  db_to = svn_wc__adm_child(local_abspath, SDB_FILE, scratch_pool);
+  SVN_ERR(svn_io_file_rename(db_from, db_to, scratch_pool));
+
+  /* Now we have a working wcng, tidy up the droppings */
+  SVN_ERR(svn_wc__db_open(&db, svn_wc__db_openmode_readwrite,
+                          NULL /* ### config */, FALSE, FALSE,
+                          scratch_pool, scratch_pool));
+  SVN_ERR(svn_wc__wq_run(db, local_abspath, cancel_func, cancel_baton,
+                         scratch_pool));
   SVN_ERR(svn_wc__db_close(db));
 
+  /* Should we have the workqueue remove this empty dir? */
+  SVN_ERR(svn_io_remove_dir2(data.root_abspath, FALSE, NULL, NULL,
+                             scratch_pool));
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/performance/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc-queries.sql?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc-queries.sql Thu Sep  9 15:59:00 2010
@@ -106,11 +106,6 @@ insert or ignore into base_node (
   kind, revnum, depth)
 values (?1, ?2, ?3, ?4, ?5, 'incomplete', 'dir', ?6, ?7);
 
--- STMT_INSERT_BASE_NODE_DATA_INCOMPLETE_DIR
-insert or ignore into node_data (
-  wc_id, local_relpath, op_depth, parent_relpath, presence, kind, depth)
-values (?1, ?2, 0, ?3, 'incomplete', 'dir', ?4);
-
 -- STMT_INSERT_WORKING_NODE_INCOMPLETE
 INSERT OR IGNORE INTO WORKING_NODE (
   wc_id, local_relpath, parent_relpath, presence, kind)

Modified: subversion/branches/performance/subversion/libsvn_wc/wc.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc.h?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc.h (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc.h Thu Sep  9 15:59:00 2010
@@ -649,6 +649,13 @@ svn_wc__upgrade_sdb(int *result_format,
                     apr_pool_t *scratch_pool);
 
 
+svn_error_t *
+svn_wc__wipe_postupgrade(const char *dir_abspath,
+                         svn_boolean_t whole_admin,
+                         svn_cancel_func_t cancel_func,
+                         void *cancel_baton,
+                         apr_pool_t *scratch_pool);
+
 /* Check whether a node is a working copy root or switched.
  *
  * If LOCAL_ABSPATH is the root of a working copy, set *WC_ROOT to TRUE,

Modified: subversion/branches/performance/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc_db.c?rev=995478&r1=995477&r2=995478&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc_db.c Thu Sep  9 15:59:00 2010
@@ -647,22 +647,27 @@ insert_base_node(void *baton, svn_sqlite
 #endif
 
 #ifdef SVN_WC__NODES
+  /* the 'r' binding below doesn't work yet...
+     no idea why; needs more investigation... */
   SVN_ERR(svn_sqlite__get_statement(&stmt_node, sdb, STMT_INSERT_NODE));
+  { svn_revnum_t rev = pibb->changed_rev;
   SVN_ERR(svn_sqlite__bindf(stmt_node, "isisnnn" /* No repos rev, id, path */
-                            "tstrssnnnnns",
-                            pibb->wc_id, pibb->local_relpath,
+                            "tstr"               /* 8 - 11 */
+                            "isnnnnns",          /* 12 - 19 */
+                            pibb->wc_id,         /* 1 */
+                            pibb->local_relpath, /* 2 */
                             (apr_int64_t)0, /* op_depth is 0 for base */
-                            parent_relpath,
-                            presence_map, pibb->status,
-                            (pibb->kind == svn_wc__db_kind_dir) ?
-                                svn_depth_to_word(pibb->depth) : NULL,
-                            kind_map, pibb->kind,
-                            pibb->changed_rev,
-                            pibb->changed_date,
-                            pibb->changed_author,
+                            parent_relpath,      /* 4 */
+                            presence_map, pibb->status, /* 8 */
+                            (pibb->kind == svn_wc__db_kind_dir) ? /* 9 */
+                               svn_depth_to_word(pibb->depth) : NULL,
+                            kind_map, pibb->kind, /* 10 */
+                            rev,                  /* 11 */
+                            pibb->changed_date,   /* 12 */
+                            pibb->changed_author, /* 13 */
                             (pibb->kind == svn_wc__db_kind_symlink) ?
-                                pibb->target : NULL));
-
+                                pibb->target : NULL)); /* 19 */
+  }
 
   if (pibb->kind == svn_wc__db_kind_file)
     SVN_ERR(svn_sqlite__bind_checksum(stmt_node, 14, pibb->checksum,
@@ -678,17 +683,20 @@ insert_base_node(void *baton, svn_sqlite
     {
       int i;
 
+#ifndef SVN_WC__NODES_ONLY
       SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
                                         STMT_INSERT_BASE_NODE_INCOMPLETE));
-#ifdef SVN_WC__NODE_DATA
+#endif
+#ifdef SVN_WC__NODES
       SVN_ERR(svn_sqlite__get_statement(&stmt_node, sdb,
-                                        STMT_INSERT_NODE_DATA_INCOMPLETE));
+                                        STMT_INSERT_NODE));
 #endif
 
       for (i = pibb->children->nelts; i--; )
         {
           const char *name = APR_ARRAY_IDX(pibb->children, i, const char *);
 
+#ifndef SVN_WC__NODES_ONLY
           SVN_ERR(svn_sqlite__bindf(stmt, "issi",
                                     pibb->wc_id,
                                     svn_relpath_join(pibb->local_relpath,
@@ -697,15 +705,17 @@ insert_base_node(void *baton, svn_sqlite
                                     pibb->local_relpath,
                                     (apr_int64_t)pibb->revision));
           SVN_ERR(svn_sqlite__insert(NULL, stmt));
-
-#ifdef SVN_WC__NODE_DATA
-          SVN_ERR(svn_sqlite__bindf(stmt_node, "isis",
+#endif
+#ifdef SVN_WC__NODES
+          SVN_ERR(svn_sqlite__bindf(stmt_node, "isisnnnsns",
                                     pibb->wc_id,
                                     svn_relpath_join(pibb->local_relpath,
                                                      name,
                                                      scratch_pool),
                                     (apr_int64_t)0 /* BASE */,
-                                    pibb->local_relpath));
+                                    pibb->local_relpath, /* parent_relpath */
+                                    "incomplete",
+                                    "unknown"));
           SVN_ERR(svn_sqlite__insert(NULL, stmt_node));
 #endif
         }
@@ -783,17 +793,21 @@ insert_incomplete_working_children(svn_s
                                    const apr_array_header_t *children,
                                    apr_pool_t *scratch_pool)
 {
+#ifndef SVN_WC__NODES_ONLY
   svn_sqlite__stmt_t *stmt;
-#ifdef SVN_WC__NODE_DATA
+#endif
+#ifdef SVN_WC__NODES
   svn_sqlite__stmt_t *stmt_node;
 #endif
   int i;
 
+#ifndef SVN_WC__NODES_ONLY
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
                                     STMT_INSERT_WORKING_NODE_INCOMPLETE));
-#ifdef SVN_WC__NODE_DATA
+#endif
+#ifdef SVN_WC__NODES
   SVN_ERR(svn_sqlite__get_statement(&stmt_node, sdb,
-                                    STMT_INSERT_NODE_DATA_INCOMPLETE));
+                                    STMT_INSERT_NODE));
 #endif
 
 
@@ -801,21 +815,25 @@ insert_incomplete_working_children(svn_s
     {
       const char *name = APR_ARRAY_IDX(children, i, const char *);
 
+#ifndef SVN_WC__NODES_ONLY
       SVN_ERR(svn_sqlite__bindf(stmt, "iss",
                                 wc_id,
                                 svn_relpath_join(local_relpath, name,
                                                  scratch_pool),
                                 local_relpath));
       SVN_ERR(svn_sqlite__insert(NULL, stmt));
-
-#ifdef SVN_WC__NODE_DATA
-      SVN_ERR(svn_sqlite__bindf(stmt_node, "isis",
+#endif
+#ifdef SVN_WC__NODES
+      SVN_ERR(svn_sqlite__bindf(stmt_node, "isisnnnsns",
                                 wc_id,
                                 svn_relpath_join(local_relpath, name,
                                                  scratch_pool),
                                 (apr_int64_t) 2, /* ### op_depth
                                                     non-THIS_DIR working */
-                                local_relpath));
+                                local_relpath,
+                                "incomplete", /* 8, presence */
+                                "unknown"));  /* 10, kind */
+
       SVN_ERR(svn_sqlite__insert(NULL, stmt_node));
 #endif
     }
@@ -8591,6 +8609,7 @@ svn_wc__db_temp_op_set_file_external(svn
       SVN_ERR(create_repos_id(&repos_id, repos_root_url, repos_uuid,
                               pdh->wcroot->sdb, scratch_pool));
 
+#ifndef SVN_WC__NODES_ONLY
       /* ### Insert a switched not present base node. Luckily this hack
              is not as ugly as the original file externals hack. */
       SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
@@ -8607,6 +8626,7 @@ svn_wc__db_temp_op_set_file_external(svn
                                 kind_map, svn_wc__db_kind_file));
 
       SVN_ERR(svn_sqlite__insert(NULL, stmt));
+#endif
 
 #ifdef SVN_WC__NODES
 
@@ -8913,7 +8933,7 @@ set_new_dir_to_incomplete_txn(void *bato
   SVN_ERR(svn_sqlite__step_done(stmt));
 #endif
 
-
+#ifndef SVN_WC__NODES_ONLY
   /* Insert the incomplete base node */
   SVN_ERR(svn_sqlite__get_statement(&stmt, dtb->pdh->wcroot->sdb,
                                     STMT_INSERT_BASE_NODE_INCOMPLETE_DIR));
@@ -8930,20 +8950,27 @@ set_new_dir_to_incomplete_txn(void *bato
     SVN_ERR(svn_sqlite__bind_text(stmt, 7, svn_depth_to_word(dtb->depth)));
 
   SVN_ERR(svn_sqlite__step_done(stmt));
+#endif
 
-#ifdef SVN_WC__NODE_DATA
+
+#ifdef SVN_WC__NODES
 
   /* Insert the incomplete base node */
   SVN_ERR(svn_sqlite__get_statement(&stmt, dtb->pdh->wcroot->sdb,
-                                    STMT_INSERT_BASE_NODE_DATA_INCOMPLETE_DIR));
+                                    STMT_INSERT_NODE));
 
-  SVN_ERR(svn_sqlite__bindf(stmt, "iss", dtb->pdh->wcroot->wc_id,
-                            dtb->local_relpath,
-                            parent_relpath));
+  SVN_ERR(svn_sqlite__bindf(stmt, "isis" /* 1 - 4 */
+                            "nnn" "sns", /* 5 - 7(n), 8, 9(n), 10 */
+                            dtb->pdh->wcroot->wc_id, /* 1 */
+                            dtb->local_relpath,      /* 2 */
+                            (apr_int64_t)0, /* op_depth == 0; BASE */
+                            parent_relpath,          /* 4 */
+                            "incomplete",            /* 8, presence */
+                            "dir"));                 /* 10, kind */
 
   /* If depth is not unknown: record depth */
   if (dtb->depth >= svn_depth_empty && dtb->depth <= svn_depth_infinity)
-    SVN_ERR(svn_sqlite__bind_text(stmt, 4, svn_depth_to_word(dtb->depth)));
+    SVN_ERR(svn_sqlite__bind_text(stmt, 9, svn_depth_to_word(dtb->depth)));
 
   SVN_ERR(svn_sqlite__step_done(stmt));