You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/03/05 22:39:33 UTC

svn commit: r1078365 [4/5] - in /subversion/branches/performance: ./ build/generator/ contrib/client-side/ notes/ notes/feedback/ notes/wc-ng/ subversion/bindings/swig/perl/native/ subversion/include/ subversion/include/private/ subversion/libsvn_clien...

Modified: subversion/branches/performance/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc_db.h?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc_db.h Sat Mar  5 21:39:30 2011
@@ -890,7 +890,11 @@ svn_wc__db_pristine_get_future_path(cons
 
 
 /* Set *CONTENTS to a readable stream that will yield the pristine text
-   identified by CHECKSUM (### which should/must be its SHA-1 checksum?).
+   identified by SHA1_CHECKSUM (### which should/must be its SHA-1 checksum?)
+   within the WC identified by WRI_ABSPATH in DB.
+
+   Even if the pristine text is removed from the store while it is being
+   read, the stream will remain valid and readable until it is closed.
 
    Allocate the stream in RESULT_POOL. */
 svn_error_t *
@@ -1246,15 +1250,19 @@ svn_wc__db_op_revert_actual(svn_wc__db_t
 /* Revert all local changes which are being maintained in the database,
  * including conflict storage, properties and text modification status.
  *
- * This is a non-recursive operation.
- *
  * Returns SVN_ERR_WC_INVALID_OPERATION_DEPTH if the revert is not
  * possible, e.g. copy/delete but not a root, or a copy root with
  * children.
+ *
+ * At present only depth=empty and depth=infinity are supported.
+ *
+ * ### Need to return the modified paths for notification.  An array
+ * ### or hash?  A temporary SQLite table?
  */
 svn_error_t *
 svn_wc__db_op_revert(svn_wc__db_t *db,
                      const char *local_abspath,
+                     svn_depth_t depth,
                      apr_pool_t *scratch_pool);
 
 
@@ -1584,10 +1592,12 @@ svn_wc__db_read_props(apr_hash_t **props
 /* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
  * a hash table mapping <tt>char *</tt> names onto svn_string_t *
  * values for any properties of file child nodes of LOCAL_ABSPATH.
+ * If PRISTINE is TRUE, read the pristine props (op_depth = 0).
  */
 svn_error_t *
 svn_wc__db_read_props_of_files(svn_wc__db_t *db,
                                const char *local_abspath,
+                               svn_boolean_t pristine,
                                svn_wc__proplist_receiver_t receiver_func,
                                void *receiver_baton,
                                svn_cancel_func_t cancel_func,
@@ -1597,10 +1607,12 @@ svn_wc__db_read_props_of_files(svn_wc__d
 /* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
  * a hash table mapping <tt>char *</tt> names onto svn_string_t *
  * values for any properties of immediate child nodes of LOCAL_ABSPATH.
+ * If PRISTINE is TRUE, read the pristine props (op_depth = 0).
  */
 svn_error_t *
 svn_wc__db_read_props_of_immediates(svn_wc__db_t *db,
                                     const char *local_abspath,
+                                    svn_boolean_t pristine,
                                     svn_wc__proplist_receiver_t receiver_func,
                                     void *receiver_baton,
                                     svn_cancel_func_t cancel_func,
@@ -1610,10 +1622,12 @@ svn_wc__db_read_props_of_immediates(svn_
 /* Call RECEIVER_FUNC, passing RECEIVER_BATON, an absolute path, and
  * a hash table mapping <tt>char *</tt> names onto svn_string_t *
  * values for any properties of all (recursive) child nodes of LOCAL_ABSPATH.
+ * If PRISTINE is TRUE, read the pristine props (op_depth = 0).
  */
 svn_error_t *
 svn_wc__db_read_props_recursive(svn_wc__db_t *db,
                                 const char *local_abspath,
+                                svn_boolean_t pristine,
                                 svn_wc__proplist_receiver_t receiver_func,
                                 void *receiver_baton,
                                 svn_cancel_func_t cancel_func,
@@ -2486,6 +2500,26 @@ svn_wc__db_temp_below_work(svn_boolean_t
                            apr_pool_t *scratch_pool);
 
 
+/* Set *MIN_REVISION and *MAX_REVISION to the lowest and highest revision
+ * numbers found within LOCAL_ABSPATH in the working copy using DB.
+ * Only nodes with op_depth zero and presence 'normal' or 'incomplete'
+ * are considered, so that added, deleted or excluded nodes do not affect
+ * the result. */
+svn_error_t *
+svn_wc__db_get_min_max_revisions(svn_revnum_t *min_revision,
+                                 svn_revnum_t *max_revision,
+                                 svn_wc__db_t *db,
+                                 const char *local_abspath,
+                                 apr_pool_t *scratch_pool);
+
+/* Indicate in *HAS_ABSENT_CHILDREN whether there are any absent children
+ * beneath LOCAL_ABSPATH in the working copy using DB. */
+svn_error_t *
+svn_wc__db_has_absent_children(svn_boolean_t *has_absent_children,
+                               svn_wc__db_t *db,
+                               const char *local_abspath,
+                               apr_pool_t *scratch_pool);
+
 /* @} */
 
 

Modified: subversion/branches/performance/subversion/libsvn_wc/wc_db_pdh.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc_db_pdh.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc_db_pdh.c (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc_db_pdh.c Sat Mar  5 21:39:30 2011
@@ -41,7 +41,6 @@
 
 
 
-
 /* Get the format version from a wc-1 directory. If it is not a working copy
    directory, then it sets VERSION to zero and returns no error.  */
 static svn_error_t *
@@ -127,34 +126,6 @@ close_wcroot(void *data)
 }
 
 
-svn_wc__db_pdh_t *
-svn_wc__db_pdh_get_or_create(svn_wc__db_t *db,
-                             const char *local_dir_abspath,
-                             svn_boolean_t create_allowed,
-                             apr_pool_t *scratch_pool)
-{
-  svn_wc__db_pdh_t *pdh = apr_hash_get(db->dir_data,
-                                       local_dir_abspath, APR_HASH_KEY_STRING);
-
-  if (pdh == NULL && create_allowed)
-    {
-      pdh = apr_pcalloc(db->state_pool, sizeof(*pdh));
-
-      /* Copy the path for the proper lifetime.  */
-      pdh->local_abspath = apr_pstrdup(db->state_pool, local_dir_abspath);
-
-      /* We don't know anything about this directory, so we cannot construct
-         a svn_wc__db_wcroot_t for it (yet).  */
-
-      /* ### parent */
-
-      apr_hash_set(db->dir_data, pdh->local_abspath, APR_HASH_KEY_STRING, pdh);
-    }
-
-  return pdh;
-}
-
-
 svn_error_t *
 svn_wc__db_open(svn_wc__db_t **db,
                 svn_wc__db_openmode_t mode,
@@ -188,19 +159,13 @@ svn_wc__db_close(svn_wc__db_t *db)
        hi;
        hi = apr_hash_next(hi))
     {
-      const void *key;
-      apr_ssize_t klen;
-      void *val;
-      svn_wc__db_pdh_t *pdh;
-
-      apr_hash_this(hi, &key, &klen, &val);
-      pdh = val;
-
-      if (pdh->wcroot && pdh->wcroot->sdb)
-        apr_hash_set(roots, pdh->wcroot->abspath, APR_HASH_KEY_STRING,
-                     pdh->wcroot);
+      svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi);
+      const char *local_abspath = svn__apr_hash_index_key(hi);
 
-      apr_hash_set(db->dir_data, key, klen, NULL);
+      if (wcroot->sdb)
+        apr_hash_set(roots, wcroot->abspath, APR_HASH_KEY_STRING, wcroot);
+
+      apr_hash_set(db->dir_data, local_abspath, APR_HASH_KEY_STRING, NULL);
     }
 
   /* Run the cleanup for each WCROOT.  */
@@ -317,12 +282,12 @@ svn_wc__db_close_many_wcroots(apr_hash_t
 
 
 /* POOL may be NULL if the lifetime of LOCAL_ABSPATH is sufficient.  */
-const char *
-svn_wc__db_pdh_compute_relpath(const svn_wc__db_pdh_t *pdh,
-                               apr_pool_t *result_pool)
+static const char *
+compute_relpath(const svn_wc__db_wcroot_t *wcroot,
+                const char *local_abspath,
+                apr_pool_t *result_pool)
 {
-  const char *relpath = svn_dirent_is_child(pdh->wcroot->abspath,
-                                            pdh->local_abspath,
+  const char *relpath = svn_dirent_is_child(wcroot->abspath, local_abspath,
                                             result_pool);
   if (relpath == NULL)
     return "";
@@ -331,20 +296,22 @@ svn_wc__db_pdh_compute_relpath(const svn
 
 
 svn_error_t *
-svn_wc__db_pdh_parse_local_abspath(svn_wc__db_pdh_t **pdh,
-                                   const char **local_relpath,
-                                   svn_wc__db_t *db,
-                                   const char *local_abspath,
-                                   svn_sqlite__mode_t smode,
-                                   apr_pool_t *result_pool,
-                                   apr_pool_t *scratch_pool)
+svn_wc__db_wcroot_parse_local_abspath(svn_wc__db_wcroot_t **wcroot,
+                                      const char **local_relpath,
+                                      svn_wc__db_t *db,
+                                      const char *local_abspath,
+                                      svn_sqlite__mode_t smode,
+                                      apr_pool_t *result_pool,
+                                      apr_pool_t *scratch_pool)
 {
+  const char *local_dir_abspath;
   const char *original_abspath = local_abspath;
   svn_node_kind_t kind;
   svn_boolean_t special;
   const char *build_relpath;
-  svn_wc__db_pdh_t *found_pdh = NULL;
-  svn_wc__db_pdh_t *child_pdh;
+  svn_wc__db_wcroot_t *probe_wcroot;
+  svn_wc__db_wcroot_t *found_wcroot = NULL;
+  const char *scan_abspath;
   svn_sqlite__db_t *sdb;
   svn_boolean_t moved_upwards = FALSE;
   svn_boolean_t always_check = FALSE;
@@ -363,15 +330,19 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
      ### everything in readwrite mode.  */
   smode = svn_sqlite__mode_readwrite;
 
-  *pdh = apr_hash_get(db->dir_data, local_abspath, APR_HASH_KEY_STRING);
-  if (*pdh != NULL && (*pdh)->wcroot != NULL)
+  probe_wcroot = apr_hash_get(db->dir_data, local_abspath,
+                              APR_HASH_KEY_STRING);
+  if (probe_wcroot != NULL)
     {
+      *wcroot = probe_wcroot;
+
       /* We got lucky. Just return the thing BEFORE performing any I/O.  */
       /* ### validate SMODE against how we opened wcroot->sdb? and against
          ### DB->mode? (will we record per-dir mode?)  */
 
       /* ### for most callers, we could pass NULL for result_pool.  */
-      *local_relpath = svn_wc__db_pdh_compute_relpath(*pdh, result_pool);
+      *local_relpath = compute_relpath(probe_wcroot, local_abspath,
+                                       result_pool);
 
       return SVN_NO_ERROR;
     }
@@ -392,21 +363,21 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
          For both of these cases, strip the basename off of the path and
          move up one level. Keep record of what we strip, though, since
          we'll need it later to construct local_relpath.  */
-      svn_dirent_split(&local_abspath, &build_relpath, local_abspath,
+      svn_dirent_split(&local_dir_abspath, &build_relpath, local_abspath,
                        scratch_pool);
 
-      /* ### if *pdh != NULL (from further above), then there is (quite
-         ### probably) a bogus value in the DIR_DATA hash table. maybe
-         ### clear it out? but what if there is an access baton?  */
-
       /* Is this directory in our hash?  */
-      *pdh = apr_hash_get(db->dir_data, local_abspath, APR_HASH_KEY_STRING);
-      if (*pdh != NULL && (*pdh)->wcroot != NULL)
+      probe_wcroot = apr_hash_get(db->dir_data, local_dir_abspath,
+                                  APR_HASH_KEY_STRING);
+      if (probe_wcroot != NULL)
         {
           const char *dir_relpath;
 
+          *wcroot = probe_wcroot;
+
           /* Stashed directory's local_relpath + basename. */
-          dir_relpath = svn_wc__db_pdh_compute_relpath(*pdh, NULL);
+          dir_relpath = compute_relpath(probe_wcroot, local_dir_abspath,
+                                        NULL);
           *local_relpath = svn_relpath_join(dir_relpath,
                                             build_relpath,
                                             result_pool);
@@ -419,31 +390,25 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
          rather than bailing out after the first check.  */
       if (kind == svn_node_none)
         always_check = TRUE;
+
+      /* Start the scanning at LOCAL_DIR_ABSPATH.  */
+      local_abspath = local_dir_abspath;
     }
   else
     {
       /* Start the local_relpath empty. If *this* directory contains the
          wc.db, then relpath will be the empty string.  */
       build_relpath = "";
-    }
-
-  /* LOCAL_ABSPATH refers to a directory at this point. The PDH corresponding
-     to that directory is what we need to return. At this point, we've
-     determined that a PDH with a discovered WCROOT is NOT in the DB's hash
-     table of wcdirs. Let's fill in an existing one, or create one. Then
-     go figure out where the WCROOT is.  */
 
-  if (*pdh == NULL)
-    {
-      *pdh = apr_pcalloc(db->state_pool, sizeof(**pdh));
-      (*pdh)->local_abspath = apr_pstrdup(db->state_pool, local_abspath);
-    }
-  else
-    {
-      /* The PDH should have been built correctly (so far).  */
-      SVN_ERR_ASSERT(strcmp((*pdh)->local_abspath, local_abspath) == 0);
+      /* Remember the dir containing LOCAL_ABSPATH (they're the same).  */
+      local_dir_abspath = local_abspath;
     }
 
+  /* LOCAL_ABSPATH refers to a directory at this point. At this point,
+     we've determined that an associated WCROOT is NOT in the DB's hash
+     table for this directory. Let's find an existing one in the ancestors,
+     or create one when we find the actual wcroot.  */
+
   /* Assume that LOCAL_ABSPATH is a directory, and look for the SQLite
      database in the right place. If we find it... great! If not, then
      peel off some components, and try again. */
@@ -493,27 +458,21 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
       moved_upwards = TRUE;
 
       /* Is the parent directory recorded in our hash?  */
-      found_pdh = apr_hash_get(db->dir_data,
-                               local_abspath, APR_HASH_KEY_STRING);
-      if (found_pdh != NULL)
-        {
-          if (found_pdh->wcroot != NULL)
-            break;
-          found_pdh = NULL;
-        }
+      found_wcroot = apr_hash_get(db->dir_data, local_abspath,
+                                  APR_HASH_KEY_STRING);
+      if (found_wcroot != NULL)
+        break;
     }
 
-  if (found_pdh != NULL)
+  if (found_wcroot != NULL)
     {
-      /* We found a PDH with data in it. We can now construct the child
-         from this, rather than continuing to scan upwards.  */
-
-      /* The subdirectory uses the same WCROOT as the parent dir.  */
-      (*pdh)->wcroot = found_pdh->wcroot;
+      /* We found a hash table entry for an ancestor, so we stopped scanning
+         since all subdirectories use the same WCROOT.  */
+      *wcroot = found_wcroot;
     }
   else if (wc_format == 0)
     {
-      /* We finally found the database. Construct the PDH record.  */
+      /* We finally found the database. Construct a wcroot_t for it.  */
 
       apr_int64_t wc_id;
       svn_error_t *err;
@@ -534,7 +493,7 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
          inside the wcroot, but we know the abspath is this directory
          (ie. where we found it).  */
 
-      SVN_ERR(svn_wc__db_pdh_create_wcroot(&(*pdh)->wcroot,
+      SVN_ERR(svn_wc__db_pdh_create_wcroot(wcroot,
                             apr_pstrdup(db->state_pool, local_abspath),
                             sdb, wc_id, FORMAT_FROM_SDB,
                             db->auto_upgrade, db->enforce_empty_wq,
@@ -543,7 +502,7 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
   else
     {
       /* We found a wc-1 working copy directory.  */
-      SVN_ERR(svn_wc__db_pdh_create_wcroot(&(*pdh)->wcroot,
+      SVN_ERR(svn_wc__db_pdh_create_wcroot(wcroot,
                             apr_pstrdup(db->state_pool, local_abspath),
                             NULL, UNKNOWN_WC_ID, wc_format,
                             db->auto_upgrade, db->enforce_empty_wq,
@@ -555,109 +514,72 @@ svn_wc__db_pdh_parse_local_abspath(svn_w
 
     /* The subdirectory's relpath is easily computed relative to the
        wcroot that we just found.  */
-    dir_relpath = svn_wc__db_pdh_compute_relpath(*pdh, NULL);
+    dir_relpath = compute_relpath(*wcroot, local_dir_abspath, NULL);
 
     /* And the result local_relpath may include a filename.  */
     *local_relpath = svn_relpath_join(dir_relpath, build_relpath, result_pool);
   }
 
-  /* The PDH is complete. Stash it into DB.  */
+  /* We've found the appropriate WCROOT for the requested path. Stash
+     it into that path's directory.  */
   apr_hash_set(db->dir_data,
-               (*pdh)->local_abspath, APR_HASH_KEY_STRING,
-               *pdh);
+               apr_pstrdup(db->state_pool, local_dir_abspath),
+               APR_HASH_KEY_STRING,
+               *wcroot);
 
   /* Did we traverse up to parent directories?  */
   if (!moved_upwards)
     {
       /* We did NOT move to a parent of the original requested directory.
-         We've constructed and filled in a PDH for the request, so we
+         We've constructed and filled in a WCROOT for the request, so we
          are done.  */
       return SVN_NO_ERROR;
     }
 
-  /* The PDH that we just built was for the LOCAL_ABSPATH originally passed
-     into this function. We stepped *at least* one directory above that.
-     We should now create PDH records for each parent directory that does
+  /* The WCROOT that we just found/built was for the LOCAL_ABSPATH originally
+     passed into this function. We stepped *at least* one directory above that.
+     We should now associate the WROOT for each parent directory that does
      not (yet) have one.  */
 
-  child_pdh = *pdh;
+  scan_abspath = local_dir_abspath;
 
   do
     {
-      const char *parent_dir = svn_dirent_dirname(child_pdh->local_abspath,
-                                                  scratch_pool);
-      svn_wc__db_pdh_t *parent_pdh;
+      const char *parent_dir = svn_dirent_dirname(scan_abspath, scratch_pool);
+      svn_wc__db_wcroot_t *parent_wcroot;
 
-      parent_pdh = apr_hash_get(db->dir_data, parent_dir, APR_HASH_KEY_STRING);
-      if (parent_pdh == NULL)
-        {
-          parent_pdh = apr_pcalloc(db->state_pool, sizeof(*parent_pdh));
-          parent_pdh->local_abspath = apr_pstrdup(db->state_pool, parent_dir);
-
-          /* All the PDHs have the same wcroot.  */
-          parent_pdh->wcroot = (*pdh)->wcroot;
-
-          apr_hash_set(db->dir_data,
-                       parent_pdh->local_abspath, APR_HASH_KEY_STRING,
-                       parent_pdh);
-        }
-      else if (parent_pdh->wcroot == NULL)
+      parent_wcroot = apr_hash_get(db->dir_data, parent_dir,
+                                   APR_HASH_KEY_STRING);
+      if (parent_wcroot == NULL)
         {
-          parent_pdh->wcroot = (*pdh)->wcroot;
+          apr_hash_set(db->dir_data, apr_pstrdup(db->state_pool, parent_dir),
+                       APR_HASH_KEY_STRING, *wcroot);
         }
 
-      /* Point the child PDH at this (new) parent PDH. This will allow for
-         easy traversals without path munging.  */
-      child_pdh = parent_pdh;
-
-      /* Loop if we haven't reached the PDH we found, or the abspath
-         where we terminated the search (when we found wc.db). Note that
-         if we never located a PDH in our ancestry, then FOUND_PDH will
-         be NULL and that portion of the test will always be TRUE.  */
+      /* Move up a directory, stopping when we reach the directory where
+         we found/built the WCROOT.  */
+      scan_abspath = parent_dir;
     }
-  while (child_pdh != found_pdh
-         && strcmp(child_pdh->local_abspath, local_abspath) != 0);
+  while (strcmp(scan_abspath, local_abspath) != 0);
 
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_wc__db_wcroot_parse_local_abspath(svn_wc__db_wcroot_t **wcroot,
-                                      const char **local_relpath,
-                                      svn_wc__db_t *db,
-                                      const char *local_abspath,
-                                      svn_sqlite__mode_t smode,
-                                      apr_pool_t *result_pool,
-                                      apr_pool_t *scratch_pool)
-{
-  svn_wc__db_pdh_t *pdh;
-
-  /* Ideally, we'd only grab the PDH if requested, rather than unconditionally.
-     That is, we'd call this function from pdh_parse_local_abspath(), instead
-     of the other way around.  However, for the time being, we're going to
-     go with short and simple here. */
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, local_relpath, db,
-                                             local_abspath, smode, result_pool,
-                                             scratch_pool));
-  *wcroot = pdh->wcroot;
-
-  return SVN_NO_ERROR;
-}
 
 svn_error_t *
 svn_wc__db_drop_root(svn_wc__db_t *db,
                      const char *local_abspath,
                      apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *root_pdh = apr_hash_get(db->dir_data, local_abspath,
-                                            APR_HASH_KEY_STRING);
+  svn_wc__db_wcroot_t *root_wcroot = apr_hash_get(db->dir_data, local_abspath,
+                                                  APR_HASH_KEY_STRING);
   apr_hash_index_t *hi;
   apr_status_t result;
 
-  if (!root_pdh)
+  if (!root_wcroot)
     return SVN_NO_ERROR;
 
-  if (!root_pdh->wcroot || strcmp(root_pdh->wcroot->abspath, local_abspath))
+  if (strcmp(root_wcroot->abspath, local_abspath) != 0)
     return svn_error_createf(SVN_ERR_WC_NOT_WORKING_COPY, NULL,
                              _("'%s' is not a working copy root"),
                              svn_dirent_local_style(local_abspath,
@@ -667,14 +589,14 @@ svn_wc__db_drop_root(svn_wc__db_t *db,
        hi;
        hi = apr_hash_next(hi))
     {
-      svn_wc__db_pdh_t *pdh = svn__apr_hash_index_val(hi);
+      svn_wc__db_wcroot_t *wcroot = svn__apr_hash_index_val(hi);
 
-      if (pdh->wcroot == root_pdh->wcroot)
+      if (wcroot == root_wcroot)
         apr_hash_set(db->dir_data,
-                     pdh->local_abspath, svn__apr_hash_index_klen(hi), NULL);
+                     svn__apr_hash_index_key(hi), APR_HASH_KEY_STRING, NULL);
     }
 
-  result = apr_pool_cleanup_run(db->state_pool, root_pdh->wcroot, close_wcroot);
+  result = apr_pool_cleanup_run(db->state_pool, root_wcroot, close_wcroot);
   if (result != APR_SUCCESS)
     return svn_error_wrap_apr(result, NULL);
 

Modified: subversion/branches/performance/subversion/libsvn_wc/wc_db_pristine.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc_db_pristine.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc_db_pristine.c (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc_db_pristine.c Sat Mar  5 21:39:30 2011
@@ -1,6 +1,8 @@
 /*
  * wc_db_pristine.c :  Pristine ("text base") management
  *
+ * See the spec in 'notes/wc-ng/pristine-store'.
+ *
  * ====================================================================
  *    Licensed to the Apache Software Foundation (ASF) under one
  *    or more contributor license agreements.  See the NOTICE file
@@ -114,7 +116,7 @@ svn_wc__db_pristine_get_path(const char 
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
   svn_boolean_t present;
 
@@ -129,11 +131,11 @@ svn_wc__db_pristine_get_path(const char 
                                          scratch_pool, scratch_pool));
   SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath,
                                              db, wri_abspath,
                                              svn_sqlite__mode_readonly,
                                              scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
   SVN_ERR(svn_wc__db_pristine_check(&present, db, wri_abspath, sha1_checksum,
                                     scratch_pool));
@@ -141,7 +143,7 @@ svn_wc__db_pristine_get_path(const char 
     return svn_error_createf(SVN_ERR_WC_DB_ERROR, NULL,
                              _("Pristine text not found"));
 
-  SVN_ERR(get_pristine_fname(pristine_abspath, pdh->wcroot->abspath,
+  SVN_ERR(get_pristine_fname(pristine_abspath, wcroot->abspath,
                              sha1_checksum,
                              FALSE /* create_subdir */,
                              result_pool, scratch_pool));
@@ -163,6 +165,62 @@ svn_wc__db_pristine_get_future_path(cons
   return SVN_NO_ERROR;
 }
 
+/* Data for pristine_read_txn(). */
+typedef struct pristine_read_baton_t
+{
+  /* Where to put the result stream. */
+  svn_stream_t **contents;
+  /* The pristine text's SHA-1 checksum. */
+  const svn_checksum_t *sha1_checksum;
+  /* The path to the pristine file (within the pristine store). */
+  const char *pristine_abspath;
+  /* The pool from which to allocate the result stream. */
+  apr_pool_t *result_pool;
+} pristine_read_baton_t;
+
+/* Set (*BATON->contents) to a readable stream from which the pristine text
+ * identified by BATON->sha1_checksum can be read from the pristine store of
+ * SDB.  If that text is not in the pristine store, return an error.
+ *
+ * Even if the pristine text is removed from the store while it is being
+ * read, the stream will remain valid and readable until it is closed.
+ *
+ * Allocate the stream in BATON->result_pool.
+ *
+ * This function expects to be executed inside a SQLite txn.
+ *
+ * Implements 'notes/wc-ng/pristine-store' section A-3(d).
+ * Implements svn_sqlite__transaction_callback_t. */
+static svn_error_t *
+pristine_read_txn(void *baton,
+                  svn_sqlite__db_t *sdb,
+                  apr_pool_t *scratch_pool)
+{
+  pristine_read_baton_t *b = baton;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  /* Check that this pristine text is present in the store.  (The presence
+   * of the file is not sufficient.) */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_PRISTINE));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, b->sha1_checksum, scratch_pool));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  SVN_ERR(svn_sqlite__reset(stmt));
+  if (! have_row)
+    {
+      return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
+                               _("Pristine text '%s' not present"),
+                               svn_checksum_to_cstring_display(
+                                 b->sha1_checksum, scratch_pool));
+    }
+
+  /* Open the file as a readable stream.  It will remain readable even when
+   * deleted from disk; APR guarantees that on Windows as well as Unix. */
+  SVN_ERR(svn_stream_open_readonly(b->contents, b->pristine_abspath,
+                                   b->result_pool, scratch_pool));
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_wc__db_pristine_read(svn_stream_t **contents,
                          svn_wc__db_t *db,
@@ -171,9 +229,9 @@ svn_wc__db_pristine_read(svn_stream_t **
                          apr_pool_t *result_pool,
                          apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
-  const char *pristine_abspath;
+  pristine_read_baton_t b;
 
   SVN_ERR_ASSERT(contents != NULL);
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
@@ -186,23 +244,37 @@ svn_wc__db_pristine_read(svn_stream_t **
                                          scratch_pool, scratch_pool));
   SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
-  /* ### should we look in the PRISTINE table for anything?  */
-
-  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+  b.contents = contents;
+  b.sha1_checksum = sha1_checksum;
+  b.result_pool = result_pool;
+  SVN_ERR(get_pristine_fname(&b.pristine_abspath, wcroot->abspath,
                              sha1_checksum,
                              FALSE /* create_subdir */,
                              scratch_pool, scratch_pool));
-  return svn_error_return(svn_stream_open_readonly(
-                            contents, pristine_abspath,
-                            result_pool, scratch_pool));
+  SVN_ERR(svn_sqlite__with_transaction(wcroot->sdb, pristine_read_txn, &b,
+                                       scratch_pool));
+
+  return SVN_NO_ERROR;
 }
 
 
+/* Return the absolute path to the temporary directory for pristine text
+   files within WCROOT. */
+static char *
+pristine_get_tempdir(svn_wc__db_wcroot_t *wcroot,
+                     apr_pool_t *result_pool,
+                     apr_pool_t *scratch_pool)
+{
+  return svn_dirent_join_many(result_pool, wcroot->abspath,
+                              svn_wc_get_adm_dir(scratch_pool),
+                              PRISTINE_TEMPDIR_RELPATH, (char *)NULL);
+}
+
 svn_error_t *
 svn_wc__db_pristine_get_tempdir(const char **temp_dir_abspath,
                                 svn_wc__db_t *db,
@@ -210,22 +282,104 @@ svn_wc__db_pristine_get_tempdir(const ch
                                 apr_pool_t *result_pool,
                                 apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
 
   SVN_ERR_ASSERT(temp_dir_abspath != NULL);
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  *temp_dir_abspath = pristine_get_tempdir(wcroot, result_pool, scratch_pool);
+  return SVN_NO_ERROR;
+}
+
+
+/* Data for pristine_install_txn(). */
+typedef struct pristine_install_baton_t
+{
+  /* The path to the source file that is to be moved into place. */
+  const char *tempfile_abspath;
+  /* The target path for the file (within the pristine store). */
+  const char *pristine_abspath;
+  /* The pristine text's SHA-1 checksum. */
+  const svn_checksum_t *sha1_checksum;
+  /* The pristine text's MD-5 checksum. */
+  const svn_checksum_t *md5_checksum;
+} pristine_install_baton_t;
+
+
+/* Install the pristine text described by BATON into the pristine store of
+ * SDB.  If it is already stored then just delete the new file
+ * BATON->tempfile_abspath.
+ *
+ * This function expects to be executed inside a SQLite txn that has already
+ * acquired a 'RESERVED' lock.
+ * 
+ * Implements 'notes/wc-ng/pristine-store' section A-3(a).
+ * Implements svn_sqlite__transaction_callback_t. */
+static svn_error_t *
+pristine_install_txn(void *baton,
+                     svn_sqlite__db_t *sdb,
+                     apr_pool_t *scratch_pool)
+{
+  pristine_install_baton_t *b = baton;
+  apr_finfo_t finfo;
+  svn_sqlite__stmt_t *stmt;
+  svn_boolean_t have_row;
+
+  /* If this pristine text is already present in the store, just keep it:
+   * delete the new one and return. */
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_PRISTINE));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, b->sha1_checksum, scratch_pool));
+  SVN_ERR(svn_sqlite__step(&have_row, stmt));
+  SVN_ERR(svn_sqlite__reset(stmt));
+  if (have_row)
+    {
+#ifdef SVN_DEBUG
+      /* Consistency checks.  Verify both files exist and match.
+       * ### We could check much more. */
+      {
+        apr_finfo_t finfo1, finfo2;
+        SVN_ERR(svn_io_stat(&finfo1, b->tempfile_abspath, APR_FINFO_SIZE,
+                            scratch_pool));
+        SVN_ERR(svn_io_stat(&finfo2, b->pristine_abspath, APR_FINFO_SIZE,
+                            scratch_pool));
+        if (finfo1.size != finfo2.size)
+          {
+            return svn_error_createf(
+              SVN_ERR_WC_CORRUPT_TEXT_BASE, NULL,
+              _("New pristine text '%s' has different size: %ld versus %ld"),
+              svn_checksum_to_cstring_display(b->sha1_checksum, scratch_pool),
+              (long int)finfo1.size, (long int)finfo2.size);
+          }
+      }
+#endif
+
+      /* Remove the temp file: it's already there */
+      SVN_ERR(svn_io_remove_file2(b->tempfile_abspath,
+                                  FALSE /* ignore_enoent */, scratch_pool));
+      return SVN_NO_ERROR;
+    }
+
+  /* Move the file to its target location.  (If it is already there, it is
+   * an orphan file and it doesn't matter if we overwrite it.) */
+  SVN_ERR(svn_io_file_rename(b->tempfile_abspath, b->pristine_abspath,
+                             scratch_pool));
+
+  SVN_ERR(svn_io_stat(&finfo, b->pristine_abspath, APR_FINFO_SIZE,
+                      scratch_pool));
+
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                    STMT_INSERT_PRISTINE));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, b->sha1_checksum, scratch_pool));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 2, b->md5_checksum, scratch_pool));
+  SVN_ERR(svn_sqlite__bind_int64(stmt, 3, finfo.size));
+  SVN_ERR(svn_sqlite__insert(NULL, stmt));
 
-  *temp_dir_abspath = svn_dirent_join_many(result_pool,
-                                           pdh->wcroot->abspath,
-                                           svn_wc_get_adm_dir(scratch_pool),
-                                           PRISTINE_TEMPDIR_RELPATH,
-                                           NULL);
   return SVN_NO_ERROR;
 }
 
@@ -237,13 +391,10 @@ svn_wc__db_pristine_install(svn_wc__db_t
                             const svn_checksum_t *md5_checksum,
                             apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
   const char *wri_abspath;
-  const char *pristine_abspath;
-  apr_finfo_t finfo;
-  svn_sqlite__stmt_t *stmt;
-  svn_node_kind_t kind;
+  struct pristine_install_baton_t b;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(tempfile_abspath));
   SVN_ERR_ASSERT(sha1_checksum != NULL);
@@ -259,40 +410,25 @@ svn_wc__db_pristine_install(svn_wc__db_t
                                                       scratch_pool),
                                    scratch_pool);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
+
+  b.tempfile_abspath = tempfile_abspath;
+  b.sha1_checksum = sha1_checksum;
+  b.md5_checksum = md5_checksum;
 
-  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
+  SVN_ERR(get_pristine_fname(&b.pristine_abspath, wcroot->abspath,
                              sha1_checksum,
                              TRUE /* create_subdir */,
                              scratch_pool, scratch_pool));
 
-
-  SVN_ERR(svn_io_check_path(pristine_abspath, &kind, scratch_pool));
-
-  if (kind == svn_node_file)
-    {
-      /* Remove the tempfile, it's already there */
-      return svn_error_return(
-                  svn_io_remove_file2(tempfile_abspath,
-                                      FALSE, scratch_pool));
-    }
-
-  /* Put the file into its target location.  */
-    SVN_ERR(svn_io_file_rename(tempfile_abspath, pristine_abspath,
-                               scratch_pool));
-
-  SVN_ERR(svn_io_stat(&finfo, pristine_abspath, APR_FINFO_SIZE,
-                      scratch_pool));
-
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_INSERT_PRISTINE));
-  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
-  SVN_ERR(svn_sqlite__bind_checksum(stmt, 2, md5_checksum, scratch_pool));
-  SVN_ERR(svn_sqlite__bind_int64(stmt, 3, finfo.size));
-  SVN_ERR(svn_sqlite__insert(NULL, stmt));
+  /* Ensure the SQL txn has at least a 'RESERVED' lock before we start looking
+   * at the disk, to ensure no concurrent pristine install/delete txn. */
+  SVN_ERR(svn_sqlite__with_immediate_transaction(wcroot->sdb,
+                                                 pristine_install_txn, &b,
+                                                 scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -306,7 +442,7 @@ svn_wc__db_pristine_get_md5(const svn_ch
                             apr_pool_t *result_pool,
                             apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
@@ -315,13 +451,12 @@ svn_wc__db_pristine_get_md5(const svn_ch
   SVN_ERR_ASSERT(sha1_checksum != NULL);
   SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_SELECT_PRISTINE_MD5_CHECKSUM));
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_SELECT_PRISTINE));
   SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   if (!have_row)
@@ -346,7 +481,7 @@ svn_wc__db_pristine_get_sha1(const svn_c
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
@@ -355,13 +490,13 @@ svn_wc__db_pristine_get_sha1(const svn_c
   SVN_ERR_ASSERT(sha1_checksum != NULL);
   SVN_ERR_ASSERT(md5_checksum->kind == svn_checksum_md5);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_SELECT_PRISTINE_SHA1_CHECKSUM));
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+                                    STMT_SELECT_PRISTINE_BY_MD5));
   SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, md5_checksum, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   if (!have_row)
@@ -378,44 +513,126 @@ svn_wc__db_pristine_get_sha1(const svn_c
 }
 
 
-/* If the pristine text referenced by SHA1_CHECKSUM has a reference count
- * of zero, delete it from the pristine store of WCROOT.  Delete both the
- * database row and the file on disk. */
+/* Remove the file at FILE_ABSPATH in such a way that we could re-create a
+ * new file of the same name at any time thereafter.
+ *
+ * On Windows, the file will not disappear immediately from the directory if
+ * it is still being read so the best thing to do is first rename it to a
+ * unique name. */
 static svn_error_t *
-pristine_remove_if_unreferenced(svn_wc__db_wcroot_t *wcroot,
-                                const svn_checksum_t *sha1_checksum,
-                                apr_pool_t *scratch_pool)
+remove_file(const char *file_abspath,
+            svn_wc__db_wcroot_t *wcroot,
+            svn_boolean_t ignore_enoent,
+            apr_pool_t *scratch_pool)
+{
+#ifdef WIN32
+  svn_error_t *err;
+  const char *temp_abspath;
+  const char *temp_dir_abspath
+    = pristine_get_tempdir(wcroot, scratch_pool, scratch_pool);
+
+  /* To rename the file to a unique name in the temp dir, first create a
+   * uniquely named file in the temp dir and then overwrite it. */
+  SVN_ERR(svn_io_open_unique_file3(NULL, &temp_abspath, temp_dir_abspath,
+                                   svn_io_file_del_none,
+                                   scratch_pool, scratch_pool));
+  err = svn_io_file_rename(file_abspath, temp_abspath, scratch_pool);
+  if (err && ignore_enoent && APR_STATUS_IS_ENOENT(err->apr_err))
+    svn_error_clear(err);
+  else
+    SVN_ERR(err);
+  file_abspath = temp_abspath;
+#endif
+
+  SVN_ERR(svn_io_remove_file2(file_abspath, ignore_enoent, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+/* Data for pristine_remove_if_unreferenced_txn(). */
+typedef struct pristine_remove_baton_t
 {
-  svn_sqlite__stmt_t *stmt;
+  svn_wc__db_wcroot_t *wcroot;
+  /* The pristine text's SHA-1 checksum. */
+  const svn_checksum_t *sha1_checksum;
+  /* The path to the pristine file (within the pristine store). */
   const char *pristine_abspath;
+} pristine_remove_baton_t;
+
+/* If the pristine text referenced by BATON in SDB has a reference count of
+ * zero, delete it (both the database row and the disk file).
+ *
+ * This function expects to be executed inside a SQLite txn that has already
+ * acquired a 'RESERVED' lock.
+ *
+ * Implements svn_sqlite__transaction_callback_t. */
+static svn_error_t *
+pristine_remove_if_unreferenced_txn(void *baton,
+                                    svn_sqlite__db_t *sdb,
+                                    apr_pool_t *scratch_pool)
+{
+  pristine_remove_baton_t *b = baton;
+  svn_sqlite__stmt_t *stmt;
   int affected_rows;
 
   /* Remove the DB row, if refcount is 0. */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb,
+  SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
                                     STMT_DELETE_PRISTINE_IF_UNREFERENCED));
-  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
+  SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, b->sha1_checksum, scratch_pool));
   SVN_ERR(svn_sqlite__update(&affected_rows, stmt));
 
+  /* If we removed the DB row, then remove the file. */
   if (affected_rows > 0)
     {
-      /* Remove the file. */
-      SVN_ERR(get_pristine_fname(&pristine_abspath, wcroot->abspath,
-                                 sha1_checksum, TRUE /* create_subdir */,
-                                 scratch_pool, scratch_pool));
-      SVN_ERR(svn_io_remove_file2(pristine_abspath, TRUE /* ignore_enoent */,
-                                  scratch_pool));
+      /* If the file is not present, something has gone wrong, but at this
+       * point it no longer matters.  In a debug build, raise an error, but
+       * in a release build, it is more helpful to ignore it and continue. */
+#ifdef SVN_DEBUG
+      svn_boolean_t ignore_enoent = FALSE;
+#else
+      svn_boolean_t ignore_enoent = TRUE;
+#endif
+
+      SVN_ERR(remove_file(b->pristine_abspath, b->wcroot, ignore_enoent,
+                          scratch_pool));
     }
 
   return SVN_NO_ERROR;
 }
 
+/* If the pristine text referenced by SHA1_CHECKSUM in WCROOT has a
+ * reference count of zero, delete it (both the database row and the disk
+ * file).
+ *
+ * Implements 'notes/wc-ng/pristine-store' section A-3(b). */
+static svn_error_t *
+pristine_remove_if_unreferenced(svn_wc__db_wcroot_t *wcroot,
+                                const svn_checksum_t *sha1_checksum,
+                                apr_pool_t *scratch_pool)
+{
+  pristine_remove_baton_t b;
+
+  b.wcroot = wcroot;
+  b.sha1_checksum = sha1_checksum;
+  SVN_ERR(get_pristine_fname(&b.pristine_abspath, wcroot->abspath,
+                             sha1_checksum, FALSE /* create_subdir */,
+                             scratch_pool, scratch_pool));
+
+  /* Ensure the SQL txn has at least a 'RESERVED' lock before we start looking
+   * at the disk, to ensure no concurrent pristine install/delete txn. */
+  SVN_ERR(svn_sqlite__with_immediate_transaction(
+    wcroot->sdb, pristine_remove_if_unreferenced_txn, &b, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_wc__db_pristine_remove(svn_wc__db_t *db,
                            const char *wri_abspath,
                            const svn_checksum_t *sha1_checksum,
                            apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
@@ -428,10 +645,10 @@ svn_wc__db_pristine_remove(svn_wc__db_t 
                                          scratch_pool, scratch_pool));
   SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readwrite,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
   /* If the work queue is not empty, don't delete any pristine text because
    * the work queue may contain a reference to it. */
@@ -439,8 +656,7 @@ svn_wc__db_pristine_remove(svn_wc__db_t 
     svn_sqlite__stmt_t *stmt;
     svn_boolean_t have_row;
 
-    SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                      STMT_LOOK_FOR_WORK));
+    SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_LOOK_FOR_WORK));
     SVN_ERR(svn_sqlite__step(&have_row, stmt));
     SVN_ERR(svn_sqlite__reset(stmt));
 
@@ -449,8 +665,7 @@ svn_wc__db_pristine_remove(svn_wc__db_t 
   }
 
   /* If not referenced, remove the PRISTINE table row and the file. */
-  SVN_ERR(pristine_remove_if_unreferenced(pdh->wcroot, sha1_checksum,
-                                          scratch_pool));
+  SVN_ERR(pristine_remove_if_unreferenced(wcroot, sha1_checksum, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -490,17 +705,17 @@ svn_wc__db_pristine_cleanup(svn_wc__db_t
                             const char *wri_abspath,
                             apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
-  SVN_ERR(pristine_cleanup_wcroot(pdh->wcroot, scratch_pool));
+  SVN_ERR(pristine_cleanup_wcroot(wcroot, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -513,12 +728,11 @@ svn_wc__db_pristine_check(svn_boolean_t 
                           const svn_checksum_t *sha1_checksum,
                           apr_pool_t *scratch_pool)
 {
-  svn_wc__db_pdh_t *pdh;
+  svn_wc__db_wcroot_t *wcroot;
   const char *local_relpath;
   const char *pristine_abspath;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
-  svn_node_kind_t kind_on_disk;
 
   SVN_ERR_ASSERT(present != NULL);
   SVN_ERR_ASSERT(svn_dirent_is_absolute(wri_abspath));
@@ -531,31 +745,35 @@ svn_wc__db_pristine_check(svn_boolean_t 
                                          scratch_pool, scratch_pool));
   SVN_ERR_ASSERT(sha1_checksum->kind == svn_checksum_sha1);
 
-  SVN_ERR(svn_wc__db_pdh_parse_local_abspath(&pdh, &local_relpath, db,
+  SVN_ERR(svn_wc__db_wcroot_parse_local_abspath(&wcroot, &local_relpath, db,
                               wri_abspath, svn_sqlite__mode_readonly,
                               scratch_pool, scratch_pool));
-  VERIFY_USABLE_WCROOT(pdh->wcroot);
+  VERIFY_USABLE_WCROOT(wcroot);
 
   /* Check that there is an entry in the PRISTINE table. */
-  SVN_ERR(svn_sqlite__get_statement(&stmt, pdh->wcroot->sdb,
-                                    STMT_SELECT_PRISTINE_MD5_CHECKSUM));
+  SVN_ERR(svn_sqlite__get_statement(&stmt, wcroot->sdb, STMT_SELECT_PRISTINE));
   SVN_ERR(svn_sqlite__bind_checksum(stmt, 1, sha1_checksum, scratch_pool));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));
   SVN_ERR(svn_sqlite__reset(stmt));
 
-  /* Check that the pristine text file exists. */
-  SVN_ERR(get_pristine_fname(&pristine_abspath, pdh->wcroot->abspath,
-                             sha1_checksum,
-                             FALSE /* create_subdir */,
-                             scratch_pool, scratch_pool));
-  SVN_ERR(svn_io_check_path(pristine_abspath, &kind_on_disk, scratch_pool));
+#ifdef SVN_DEBUG
+  /* Check that the pristine text file exists iff the DB says it does. */
+  if (have_row)
+    {
+      svn_node_kind_t kind_on_disk;
+      SVN_ERR(get_pristine_fname(&pristine_abspath, wcroot->abspath,
+                                 sha1_checksum, FALSE /* create_subdir */,
+                                 scratch_pool, scratch_pool));
+      SVN_ERR(svn_io_check_path(pristine_abspath, &kind_on_disk, scratch_pool));
 
-  if (kind_on_disk != (have_row ? svn_node_file : svn_node_none))
-    return svn_error_createf(SVN_ERR_WC_DB_ERROR, svn_sqlite__reset(stmt),
-                             _("The pristine text with checksum '%s' was "
-                               "found in the DB or on disk but not both"),
-                             svn_checksum_to_cstring_display(sha1_checksum,
-                                                             scratch_pool));
+      if (kind_on_disk != svn_node_file)
+        return svn_error_createf(SVN_ERR_WC_DB_ERROR, svn_sqlite__reset(stmt),
+                                 _("The pristine text with checksum '%s' was "
+                                   "found in the DB but not on disk"),
+                                 svn_checksum_to_cstring_display(sha1_checksum,
+                                                                 scratch_pool));
+    }
+#endif
 
   *present = have_row;
   return SVN_NO_ERROR;

Modified: subversion/branches/performance/subversion/libsvn_wc/wc_db_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/libsvn_wc/wc_db_private.h?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/branches/performance/subversion/libsvn_wc/wc_db_private.h Sat Mar  5 21:39:30 2011
@@ -49,22 +49,25 @@ struct svn_wc__db_t {
   svn_boolean_t enforce_empty_wq;
 
   /* Map a given working copy directory to its relevant data.
-     const char *local_abspath -> svn_wc__db_pdh_t *pdh  */
+     const char *local_abspath -> svn_wc__db_wcroot_t *wcroot  */
   apr_hash_t *dir_data;
 
   /* As we grow the state of this DB, allocate that state here. */
   apr_pool_t *state_pool;
 };
 
+
 /* Hold information about an owned lock */
 typedef struct svn_wc__db_wclock_t
 {
   /* Relative path of the lock root */
   const char *local_relpath;
+
   /* Number of levels locked (0 for infinity) */
   int levels;
 } svn_wc__db_wclock_t;
 
+
 /** Hold information about a WCROOT.
  *
  * This structure is referenced by all per-directory handles underneath it.
@@ -84,7 +87,7 @@ typedef struct svn_wc__db_wcroot_t {
      format has not (yet) been determined, this will be UNKNOWN_FORMAT.  */
   int format;
 
-  /* Array of svn_wc__db_wclock_t fields (not pointers!).
+  /* Array of svn_wc__db_wclock_t structures (not pointers!).
      Typically just one or two locks maximum. */
   apr_array_header_t *owned_locks;
 
@@ -94,31 +97,8 @@ typedef struct svn_wc__db_wcroot_t {
 
 } svn_wc__db_wcroot_t;
 
-/**  Pristine Directory Handle
- *
- * This structure records all the information that we need to deal with
- * a given working copy directory.
- */
-typedef struct svn_wc__db_pdh_t {
-
-  /* The absolute path to this working copy directory. */
-  const char *local_abspath;
-
-  /* What wcroot does this directory belong to?  */
-  svn_wc__db_wcroot_t *wcroot;
-
-} svn_wc__db_pdh_t;
-
-
 
 /* */
-svn_wc__db_pdh_t *
-svn_wc__db_pdh_get_or_create(svn_wc__db_t *db,
-                             const char *local_dir_abspath,
-                             svn_boolean_t create_allowed,
-                             apr_pool_t *scratch_pool);
-
-/* */
 svn_error_t *
 svn_wc__db_close_many_wcroots(apr_hash_t *roots,
                               apr_pool_t *state_pool,
@@ -138,29 +118,19 @@ svn_wc__db_pdh_create_wcroot(svn_wc__db_
                              apr_pool_t *result_pool,
                              apr_pool_t *scratch_pool);
 
-/* For a given LOCAL_ABSPATH, figure out what sqlite database (PDH) to
+
+/* For a given LOCAL_ABSPATH, figure out what sqlite database (WCROOT) to
    use and the RELPATH within that wcroot.  If a sqlite database needs
    to be opened, then use SMODE for it.
 
    *LOCAL_RELPATH will be allocated within RESULT_POOL. Temporary allocations
    will be made in SCRATCH_POOL.
 
-   *PDH will be allocated within DB->STATE_POOL.
+   *WCROOT will be allocated within DB->STATE_POOL.
 
    Certain internal structures will be allocated in DB->STATE_POOL.
 */
 svn_error_t *
-svn_wc__db_pdh_parse_local_abspath(svn_wc__db_pdh_t **pdh,
-                                   const char **local_relpath,
-                                   svn_wc__db_t *db,
-                                   const char *local_abspath,
-                                   svn_sqlite__mode_t smode,
-                                   apr_pool_t *result_pool,
-                                   apr_pool_t *scratch_pool);
-
-/* Similar to svn_wc__db_pdh_parse_local_abspath(), but only return the WCROOT,
-   rather than a full PDH. */
-svn_error_t *
 svn_wc__db_wcroot_parse_local_abspath(svn_wc__db_wcroot_t **wcroot,
                                       const char **local_relpath,
                                       svn_wc__db_t *db,
@@ -169,16 +139,13 @@ svn_wc__db_wcroot_parse_local_abspath(sv
                                       apr_pool_t *result_pool,
                                       apr_pool_t *scratch_pool);
 
-/* POOL may be NULL if the lifetime of LOCAL_ABSPATH is sufficient.  */
-const char *
-svn_wc__db_pdh_compute_relpath(const svn_wc__db_pdh_t *pdh,
-                               apr_pool_t *result_pool);
 
 /* Assert that the given WCROOT is usable.
    NOTE: the expression is multiply-evaluated!!  */
 #define VERIFY_USABLE_WCROOT(wcroot)  SVN_ERR_ASSERT(               \
     (wcroot) != NULL && (wcroot)->format == SVN_WC__VERSION)
 
+
 /* */
 svn_error_t *
 svn_wc__db_util_fetch_wc_id(apr_int64_t *wc_id,

Modified: subversion/branches/performance/subversion/mod_authz_svn/mod_authz_svn.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/mod_authz_svn/mod_authz_svn.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/mod_authz_svn/mod_authz_svn.c (original)
+++ subversion/branches/performance/subversion/mod_authz_svn/mod_authz_svn.c Sat Mar  5 21:39:30 2011
@@ -30,8 +30,10 @@
 #include <http_request.h>
 #include <http_protocol.h>
 #include <http_log.h>
+#include <http_config.h>
 #include <ap_config.h>
 #include <ap_provider.h>
+#include <ap_mmn.h>
 #include <apr_uri.h>
 #include <apr_lib.h>
 #include <mod_dav.h>
@@ -48,6 +50,10 @@
 
 extern module AP_MODULE_DECLARE_DATA authz_svn_module;
 
+#ifdef APLOG_USE_MODULE
+APLOG_USE_MODULE(authz_svn);
+#endif
+
 typedef struct authz_svn_config_rec {
   int authoritative;
   int anonymous;
@@ -519,12 +525,26 @@ req_check_access(request_rec *r,
   return OK;
 }
 
+/* The macros LOG_ARGS_SIGNATURE and LOG_ARGS_CASCADE are expanded as formal
+ * and actual parameters to log_access_verdict with respect to HTTPD version.
+ */
+#if AP_MODULE_MAGIC_AT_LEAST(20100606,0)
+#define LOG_ARGS_SIGNATURE const char *file, int line, int module_index
+#define LOG_ARGS_CASCADE file, line, module_index
+#else
+#define LOG_ARGS_SIGNATURE const char *file, int line
+#define LOG_ARGS_CASCADE file, line
+#endif
+
 /* Log a message indicating the access control decision made about a
- * request.  FILE and LINE should be supplied via the APLOG_MARK macro.
- * ALLOWED is boolean.  REPOS_PATH and DEST_REPOS_PATH are information
+ * request.  The macro LOG_ARGS_SIGNATURE expands to FILE, LINE and
+ * MODULE_INDEX in HTTPD 2.3 as APLOG_MARK macro has been changed for
+ * per-module loglevel configuration.  It expands to FILE and LINE 
+ * in older server versions.  ALLOWED is boolean.  
+ * REPOS_PATH and DEST_REPOS_PATH are information
  * about the request.  DEST_REPOS_PATH may be NULL. */
 static void
-log_access_verdict(const char *file, int line,
+log_access_verdict(LOG_ARGS_SIGNATURE,
                    const request_rec *r, int allowed,
                    const char *repos_path, const char *dest_repos_path)
 {
@@ -534,22 +554,22 @@ log_access_verdict(const char *file, int
   if (r->user)
     {
       if (dest_repos_path)
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: '%s' %s %s %s", verdict, r->user,
                       r->method, repos_path, dest_repos_path);
       else
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: '%s' %s %s", verdict, r->user,
                       r->method, repos_path);
     }
   else
     {
       if (dest_repos_path)
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: - %s %s %s", verdict,
                       r->method, repos_path, dest_repos_path);
       else
-        ap_log_rerror(file, line, level, 0, r,
+        ap_log_rerror(LOG_ARGS_CASCADE, level, 0, r,
                       "Access %s: - %s %s", verdict,
                       r->method, repos_path);
     }

Modified: subversion/branches/performance/subversion/mod_dav_svn/mod_dav_svn.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/mod_dav_svn/mod_dav_svn.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/mod_dav_svn/mod_dav_svn.c (original)
+++ subversion/branches/performance/subversion/mod_dav_svn/mod_dav_svn.c Sat Mar  5 21:39:30 2011
@@ -447,8 +447,6 @@ SVNInMemoryCacheSize_cmd(cmd_parms *cmd,
 static const char *
 SVNCompressionLevel_cmd(cmd_parms *cmd, void *config, const char *arg1)
 {
-  svn_fs_cache_config_t settings = *svn_fs_get_cache_config();
-
   int value = 0;
   svn_error_t *err = svn_cstring_atoi(&value, arg1);
   if (err)
@@ -457,13 +455,13 @@ SVNCompressionLevel_cmd(cmd_parms *cmd, 
       return "Invalid decimal number for the SVN compression level.";
     }
 
-  if ((value < SVN_NO_COMPRESSION_LEVEL) || (value > SVN_BEST_COMPRESSION_LEVEL))
+  if ((value < SVN_NO_COMPRESSION_LEVEL) || (value > SVN_MAX_COMPRESSION_LEVEL))
     return apr_psprintf(cmd->pool,
                         "%d is not a valid compression level. "
                         "The valid range is %d .. %d.",
                         value,
                         (int)SVN_NO_COMPRESSION_LEVEL,
-                        (int)SVN_BEST_COMPRESSION_LEVEL);
+                        (int)SVN_MAX_COMPRESSION_LEVEL);
 
   svn__compression_level = value;
 
@@ -942,9 +940,9 @@ static const command_rec cmds[] =
   /* per server */
   AP_INIT_TAKE1("SVNCompressionLevel", SVNCompressionLevel_cmd, NULL,
                 RSRC_CONF,
-                "specifies the ZIP compression level used before sending file "
-                "content over the network (0 for no compression, 9 for best, "
-                "5 is default)."),
+                "specifies the compression level used before sending file "
+                "content over the network (0 for no compression, 9 for "
+                "maximum, 5 is default)."),
 
   /* per server */
   AP_INIT_TAKE1("SVNMaxOpenFileHandles", SVNMaxOpenFileHandles_cmd, NULL,

Modified: subversion/branches/performance/subversion/svnadmin/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnadmin/main.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnadmin/main.c (original)
+++ subversion/branches/performance/subversion/svnadmin/main.c Sat Mar  5 21:39:30 2011
@@ -962,9 +962,6 @@ subcommand_help(apr_getopt_t *os, void *
 
   svn_stringbuf_t *version_footer;
 
-  /* Expect no more arguments. */
-  SVN_ERR(parse_args(NULL, os, 0, 0, pool));
-
   version_footer = svn_stringbuf_create(fs_desc_start, pool);
   SVN_ERR(svn_fs_print_modules(version_footer, pool));
 

Modified: subversion/branches/performance/subversion/svnrdump/load_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnrdump/load_editor.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnrdump/load_editor.c (original)
+++ subversion/branches/performance/subversion/svnrdump/load_editor.c Sat Mar  5 21:39:30 2011
@@ -456,8 +456,14 @@ delete_node_property(void *baton,
 static svn_error_t *
 remove_node_props(void *baton)
 {
-  /* ### Not implemented */
-  return SVN_NO_ERROR;
+  struct node_baton *nb = baton;
+  if ((nb->action == svn_node_action_add || nb->action == svn_node_action_replace)
+      && ! SVN_IS_VALID_REVNUM(nb->copyfrom_rev))
+    /* Add-without-history; no "old" properties to worry about. */
+    return SVN_NO_ERROR;
+  else
+    /* ### TODO */
+    SVN__NOT_IMPLEMENTED();
 }
 
 static svn_error_t *

Modified: subversion/branches/performance/subversion/svnserve/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnserve/main.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnserve/main.c (original)
+++ subversion/branches/performance/subversion/svnserve/main.c Sat Mar  5 21:39:30 2011
@@ -580,8 +580,8 @@ int main(int argc, const char *argv[])
           params.compression_level = atoi(arg);
           if (params.compression_level < SVN_NO_COMPRESSION_LEVEL)
             params.compression_level = SVN_NO_COMPRESSION_LEVEL;
-          if (params.compression_level > SVN_BEST_COMPRESSION_LEVEL)
-            params.compression_level = SVN_BEST_COMPRESSION_LEVEL;
+          if (params.compression_level > SVN_MAX_COMPRESSION_LEVEL)
+            params.compression_level = SVN_MAX_COMPRESSION_LEVEL;
           break;
 
         case 'M':

Modified: subversion/branches/performance/subversion/svnsync/main.c
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/svnsync/main.c?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/svnsync/main.c (original)
+++ subversion/branches/performance/subversion/svnsync/main.c Sat Mar  5 21:39:30 2011
@@ -393,11 +393,12 @@ with_locked(svn_ra_session_t *session,
             apr_pool_t *pool)
 {
   const svn_string_t *lock_string;
+  svn_error_t *err;
 
   SVN_ERR(get_lock(&lock_string, session, steal_lock, pool));
 
-  return svn_error_compose_create(
-             func(session, baton, pool),
+  err = func(session, baton, pool);
+  return svn_error_compose_create(err,
              svn_ra__release_operational_lock(session, SVNSYNC_PROP_LOCK,
                                               lock_string, pool));
 }

Modified: subversion/branches/performance/subversion/tests/cmdline/changelist_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/changelist_tests.py?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/changelist_tests.py (original)
+++ subversion/branches/performance/subversion/tests/cmdline/changelist_tests.py Sat Mar  5 21:39:30 2011
@@ -1129,6 +1129,69 @@ def move_added_keeps_changelist(sbox):
   ]
   svntest.actions.run_and_verify_info(expected_infos, kappa2_path)
 
+@XFail()
+@Issue(3820)  ### Extend to cover a merge that replaces a file with a dir
+def change_to_dir(sbox):
+  "change file in changelist to dir"
+
+  sbox.build(read_only = True)
+
+  # No changelist initially
+  expected_infos = [{'Name' : 'mu', 'Changelist' : None}]
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu visible in changelist
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'changelist', 'qq', sbox.ospath('A/mu'))
+  expected_infos = [{'Name' : 'mu', 'Changelist' : 'qq'}]
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu still visible after delete
+  svntest.actions.run_and_verify_svn(None, None, [], 'rm', sbox.ospath('A/mu'))
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu removed from changelist after replace with directory
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'mkdir', sbox.ospath('A/mu'))
+  expected_infos = [{'Changelist' : None}] # No Name for directories?
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+
+@XFail()
+@Issue(3822)
+def revert_deleted_in_changelist(sbox):
+  "revert a deleted file in a changelist"
+
+  sbox.build(read_only = True)
+
+  # No changelist initially
+  expected_infos = [{'Name' : 'mu', 'Changelist' : None}]
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu visible in changelist
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'changelist', 'qq', sbox.ospath('A/mu'))
+  expected_infos = [{'Name' : 'mu', 'Changelist' : 'qq'}]
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu still visible after delete
+  svntest.actions.run_and_verify_svn(None, None, [], 'rm', sbox.ospath('A/mu'))
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu still visible after revert
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'revert', sbox.ospath('A/mu'))
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu still visible after parent delete
+  svntest.actions.run_and_verify_svn(None, None, [], 'rm', sbox.ospath('A'))
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
+  # A/mu still visible after revert
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'revert', '-R', sbox.ospath('A'))
+  svntest.actions.run_and_verify_info(expected_infos, sbox.ospath('A/mu'))
+
 
 
 ########################################################################
@@ -1149,6 +1212,8 @@ test_list = [ None,
               tree_conflicts_and_changelists_on_commit3,
               move_keeps_changelist,
               move_added_keeps_changelist,
+              change_to_dir,
+              revert_deleted_in_changelist,
              ]
 
 if __name__ == '__main__':

Modified: subversion/branches/performance/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/diff_tests.py?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/branches/performance/subversion/tests/cmdline/diff_tests.py Sat Mar  5 21:39:30 2011
@@ -3760,6 +3760,20 @@ def diff_git_with_props_on_dir(sbox):
   svntest.actions.run_and_verify_svn(None, expected_output, [], 'diff',
                                      '-c2', '--git')
   os.chdir(was_cwd)
+
+@XFail()
+@Issue(3826)
+def diff_abs_localpath_from_wc_folder(sbox):
+  "diff absolute localpath from wc folder"
+  sbox.build(read_only = True)
+  wc_dir = sbox.wc_dir
+
+  A_path = os.path.join(wc_dir, 'A')
+  B_path = os.path.join(wc_dir, 'A', 'B')
+  os.chdir(os.path.abspath(A_path))
+  svntest.actions.run_and_verify_svn(None, None, [], 'diff',
+                                     os.path.abspath(B_path))
+  
 ########################################################################
 #Run the tests
 
@@ -3824,6 +3838,7 @@ test_list = [ None,
               diff_git_empty_files,
               diff_git_with_props,
               diff_git_with_props_on_dir,
+              diff_abs_localpath_from_wc_folder,
               ]
 
 if __name__ == '__main__':

Modified: subversion/branches/performance/subversion/tests/cmdline/externals_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/externals_tests.py?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/externals_tests.py (original)
+++ subversion/branches/performance/subversion/tests/cmdline/externals_tests.py Sat Mar  5 21:39:30 2011
@@ -1134,7 +1134,7 @@ def binary_file_externals(sbox):
   # the binary file /A/theta, but the external file is not there yet.
   # Try to actually insert the external file via a verified update:
   expected_output = svntest.wc.State(wc_dir, {
-      'A/C/external'      : Item(status='E '),
+      'A/C/external'      : Item(status='A '),
     })
 
   expected_disk = svntest.main.greek_state.copy()
@@ -1186,7 +1186,7 @@ def update_lose_file_external(sbox):
   # the file /A/mu, but the external file is not there yet.
   # Try to actually insert the external file via an update:
   expected_output = svntest.wc.State(wc_dir, {
-      'A/C/external'      : Item(status='E '),
+      'A/C/external'      : Item(status='A '),
     })
 
   expected_disk = svntest.main.greek_state.copy()
@@ -1419,7 +1419,7 @@ def wc_repos_file_externals(sbox):
   # the file /A/theta, but the external file is not there yet.
   # Try to actually insert the external file via a verified update:
   expected_output = svntest.wc.State(wc_dir, {
-      'A/C/theta'      : Item(status='E '),
+      'A/C/theta'      : Item(status='A '),
     })
 
   expected_disk = svntest.main.greek_state.copy()
@@ -1449,7 +1449,7 @@ def wc_repos_file_externals(sbox):
   # Try to actually insert the external file (A/I/theta) via a verified update:
   expected_output = svntest.wc.State(wc_dir, {
       'A/I'            : Item(status='A '),
-      'A/I/theta'      : Item(status='E '),
+      'A/I/theta'      : Item(status='A '),
     })
 
   expected_disk = svntest.main.greek_state.copy()
@@ -1527,7 +1527,7 @@ def update_modify_file_external(sbox):
   externals_prop = "^/A/mu external\n"
   change_external(sbox.ospath('A'), externals_prop)
   expected_output = svntest.wc.State(wc_dir, {
-      'A/external'      : Item(status='E '),
+      'A/external'      : Item(status='A '),
     })
   expected_disk = svntest.main.greek_state.copy()
   expected_disk.add({
@@ -1615,6 +1615,87 @@ def update_external_on_locally_added_dir
 
   probe_paths_exist([os.path.join(wc_dir, "A", "foo", "exdir_E")])
 
+# Test for issue #2267
+@Issue(2267)
+def switch_external_on_locally_added_dir(sbox):
+  "switch an external on a locally added dir"
+
+  external_url_for = externals_test_setup(sbox)
+  wc_dir         = sbox.wc_dir
+
+  repo_url       = sbox.repo_url
+  other_repo_url = repo_url + ".other"
+  A_path         = repo_url + "/A"
+  A_copy_path    = repo_url + "/A_copy"
+
+  # Create a branch of A
+  # Checkout a working copy
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'copy',
+                                     A_path, A_copy_path,
+                                     '-m', 'Create branch of A')
+
+  # Checkout a working copy
+  svntest.actions.run_and_verify_svn(None, None, [],
+                                     'checkout',
+                                     A_path, wc_dir)
+
+  # Add one new external item to the property on A/foo.  The new item is
+  # "exdir_E", deliberately added in the middle not at the end.
+  new_externals_desc = \
+           external_url_for["A/D/exdir_A"] + " exdir_A"           + \
+           "\n"                                                   + \
+           external_url_for["A/D/exdir_A/G/"] + " exdir_A/G/"     + \
+           "\n"                                                   + \
+           "exdir_E           " + other_repo_url + "/A/B/E"       + \
+           "\n"                                                   + \
+           "exdir_A/H -r 1 " + external_url_for["A/D/exdir_A/H"]  + \
+           "\n"                                                   + \
+           external_url_for["A/D/x/y/z/blah"] + " x/y/z/blah"     + \
+           "\n"
+
+  # Add A/foo and set the property on it
+  new_dir = sbox.ospath("foo")
+  sbox.simple_mkdir("foo")
+  change_external(new_dir, new_externals_desc, commit=False)
+
+  # Switch the working copy to the branch, see if we get the new item.
+  svntest.actions.run_and_verify_svn(None, None, [], 'sw', A_copy_path, wc_dir)
+
+  probe_paths_exist([os.path.join(wc_dir, "foo", "exdir_E")])
+
+@XFail()
+@Issue(3819)
+def file_external_in_sibling(sbox):
+  "update a file external in sibling dir"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  # Setup A2/iota as file external to ^/iota
+  externals_prop = "^/iota iota\n"
+  sbox.simple_mkdir("A2")
+  change_external(sbox.ospath('A2'), externals_prop)
+  sbox.simple_update()
+
+  expected_stdout = ["Updating '.' ...\n", "At revision 2.\n"]
+  os.chdir(sbox.ospath("A"))
+  svntest.actions.run_and_verify_svn(None, expected_stdout, [], 'update')
+
+@XFail()
+@Issue(3823)
+def file_external_update_without_commit(sbox):
+  "update a file external without committing target"
+
+  sbox.build(read_only=True)
+
+  # Setup A2/iota as file external to ^/iota
+  externals_prop = "^/iota iota\n"
+  sbox.simple_mkdir("A2")
+  change_external(sbox.ospath('A2'), externals_prop, commit=False)
+  # A2/ is an uncommitted added dir with an svn:externals property set.
+  sbox.simple_update()
+
 ########################################################################
 # Run the tests
 
@@ -1647,6 +1728,9 @@ test_list = [ None,
               merge_target_with_externals,
               update_modify_file_external,
               update_external_on_locally_added_dir,
+              switch_external_on_locally_added_dir,
+              file_external_in_sibling,
+              file_external_update_without_commit,
              ]
 
 if __name__ == '__main__':

Modified: subversion/branches/performance/subversion/tests/cmdline/log_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/performance/subversion/tests/cmdline/log_tests.py?rev=1078365&r1=1078364&r2=1078365&view=diff
==============================================================================
--- subversion/branches/performance/subversion/tests/cmdline/log_tests.py (original)
+++ subversion/branches/performance/subversion/tests/cmdline/log_tests.py Sat Mar  5 21:39:30 2011
@@ -446,8 +446,11 @@ def parse_log_output(log_lines):
 
   If LOG_LINES contains merge result information, then the hash also contains
 
-     'merges'   ===> list of merging revisions that resulted in this log
-  being part of the list of messages.
+     'merges'   ===> list of forward-merging revisions that resulted in this
+  log being part of the list of messages.
+
+     'reverse_merges'   ===> list of reverse-merging revisions that resulted
+  in this log being part of the list of messages.
      """
 
   # Here's some log output to look at while writing this function:
@@ -499,6 +502,7 @@ def parse_log_output(log_lines):
     match = header_re.search(this_line)
     if match and match.groups():
       is_result = 0
+      is_result_reverse = 0
       this_item = {}
       this_item['revision'] = int(match.group(1))
       this_item['author']   = match.group(2)
@@ -512,8 +516,10 @@ def parse_log_output(log_lines):
         paths = []
         path_line = log_lines.pop(0).strip()
 
-        # Stop on either a blank line or a "Merged via: ..." line
-        while path_line != '' and path_line[0:6] != 'Merged':
+        # Stop on either a blank line or a "(Reverse) Merged via: ..." line
+        while (path_line != ''
+               and path_line[0:6] != 'Merged'
+               and path_line[0:14] != 'Reverse merged'):
           paths.append( (path_line[0], path_line[2:]) )
           path_line = log_lines.pop(0).strip()
 
@@ -522,10 +528,16 @@ def parse_log_output(log_lines):
         if path_line[0:6] == 'Merged':
           is_result = 1
           result_line = path_line
+        elif path_line[0:14] == 'Reverse merged':
+          is_result_reverse = 1
+          result_line = path_line
 
       elif next_line[0:6] == 'Merged':
         is_result = 1
         result_line = next_line.strip()
+      elif next_line[0:14] == 'Reverse merged':
+        is_result_reverse = 1
+        result_line = next_line.strip()
 
       # Parse output of "Merged via: ..." line
       if is_result:
@@ -538,6 +550,17 @@ def parse_log_output(log_lines):
         # Eat blank line
         log_lines.pop(0)
 
+      # Parse output of "Reverse merged via: ..." line
+      if is_result_reverse:
+        reverse_merges = []
+        prefix_len = len('Reverse merged via: ')
+        for rev_str in result_line[prefix_len:].split(','):
+          reverse_merges.append(int(rev_str.strip()[1:]))
+        this_item['reverse_merges'] = reverse_merges
+
+        # Eat blank line
+        log_lines.pop(0)
+
       # Accumulate the log message
       msg = ''
       for line in log_lines[0:lines]:
@@ -1117,33 +1140,57 @@ Log message for revision 3.
     log_chain = parse_log_output([line+"\n" for line in log.split("\n")])
 
 
-def check_merge_results(log_chain, expected_merges):
+def check_merge_results(log_chain, expected_merges=None,
+                        expected_reverse_merges=None):
   '''Check LOG_CHAIN to see if the log information contains 'Merged via'
   information indicated by EXPECTED_MERGES.  EXPECTED_MERGES is a dictionary
   whose key is the merged revision, and whose value is the merging revision.'''
 
   # Check to see if the number and values of the revisions is correct
   for log in log_chain:
-    if log['revision'] not in expected_merges:
+    if (log['revision'] not in expected_merges
+        and (expected_reverse_merges is not None
+             and log['revision'] not in expected_reverse_merges)):
       raise SVNUnexpectedLogs("Found unexpected revision %d" %
                               log['revision'], log_chain)
 
   # Check to see that each rev in expected_merges contains the correct data
-  for rev in expected_merges:
-    try:
-      log = [x for x in log_chain if x['revision'] == rev][0]
-      if 'merges' in log.keys():
-        actual = log['merges']
-      else:
-        actual = []
-      expected = expected_merges[rev]
-
-      if actual != expected:
-        raise SVNUnexpectedLogs(("Merging revisions in rev %d not correct; " +
-                                 "expecting %s, found %s") %
+  if expected_merges:
+    for rev in expected_merges:
+      try:
+        log = [x for x in log_chain if x['revision'] == rev][0]
+        if 'merges' in log.keys():
+          actual = log['merges']
+        else:
+          actual = []
+        expected = expected_merges[rev]
+
+        if actual != expected:
+          raise SVNUnexpectedLogs(("Merging revisions in rev %d not " +
+                                   "correct; expecting %s, found %s") %
+                                  (rev, str(expected), str(actual)), log_chain)
+      except IndexError:
+        raise SVNUnexpectedLogs("Merged revision '%d' missing" % rev,
+                                log_chain)
+
+  # Check to see that each rev in expected_merges contains the correct data
+  if expected_reverse_merges:
+    for rev in expected_reverse_merges:
+      try:
+        log = [x for x in log_chain if x['revision'] == rev][0]
+        if 'reverse_merges' in log.keys():
+          actual = log['reverse_merges']
+        else:
+          actual = []
+        expected = expected_reverse_merges[rev]
+
+        if actual != expected:
+          raise SVNUnexpectedLogs(("Reverse merging revisions in rev %d not " +
+                                 "correct; expecting %s, found %s") %
                                 (rev, str(expected), str(actual)), log_chain)
-    except IndexError:
-      raise SVNUnexpectedLogs("Merged revision '%d' missing" % rev, log_chain)
+      except IndexError:
+        raise SVNUnexpectedLogs("Reverse merged revision '%d' missing" % rev,
+                                log_chain)
 
 
 @SkipUnless(server_has_mergeinfo)
@@ -1763,6 +1810,172 @@ def log_of_local_copy(sbox):
                           "differs from that on move source '%s'"
                           % (psi_moved_path, psi_path))
 
+#----------------------------------------------------------------------
+
+@SkipUnless(server_has_mergeinfo)
+@Issue(3176)
+@XFail()
+def merge_sensitive_log_reverse_merges(sbox):
+  "log -g differentiates forward and reverse merges"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  wc_disk, wc_status = set_up_branch(sbox)
+
+  A_path      = os.path.join(wc_dir, 'A')
+  A_COPY_path = os.path.join(wc_dir, 'A_COPY')
+  D_COPY_path = os.path.join(wc_dir, 'A_COPY', 'D')
+  
+  # Merge -c3,5 from A to A_COPY, commit as r7
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', '-c3,5', A_path, A_COPY_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Merge -c3,5 from A to A_COPY',
+                       wc_dir)
+    
+  # Merge -c-3,-5,4,6 from A to A_COPY, commit as r8
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', '-c-3,4,-5,6', A_path, A_COPY_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Merge -c-3,-5,4,6 from A to A_COPY',
+                       wc_dir)
+
+  # Update so
+  svntest.main.run_svn(None, 'up', wc_dir)
+
+  # Run log -g on path with explicit mergeinfo (A_COPY).
+  exit_code, out, err = svntest.actions.run_and_verify_svn(None, None, [],
+                                                           'log', '-g', '-r8',
+                                                           A_COPY_path)
+  # This test currently fails because reverse merges are not differentiated
+  # from forward merges.
+  log_chain = parse_log_output(out)
+  expected_merges = {
+    8 : [],
+    6 : [8],
+    4 : [8],
+  }
+  expected_reverse_merges = {
+    5 : [8],
+    3 : [8],
+  }
+  check_merge_results(log_chain, expected_merges, expected_reverse_merges)
+
+  # Run log -g on path with inherited mergeinfo (A_COPY/D).
+  exit_code, out, err = svntest.actions.run_and_verify_svn(None, None, [],
+                                                           'log', '-g', '-r8',
+                                                           D_COPY_path)
+  log_chain = parse_log_output(out)
+  # expected_merges is the same as before.
+  expected_reverse_merges = {
+    # 5 : [8], r5 only affects A_COPY/B/E/beta
+    3 : [8],
+  }
+  check_merge_results(log_chain, expected_merges, expected_reverse_merges)
+
+#----------------------------------------------------------------------
+
+@SkipUnless(server_has_mergeinfo)
+@Issue(3650)
+@XFail()
+def merge_sensitive_log_ignores_cyclic_merges(sbox):
+  "log -g should ignore cyclic merges"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+  wc_disk, wc_status = set_up_branch(sbox)
+
+  A_path        = os.path.join(wc_dir, 'A')
+  X_path        = os.path.join(wc_dir, 'A', 'C', 'X')
+  kappa_path    = os.path.join(wc_dir, 'A', 'C', 'X', 'kappa')
+  chi_path      = os.path.join(wc_dir, 'A', 'D', 'H', 'chi')
+  A_COPY_path   = os.path.join(wc_dir, 'A_COPY')
+  mu_COPY_path  = os.path.join(wc_dir, 'A_COPY', 'mu')
+  tau_COPY_path = os.path.join(wc_dir, 'A_COPY', 'D', 'G', 'tau')
+  Z_COPY_path   = os.path.join(wc_dir, 'A_COPY', 'C', 'Z')
+  nu_COPY_path  = os.path.join(wc_dir, 'A_COPY', 'C', 'Z', 'nu')
+
+  # Make an edit on the "branch" to A_COPY/mu, commit as r7.
+  svntest.main.file_write(mu_COPY_path, "Branch edit.\n")
+  svntest.main.run_svn(None, 'ci', '-m', 'Branch edit', wc_dir)
+
+  # Make an edit on both the "trunk" and the "branch", commit as r8.
+  svntest.main.file_write(chi_path, "Trunk edit.\n")
+  svntest.main.file_write(tau_COPY_path, "Branch edit.\n")
+  svntest.main.run_svn(None, 'ci', '-m', 'Branch and trunk edits in one rev',
+                       wc_dir)
+
+  # Sync merge A to A_COPY, commit as r9
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', sbox.repo_url + '/A', A_COPY_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Sync merge A to A_COPY', wc_dir)
+
+  # Reintegrate A_COPY to A, commit as r10
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', '--reintegrate',
+                       sbox.repo_url + '/A_COPY', A_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Reintegrate A_COPY to A', wc_dir)
+
+  # Do a --record-only merge of r10 from A to A_COPY, commit as r11.
+  # This will allow us to continue using the branch without deleting it.
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', sbox.repo_url + '/A', A_COPY_path)
+  svntest.main.run_svn(None, 'ci', '-m',
+                       '--record-only merge r10 from A to A_COPY', wc_dir)
+
+  # Make an edit on the "branch"; add A_COPY/C and A_COPY/C/Z/nu,
+  # commit as r12.
+  svntest.main.run_svn(None, 'mkdir', Z_COPY_path)
+  svntest.main.file_write(nu_COPY_path, "A new branch file.\n")
+  svntest.main.run_svn(None, 'add', nu_COPY_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Branch edit: Add a subtree', wc_dir)
+
+  # Make an edit on the "trunk"; add A/C/X and A/C/X/kappa,
+  # commit as r13.
+  svntest.main.run_svn(None, 'mkdir', X_path)
+  svntest.main.file_write(kappa_path, "A new trunk file.\n")
+  svntest.main.run_svn(None, 'add', kappa_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Trunk edit: Add a subtree', wc_dir)
+  svntest.main.run_svn(None, 'up', wc_dir)
+
+  # Sync merge A to A_COPY, commit as r14
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', sbox.repo_url + '/A', A_COPY_path)
+  svntest.main.run_svn(None, 'ci', '-m', 'Sync merge A to A_COPY', wc_dir)
+
+  # Reintegrate A_COPY to A, commit as r15
+  svntest.main.run_svn(None, 'up', wc_dir)
+  svntest.main.run_svn(None, 'merge', '--reintegrate',
+                       sbox.repo_url + '/A_COPY', A_path)
+  svntest.main.run_svn(None, 'ci', '-m', '2nd reintegrate of A_COPY to A',
+                       wc_dir)
+
+  # Run 'svn log -g A'.  This currently fails because r13, r10, r6, r5, r4,
+  # and r3 are all reported normally (i.e. as part of A's own history), but
+  # they are *also* reported several times as merged via the the
+  # [sync|reintegrate|record-only] merges between A and A_COPY.
+  expected_merges = {
+    15 : [],
+    14 : [15],
+    13 : [],
+    12 : [15],
+    11 : [15],
+    10 : [],
+    9  : [15,11],
+    8  : [15,11,9],
+    7  : [15,11],
+    6  : [],
+    5  : [],    
+    4  : [],
+    3  : [],
+    2  : [15,11],
+    1  : [],
+  }
+  svntest.main.run_svn(None, 'up', wc_dir)
+  exit_code, out, err = svntest.actions.run_and_verify_svn(None, None, [],
+                                                           'log', '-g',
+                                                           A_path)
+  log_chain = parse_log_output(out)
+  check_merge_results(log_chain, expected_merges)
+
 ########################################################################
 # Run the tests
 
@@ -1798,6 +2011,8 @@ test_list = [ None,
               merge_sensitive_log_added_mergeinfo_replaces_inherited,
               merge_sensitive_log_propmod_merge_inheriting_path,
               log_of_local_copy,
+              merge_sensitive_log_reverse_merges,
+              merge_sensitive_log_ignores_cyclic_merges,
              ]
 
 if __name__ == '__main__':