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/15 21:32:38 UTC

svn commit: r997472 [20/41] - in /subversion/branches/py-tests-as-modules: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ contrib/server-side/ notes/ notes/tree-conflicts/ notes/wc-ng/ subversion/bindings/javahl/native/ subversi...

Modified: subversion/branches/py-tests-as-modules/subversion/libsvn_wc/ambient_depth_filter_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/libsvn_wc/ambient_depth_filter_editor.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/libsvn_wc/ambient_depth_filter_editor.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/libsvn_wc/ambient_depth_filter_editor.c Wed Sep 15 19:32:26 2010
@@ -29,7 +29,6 @@
 #include "svn_path.h"
 
 #include "wc.h"
-#include "lock.h"
 
 /*
      Notes on the general depth-filtering strategy.
@@ -96,6 +95,7 @@ struct edit_baton
   svn_wc__db_t *db;
   const char *anchor_abspath;
   const char *target;
+  svn_boolean_t read_base;
 };
 
 struct file_baton
@@ -114,6 +114,75 @@ struct dir_baton
   void *wrapped_baton;
 };
 
+/* Helper to call either svn_wc__db_base_get_info or svn_wc__db_read_info for
+   obtaining information for the ambient depth editor */
+static svn_error_t *
+ambient_read_info(svn_boolean_t *hidden,
+                  svn_wc__db_status_t *status,
+                  svn_wc__db_kind_t *kind,
+                  svn_depth_t *depth,
+                  svn_wc__db_t *db,
+                  const char *local_abspath,
+                  svn_boolean_t read_base,
+                  apr_pool_t *scratch_pool)
+{
+  svn_error_t *err;
+  svn_wc__db_status_t status_p;
+
+  SVN_ERR_ASSERT(kind != NULL);
+
+  if (hidden)
+    {
+      *hidden = FALSE;
+
+      if (!status)
+        status = &status_p;
+    }
+
+  if (read_base)
+    err = svn_wc__db_base_get_info(status, kind, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL, depth, NULL, NULL,
+                                   NULL, NULL,
+                                   db, local_abspath,
+                                   scratch_pool, scratch_pool);
+  else
+    err = svn_wc__db_read_info(status, kind, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, depth, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL,
+                               db, local_abspath, scratch_pool, scratch_pool);
+
+
+  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      svn_error_clear(err);
+
+      *kind = svn_wc__db_kind_unknown;
+      if (status)
+        *status = svn_wc__db_status_normal;
+      if (depth)
+        *depth = svn_depth_unknown;
+
+      return SVN_NO_ERROR;
+    }
+  else
+    SVN_ERR(err);
+
+  if (hidden)
+    switch (*status)
+      {
+        case svn_wc__db_status_not_present:
+        case svn_wc__db_status_absent:
+        case svn_wc__db_status_excluded:
+          *hidden = TRUE;
+          break;
+        default:
+          break;
+      }
+
+  return SVN_NO_ERROR;
+}
+
 /* */
 static svn_error_t *
 make_dir_baton(struct dir_baton **d_p,
@@ -148,8 +217,8 @@ make_dir_baton(struct dir_baton **d_p,
     {
       const char *abspath;
       svn_boolean_t exclude;
-      svn_error_t *err;
       svn_wc__db_status_t status;
+      svn_wc__db_kind_t kind;
       svn_boolean_t exists = TRUE;
 
       abspath = svn_dirent_join(eb->anchor_abspath,
@@ -157,22 +226,10 @@ make_dir_baton(struct dir_baton **d_p,
                                                          path),
                                 pool);
 
-      err = svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                 NULL, NULL, NULL,
-                                 eb->db, abspath, pool, pool);
+      SVN_ERR(ambient_read_info(NULL, &status, &kind, NULL,
+                                eb->db, abspath, eb->read_base, pool));
 
-      if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-        {
-          svn_error_clear(err);
-          exists = FALSE;
-        }
-      else
-        SVN_ERR(err);
-
-      if (exists)
-        SVN_ERR(svn_wc__db_node_hidden(&exists, eb->db, abspath, pool));
+      exists = (kind != svn_wc__db_kind_unknown);
 
       if (pb->ambient_depth == svn_depth_empty
           || pb->ambient_depth == svn_depth_files)
@@ -216,6 +273,10 @@ make_file_baton(struct file_baton **f_p,
 {
   struct file_baton *f = apr_pcalloc(pool, sizeof(*f));
   struct edit_baton *eb = pb->edit_baton;
+  svn_wc__db_status_t status;
+  svn_wc__db_kind_t kind;
+  svn_boolean_t hidden;
+  const char *abspath;
 
   SVN_ERR_ASSERT(path);
 
@@ -226,31 +287,22 @@ make_file_baton(struct file_baton **f_p,
       return SVN_NO_ERROR;
     }
 
+  abspath = svn_dirent_join(eb->anchor_abspath,
+                            svn_dirent_skip_ancestor(eb->anchor_abspath,
+                                                     path),
+                            pool);
+
+  SVN_ERR(ambient_read_info(&hidden, &status, &kind, NULL,
+                            eb->db, abspath, eb->read_base, pool));
+
   if (pb->ambient_depth == svn_depth_empty)
     {
       /* This is not a depth upgrade, and the parent directory is
          depth==empty.  So if the parent doesn't
          already have an entry for the file, then the parent
          doesn't want to hear about the file at all. */
-      svn_wc__db_kind_t kind;
-      svn_boolean_t unavailable = FALSE;
-      const char *abspath;
-
-      abspath = svn_dirent_join(eb->anchor_abspath,
-                                svn_dirent_skip_ancestor(eb->anchor_abspath,
-                                                         path),
-                                pool);
-
-      SVN_ERR(svn_wc__db_read_kind(&kind, pb->edit_baton->db, abspath, TRUE,
-                                   pool));
-
-      if (kind == svn_wc__db_kind_unknown)
-        unavailable = TRUE;
-      else
-        SVN_ERR(svn_wc__db_node_hidden(&unavailable, pb->edit_baton->db,
-                                       abspath, pool));
-
-      if (unavailable)
+      
+      if (hidden || kind == svn_wc__db_kind_unknown)
         {
           f->ambiently_excluded = TRUE;
           *f_p = f;
@@ -258,6 +310,16 @@ make_file_baton(struct file_baton **f_p,
         }
     }
 
+  /* If pb->ambient_depth == svn_depth_unknown we are pulling
+     in new nodes */
+  if (pb->ambient_depth != svn_depth_unknown
+      && status == svn_wc__db_status_excluded)
+    {
+      f->ambiently_excluded = TRUE;
+      *f_p = f;
+      return SVN_NO_ERROR;
+    }
+
   f->edit_baton = pb->edit_baton;
 
   *f_p = f;
@@ -299,28 +361,17 @@ open_root(void *edit_baton,
   if (! *eb->target)
     {
       /* For an update with a NULL target, this is equivalent to open_dir(): */
+      svn_wc__db_kind_t kind;
       svn_boolean_t hidden;
-      svn_error_t *err;
+      svn_depth_t depth;
 
       /* Read the depth from the entry. */
-      err = svn_wc__db_node_hidden(&hidden, eb->db, eb->anchor_abspath, pool);
-
-      if (!err && !hidden)
-        {
-          svn_depth_t depth;
-          SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, &depth, NULL,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       NULL, NULL, NULL, NULL, NULL, NULL,
-                                       eb->db, eb->anchor_abspath,
-                                       pool, pool));
+      SVN_ERR(ambient_read_info(&hidden, NULL, &kind, &depth,
+                                eb->db, eb->anchor_abspath, eb->read_base,
+                                pool));
 
+      if (kind != svn_wc__db_kind_unknown && !hidden)
           b->ambient_depth = depth;
-        }
-      else if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
-        svn_error_clear(err);
-      else
-        SVN_ERR(err);
     }
 
   return eb->wrapped_editor->open_root(eb->wrapped_edit_baton, base_revision,
@@ -354,13 +405,11 @@ delete_entry(const char *path,
                                                          path),
                                 pool);
 
-      SVN_ERR(svn_wc__db_read_kind(&kind, eb->db, abspath, TRUE, pool));
-
-      if (kind == svn_wc__db_kind_unknown)
-        return SVN_NO_ERROR;
+      SVN_ERR(ambient_read_info(&hidden, NULL, &kind, NULL,
+                                eb->db, abspath, eb->read_base, pool));
 
-      SVN_ERR(svn_wc__db_node_hidden(&hidden, eb->db, abspath, pool));
-      if (hidden)
+      if (kind == svn_wc__db_kind_unknown
+          || hidden)
         return SVN_NO_ERROR;
     }
 
@@ -426,8 +475,9 @@ open_directory(const char *path,
   struct edit_baton *eb = pb->edit_baton;
   struct dir_baton *b;
   const char *local_abspath;
+  svn_wc__db_kind_t kind;
   svn_boolean_t hidden;
-  svn_error_t *err;
+  svn_depth_t depth;
 
   SVN_ERR(make_dir_baton(&b, path, eb, pb, pool));
   *child_baton = b;
@@ -448,22 +498,14 @@ open_directory(const char *path,
                                   pool);
 
 
-  err = svn_wc__db_node_hidden(&hidden, eb->db, local_abspath, pool);
+  SVN_ERR(ambient_read_info(&hidden, NULL, &kind, &depth,
+                            eb->db, local_abspath, eb->read_base, pool));
 
-  if ((err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND) ||
-      hidden)
+  if (kind != svn_wc__db_kind_unknown
+      && !hidden)
     {
-      svn_error_clear(err);
-      return SVN_NO_ERROR;
+      b->ambient_depth = depth;
     }
-  else
-    SVN_ERR(err);
-
-  SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, &b->ambient_depth, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL,
-                               eb->db, local_abspath, pool, pool));
 
   return SVN_NO_ERROR;
 }
@@ -645,19 +687,20 @@ close_edit(void *edit_baton,
 svn_error_t *
 svn_wc__ambient_depth_filter_editor(const svn_delta_editor_t **editor,
                                     void **edit_baton,
-                                    const svn_delta_editor_t *wrapped_editor,
-                                    void *wrapped_edit_baton,
+                                    svn_wc__db_t *db,
                                     const char *anchor_abspath,
                                     const char *target,
-                                    svn_wc__db_t *db,
-                                    apr_pool_t *pool)
+                                    svn_boolean_t read_base,
+                                    const svn_delta_editor_t *wrapped_editor,
+                                    void *wrapped_edit_baton,
+                                    apr_pool_t *result_pool)
 {
   svn_delta_editor_t *depth_filter_editor;
   struct edit_baton *eb;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(anchor_abspath));
 
-  depth_filter_editor = svn_delta_default_editor(pool);
+  depth_filter_editor = svn_delta_default_editor(result_pool);
   depth_filter_editor->set_target_revision = set_target_revision;
   depth_filter_editor->open_root = open_root;
   depth_filter_editor->delete_entry = delete_entry;
@@ -674,12 +717,13 @@ svn_wc__ambient_depth_filter_editor(cons
   depth_filter_editor->absent_file = absent_file;
   depth_filter_editor->close_edit = close_edit;
 
-  eb = apr_palloc(pool, sizeof(*eb));
+  eb = apr_pcalloc(result_pool, sizeof(*eb));
   eb->wrapped_editor = wrapped_editor;
   eb->wrapped_edit_baton = wrapped_edit_baton;
   eb->db = db;
   eb->anchor_abspath = anchor_abspath;
   eb->target = target;
+  eb->read_base = read_base;
 
   *editor = depth_filter_editor;
   *edit_baton = eb;

Modified: subversion/branches/py-tests-as-modules/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/libsvn_wc/copy.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/libsvn_wc/copy.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/libsvn_wc/copy.c Wed Sep 15 19:32:26 2010
@@ -34,13 +34,11 @@
 #include "svn_path.h"
 
 #include "wc.h"
-#include "log.h"
 #include "workqueue.h"
 #include "adm_files.h"
-#include "entries.h"
 #include "props.h"
 #include "translate.h"
-#include "lock.h"
+#include "entries.h"
 
 #include "svn_private_config.h"
 #include "private/svn_wc_private.h"
@@ -125,9 +123,10 @@ copy_to_tmpdir(const char **dst_abspath,
    This also works for versioned symlinks that are stored in the db as
    svn_wc__db_kind_file with svn:special set. */
 static svn_error_t *
-copy_versioned_file(svn_wc_context_t *wc_ctx,
+copy_versioned_file(svn_wc__db_t *db,
                     const char *src_abspath,
                     const char *dst_abspath,
+                    svn_boolean_t metadata_only,
                     svn_cancel_func_t cancel_func,
                     void *cancel_baton,
                     svn_wc_notify_func2_t notify_func,
@@ -137,133 +136,82 @@ copy_versioned_file(svn_wc_context_t *wc
   svn_skel_t *work_items = NULL;
   const char *dir_abspath = svn_dirent_dirname(dst_abspath, scratch_pool);
   const char *tmpdir_abspath;
-#ifndef SVN_EXPERIMENTAL_PRISTINE
   svn_stream_t *src_pristine;
-  svn_wc__db_status_t src_status; 
-#endif
   const char *tmp_dst_abspath;
   svn_node_kind_t kind;
 
-  SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, wc_ctx->db,
-                                         dst_abspath,
+  SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, db, dst_abspath,
                                          scratch_pool, scratch_pool));
 
-  
-  /* This goes away when we stop using revert bases. */
-  {
-    svn_wc__db_status_t dst_status; 
-    svn_boolean_t will_replace;
-    svn_error_t *err;
+  /* This goes away when we centralise, but until then we might need
+     to do a cross-db pristine copy. */
+  if (strcmp(svn_dirent_dirname(src_abspath, scratch_pool),
+             svn_dirent_dirname(dst_abspath, scratch_pool)))
+    {
+      const svn_checksum_t *checksum;
+
+      SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL,
+                                   &checksum,
+                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                   NULL, NULL, NULL, NULL, NULL,
+                                   db, src_abspath,
+                                   scratch_pool, scratch_pool));
+      if (checksum)
+        {
+          svn_stream_t *tmp_pristine;
+          const char *tmp_pristine_abspath;
+          const svn_checksum_t *sha1_checksum, *md5_checksum;
 
-    err = svn_wc__db_read_info(&dst_status,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL,
-                               wc_ctx->db, dst_abspath,
-                               scratch_pool, scratch_pool);
-    if (err && err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
-      return svn_error_return(err);
-    will_replace = (!err && dst_status == svn_wc__db_status_deleted);
-    svn_error_clear(err);
-    if (will_replace)
-      SVN_ERR(svn_wc__wq_prepare_revert_files(wc_ctx->db, dst_abspath,
+          if (checksum->kind == svn_checksum_md5)
+            {
+              md5_checksum = checksum;
+              SVN_ERR(svn_wc__db_pristine_get_sha1(&sha1_checksum, db,
+                                                   src_abspath, checksum,
+                                                   scratch_pool, scratch_pool));
+            }
+          else
+            {
+              sha1_checksum = checksum;
+              SVN_ERR(svn_wc__db_pristine_get_md5(&md5_checksum, db,
+                                                  src_abspath, checksum,
+                                                  scratch_pool, scratch_pool));
+            }
+          SVN_ERR(svn_wc__db_pristine_read(&src_pristine, db,
+                                           src_abspath, sha1_checksum,
+                                           scratch_pool, scratch_pool));
+          SVN_ERR(svn_stream_open_unique(&tmp_pristine, &tmp_pristine_abspath,
+                                         tmpdir_abspath, svn_io_file_del_none,
+                                         scratch_pool, scratch_pool));
+          SVN_ERR(svn_stream_copy3(src_pristine, tmp_pristine,
+                                   cancel_func, cancel_baton,
+                                   scratch_pool));
+          SVN_ERR(svn_wc__db_pristine_install(db, tmp_pristine_abspath,
+                                              sha1_checksum, md5_checksum,
                                               scratch_pool));
-  }
-
-#ifndef SVN_EXPERIMENTAL_PRISTINE
-  /* This goes away when the pristine store is enabled; the copy
-     shares the same pristine as the source so nothing needs to be
-     copied. */
-  SVN_ERR(svn_wc__db_read_info(&src_status,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                               NULL, NULL,
-                               wc_ctx->db, src_abspath,
-                               scratch_pool, scratch_pool));
-  if (src_status == svn_wc__db_status_absent
-      || src_status == svn_wc__db_status_excluded
-      || src_status == svn_wc__db_status_not_present)
-    src_pristine = NULL;
-  else
-    SVN_ERR(svn_wc__get_pristine_contents(&src_pristine, wc_ctx->db,
-                                          src_abspath,
-                                          scratch_pool, scratch_pool));
-
-  if (src_pristine)
-    {
-      svn_skel_t *work_item;
-      svn_stream_t *tmp_pristine;
-      const char *tmp_pristine_abspath, *dst_pristine_abspath;
-
-      SVN_ERR(svn_stream_open_unique(&tmp_pristine, &tmp_pristine_abspath,
-                                     tmpdir_abspath, svn_io_file_del_none,
-                                     scratch_pool, scratch_pool));
-      SVN_ERR(svn_stream_copy3(src_pristine, tmp_pristine,
-                               cancel_func, cancel_baton, scratch_pool));
-      SVN_ERR(svn_wc__text_base_path(&dst_pristine_abspath, wc_ctx->db,
-                                     dst_abspath, scratch_pool));
-      SVN_ERR(svn_wc__loggy_move(&work_item, wc_ctx->db, dir_abspath,
-                                 tmp_pristine_abspath, dst_pristine_abspath,
-                                 scratch_pool));
-      work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+        }
     }
-#endif
-
-#if (SVN_WC__VERSION < SVN_WC__PROPS_IN_DB)
-  /* This goes away when we move to in-db-props. */
-  {
-    apr_hash_t *src_props;
 
-    SVN_ERR(svn_wc__get_pristine_props(&src_props, wc_ctx->db, src_abspath,
-                                       scratch_pool, scratch_pool));
-    if (src_props && apr_hash_count(src_props))
-      {
-        svn_skel_t *work_item;
-        const char *props_abspath;
-
-        SVN_ERR(svn_wc__prop_path(&props_abspath, dst_abspath, 
-                                  svn_wc__db_kind_file, svn_wc__props_base,
-                                  scratch_pool));
-        SVN_ERR(svn_wc__wq_build_write_old_props(&work_item, props_abspath,
-                                                 src_props, scratch_pool));
-        work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
-      }
-
-    SVN_ERR(svn_wc__get_actual_props(&src_props, wc_ctx->db, src_abspath,
-                                     scratch_pool, scratch_pool));
-    if (src_props && apr_hash_count(src_props))
-      {
-        svn_skel_t *work_item;
-        const char *props_abspath;
-
-        SVN_ERR(svn_wc__prop_path(&props_abspath, dst_abspath, 
-                                  svn_wc__db_kind_file, svn_wc__props_working,
-                                  scratch_pool));
-        SVN_ERR(svn_wc__wq_build_write_old_props(&work_item, props_abspath,
-                                                 src_props, scratch_pool));
-        work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
-      }
-  }
-#endif
-
-  SVN_ERR(copy_to_tmpdir(&tmp_dst_abspath, &kind, src_abspath, tmpdir_abspath,
-                         TRUE, /* recursive */
-                         cancel_func, cancel_baton, scratch_pool));
-  if (tmp_dst_abspath)
+  if (!metadata_only)
     {
-      svn_skel_t *work_item;
+      SVN_ERR(copy_to_tmpdir(&tmp_dst_abspath, &kind, src_abspath,
+                             tmpdir_abspath,
+                             TRUE, /* recursive */
+                             cancel_func, cancel_baton, scratch_pool));
+      if (tmp_dst_abspath)
+        {
+          svn_skel_t *work_item;
 
-      SVN_ERR(svn_wc__loggy_move(&work_item, wc_ctx->db, dir_abspath,
-                                 tmp_dst_abspath, dst_abspath,
-                                 scratch_pool));
-      work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+          SVN_ERR(svn_wc__wq_build_file_move(&work_item, db,
+                                             tmp_dst_abspath, dst_abspath,
+                                             scratch_pool, scratch_pool));
+          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+        }
     }
 
-  SVN_ERR(svn_wc__db_op_copy(wc_ctx->db, src_abspath, dst_abspath,
+  SVN_ERR(svn_wc__db_op_copy(db, src_abspath, dst_abspath,
                              work_items, scratch_pool));
-  SVN_ERR(svn_wc__wq_run(wc_ctx->db, dir_abspath,
+  SVN_ERR(svn_wc__wq_run(db, dir_abspath,
                          cancel_func, cancel_baton, scratch_pool));
 
   if (notify_func)
@@ -278,9 +226,10 @@ copy_versioned_file(svn_wc_context_t *wc
 }
 
 static svn_error_t *
-copy_versioned_dir(svn_wc_context_t *wc_ctx,
+copy_versioned_dir(svn_wc__db_t *db,
                    const char *src_abspath,
                    const char *dst_abspath,
+                   svn_boolean_t metadata_only,
                    svn_cancel_func_t cancel_func,
                    void *cancel_baton,
                    svn_wc_notify_func2_t notify_func,
@@ -297,148 +246,31 @@ copy_versioned_dir(svn_wc_context_t *wc_
   apr_pool_t *iterpool;
   int i;
 
-  SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, wc_ctx->db,
-                                         dst_abspath,
-                                         scratch_pool, scratch_pool));
-
-  SVN_ERR(copy_to_tmpdir(&tmp_dst_abspath, &kind, src_abspath, tmpdir_abspath,
-                         FALSE, /* recursive */
-                         cancel_func, cancel_baton, scratch_pool));
-  if (tmp_dst_abspath)
+  if (!metadata_only)
     {
-      svn_skel_t *work_item;
-
-      SVN_ERR(svn_wc__loggy_move(&work_item, wc_ctx->db, dir_abspath,
-                                 tmp_dst_abspath, dst_abspath,
-                                 scratch_pool));
-      work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
+      SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&tmpdir_abspath, db,
+                                             dst_abspath,
+                                             scratch_pool, scratch_pool));
 
-      if (kind == svn_node_dir)
+      SVN_ERR(copy_to_tmpdir(&tmp_dst_abspath, &kind, src_abspath,
+                             tmpdir_abspath, FALSE, /* recursive */
+                             cancel_func, cancel_baton, scratch_pool));
+      if (tmp_dst_abspath)
         {
-          /* 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, *parent_url, *url;
-          const char *repos_root_url, *repos_uuid;
-          svn_revnum_t revision;
-          svn_depth_t depth;
-          svn_wc__db_status_t status;
-
-          svn_dirent_split(dst_abspath, &dst_parent_abspath, &name,
-                           scratch_pool);
-          SVN_ERR(svn_wc__node_get_url(&parent_url, wc_ctx, dst_parent_abspath,
-                                       scratch_pool, scratch_pool));
-          url = svn_uri_join(parent_url, name, 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, /* text_mod */
-                                       NULL, /* props_mod */
-                                       NULL, /* base_shadowed */
-                                       NULL, /* conflicted */
-                                       NULL, /* lock */
-                                       wc_ctx->db, src_abspath,
-                                       scratch_pool, scratch_pool));
-          
-          if (status == svn_wc__db_status_added)
-            SVN_ERR(svn_wc__db_scan_addition(NULL /* status */,
-                                             NULL /* op_root_abspath */,
-                                             NULL /* repos_relpath */,
-                                             &repos_root_url,
-                                             &repos_uuid,
-                                             NULL /* original_repos_relpath */,
-                                             NULL /* original_root_url */,
-                                             NULL /* original_uuid */,
-                                             NULL /* original_revision */,
-                                             wc_ctx->db, src_abspath,
-                                             scratch_pool, scratch_pool));
+          svn_skel_t *work_item;
 
-          SVN_ERR(svn_wc__internal_ensure_adm(wc_ctx->db, tmp_dst_abspath,
-                                              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(wc_ctx->db, tmp_dst_abspath,
-                                         scratch_pool));
-
-          /* ### Need to close the database so that Windows can move
-             ### the directory.  Is this the right way to do it?  This
-             ### is not temporary code so the _temp_ name isn't
-             ### right. */
-          SVN_ERR(svn_wc__db_temp_forget_directory(wc_ctx->db, tmp_dst_abspath,
-                                                   scratch_pool));
+          SVN_ERR(svn_wc__wq_build_file_move(&work_item, db,
+                                             tmp_dst_abspath, dst_abspath,
+                                             scratch_pool, scratch_pool));
+          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
         }
     }
 
-#if (SVN_WC__VERSION < SVN_WC__PROPS_IN_DB)
-  /* This goes away when we move to in-db-props. */
-  {
-    apr_hash_t *src_props;
-
-    SVN_ERR(svn_wc__get_pristine_props(&src_props, wc_ctx->db, src_abspath,
-                                       scratch_pool, scratch_pool));
-    if (src_props && apr_hash_count(src_props))
-      {
-        svn_skel_t *work_item;
-        const char *props_abspath;
-
-        SVN_ERR(svn_wc__prop_path(&props_abspath, dst_abspath, 
-                                  svn_wc__db_kind_dir, svn_wc__props_base,
-                                  scratch_pool));
-        SVN_ERR(svn_wc__wq_build_write_old_props(&work_item, props_abspath,
-                                                 src_props, scratch_pool));
-        work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
-      }
-
-    SVN_ERR(svn_wc__get_actual_props(&src_props, wc_ctx->db, src_abspath,
-                                     scratch_pool, scratch_pool));
-    if (src_props && apr_hash_count(src_props))
-      {
-        svn_skel_t *work_item;
-        const char *props_abspath;
-
-        SVN_ERR(svn_wc__prop_path(&props_abspath, dst_abspath, 
-                                  svn_wc__db_kind_dir, svn_wc__props_working,
-                                  scratch_pool));
-        SVN_ERR(svn_wc__wq_build_write_old_props(&work_item, props_abspath,
-                                                 src_props, scratch_pool));
-        work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
-      }
-  }
-#endif
-
-  SVN_ERR(svn_wc__db_op_copy(wc_ctx->db, src_abspath, dst_abspath,
+  SVN_ERR(svn_wc__db_op_copy(db, src_abspath, dst_abspath,
                              work_items, scratch_pool));
-  SVN_ERR(svn_wc__wq_run(wc_ctx->db, dir_abspath,
+  SVN_ERR(svn_wc__wq_run(db, dir_abspath,
                          cancel_func, cancel_baton, scratch_pool));
 
-  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 move the destination into place. */
-      SVN_ERR(svn_wc__db_op_copy(wc_ctx->db, src_abspath, dst_abspath,
-                                 NULL, scratch_pool));
-    }
-
   if (notify_func)
     {
       svn_wc_notify_t *notify
@@ -448,12 +280,15 @@ copy_versioned_dir(svn_wc_context_t *wc_
       (*notify_func)(notify_baton, notify, scratch_pool);
     }
 
-  if (kind == svn_node_dir)
-    /* All children, versioned and unversioned */
-    SVN_ERR(svn_io_get_dirents2(&children, src_abspath, scratch_pool));
+  if (!metadata_only && kind == svn_node_dir)
+    /* All children, versioned and unversioned.  We're only interested in the
+       names of the children, so we can pass TRUE as the only_check_type
+       param. */
+    SVN_ERR(svn_io_get_dirents3(&children, src_abspath, TRUE,
+                                scratch_pool, scratch_pool));
 
   /* Copy all the versioned children */
-  SVN_ERR(svn_wc__db_read_children(&versioned_children, wc_ctx->db, src_abspath,
+  SVN_ERR(svn_wc__db_read_children(&versioned_children, db, src_abspath,
                                    scratch_pool, scratch_pool));
   iterpool = svn_pool_create(scratch_pool);
   for (i = 0; i < versioned_children->nelts; ++i)
@@ -469,17 +304,19 @@ copy_versioned_dir(svn_wc_context_t *wc_
       child_src_abspath = svn_dirent_join(src_abspath, child_name, iterpool);
       child_dst_abspath = svn_dirent_join(dst_abspath, child_name, iterpool);
 
-      SVN_ERR(svn_wc__db_read_kind(&child_kind, wc_ctx->db, child_src_abspath,
+      SVN_ERR(svn_wc__db_read_kind(&child_kind, db, child_src_abspath,
                                    TRUE, iterpool));
 
       if (child_kind == svn_wc__db_kind_file)
-        SVN_ERR(copy_versioned_file(wc_ctx,
+        SVN_ERR(copy_versioned_file(db,
                                     child_src_abspath, child_dst_abspath,
+                                    metadata_only,
                                     cancel_func, cancel_baton, NULL, NULL,
                                     iterpool));
       else if (child_kind == svn_wc__db_kind_dir)
-        SVN_ERR(copy_versioned_dir(wc_ctx,
+        SVN_ERR(copy_versioned_dir(db,
                                    child_src_abspath, child_dst_abspath,
+                                   metadata_only,
                                    cancel_func, cancel_baton, NULL, NULL,
                                    iterpool));
       else
@@ -488,12 +325,12 @@ copy_versioned_dir(svn_wc_context_t *wc_
                                  svn_dirent_local_style(child_src_abspath,
                                                         scratch_pool));
 
-      if (kind == svn_node_dir)
+      if (!metadata_only && kind == svn_node_dir)
         /* Remove versioned child as it has been handled */
         apr_hash_set(children, child_name, APR_HASH_KEY_STRING, NULL);
     }
 
-  if (kind == svn_node_dir)
+  if (!metadata_only && kind == svn_node_dir)
     {
       /* All the remaining children are unversioned. */
       apr_hash_index_t *hi;
@@ -521,15 +358,16 @@ copy_versioned_dir(svn_wc_context_t *wc_
           if (tmp_dst_abspath)
             {
               svn_skel_t *work_item;
-              SVN_ERR(svn_wc__loggy_move(&work_item, wc_ctx->db, dir_abspath,
-                                         tmp_dst_abspath, unver_dst_abspath,
-                                         iterpool));
-              SVN_ERR(svn_wc__db_wq_add(wc_ctx->db, dst_abspath, work_item,
+              SVN_ERR(svn_wc__wq_build_file_move(&work_item, db,
+                                                 tmp_dst_abspath,
+                                                 unver_dst_abspath,
+                                                 iterpool, iterpool));
+              SVN_ERR(svn_wc__db_wq_add(db, dst_abspath, work_item,
                                         iterpool));
             }
 
         }
-      SVN_ERR(svn_wc__wq_run(wc_ctx->db, dst_abspath, cancel_func, cancel_baton,
+      SVN_ERR(svn_wc__wq_run(db, dst_abspath, cancel_func, cancel_baton,
                              scratch_pool));
     }
 
@@ -546,58 +384,125 @@ svn_error_t *
 svn_wc_copy3(svn_wc_context_t *wc_ctx,
              const char *src_abspath,
              const char *dst_abspath,
+             svn_boolean_t metadata_only,
              svn_cancel_func_t cancel_func,
              void *cancel_baton,
              svn_wc_notify_func2_t notify_func,
              void *notify_baton,
              apr_pool_t *scratch_pool)
 {
+  svn_wc__db_t *db = wc_ctx->db;
   svn_node_kind_t src_kind;
-  const svn_wc_entry_t *dst_entry, *src_entry;
-  svn_wc__db_kind_t kind;
-  const char *dstdir_abspath, *dst_basename;
-
-  svn_dirent_split(dst_abspath, &dstdir_abspath, &dst_basename, scratch_pool);
-
-  SVN_ERR(svn_wc__get_entry_versioned(&dst_entry, wc_ctx, dstdir_abspath,
-                                      svn_node_dir, FALSE, FALSE,
-                                      scratch_pool, scratch_pool));
-  SVN_ERR(svn_wc__get_entry_versioned(&src_entry, wc_ctx, src_abspath,
-                                      svn_node_unknown, FALSE, FALSE,
-                                      scratch_pool, scratch_pool));
-
-  if ((src_entry->repos != NULL && dst_entry->repos != NULL) &&
-      strcmp(src_entry->repos, dst_entry->repos) != 0)
-    return svn_error_createf
-      (SVN_ERR_WC_INVALID_SCHEDULE, NULL,
-       _("Cannot copy to '%s', as it is not from repository '%s'; "
-         "it is from '%s'"),
-       svn_dirent_local_style(dst_abspath, scratch_pool),
-       src_entry->repos, dst_entry->repos);
-  if (dst_entry->schedule == svn_wc_schedule_delete)
-    return svn_error_createf
-      (SVN_ERR_WC_INVALID_SCHEDULE, NULL,
-       _("Cannot copy to '%s' as it is scheduled for deletion"),
-       svn_dirent_local_style(dst_abspath, scratch_pool));
+  svn_wc__db_kind_t src_db_kind;
+  const char *dstdir_abspath;
+  
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(src_abspath));
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(dst_abspath));
+  
+  dstdir_abspath = svn_dirent_dirname(dst_abspath, scratch_pool);
+
+  {
+    svn_wc__db_status_t src_status, dstdir_status;
+    const char *src_repos_root_url, *dst_repos_root_url;
+    const char *src_repos_uuid, *dst_repos_uuid;
+    svn_error_t *err;
+
+    err = svn_wc__db_read_info(&src_status, &src_db_kind, NULL, NULL,
+                               &src_repos_root_url, &src_repos_uuid, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL,
+                               db, src_abspath, scratch_pool, scratch_pool);
+
+    if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+      {
+        /* Replicate old error code and text */
+        svn_error_clear(err);
+        return svn_error_createf(SVN_ERR_ENTRY_NOT_FOUND, NULL,
+                                 _("'%s' is not under version control"),
+                                 svn_dirent_local_style(src_abspath,
+                                                        scratch_pool));
+      }
+    else
+      SVN_ERR(err);
+
+    SVN_ERR(svn_wc__db_read_info(&dstdir_status, NULL, NULL, NULL,
+                                 &dst_repos_root_url, &dst_repos_uuid, NULL,
+                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                                 NULL, NULL, NULL,
+                                 db, dstdir_abspath, scratch_pool, scratch_pool));
+
+    if (!src_repos_root_url)
+      {
+        if (src_status == svn_wc__db_status_added)
+          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL,
+                                           &src_repos_root_url,
+                                           &src_repos_uuid, NULL, NULL, NULL,
+                                           NULL,
+                                           db, src_abspath,
+                                           scratch_pool, scratch_pool));
+        else
+          /* If not added, the node must have a base or we can't copy */
+          SVN_ERR(svn_wc__db_scan_base_repos(NULL, &src_repos_root_url,
+                                             &src_repos_uuid,
+                                             db, src_abspath,
+                                             scratch_pool, scratch_pool));
+      }
+
+    if (!dst_repos_root_url)
+      {
+        if (dstdir_status == svn_wc__db_status_added)
+          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL,
+                                           &dst_repos_root_url,
+                                           &dst_repos_uuid, NULL, NULL, NULL,
+                                           NULL,
+                                           db, dstdir_abspath,
+                                           scratch_pool, scratch_pool));
+        else
+          /* If not added, the node must have a base or we can't copy */
+          SVN_ERR(svn_wc__db_scan_base_repos(NULL, &dst_repos_root_url,
+                                             &dst_repos_uuid,
+                                             db, dstdir_abspath,
+                                             scratch_pool, scratch_pool));
+      }
+
+    if (strcmp(src_repos_root_url, dst_repos_root_url) != 0
+        || strcmp(src_repos_uuid, dst_repos_uuid) != 0)
+      return svn_error_createf(
+         SVN_ERR_WC_INVALID_SCHEDULE, NULL,
+         _("Cannot copy to '%s', as it is not from repository '%s'; "
+           "it is from '%s'"),
+         svn_dirent_local_style(dst_abspath, scratch_pool),
+         src_repos_root_url, dst_repos_root_url);
+
+    if (dstdir_status == svn_wc__db_status_deleted)
+      return svn_error_createf(
+         SVN_ERR_WC_INVALID_SCHEDULE, NULL,
+         _("Cannot copy to '%s' as it is scheduled for deletion"),
+         svn_dirent_local_style(dst_abspath, scratch_pool));
+  }
 
   /* TODO(#2843): Rework the error report. */
   /* Check if the copy target is missing or hidden and thus not exist on the
      disk, before actually doing the file copy. */
-  SVN_ERR(svn_wc__db_read_kind(&kind, wc_ctx->db, dst_abspath, TRUE,
-                               scratch_pool));
+  {
+    svn_wc__db_status_t dst_status;
+    svn_error_t *err;
 
-  if (kind != svn_wc__db_kind_unknown)
-    {
-      svn_wc__db_status_t status;
+    err = svn_wc__db_read_info(&dst_status, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+                               NULL, NULL,
+                               db, dst_abspath, scratch_pool, scratch_pool);
 
-      SVN_ERR(svn_wc__db_read_info(&status, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-                                   NULL, NULL, NULL,
-                                   wc_ctx->db, dst_abspath,
-                                   scratch_pool, scratch_pool));
+    if (err && err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
+      return svn_error_return(err);
+
+    svn_error_clear(err);
 
-      switch (status)
+    if (!err)
+      switch (dst_status)
         {
           case svn_wc__db_status_excluded:
             return svn_error_createf(
@@ -611,18 +516,23 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
                      _("'%s' is already under version control"),
                      svn_dirent_local_style(dst_abspath, scratch_pool));
 
-          /* Explicitly ignore other statii */
+          case svn_wc__db_status_deleted:
+          case svn_wc__db_status_not_present:
+            break; /* OK to add */
+
           default:
-            break;
+            return svn_error_createf(SVN_ERR_ENTRY_EXISTS, NULL,
+                               _("There is already a versioned item '%s'"),
+                               svn_dirent_local_style(dst_abspath,
+                                                      scratch_pool));
         }
-    }
+  }
 
   SVN_ERR(svn_io_check_path(src_abspath, &src_kind, scratch_pool));
 
-  if (src_kind == svn_node_file ||
-      (src_entry->kind == svn_node_file && src_kind == svn_node_none))
+  if (!metadata_only)
     {
-      svn_node_kind_t dst_kind, dst_db_kind;
+      svn_node_kind_t dst_kind;
 
       /* This is the error checking from copy_file_administratively
          but converted to wc-ng.  It's not in copy_file since this
@@ -634,32 +544,19 @@ svn_wc_copy3(svn_wc_context_t *wc_ctx,
                                  _("'%s' already exists and is in the way"),
                                  svn_dirent_local_style(dst_abspath,
                                                         scratch_pool));
-      SVN_ERR(svn_wc_read_kind(&dst_db_kind, wc_ctx, dst_abspath, TRUE,
-                               scratch_pool));
-      if (dst_db_kind != svn_node_none)
-        {
-          svn_boolean_t is_deleted, is_present;
-
-          SVN_ERR(svn_wc__node_is_status_deleted(&is_deleted, wc_ctx,
-                                                 dst_abspath, scratch_pool));
-          SVN_ERR(svn_wc__node_is_status_present(&is_present, wc_ctx,
-                                                 dst_abspath, scratch_pool));
-          if (is_present && !is_deleted)
-            return svn_error_createf(SVN_ERR_ENTRY_EXISTS, NULL,
-                               _("There is already a versioned item '%s'"),
-                               svn_dirent_local_style(dst_abspath,
-                                                      scratch_pool));
-
-        }
+    }
 
-      SVN_ERR(copy_versioned_file(wc_ctx, src_abspath, dst_abspath,
+  if (src_db_kind == svn_wc__db_kind_file
+      || src_db_kind == svn_wc__db_kind_symlink)
+    {
+      SVN_ERR(copy_versioned_file(db, src_abspath, dst_abspath, metadata_only,
                                   cancel_func, cancel_baton,
                                   notify_func, notify_baton,
                                   scratch_pool));
     }
-  else if (src_kind == svn_node_dir)
+  else
     {
-      SVN_ERR(copy_versioned_dir(wc_ctx, src_abspath, dst_abspath,
+      SVN_ERR(copy_versioned_dir(db, src_abspath, dst_abspath, metadata_only,
                                  cancel_func, cancel_baton,
                                  notify_func, notify_baton,
                                  scratch_pool));

Modified: subversion/branches/py-tests-as-modules/subversion/libsvn_wc/crop.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/libsvn_wc/crop.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/libsvn_wc/crop.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/libsvn_wc/crop.c Wed Sep 15 19:32:26 2010
@@ -31,9 +31,6 @@
 #include "svn_path.h"
 
 #include "wc.h"
-#include "lock.h"
-#include "entries.h"
-#include "adm_files.h"
 
 #include "svn_private_config.h"
 
@@ -88,12 +85,13 @@ crop_children(svn_wc__db_t *db,
                                NULL,
                                db, local_abspath, pool, iterpool));
 
+  if (dir_depth == svn_depth_unknown)
+    dir_depth = svn_depth_infinity;
+
   /* Update the depth of target first, if needed. */
   if (dir_depth > depth)
-    {
-      SVN_ERR(svn_wc__db_temp_op_set_dir_depth(db, local_abspath, depth,
-                                               iterpool));
-    }
+    SVN_ERR(svn_wc__db_temp_op_set_dir_depth(db, local_abspath, depth,
+                                             iterpool));
 
   /* Looping over current directory's SVN entries: */
   SVN_ERR(svn_wc__db_read_children(&children, db, local_abspath, pool,
@@ -253,7 +251,6 @@ svn_wc_exclude(svn_wc_context_t *wc_ctx,
         SVN_ERR_MALFUNCTION();
 
       case svn_wc__db_status_added:
-      case svn_wc__db_status_obstructed_add:
         /* Would have to check parents if we want to allow this */
         return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                                  _("Cannot exclude '%s': it is to be added "
@@ -261,7 +258,6 @@ svn_wc_exclude(svn_wc_context_t *wc_ctx,
                                  svn_dirent_local_style(local_abspath,
                                                         scratch_pool));
       case svn_wc__db_status_deleted:
-      case svn_wc__db_status_obstructed_delete:
         /* Would have to check parents if we want to allow this */
         return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                                  _("Cannot exclude '%s': it is to be deleted "
@@ -271,7 +267,6 @@ svn_wc_exclude(svn_wc_context_t *wc_ctx,
 
       case svn_wc__db_status_normal:
       case svn_wc__db_status_incomplete:
-      case svn_wc__db_status_obstructed:
       default:
         break; /* Ok to exclude */
     }
@@ -359,16 +354,14 @@ svn_wc_crop_tree2(svn_wc_context_t *wc_c
                                svn_dirent_local_style(local_abspath,
                                                       scratch_pool));
 
-    if (status == svn_wc__db_status_deleted ||
-        status == svn_wc__db_status_obstructed_delete)
+    if (status == svn_wc__db_status_deleted)
       return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                                _("Cannot crop '%s': it is going to be removed "
                                  "from repository. Try commit instead"),
                                svn_dirent_local_style(local_abspath,
                                                       scratch_pool));
 
-    if (status == svn_wc__db_status_added ||
-        status == svn_wc__db_status_obstructed_add)
+    if (status == svn_wc__db_status_added)
       return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
                                _("Cannot crop '%s': it is to be added "
                                  "to the repository. Try commit instead"),

Modified: subversion/branches/py-tests-as-modules/subversion/libsvn_wc/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/libsvn_wc/deprecated.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/libsvn_wc/deprecated.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/libsvn_wc/deprecated.c Wed Sep 15 19:32:26 2010
@@ -34,12 +34,15 @@
 #include "svn_props.h"
 #include "svn_time.h"
 #include "svn_dirent_uri.h"
+#include "svn_path.h"
 
 #include "private/svn_wc_private.h"
 
 #include "wc.h"
+#include "entries.h"
 #include "lock.h"
 #include "props.h"
+#include "translate.h"
 #include "workqueue.h"
 
 #include "svn_private_config.h"
@@ -418,12 +421,14 @@ svn_wc_transmit_text_deltas2(const char 
                                          svn_wc__adm_get_db(adm_access),
                                          pool));
 
-  SVN_ERR(svn_wc_transmit_text_deltas3(tempfile,
-                                       digest ? &new_text_base_md5_checksum
-                                              : NULL,
-                                       NULL, wc_ctx,
-                                       local_abspath, fulltext, editor,
-                                       file_baton, pool, pool));
+  SVN_ERR(svn_wc__internal_transmit_text_deltas(tempfile,
+                                                (digest
+                                                 ? &new_text_base_md5_checksum
+                                                 : NULL),
+                                                NULL, wc_ctx->db,
+                                                local_abspath, fulltext,
+                                                editor, file_baton,
+                                                pool, pool));
 
   if (digest)
     memcpy(digest, new_text_base_md5_checksum->digest, APR_MD5_DIGESTSIZE);
@@ -558,6 +563,70 @@ svn_wc_get_pristine_contents(svn_stream_
 
 
 svn_error_t *
+svn_wc_queue_committed2(svn_wc_committed_queue_t *queue,
+                        const char *path,
+                        svn_wc_adm_access_t *adm_access,
+                        svn_boolean_t recurse,
+                        const apr_array_header_t *wcprop_changes,
+                        svn_boolean_t remove_lock,
+                        svn_boolean_t remove_changelist,
+                        const svn_checksum_t *md5_checksum,
+                        apr_pool_t *scratch_pool)
+{
+  const char *local_abspath;
+
+  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
+  return svn_wc_queue_committed3(queue, local_abspath, recurse, wcprop_changes,
+                                 remove_lock, remove_changelist, md5_checksum,
+                                 NULL /* sha1_checksum */, scratch_pool);
+}
+
+svn_error_t *
+svn_wc_queue_committed(svn_wc_committed_queue_t **queue,
+                       const char *path,
+                       svn_wc_adm_access_t *adm_access,
+                       svn_boolean_t recurse,
+                       const apr_array_header_t *wcprop_changes,
+                       svn_boolean_t remove_lock,
+                       svn_boolean_t remove_changelist,
+                       const unsigned char *digest,
+                       apr_pool_t *pool)
+{
+  const svn_checksum_t *md5_checksum;
+
+  if (digest)
+    md5_checksum = svn_checksum__from_digest(
+                   digest, svn_checksum_md5,
+                   svn_wc__get_committed_queue_pool(*queue));
+  else
+    md5_checksum = NULL;
+
+  return svn_wc_queue_committed2(*queue, path, adm_access, recurse,
+                                 wcprop_changes, remove_lock,
+                                 remove_changelist, md5_checksum, pool);
+}
+
+svn_error_t *
+svn_wc_process_committed_queue(svn_wc_committed_queue_t *queue,
+                               svn_wc_adm_access_t *adm_access,
+                               svn_revnum_t new_revnum,
+                               const char *rev_date,
+                               const char *rev_author,
+                               apr_pool_t *pool)
+{
+  svn_wc_context_t *wc_ctx;
+
+  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
+                                         svn_wc__adm_get_db(adm_access),
+                                         pool));
+  SVN_ERR(svn_wc_process_committed_queue2(queue, wc_ctx, new_revnum,
+                                          rev_date, rev_author, pool));
+  SVN_ERR(svn_wc_context_destroy(wc_ctx));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_wc_process_committed4(const char *path,
                           svn_wc_adm_access_t *adm_access,
                           svn_boolean_t recurse,
@@ -589,7 +658,7 @@ svn_wc_process_committed4(const char *pa
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
   wcprop_changes_hash = svn_wc__prop_array_to_hash(wcprop_changes, pool);
-  SVN_ERR(svn_wc__process_committed_internal(db, local_abspath, recurse,
+  SVN_ERR(svn_wc__process_committed_internal(db, local_abspath, recurse, TRUE,
                                              new_revnum, new_date, rev_author,
                                              wcprop_changes_hash,
                                              !remove_lock, !remove_changelist,
@@ -1053,14 +1122,22 @@ svn_wc_get_ancestry(char **url,
                     apr_pool_t *pool)
 {
   const char *local_abspath;
+  const svn_wc_entry_t *entry;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
-  return svn_error_return(svn_wc__internal_get_ancestry(
-                            (const char **)url, rev,
-                            svn_wc__adm_get_db(adm_access),
-                            local_abspath,
+  SVN_ERR(svn_wc__get_entry(&entry, svn_wc__adm_get_db(adm_access),
+                            local_abspath, FALSE,
+                            svn_node_unknown,
                             pool, pool));
+
+  if (url)
+    *url = apr_pstrdup(pool, entry->url);
+
+  if (rev)
+    *rev = entry->revision;
+
+  return SVN_NO_ERROR;
 }
 
 svn_error_t *
@@ -1712,6 +1789,7 @@ svn_wc_get_diff_editor5(svn_wc_adm_acces
                                    depth,
                                    ignore_ancestry,
                                    FALSE,
+                                   FALSE,
                                    use_text_base,
                                    reverse_order,
                                    changelists,
@@ -1863,6 +1941,7 @@ svn_wc_diff5(svn_wc_adm_access_t *anchor
                        depth,
                        ignore_ancestry,
                        FALSE,
+                       FALSE,
                        changelists,
                        NULL, NULL,
                        pool));
@@ -1968,27 +2047,11 @@ svn_wc_mark_missing_deleted(const char *
                             svn_wc_adm_access_t *parent,
                             apr_pool_t *pool)
 {
-#if SINGLE_DB
   /* With a single DB a node will never be missing */
   return svn_error_createf(SVN_ERR_WC_PATH_FOUND, NULL,
                            _("Unexpectedly found '%s': "
                              "path is marked 'missing'"),
-                           svn_dirent_local_style(path, scratch_pool));
-#else
-  const char *local_abspath;
-  svn_wc_context_t *wc_ctx;
-
-  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
-                                         svn_wc__adm_get_db(parent), pool));
-
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
-
-  SVN_ERR(svn_wc__temp_mark_missing_not_present(local_abspath, wc_ctx, pool));
-
-  SVN_ERR(svn_wc_context_destroy(wc_ctx));
-
-  return SVN_NO_ERROR;
-#endif
+                           svn_dirent_local_style(path, pool));
 }
 
 
@@ -2073,13 +2136,19 @@ svn_wc_prop_set3(const char *name,
 {
   svn_wc_context_t *wc_ctx;
   const char *local_abspath;
+  svn_error_t *err;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
   SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
                                          svn_wc__adm_get_db(adm_access), pool));
 
-  SVN_ERR(svn_wc_prop_set4(wc_ctx, local_abspath, name, value, skip_checks,
-                           notify_func, notify_baton, pool));
+  err = svn_wc_prop_set4(wc_ctx, local_abspath, name, value, skip_checks,
+                         notify_func, notify_baton, pool);
+
+  if (err && err->apr_err == SVN_ERR_WC_INVALID_SCHEDULE)
+    svn_error_clear(err);
+  else
+    SVN_ERR(err);
 
   return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
@@ -2142,12 +2211,18 @@ svn_wc_prop_get(const svn_string_t **val
 
   svn_wc_context_t *wc_ctx;
   const char *local_abspath;
+  svn_error_t *err;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
   SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
                                          svn_wc__adm_get_db(adm_access), pool));
 
-  SVN_ERR(svn_wc_prop_get2(value, wc_ctx, local_abspath, name, pool, pool));
+  err = svn_wc_prop_get2(value, wc_ctx, local_abspath, name, pool, pool);
+
+  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    svn_error_clear(err);
+  else
+    SVN_ERR(err);
 
   return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
@@ -2241,12 +2316,29 @@ svn_wc_props_modified_p(svn_boolean_t *m
                         svn_wc_adm_access_t *adm_access,
                         apr_pool_t *pool)
 {
-  svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
+  svn_wc_context_t *wc_ctx;
   const char *local_abspath;
+  svn_error_t *err;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
+  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
+                                         svn_wc__adm_get_db(adm_access), pool));
+
+  err = svn_wc_props_modified_p2(modified_p,
+                                 wc_ctx,
+                                 local_abspath,
+                                 pool);
 
-  return svn_wc__props_modified(modified_p, db, local_abspath, pool);
+  if (err)
+    {
+      if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
+        return svn_error_return(err);
+
+      svn_error_clear(err);
+      *modified_p = FALSE;
+    }
+
+  return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
 
 
@@ -2777,6 +2869,13 @@ svn_wc_is_wc_root(svn_boolean_t *wc_root
   const char *local_abspath;
   svn_error_t *err;
 
+  /* Subversion <= 1.6 said that '.' or a drive root is a WC root. */
+  if (svn_path_is_empty(path) || svn_dirent_is_root(path, strlen(path)))
+    {
+      *wc_root = TRUE;
+      return SVN_NO_ERROR;
+    }
+
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
   SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
                                          svn_wc__adm_get_db(adm_access),
@@ -2788,9 +2887,9 @@ svn_wc_is_wc_root(svn_boolean_t *wc_root
       && (err->apr_err == SVN_ERR_WC_NOT_WORKING_COPY
           || err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND))
     {
-      /* Subversion <= 1.6 just said that a not versioned path is not a root */
+      /* Subversion <= 1.6 said that an unversioned path is a WC root. */
       svn_error_clear(err);
-      *wc_root = FALSE;
+      *wc_root = TRUE;
     }
   else
     SVN_ERR(err);
@@ -3212,19 +3311,14 @@ svn_wc_translated_stream(svn_stream_t **
 {
   const char *local_abspath;
   const char *versioned_abspath;
-  svn_wc_context_t *wc_ctx;
 
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
   SVN_ERR(svn_dirent_get_absolute(&versioned_abspath, versioned_file, pool));
-  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL /* config */,
-                                         svn_wc__adm_get_db(adm_access),
-                                         pool));
-
-  SVN_ERR(svn_wc_translated_stream2(stream, wc_ctx, local_abspath,
-                                    versioned_abspath, flags,
-                                    pool, pool));
 
-  return svn_error_return(svn_wc_context_destroy(wc_ctx));
+  return svn_error_return(
+    svn_wc__internal_translated_stream(stream, svn_wc__adm_get_db(adm_access),
+                                       local_abspath, versioned_abspath, flags,
+                                       pool, pool));
 }
 
 svn_error_t *
@@ -3238,15 +3332,13 @@ svn_wc_translated_file2(const char **xla
   const char *versioned_abspath;
   const char *root;
   const char *tmp_root;
-  svn_wc_context_t *wc_ctx;
 
   SVN_ERR(svn_dirent_get_absolute(&versioned_abspath, versioned_file, pool));
-  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
-                                         svn_wc__adm_get_db(adm_access),
-                                         pool));
 
-  SVN_ERR(svn_wc_translated_file3(xlated_path, src, wc_ctx, versioned_abspath,
-                                  flags, NULL, NULL, pool, pool));
+  SVN_ERR(svn_wc__internal_translated_file(xlated_path, src,
+                                           svn_wc__adm_get_db(adm_access),
+                                           versioned_abspath,
+                                           flags, NULL, NULL, pool, pool));
   if (! svn_dirent_is_absolute(versioned_file))
     {
       SVN_ERR(svn_io_temp_dir(&tmp_root, pool));
@@ -3257,7 +3349,7 @@ svn_wc_translated_file2(const char **xla
         }
     }
 
-  return svn_error_return(svn_wc_context_destroy(wc_ctx));
+  return SVN_NO_ERROR;
 }
 
 /*** From relocate.c ***/
@@ -3542,6 +3634,7 @@ svn_wc_copy2(const char *src,
   SVN_ERR(svn_wc_copy3(wc_ctx,
                        src_abspath,
                        dst_abspath,
+                       FALSE /* metadata_only */, 
                        cancel_func, cancel_baton,
                        notify_func, notify_baton,
                        pool));
@@ -3788,70 +3881,6 @@ svn_wc_crop_tree(svn_wc_adm_access_t *an
   return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
 
-svn_error_t *
-svn_wc_queue_committed2(svn_wc_committed_queue_t *queue,
-                        const char *path,
-                        svn_wc_adm_access_t *adm_access,
-                        svn_boolean_t recurse,
-                        const apr_array_header_t *wcprop_changes,
-                        svn_boolean_t remove_lock,
-                        svn_boolean_t remove_changelist,
-                        const svn_checksum_t *md5_checksum,
-                        apr_pool_t *scratch_pool)
-{
-  const char *local_abspath;
-
-  SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, scratch_pool));
-  return svn_wc_queue_committed3(queue, local_abspath, recurse, wcprop_changes,
-                                 remove_lock, remove_changelist, md5_checksum,
-                                 NULL /* sha1_checksum */, scratch_pool);
-}
-
-svn_error_t *
-svn_wc_queue_committed(svn_wc_committed_queue_t **queue,
-                       const char *path,
-                       svn_wc_adm_access_t *adm_access,
-                       svn_boolean_t recurse,
-                       const apr_array_header_t *wcprop_changes,
-                       svn_boolean_t remove_lock,
-                       svn_boolean_t remove_changelist,
-                       const unsigned char *digest,
-                       apr_pool_t *pool)
-{
-  const svn_checksum_t *md5_checksum;
-
-  if (digest)
-    md5_checksum = svn_checksum__from_digest(
-                   digest, svn_checksum_md5,
-                   svn_wc__get_committed_queue_pool(*queue));
-  else
-    md5_checksum = NULL;
-
-  return svn_wc_queue_committed2(*queue, path, adm_access, recurse,
-                                 wcprop_changes, remove_lock,
-                                 remove_changelist, md5_checksum, pool);
-}
-
-svn_error_t *
-svn_wc_process_committed_queue(svn_wc_committed_queue_t *queue,
-                               svn_wc_adm_access_t *adm_access,
-                               svn_revnum_t new_revnum,
-                               const char *rev_date,
-                               const char *rev_author,
-                               apr_pool_t *pool)
-{
-  svn_wc_context_t *wc_ctx;
-
-  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
-                                         svn_wc__adm_get_db(adm_access),
-                                         pool));
-  SVN_ERR(svn_wc_process_committed_queue2(queue, wc_ctx, new_revnum,
-                                          rev_date, rev_author, pool));
-  SVN_ERR(svn_wc_context_destroy(wc_ctx));
-
-  return SVN_NO_ERROR;
-}
-
 #ifdef SVN_DISABLE_FULL_VERSION_MATCH
 /* This double underscore name is used by the 1.6 libsvn_client.
    Keeping this name is sufficient for the 1.6 libsvn_client to link
@@ -3875,22 +3904,15 @@ svn_wc__entry_versioned_internal(const s
                                  int caller_lineno,
                                  apr_pool_t *pool)
 {
-  svn_wc_context_t *wc_ctx;
   const char *local_abspath;
 
-  SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
-                                         svn_wc__adm_get_db(adm_access),
-                                         pool));
-
   SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool));
 
-  SVN_ERR(svn_wc__get_entry_versioned(entry, wc_ctx, local_abspath,
-                                      svn_node_unknown, show_hidden,
-                                      FALSE, /* NEED_PARENT_STUB */
+  SVN_ERR(svn_wc__get_entry_versioned(entry, svn_wc__adm_get_db(adm_access),
+                                      local_abspath, svn_node_unknown,
+                                      show_hidden,
                                       pool, pool));
 
-  SVN_ERR(svn_wc_context_destroy(wc_ctx));
-
   return SVN_NO_ERROR;
 }
 #endif

Modified: subversion/branches/py-tests-as-modules/subversion/libsvn_wc/diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/py-tests-as-modules/subversion/libsvn_wc/diff.c?rev=997472&r1=997471&r2=997472&view=diff
==============================================================================
--- subversion/branches/py-tests-as-modules/subversion/libsvn_wc/diff.c (original)
+++ subversion/branches/py-tests-as-modules/subversion/libsvn_wc/diff.c Wed Sep 15 19:32:26 2010
@@ -58,8 +58,6 @@
 #include "wc.h"
 #include "props.h"
 #include "adm_files.h"
-#include "lock.h"
-#include "entries.h"
 #include "translate.h"
 
 #include "svn_private_config.h"
@@ -155,7 +153,6 @@ get_nearest_pristine_text_as_file(const 
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool)
 {
-#ifdef SVN_EXPERIMENTAL_PRISTINE
   const svn_checksum_t *checksum;
 
   SVN_ERR(svn_wc__db_read_info(NULL, NULL, NULL, NULL, NULL, NULL,
@@ -188,34 +185,6 @@ get_nearest_pristine_text_as_file(const 
                                            result_pool, scratch_pool));
       return SVN_NO_ERROR;
     }
-#else
-  svn_error_t *err;
-
-  err = svn_wc__text_base_path_to_read(result_abspath, db, local_abspath,
-                                       result_pool, scratch_pool);
-
-  if (err && err->apr_err == SVN_ERR_WC_PATH_UNEXPECTED_STATUS)
-    svn_error_clear(err);
-  else
-    return svn_error_return(err);
-
-  err = svn_wc__text_revert_path_to_read(result_abspath, db, local_abspath,
-                                         result_pool);
-
-  /* If there is no revert base to diff either, don't attempt to diff it.
-     ### This is a band-aid.
-     ### In WC-NG, files added within a copied subtree are marked "copied",
-     ### which will cause the code below to end up calling
-     ### eb->callbacks->file_changed() with a non-existent text-base.
-     ### Not sure how to properly tell apart a file added within a copied
-     ### subtree from a copied file. But eventually we'll have to get the
-     ### base text from the pristine store anyway and use tempfiles (or
-     ### streams, hopefully) for diffing, so this hack will just go away. */
-  if (err && err->apr_err == SVN_ERR_WC_PATH_UNEXPECTED_STATUS)
-    svn_error_clear(err);
-  else
-    return svn_error_return(err);
-#endif
 
   *result_abspath = NULL;
   return SVN_NO_ERROR;
@@ -258,6 +227,9 @@ struct edit_baton {
   /* Should this diff not compare copied files with their source? */
   svn_boolean_t show_copies_as_adds;
 
+  /* Are we producing a git-style diff? */
+  svn_boolean_t use_git_diff_format;
+
   /* Possibly diff repos against text-bases instead of working files. */
   svn_boolean_t use_text_base;
 
@@ -381,6 +353,7 @@ make_edit_baton(struct edit_baton **edit
                 svn_depth_t depth,
                 svn_boolean_t ignore_ancestry,
                 svn_boolean_t show_copies_as_adds,
+                svn_boolean_t use_git_diff_format,
                 svn_boolean_t use_text_base,
                 svn_boolean_t reverse_order,
                 const apr_array_header_t *changelists,
@@ -404,6 +377,7 @@ make_edit_baton(struct edit_baton **edit
   eb->depth = depth;
   eb->ignore_ancestry = ignore_ancestry;
   eb->show_copies_as_adds = show_copies_as_adds;
+  eb->use_git_diff_format = use_git_diff_format;
   eb->use_text_base = use_text_base;
   eb->reverse_order = reverse_order;
   eb->changelist_hash = changelist_hash;
@@ -587,6 +561,7 @@ file_diff(struct dir_baton *db,
   const char *empty_file;
   svn_boolean_t replaced;
   svn_wc__db_status_t status;
+  const char *original_repos_relpath;
   svn_revnum_t revision;
   svn_revnum_t revert_base_revnum;
   svn_boolean_t have_base;
@@ -616,16 +591,16 @@ file_diff(struct dir_baton *db,
                                      NULL, NULL, NULL, NULL, NULL, NULL,
                                      eb->db, local_abspath, pool, pool));
 
-  replaced = ((status == svn_wc__db_status_added
-               || status == svn_wc__db_status_obstructed_add)
+  replaced = ((status == svn_wc__db_status_added)
               && have_base
               && base_status != svn_wc__db_status_not_present);
 
   /* Now refine ADDED to one of: ADDED, COPIED, MOVED_HERE. Note that only
      the latter two have corresponding pristine info to diff against.  */
   if (status == svn_wc__db_status_added)
-    SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
-                                     NULL, NULL, NULL, eb->db, local_abspath,
+    SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL,
+                                     &original_repos_relpath, NULL, NULL,
+                                     NULL, eb->db, local_abspath,
                                      pool, pool));
 
   /* A wc-wc diff of replaced files actually shows a diff against the
@@ -689,11 +664,15 @@ file_diff(struct dir_baton *db,
   * If the item is schedule-add *with history*, then we usually want
   * to see the usual working vs. text-base comparison, which will show changes
   * made since the file was copied.  But in case we're showing copies as adds,
-  * we need to compare the copied file to the empty file. */
+  * we need to compare the copied file to the empty file. If we're doing a git
+  * diff, and the file was copied, we need to report the file as added and
+  * diff it against the text base, so that a "copied" git diff header, and
+  * possibly a diff against the copy source, will be generated for it. */
   if ((! replaced && status == svn_wc__db_status_added) ||
      (replaced && ! eb->ignore_ancestry) ||
      ((status == svn_wc__db_status_copied ||
-       status == svn_wc__db_status_moved_here) && eb->show_copies_as_adds))
+       status == svn_wc__db_status_moved_here) &&
+         (eb->show_copies_as_adds || eb->use_git_diff_format)))
     {
       const char *translated = NULL;
       const char *working_mimetype;
@@ -718,28 +697,30 @@ file_diff(struct dir_baton *db,
               pool, pool));
 
       SVN_ERR(eb->callbacks->file_added(NULL, NULL, NULL, NULL, path,
-                                        empty_file,
+                                        (! eb->show_copies_as_adds &&
+                                         eb->use_git_diff_format &&
+                                         status != svn_wc__db_status_added) ?
+                                          textbase : empty_file,
                                         translated,
                                         0, revision,
                                         NULL,
                                         working_mimetype,
-                                        NULL, SVN_INVALID_REVNUM,
-                                        propchanges, baseprops,
-                                        eb->callback_baton,
+                                        original_repos_relpath,
+                                        SVN_INVALID_REVNUM, propchanges,
+                                        baseprops, eb->callback_baton,
                                         pool));
     }
   else
     {
-      svn_boolean_t modified;
       const char *translated = NULL;
       apr_hash_t *baseprops;
       const char *base_mimetype;
       const char *working_mimetype;
       apr_hash_t *workingprops;
       apr_array_header_t *propchanges;
+      svn_boolean_t modified;
 
       /* Here we deal with showing pure modifications. */
-
       SVN_ERR(svn_wc__internal_text_modified_p(&modified, eb->db,
                                                local_abspath, FALSE, TRUE,
                                                pool));
@@ -765,9 +746,9 @@ file_diff(struct dir_baton *db,
           /* We don't want the normal pristine properties (which are
              from the WORKING tree). We want the pristines associated
              with the BASE tree, which are saved as "revert" props.  */
-          SVN_ERR(svn_wc__get_revert_props(&baseprops,
-                                           eb->db, local_abspath,
-                                           pool, pool));
+          SVN_ERR(svn_wc__db_base_get_props(&baseprops,
+                                            eb->db, local_abspath,
+                                            pool, pool));
         }
       else
         {
@@ -779,6 +760,10 @@ file_diff(struct dir_baton *db,
 
           SVN_ERR(svn_wc__get_pristine_props(&baseprops, eb->db, local_abspath,
                                              pool, pool));
+
+          /* baseprops will be NULL for added nodes */
+          if (!baseprops)
+            baseprops = apr_hash_make(pool);
         }
       base_mimetype = get_prop_mimetype(baseprops);
 
@@ -1537,7 +1522,7 @@ apply_textdelta(void *file_baton,
                                      NULL, NULL, NULL, eb->db,
                                      fb->local_abspath, pool, pool));
 
-  svn_dirent_split(fb->wc_path, &parent, &base_name, fb->pool);
+  svn_dirent_split(&parent, &base_name, fb->wc_path, fb->pool);
 
   /* If the node is added-with-history, then this is not actually
      an add, but a modification. */
@@ -1842,6 +1827,7 @@ svn_wc_get_diff_editor6(const svn_delta_
                         svn_depth_t depth,
                         svn_boolean_t ignore_ancestry,
                         svn_boolean_t show_copies_as_adds,
+                        svn_boolean_t use_git_diff_format,
                         svn_boolean_t use_text_base,
                         svn_boolean_t reverse_order,
                         const apr_array_header_t *changelists,
@@ -1861,6 +1847,7 @@ svn_wc_get_diff_editor6(const svn_delta_
                           anchor_path, target,
                           callbacks, callback_baton,
                           depth, ignore_ancestry, show_copies_as_adds,
+                          use_git_diff_format,
                           use_text_base, reverse_order, changelists,
                           cancel_func, cancel_baton,
                           result_pool));
@@ -1889,11 +1876,12 @@ svn_wc_get_diff_editor6(const svn_delta_
   if (depth == svn_depth_unknown)
     SVN_ERR(svn_wc__ambient_depth_filter_editor(&inner_editor,
                                                 &inner_baton,
-                                                inner_editor,
-                                                inner_baton,
+                                                wc_ctx->db,
                                                 anchor_abspath,
                                                 target,
-                                                wc_ctx->db,
+                                                FALSE /* read_base */,
+                                                inner_editor,
+                                                inner_baton,
                                                 result_pool));
 
   return svn_delta_get_cancellation_editor(cancel_func,
@@ -1915,6 +1903,7 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
              svn_depth_t depth,
              svn_boolean_t ignore_ancestry,
              svn_boolean_t show_copies_as_adds,
+             svn_boolean_t use_git_diff_format,
              const apr_array_header_t *changelists,
              svn_cancel_func_t cancel_func,
              void *cancel_baton,
@@ -1937,7 +1926,7 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
       target = "";
     }
   else
-    svn_dirent_split(target_path, &anchor_path, &target, pool);
+    svn_dirent_split(&anchor_path, &target, target_path, pool);
 
   SVN_ERR(make_edit_baton(&eb,
                           wc_ctx->db,
@@ -1945,6 +1934,7 @@ svn_wc_diff6(svn_wc_context_t *wc_ctx,
                           target,
                           callbacks, callback_baton,
                           depth, ignore_ancestry, show_copies_as_adds,
+                          use_git_diff_format,
                           FALSE, FALSE, changelists,
                           cancel_func, cancel_baton,
                           pool));