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 2011/09/14 15:46:59 UTC

svn commit: r1170622 [3/7] - in /subversion/branches/fs-py: ./ notes/ subversion/bindings/javahl/tests/org/apache/subversion/javahl/ subversion/include/ subversion/include/private/ subversion/libsvn_client/ subversion/libsvn_delta/ subversion/libsvn_fs...

Modified: subversion/branches/fs-py/subversion/libsvn_delta/compat.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_delta/compat.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_delta/compat.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_delta/compat.c Wed Sep 14 13:46:56 2011
@@ -21,11 +21,11 @@
  * ====================================================================
  */
 
-#include <apr_pools.h>
-
 #include "svn_types.h"
 #include "svn_error.h"
 #include "svn_delta.h"
+#include "svn_sorts.h"
+#include "svn_pools.h"
 
 
 struct file_rev_handler_wrapper_baton {
@@ -76,3 +76,624 @@ svn_compat_wrap_file_rev_handler(svn_fil
   *handler2_baton = fwb;
   *handler2 = file_rev_handler_wrapper;
 }
+
+
+/* The following code maps the calls to a traditional delta editor to an
+ * Editorv2 editor.  It does this by keeping track of a lot of state, and
+ * then communicating that state to Ev2 upon closure of the file or dir (or
+ * edit).  Note that Ev2 calls add_symlink() and set_target() are not present
+ * in the delta editor paradigm, so we never call them.
+ *
+ * The general idea here is that we have to see *all* the actions on a node's
+ * parent before we can process that node, which means we need to buffer a
+ * large amount of information in the dir batons, and then process it in the
+ * close_directory() handler. */
+
+struct ev2_edit_baton
+{
+  svn_editor_t *editor;
+  apr_hash_t *paths;
+  apr_pool_t *edit_pool;
+};
+
+struct ev2_dir_baton
+{
+  struct ev2_edit_baton *eb;
+  const char *path;
+};
+
+struct ev2_file_baton
+{
+  struct ev2_edit_baton *eb;
+  const char *path;
+};
+
+enum action
+{
+  add,
+  delete,
+  set_prop
+};
+
+struct path_action
+{
+  enum action action;
+  void *args;
+};
+
+struct prop_args
+{
+  const char *name;
+  const svn_string_t *value;
+};
+
+static svn_error_t *
+add_action(struct ev2_edit_baton *eb,
+           const char *path,
+           enum action action,
+           void *args)
+{
+  struct path_action *p_action;
+  apr_array_header_t *action_list = apr_hash_get(eb->paths, path,
+                                                 APR_HASH_KEY_STRING);
+
+  p_action = apr_palloc(eb->edit_pool, sizeof(*p_action));
+  p_action->action = action;
+  p_action->args = args;
+
+  if (action_list == NULL)
+    {
+      action_list = apr_array_make(eb->edit_pool, 1,
+                                   sizeof(struct path_action *));
+      apr_hash_set(eb->paths, apr_pstrdup(eb->edit_pool, path),
+                   APR_HASH_KEY_STRING, action_list);
+    }
+
+  APR_ARRAY_PUSH(action_list, struct path_action *) = p_action;
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_set_target_revision(void *edit_baton,
+                        svn_revnum_t target_revision,
+                        apr_pool_t *scratch_pool)
+{
+  struct ev2_edit_baton *eb = edit_baton;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_open_root(void *edit_baton,
+              svn_revnum_t base_revision,
+              apr_pool_t *result_pool,
+              void **root_baton)
+{
+  struct ev2_dir_baton *db = apr_palloc(result_pool, sizeof(*db));
+  struct ev2_edit_baton *eb = edit_baton;
+
+  db->eb = eb;
+
+  *root_baton = db;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_delete_entry(const char *path,
+                 svn_revnum_t revision,
+                 void *parent_baton,
+                 apr_pool_t *scratch_pool)
+{
+  struct ev2_dir_baton *pb = parent_baton;
+  svn_revnum_t *revnum = apr_palloc(pb->eb->edit_pool, sizeof(*revnum));
+
+  *revnum = revision;
+  SVN_ERR(add_action(pb->eb, path, delete, revnum));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_add_directory(const char *path,
+                  void *parent_baton,
+                  const char *copyfrom_path,
+                  svn_revnum_t copyfrom_revision,
+                  apr_pool_t *result_pool,
+                  void **child_baton)
+{
+  struct ev2_dir_baton *pb = parent_baton;
+  struct ev2_dir_baton *cb = apr_palloc(result_pool, sizeof(*cb));
+  svn_node_kind_t *kind;
+
+  kind = apr_palloc(pb->eb->edit_pool, sizeof(*kind));
+  *kind = svn_node_dir;
+  SVN_ERR(add_action(pb->eb, path, add, kind));
+
+  cb->eb = pb->eb;
+  cb->path = apr_pstrdup(result_pool, path);
+  *child_baton = cb;
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_open_directory(const char *path,
+                   void *parent_baton,
+                   svn_revnum_t base_revision,
+                   apr_pool_t *result_pool,
+                   void **child_baton)
+{
+  struct ev2_dir_baton *pb = parent_baton;
+  struct ev2_dir_baton *db = apr_palloc(result_pool, sizeof(*db));
+
+  db->eb = pb->eb;
+  db->path = apr_pstrdup(result_pool, path);
+
+  *child_baton = db;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_change_dir_prop(void *dir_baton,
+                    const char *name,
+                    const svn_string_t *value,
+                    apr_pool_t *scratch_pool)
+{
+  struct ev2_dir_baton *db = dir_baton;
+  struct prop_args *p_args = apr_palloc(db->eb->edit_pool, sizeof(*p_args));
+
+  p_args->name = apr_pstrdup(db->eb->edit_pool, name);
+  p_args->value = value ? svn_string_dup(value, db->eb->edit_pool) : NULL;
+
+  SVN_ERR(add_action(db->eb, db->path, set_prop, p_args));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_close_directory(void *dir_baton,
+                    apr_pool_t *scratch_pool)
+{
+  struct ev2_dir_baton *db = dir_baton;
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_absent_directory(const char *path,
+                     void *parent_baton,
+                     apr_pool_t *scratch_pool)
+{
+  struct ev2_dir_baton *pb = parent_baton;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_add_file(const char *path,
+             void *parent_baton,
+             const char *copyfrom_path,
+             svn_revnum_t copyfrom_revision,
+             apr_pool_t *result_pool,
+             void **file_baton)
+{
+  struct ev2_file_baton *fb = apr_palloc(result_pool, sizeof(*fb));
+  struct ev2_dir_baton *pb = parent_baton;
+  svn_node_kind_t *kind;
+
+  fb->eb = pb->eb;
+  fb->path = apr_pstrdup(result_pool, path);
+  *file_baton = fb;
+
+  kind = apr_palloc(pb->eb->edit_pool, sizeof(*kind));
+  *kind = svn_node_file;
+  SVN_ERR(add_action(pb->eb, path, add, kind));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_open_file(const char *path,
+              void *parent_baton,
+              svn_revnum_t base_revision,
+              apr_pool_t *result_pool,
+              void **file_baton)
+{
+  struct ev2_file_baton *fb = apr_palloc(result_pool, sizeof(*fb));
+  struct ev2_dir_baton *pb = parent_baton;
+
+  fb->eb = pb->eb;
+  fb->path = apr_pstrdup(result_pool, path);
+
+  *file_baton = fb;
+  return SVN_NO_ERROR;
+}
+
+
+static svn_error_t *
+ev2_apply_textdelta(void *file_baton,
+                    const char *base_checksum,
+                    apr_pool_t *result_pool,
+                    svn_txdelta_window_handler_t *handler,
+                    void **handler_baton)
+{
+  struct ev2_file_baton *fb = file_baton;
+
+  *handler_baton = NULL;
+  *handler = svn_delta_noop_window_handler;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_change_file_prop(void *file_baton,
+                     const char *name,
+                     const svn_string_t *value,
+                     apr_pool_t *scratch_pool)
+{
+  struct ev2_file_baton *fb = file_baton;
+  struct prop_args *p_args = apr_palloc(fb->eb->edit_pool, sizeof(*p_args));
+
+  p_args->name = apr_pstrdup(fb->eb->edit_pool, name);
+  p_args->value = value ? svn_string_dup(value, fb->eb->edit_pool) : NULL;
+
+  SVN_ERR(add_action(fb->eb, fb->path, set_prop, p_args));
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_close_file(void *file_baton,
+               const char *text_checksum,
+               apr_pool_t *scratch_pool)
+{
+  struct ev2_file_baton *fb = file_baton;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_absent_file(const char *path,
+                void *parent_baton,
+                apr_pool_t *scratch_pool)
+{
+  struct ev2_dir_baton *pb = parent_baton;
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+ev2_close_edit(void *edit_baton,
+               apr_pool_t *scratch_pool)
+{
+  struct ev2_edit_baton *eb = edit_baton;
+  apr_array_header_t *sorted_hash;
+  apr_pool_t *iterpool;
+  int i;
+
+  /* Sort the paths touched by this edit.
+   * Ev2 doesn't really have any particular need for depth-first-ness, but
+   * we want to ensure all parent directories are handled before children in
+   * the case of adds (which does introduce an element of depth-first-ness). */
+  sorted_hash = svn_sort__hash(eb->paths, svn_sort_compare_items_as_paths,
+                               scratch_pool);
+
+  iterpool = svn_pool_create(scratch_pool);
+  for (i = 0; i < sorted_hash->nelts; i++)
+    {
+      svn_sort__item_t *item = &APR_ARRAY_IDX(sorted_hash, i, svn_sort__item_t);
+      apr_array_header_t *actions = item->value;
+      const char *path = item->key;
+      apr_hash_t *props = NULL;
+      int j;
+
+      svn_pool_clear(iterpool);
+
+      /* Go through all of our actions, populating various datastructures
+       * dependent on them. */
+      for (j = 0; j < actions->nelts; j++)
+        {
+          struct path_action *action = APR_ARRAY_IDX(actions, j,
+                                                     struct path_action *);
+
+          switch (action->action)
+            {
+              case set_prop:
+                {
+                  struct prop_args *p_args = action->args;
+
+                  if (!props)
+                    props = apr_hash_make(iterpool);
+
+                  apr_hash_set(props, p_args->name, APR_HASH_KEY_STRING,
+                               p_args->value);
+                  break;
+                }
+
+              case delete:
+                {
+                  svn_revnum_t *revnum = action->args;
+
+                  /* If we get a delete, we'd better not have gotten any
+                     other actions for this path later, so we can go ahead
+                     and call our handler. */
+                  SVN_ERR(svn_editor_delete(eb->editor, path, *revnum));
+                  break;
+                }
+
+              default:
+                break;
+            }
+        }
+
+      /* We've now got a wholistic view of what has happened to this node,
+       * so we can call our own editor APIs on it. */
+
+      /* We don't want to just unconditionally call set_props on our PROPS
+         hash, since if we didn't get an set props actions, that hash would
+         be invalid (or if it was valid, it would be empty and we'd delete
+         all the properties).  So instead, we only allocate the hash when
+         we know we've seen a SET_PROP action, and ensure that hash is valid
+         when calling the Ev2 function below. */
+      if (props)
+        SVN_ERR(svn_editor_set_props(eb->editor, path, SVN_INVALID_REVNUM,
+                                     props, TRUE));
+    }
+  svn_pool_destroy(iterpool);
+
+  return svn_error_trace(svn_editor_complete(eb->editor));
+}
+
+static svn_error_t *
+ev2_abort_edit(void *edit_baton,
+               apr_pool_t *scratch_pool)
+{
+  struct ev2_edit_baton *eb = edit_baton;
+
+  return svn_error_trace(svn_editor_abort(eb->editor));
+}
+
+svn_error_t *
+svn_delta_from_editor(const svn_delta_editor_t **deditor,
+                      void **dedit_baton,
+                      svn_editor_t *editor,
+                      apr_pool_t *pool)
+{
+  /* Static 'cause we don't want it to be on the stack. */
+  static svn_delta_editor_t delta_editor = {
+      ev2_set_target_revision,
+      ev2_open_root,
+      ev2_delete_entry,
+      ev2_add_directory,
+      ev2_open_directory,
+      ev2_change_dir_prop,
+      ev2_close_directory,
+      ev2_absent_directory,
+      ev2_add_file,
+      ev2_open_file,
+      ev2_apply_textdelta,
+      ev2_change_file_prop,
+      ev2_close_file,
+      ev2_absent_file,
+      ev2_close_edit,
+      ev2_abort_edit
+    };
+  struct ev2_edit_baton *eb = apr_palloc(pool, sizeof(*eb));
+
+  eb->editor = editor;
+  eb->paths = apr_hash_make(pool);
+  eb->edit_pool = pool;
+
+  *dedit_baton = eb;
+  *deditor = &delta_editor;
+
+  return SVN_NO_ERROR;
+}
+
+
+struct editor_baton
+{
+  const svn_delta_editor_t *deditor;
+  void *dedit_baton;
+};
+
+/* This implements svn_editor_cb_add_directory_t */
+static svn_error_t *
+add_directory_cb(void *baton,
+                 const char *relpath,
+                 const apr_array_header_t *children,
+                 apr_hash_t *props,
+                 svn_revnum_t replaces_rev,
+                 apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_add_file_t */
+static svn_error_t *
+add_file_cb(void *baton,
+            const char *relpath,
+            apr_hash_t *props,
+            svn_revnum_t replaces_rev,
+            apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_add_symlink_t */
+static svn_error_t *
+add_symlink_cb(void *baton,
+               const char *relpath,
+               const char *target,
+               apr_hash_t *props,
+               svn_revnum_t replaces_rev,
+               apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_add_absent_t */
+static svn_error_t *
+add_absent_cb(void *baton,
+              const char *relpath,
+              svn_node_kind_t kind,
+              svn_revnum_t replaces_rev,
+              apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_set_props_t */
+static svn_error_t *
+set_props_cb(void *baton,
+             const char *relpath,
+             svn_revnum_t revision,
+             apr_hash_t *props,
+             svn_boolean_t complete,
+             apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_set_text_t */
+static svn_error_t *
+set_text_cb(void *baton,
+            const char *relpath,
+            svn_revnum_t revision,
+            const svn_checksum_t *checksum,
+            svn_stream_t *contents,
+            apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_set_target_t */
+static svn_error_t *
+set_target_cb(void *baton,
+              const char *relpath,
+              svn_revnum_t revision,
+              const char *target,
+              apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_delete_t */
+static svn_error_t *
+delete_cb(void *baton,
+          const char *relpath,
+          svn_revnum_t revision,
+          apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_copy_t */
+static svn_error_t *
+copy_cb(void *baton,
+        const char *src_relpath,
+        svn_revnum_t src_revision,
+        const char *dst_relpath,
+        svn_revnum_t replaces_rev,
+        apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_move_t */
+static svn_error_t *
+move_cb(void *baton,
+        const char *src_relpath,
+        svn_revnum_t src_revision,
+        const char *dst_relpath,
+        svn_revnum_t replaces_rev,
+        apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* This implements svn_editor_cb_complete_t */
+static svn_error_t *
+complete_cb(void *baton,
+            apr_pool_t *scratch_pool)
+{
+  struct editor_baton *eb = baton;
+  return svn_error_trace(eb->deditor->close_edit(eb->dedit_baton,
+                                                 scratch_pool));
+}
+
+/* This implements svn_editor_cb_abort_t */
+static svn_error_t *
+abort_cb(void *baton,
+         apr_pool_t *scratch_pool)
+{
+  struct editor_baton *eb = baton;
+  return svn_error_trace(eb->deditor->abort_edit(eb->dedit_baton,
+                                                 scratch_pool));
+}
+
+svn_error_t *
+svn_editor_from_delta(svn_editor_t **editor_p,
+                      const svn_delta_editor_t *deditor,
+                      void *dedit_baton,
+                      svn_cancel_func_t cancel_func,
+                      void *cancel_baton,
+                      apr_pool_t *result_pool,
+                      apr_pool_t *scratch_pool)
+{
+  svn_editor_t *editor;
+  static const svn_editor_cb_many_t editor_cbs = {
+      add_directory_cb,
+      add_file_cb,
+      add_symlink_cb,
+      add_absent_cb,
+      set_props_cb,
+      set_text_cb,
+      set_target_cb,
+      delete_cb,
+      copy_cb,
+      move_cb,
+      complete_cb,
+      abort_cb
+    };
+  struct editor_baton *eb = apr_palloc(result_pool, sizeof(*eb));
+
+  eb->deditor = deditor;
+  eb->dedit_baton = dedit_baton;
+
+  SVN_ERR(svn_editor_create(&editor, eb, cancel_func, cancel_baton,
+                            result_pool, scratch_pool));
+  SVN_ERR(svn_editor_setcb_many(editor, &editor_cbs, scratch_pool));
+
+  *editor_p = editor;
+
+  return SVN_NO_ERROR;
+}
+
+
+/* Uncomment below to add editor shims throughout Subversion.  In it's
+ * current state, that will likely break The World. */
+/* #define ENABLE_EDITOR_SHIMS*/
+
+svn_error_t *
+svn_editor__insert_shims(const svn_delta_editor_t **deditor_out,
+                         void **dedit_baton_out,
+                         const svn_delta_editor_t *deditor_in,
+                         void *dedit_baton_in,
+                         apr_pool_t *result_pool,
+                         apr_pool_t *scratch_pool)
+{
+#ifndef ENABLE_EDITOR_SHIMS
+  /* Shims disabled, just copy the editor and baton directly. */
+  *deditor_out = deditor_in;
+  *dedit_baton_out = dedit_baton_in;
+#else
+  /* Use our shim APIs to create an intermediate svn_editor_t, and then
+     wrap that again back into a svn_delta_editor_t.  This introduces
+     a lot of overhead. */
+  svn_editor_t *editor;
+
+  SVN_ERR(svn_editor_from_delta(&editor, deditor_in, dedit_baton_in,
+                                NULL, NULL, result_pool, scratch_pool));
+  SVN_ERR(svn_delta_from_editor(deditor_out, dedit_baton_out, editor,
+                                result_pool));
+
+#endif
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/fs-py/subversion/libsvn_delta/editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_delta/editor.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_delta/editor.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_delta/editor.c Wed Sep 14 13:46:56 2011
@@ -26,8 +26,17 @@
 #include "svn_types.h"
 #include "svn_error.h"
 #include "svn_pools.h"
+#include "svn_editor.h"
+#include "svn_dirent_uri.h"
 
-#include "private/svn_editor.h"
+#ifdef SVN_DEBUG
+/* This enables runtime checks of the editor API constraints.  This may
+   introduce additional memory and runtime overhead, and should not be used
+   in production builds.
+   
+   ### Remove before release? */
+#define ENABLE_ORDERING_CHECK
+#endif
 
 
 struct svn_editor_t
@@ -44,6 +53,16 @@ struct svn_editor_t
 
   /* This pool is used as the scratch_pool for all callbacks.  */
   apr_pool_t *scratch_pool;
+
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_t *pending_incomplete_children;
+  apr_hash_t *needs_text;
+  apr_hash_t *completed_nodes;
+  apr_hash_t *needs_text_or_target;
+  svn_boolean_t finished;
+
+  apr_pool_t *result_pool;
+#endif
 };
 
 
@@ -61,6 +80,14 @@ svn_editor_create(svn_editor_t **editor,
   (*editor)->cancel_func = cancel_func;
   (*editor)->cancel_baton = cancel_baton;
   (*editor)->scratch_pool = svn_pool_create(result_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  (*editor)->pending_incomplete_children = apr_hash_make(result_pool);
+  (*editor)->needs_text = apr_hash_make(result_pool);
+  (*editor)->completed_nodes = apr_hash_make(result_pool);
+  (*editor)->needs_text_or_target = apr_hash_make(result_pool);
+  (*editor)->finished = FALSE;
+  (*editor)->result_pool = result_pool;
+#endif
 
   return SVN_NO_ERROR;
 }
@@ -222,6 +249,11 @@ svn_editor_add_directory(svn_editor_t *e
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_add_directory != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -229,6 +261,22 @@ svn_editor_add_directory(svn_editor_t *e
   err = editor->funcs.cb_add_directory(editor->baton, relpath, children,
                                        props, replaces_rev,
                                        editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->pending_incomplete_children, relpath,
+               APR_HASH_KEY_STRING, NULL);
+  {
+    int i;
+    for (i = 0; i < children->nelts; i++)
+      {
+        const char *child_basename = APR_ARRAY_IDX(children, i, const char *);
+        const char *child = svn_relpath_join(relpath, child_basename,
+                                             editor->result_pool);
+
+        apr_hash_set(editor->pending_incomplete_children, child,
+                     APR_HASH_KEY_STRING, (void *)0xdeadbeef);
+      }
+  }
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -243,12 +291,23 @@ svn_editor_add_file(svn_editor_t *editor
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_add_file != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_add_file(editor->baton, relpath, props,
                                   replaces_rev, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->pending_incomplete_children, relpath,
+               APR_HASH_KEY_STRING, NULL);
+  apr_hash_set(editor->needs_text, apr_pstrdup(editor->result_pool, relpath),
+               APR_HASH_KEY_STRING, (void *) 0xcafeface);
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -264,12 +323,21 @@ svn_editor_add_symlink(svn_editor_t *edi
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_add_symlink != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_add_symlink(editor->baton, relpath, target, props,
                                      replaces_rev, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->pending_incomplete_children, relpath,
+               APR_HASH_KEY_STRING, NULL);
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -284,12 +352,21 @@ svn_editor_add_absent(svn_editor_t *edit
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_add_absent != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_add_absent(editor->baton, relpath, kind,
                                     replaces_rev, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->pending_incomplete_children, relpath,
+               APR_HASH_KEY_STRING, NULL);
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -305,12 +382,33 @@ svn_editor_set_props(svn_editor_t *edito
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_set_props != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_set_props(editor->baton, relpath, revision, props,
                                    complete, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  /* ### Some of the ordering here depends upon the kind of RELPATH, but
+   * ### we have no way of determining what that is. */
+  if (complete)
+    {
+      apr_hash_set(editor->completed_nodes,
+                   apr_pstrdup(editor->result_pool, relpath),
+                   APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+    }
+  else
+    {
+      apr_hash_set(editor->needs_text_or_target,
+                   apr_pstrdup(editor->result_pool, relpath),
+                   APR_HASH_KEY_STRING, (void *) 0xba5eba11);
+    }
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -326,12 +424,25 @@ svn_editor_set_text(svn_editor_t *editor
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_set_text != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_set_text(editor->baton, relpath, revision,
                                   checksum, contents, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->needs_text, relpath, APR_HASH_KEY_STRING, NULL);
+  apr_hash_set(editor->needs_text_or_target, relpath, APR_HASH_KEY_STRING,
+               NULL);
+  apr_hash_set(editor->completed_nodes,
+               apr_pstrdup(editor->result_pool, relpath),
+               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -346,12 +457,24 @@ svn_editor_set_target(svn_editor_t *edit
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_set_target != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_set_target(editor->baton, relpath, revision,
                                     target, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->needs_text_or_target, relpath, APR_HASH_KEY_STRING,
+               NULL);
+  apr_hash_set(editor->completed_nodes,
+               apr_pstrdup(editor->result_pool, relpath),
+               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -365,12 +488,22 @@ svn_editor_delete(svn_editor_t *editor,
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_delete != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
 
   err = editor->funcs.cb_delete(editor->baton, relpath, revision,
                                 editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  apr_hash_set(editor->completed_nodes,
+               apr_pstrdup(editor->result_pool, relpath),
+               APR_HASH_KEY_STRING, (void *) 0x5ca1ab1e);
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -386,6 +519,11 @@ svn_editor_copy(svn_editor_t *editor,
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_copy != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, dst_relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -408,6 +546,11 @@ svn_editor_move(svn_editor_t *editor,
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_move != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(!editor->finished);
+  SVN_ERR_ASSERT(!apr_hash_get(editor->completed_nodes, dst_relpath,
+                               APR_HASH_KEY_STRING));
+#endif
 
   if (editor->cancel_func)
     SVN_ERR(editor->cancel_func(editor->cancel_baton));
@@ -426,8 +569,16 @@ svn_editor_complete(svn_editor_t *editor
   svn_error_t *err;
 
   SVN_ERR_ASSERT(editor->funcs.cb_complete != NULL);
+#ifdef ENABLE_ORDERING_CHECK
+  SVN_ERR_ASSERT(apr_hash_count(editor->pending_incomplete_children) == 0);
+  SVN_ERR_ASSERT(apr_hash_count(editor->needs_text) == 0);
+  SVN_ERR_ASSERT(apr_hash_count(editor->needs_text_or_target) == 0);
+#endif
 
   err = editor->funcs.cb_complete(editor->baton, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  editor->finished = TRUE;
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }
@@ -441,6 +592,9 @@ svn_editor_abort(svn_editor_t *editor)
   SVN_ERR_ASSERT(editor->funcs.cb_abort != NULL);
 
   err = editor->funcs.cb_abort(editor->baton, editor->scratch_pool);
+#ifdef ENABLE_ORDERING_CHECK
+  editor->finished = TRUE;
+#endif
   svn_pool_clear(editor->scratch_pool);
   return err;
 }

Modified: subversion/branches/fs-py/subversion/libsvn_fs/fs-loader.h
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs/fs-loader.h?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_fs/fs-loader.h (original)
+++ subversion/branches/fs-py/subversion/libsvn_fs/fs-loader.h Wed Sep 14 13:46:56 2011
@@ -36,13 +36,14 @@ extern "C" {
 /* The FS loader library implements the a front end to "filesystem
    abstract providers" (FSAPs), which implement the svn_fs API.
 
-   The loader library divides up the FS API into five categories:
+   The loader library divides up the FS API into several categories:
 
      - Top-level functions, which operate on paths to an FS
      - Functions which operate on an FS object
      - Functions which operate on a transaction object
      - Functions which operate on a root object
      - Functions which operate on a history object
+     - Functions which operate on a noderev-ID object
 
    Some generic fields of the FS, transaction, root, and history
    objects are defined by the loader library; the rest are stored in

Modified: subversion/branches/fs-py/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_fs/fs_fs.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_fs_fs/fs_fs.c Wed Sep 14 13:46:56 2011
@@ -147,6 +147,9 @@ read_min_unpacked_rev(svn_revnum_t *min_
 static svn_error_t *
 update_min_unpacked_rev(svn_fs_t *fs, apr_pool_t *pool);
 
+static svn_error_t *
+get_youngest(svn_revnum_t *youngest_p, const char *fs_path, apr_pool_t *pool);
+
 /* Pathname helper functions */
 
 /* Return TRUE is REV is packed in FS, FALSE otherwise. */
@@ -590,10 +593,8 @@ with_some_lock(svn_fs_t *fs,
       fs_fs_data_t *ffd = fs->fsap_data;
       if (ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT)
         SVN_ERR(update_min_unpacked_rev(fs, pool));
-#if 0 /* Might be a good idea? */
       SVN_ERR(get_youngest(&ffd->youngest_rev_cache, fs->path,
                            pool));
-#endif
       err = body(baton, subpool);
     }
 
@@ -1197,9 +1198,6 @@ update_min_unpacked_rev(svn_fs_t *fs, ap
                                pool);
 }
 
-static svn_error_t *
-get_youngest(svn_revnum_t *youngest_p, const char *fs_path, apr_pool_t *pool);
-
 svn_error_t *
 svn_fs_fs__open(svn_fs_t *fs, const char *path, apr_pool_t *pool)
 {
@@ -7419,7 +7417,6 @@ struct change_rev_prop_baton {
 /* The work-horse for svn_fs_fs__change_rev_prop, called with the FS
    write lock.  This implements the svn_fs_fs__with_write_lock()
    'body' callback type.  BATON is a 'struct change_rev_prop_baton *'. */
-
 static svn_error_t *
 change_rev_prop_body(void *baton, apr_pool_t *pool)
 {

Modified: subversion/branches/fs-py/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_fs/tree.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_fs_fs/tree.c Wed Sep 14 13:46:56 2011
@@ -1892,7 +1892,7 @@ fs_delete_node(svn_fs_root_t *root,
 {
   parent_path_t *parent_path;
   const char *txn_id = root->txn;
-  apr_int64_t mergeinfo_count;
+  apr_int64_t mergeinfo_count = 0;
   svn_node_kind_t kind;
 
   if (! root->is_txn_root)
@@ -1927,7 +1927,7 @@ fs_delete_node(svn_fs_root_t *root,
                                     pool));
 
   /* Update mergeinfo counts for parents */
-  if (svn_fs_fs__fs_supports_mergeinfo(root->fs) && mergeinfo_count > 0)
+  if (mergeinfo_count > 0)
     SVN_ERR(increment_mergeinfo_up_tree(parent_path->parent,
                                         -mergeinfo_count,
                                         pool));
@@ -3048,7 +3048,7 @@ fs_node_origin_rev(svn_revnum_t *revisio
 
     /* Walk the predecessor links back to origin. */
     SVN_ERR(fs_node_id(&pred_id, curroot, lastpath->data, predidpool));
-    while (pred_id)
+    do
       {
         svn_pool_clear(subpool);
         SVN_ERR(svn_fs_fs__dag_get_node(&node, fs, pred_id, subpool));
@@ -3062,6 +3062,7 @@ fs_node_origin_rev(svn_revnum_t *revisio
         SVN_ERR(svn_fs_fs__dag_get_predecessor_id(&pred_id, node, subpool));
         pred_id = pred_id ? svn_fs_fs__id_copy(pred_id, predidpool) : NULL;
       }
+    while (pred_id);
 
     /* When we get here, NODE should be the first node-revision in our
        chain. */

Modified: subversion/branches/fs-py/subversion/libsvn_ra/ra_loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra/ra_loader.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra/ra_loader.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra/ra_loader.c Wed Sep 14 13:46:56 2011
@@ -574,19 +574,13 @@ svn_error_t *svn_ra_get_path_relative_to
                                                  apr_pool_t *pool)
 {
   const char *sess_url;
+
   SVN_ERR(session->vtable->get_session_url(session, &sess_url, pool));
-  if (strcmp(sess_url, url) == 0)
-    {
-      *rel_path = "";
-    }
-  else
-    {
-      *rel_path = svn_uri__is_child(sess_url, url, pool);
-      if (! *rel_path)
-        return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
-                                 _("'%s' isn't a child of session URL '%s'"),
-                                 url, sess_url);
-    }
+  *rel_path = svn_uri_skip_ancestor(sess_url, url, pool);
+  if (! *rel_path)
+    return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
+                             _("'%s' isn't a child of session URL '%s'"),
+                             url, sess_url);
   return SVN_NO_ERROR;
 }
 
@@ -596,21 +590,14 @@ svn_error_t *svn_ra_get_path_relative_to
                                               apr_pool_t *pool)
 {
   const char *root_url;
-  SVN_ERR(session->vtable->get_repos_root(session, &root_url, pool));
-  if (strcmp(root_url, url) == 0)
-    {
-      *rel_path = "";
-    }
-  else
-    {
-      *rel_path = svn_uri__is_child(root_url, url, pool);
-      if (! *rel_path)
-        return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
-                                 _("'%s' isn't a child of repository root "
-                                   "URL '%s'"),
-                                 url, root_url);
-    }
 
+  SVN_ERR(session->vtable->get_repos_root(session, &root_url, pool));
+  *rel_path = svn_uri_skip_ancestor(root_url, url, pool);
+  if (! *rel_path)
+    return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
+                             _("'%s' isn't a child of repository root "
+                               "URL '%s'"),
+                             url, root_url);
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/libsvn_ra_neon/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_neon/commit.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_neon/commit.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_neon/commit.c Wed Sep 14 13:46:56 2011
@@ -1620,5 +1620,9 @@ svn_error_t * svn_ra_neon__get_commit_ed
 
   *editor = commit_editor;
   *edit_baton = cc;
+
+  SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
+                                   pool, pool));
+
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/fs-py/subversion/libsvn_ra_neon/session.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_neon/session.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_neon/session.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_neon/session.c Wed Sep 14 13:46:56 2011
@@ -1145,19 +1145,13 @@ svn_ra_neon__get_path_relative_to_root(s
   const char *root_url;
 
   SVN_ERR(svn_ra_neon__get_repos_root(session, &root_url, pool));
-  if (strcmp(root_url, url) == 0)
-    {
-      *rel_path = "";
-    }
-  else
-    {
-      *rel_path = svn_uri__is_child(root_url, url, pool);
-      if (! *rel_path)
-        return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
-                                 _("'%s' isn't a child of repository root "
-                                   "URL '%s'"),
-                                 url, root_url);
-    }
+  *rel_path = svn_uri_skip_ancestor(root_url, url, pool);
+  if (! *rel_path)
+    return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
+                             _("'%s' isn't a child of repository root "
+                               "URL '%s'"),
+                             url, root_url);
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_serf/commit.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_serf/commit.c Wed Sep 14 13:46:56 2011
@@ -2366,6 +2366,9 @@ svn_ra_serf__get_commit_editor(svn_ra_se
   *ret_editor = editor;
   *edit_baton = ctx;
 
+  SVN_ERR(svn_editor__insert_shims(ret_editor, edit_baton, *ret_editor,
+                                   *edit_baton, pool, pool));
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_serf/update.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_serf/update.c Wed Sep 14 13:46:56 2011
@@ -1604,9 +1604,11 @@ start_report(svn_ra_serf__xml_parser_t *
 
       SVN_ERR(open_dir(info->dir));
 
-      SVN_ERR(ctx->update_editor->absent_directory(file_name,
-                                                   info->dir->dir_baton,
-                                                   info->dir->pool));
+      SVN_ERR(ctx->update_editor->absent_directory(
+                                        svn_relpath_join(info->name, file_name,
+                                                         info->dir->pool),
+                                        info->dir->dir_baton,
+                                        info->dir->pool));
     }
   else if ((state == OPEN_DIR || state == ADD_DIR) &&
            strcmp(name.name, "absent-file") == 0)
@@ -1627,9 +1629,11 @@ start_report(svn_ra_serf__xml_parser_t *
 
       SVN_ERR(open_dir(info->dir));
 
-      SVN_ERR(ctx->update_editor->absent_file(file_name,
-                                              info->dir->dir_baton,
-                                              info->dir->pool));
+      SVN_ERR(ctx->update_editor->absent_file(
+                                        svn_relpath_join(info->name, file_name,
+                                                         info->dir->pool),
+                                        info->dir->dir_baton,
+                                        info->dir->pool));
     }
   else if (state == OPEN_DIR || state == ADD_DIR)
     {

Modified: subversion/branches/fs-py/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_svn/client.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_svn/client.c Wed Sep 14 13:46:56 2011
@@ -2279,19 +2279,12 @@ static svn_error_t *path_relative_to_roo
   const char *root_url;
 
   SVN_ERR(ra_svn_get_repos_root(session, &root_url, pool));
-  if (strcmp(root_url, url) == 0)
-    {
-      *rel_path = "";
-    }
-  else
-    {
-      *rel_path = svn_uri__is_child(root_url, url, pool);
-      if (! *rel_path)
-        return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
-                                 _("'%s' isn't a child of repository root "
-                                   "URL '%s'"),
-                                 url, root_url);
-    }
+  *rel_path = svn_uri_skip_ancestor(root_url, url, pool);
+  if (! *rel_path)
+    return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
+                             _("'%s' isn't a child of repository root "
+                               "URL '%s'"),
+                             url, root_url);
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/libsvn_ra_svn/cyrus_auth.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_svn/cyrus_auth.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_svn/cyrus_auth.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_svn/cyrus_auth.c Wed Sep 14 13:46:56 2011
@@ -738,9 +738,7 @@ svn_ra_svn__do_cyrus_auth(svn_ra_svn__se
   const char *mechstring = "", *last_err = "", *realmstring;
   const char *local_addrport = NULL, *remote_addrport = NULL;
   svn_boolean_t success;
-  /* Reserve space for 3 callbacks (for the username, password and the
-     array terminator). */
-  sasl_callback_t callbacks[3];
+  sasl_callback_t *callbacks;
   cred_baton_t cred_baton;
   int i;
 
@@ -776,6 +774,13 @@ svn_ra_svn__do_cyrus_auth(svn_ra_svn__se
   cred_baton.realmstring = realmstring;
   cred_baton.pool = pool;
 
+  /* Reserve space for 3 callbacks (for the username, password and the
+     array terminator).  These structures must persist until the
+     disposal of the SASL context at pool cleanup, however the
+     callback functions will not be invoked outside this function so
+     other structures can have a shorter lifetime. */
+  callbacks = apr_palloc(sess->conn->pool, sizeof(*callbacks) * 3);
+
   /* Initialize the callbacks array. */
 
   /* The username callback. */
@@ -818,7 +823,7 @@ svn_ra_svn__do_cyrus_auth(svn_ra_svn__se
           return cred_baton.err;
         }
       if (cred_baton.no_more_creds
-          || (! success && ! err && ! cred_baton.was_used))
+          || (! err && ! success && ! cred_baton.was_used))
         {
           svn_error_clear(err);
           /* If we ran out of authentication providers, or if we got a server

Modified: subversion/branches/fs-py/subversion/libsvn_ra_svn/editorp.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_ra_svn/editorp.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_ra_svn/editorp.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_ra_svn/editorp.c Wed Sep 14 13:46:56 2011
@@ -435,6 +435,9 @@ void svn_ra_svn_get_editor(const svn_del
 
   *editor = ra_svn_editor;
   *edit_baton = eb;
+
+  svn_error_clear(svn_editor__insert_shims(editor, edit_baton, *editor,
+                                           *edit_baton, pool, pool));
 }
 
 /* --- DRIVING AN EDITOR --- */

Modified: subversion/branches/fs-py/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_repos/authz.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_repos/authz.c Wed Sep 14 13:46:56 2011
@@ -723,8 +723,25 @@ static svn_boolean_t authz_validate_sect
     svn_config_enumerate2(b->config, name, authz_validate_alias,
                           baton, pool);
   else
-    svn_config_enumerate2(b->config, name, authz_validate_rule,
-                          baton, pool);
+    {
+      /* Validate the section's name. Skip the optional REPOS_NAME. */
+      const char *fspath = strchr(name, ':');
+      if (fspath)
+        fspath++;
+      else
+        fspath = name;
+      if (! svn_fspath__is_canonical(fspath))
+        {
+          b->err = svn_error_createf(SVN_ERR_AUTHZ_INVALID_CONFIG, NULL,
+                                     "Section name '%s' contains non-canonical "
+                                     "fspath '%s'",
+                                     name, fspath);
+          return FALSE;
+        }
+
+      svn_config_enumerate2(b->config, name, authz_validate_rule,
+                            baton, pool);
+    }
 
   if (b->err)
     return FALSE;

Modified: subversion/branches/fs-py/subversion/libsvn_repos/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_repos/commit.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_repos/commit.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_repos/commit.c Wed Sep 14 13:46:56 2011
@@ -853,5 +853,8 @@ svn_repos_get_commit_editor5(const svn_d
   *edit_baton = eb;
   *editor = e;
 
+  SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
+                                   pool, pool));
+
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/fs-py/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_repos/dump.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_repos/dump.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_repos/dump.c Wed Sep 14 13:46:56 2011
@@ -896,6 +896,9 @@ get_dump_editor(const svn_delta_editor_t
   *edit_baton = eb;
   *editor = dump_editor;
 
+  SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
+                                   pool, pool));
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/libsvn_repos/replay.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_repos/replay.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_repos/replay.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_repos/replay.c Wed Sep 14 13:46:56 2011
@@ -136,7 +136,7 @@ struct path_driver_cb_baton
   void *authz_read_baton;
 
   const char *base_path; /* relpath */
-  int base_path_len;
+  size_t base_path_len;
 
   svn_revnum_t low_water_mark;
   /* Stack of active copy operations. */
@@ -372,7 +372,7 @@ path_driver_cb_func(void **dir_baton,
   svn_fs_root_t *source_root = cb->compare_root;
   const char *source_fspath = NULL;
   const char *base_path = cb->base_path;
-  int base_path_len = cb->base_path_len;
+  size_t base_path_len = cb->base_path_len;
 
   *dir_baton = NULL;
 

Modified: subversion/branches/fs-py/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_repos/reporter.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_repos/reporter.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_repos/reporter.c Wed Sep 14 13:46:56 2011
@@ -1233,6 +1233,8 @@ drive(report_baton_t *b, svn_revnum_t s_
 
   /* Collect information about the source and target nodes. */
   s_fullpath = svn_fspath__join(b->fs_base, b->s_operand, pool);
+  /* ### Weird: When I have a file external defined as "^/A/a X/xa",
+   * ### S_FULLPATH becomes "/A/a/xa" here, which is complete nonsense. */
   SVN_ERR(get_source_root(b, &s_root, s_rev));
   SVN_ERR(fake_dirent(&s_entry, s_root, s_fullpath, pool));
   SVN_ERR(fake_dirent(&t_entry, b->t_root, b->t_path, pool));

Modified: subversion/branches/fs-py/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_subr/error.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_subr/error.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_subr/error.c Wed Sep 14 13:46:56 2011
@@ -64,8 +64,9 @@ static const char SVN_FILE_LINE_UNDEFINE
 #undef svn_error_quick_wrap
 #undef svn_error_wrap_apr
 
-/* Note: This function was historically in the public API, so we need
- * to define it even when !SVN_DEBUG. */
+/* Note: Although this is a "__" function, it was historically in the
+ * public ABI, so we can never change it or remove its signature, even
+ * though it is now only used in SVN_DEBUG mode. */
 void
 svn_error__locate(const char *file, long line)
 {
@@ -663,6 +664,8 @@ svn_error_set_malfunction_handler(svn_er
   return old_malfunction_handler;
 }
 
+/* Note: Although this is a "__" function, it is in the public ABI, so
+ * we can never remove it or change its signature. */
 svn_error_t *
 svn_error__malfunction(svn_boolean_t can_return,
                        const char *file, int line,

Modified: subversion/branches/fs-py/subversion/libsvn_subr/iter.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_subr/iter.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_subr/iter.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_subr/iter.c Wed Sep 14 13:46:56 2011
@@ -176,6 +176,8 @@ svn_iter_apr_array(svn_boolean_t *comple
   return err;
 }
 
+/* Note: Although this is a "__" function, it is in the public ABI, so
+ * we can never remove it or change its signature. */
 svn_error_t *
 svn_iter__break(void)
 {

Modified: subversion/branches/fs-py/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_subr/mergeinfo.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_subr/mergeinfo.c Wed Sep 14 13:46:56 2011
@@ -301,143 +301,168 @@ combine_with_lastrange(const svn_merge_r
              intersect but have differing inheritability.  Check for the
              first case as that is easy to handle. */
           intersection_type_t intersection_type;
+          svn_boolean_t sorted = FALSE;
 
           SVN_ERR(get_type_of_intersection(new_range, lastrange,
                                            &intersection_type));
 
-              switch (intersection_type)
+          switch (intersection_type)
+            {
+              case svn__no_intersection:
+                /* NEW_RANGE and *LASTRANGE *really* don't intersect so
+                   just push NEW_RANGE only RANGELIST. */
+                APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) =
+                  svn_merge_range_dup(new_range, result_pool);
+                sorted = (svn_sort_compare_ranges(&lastrange,
+                                                  &new_range) < 0);
+                break;
+
+              case svn__equal_intersection:
+                /* They range are equal so all we do is force the
+                   inheritability of lastrange to true. */
+                lastrange->inheritable = TRUE;
+                sorted = TRUE;
+                break;
+
+              case svn__adjoining_intersection:
+                /* They adjoin but don't overlap so just push NEW_RANGE
+                   onto RANGELIST. */
+                APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) =
+                  svn_merge_range_dup(new_range, result_pool);
+                sorted = (svn_sort_compare_ranges(&lastrange,
+                                                  &new_range) < 0);
+                break;
+
+              case svn__overlapping_intersection:
+                /* They ranges overlap but neither is a proper subset of
+                   the other.  We'll end up pusing two new ranges onto
+                   RANGELIST, the intersecting part and the part unique to
+                   NEW_RANGE.*/
                 {
-                  case svn__no_intersection:
-                    /* NEW_RANGE and *LASTRANGE *really* don't intersect so
-                       just push NEW_RANGE only RANGELIST. */
-                    APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) =
-                      svn_merge_range_dup(new_range, result_pool);
-                    break;
-
-                  case svn__equal_intersection:
-                    /* They range are equal so all we do is force the
-                       inheritability of lastrange to true. */
-                    lastrange->inheritable = TRUE;
-                    break;
-
-                  case svn__adjoining_intersection:
-                    /* They adjoin but don't overlap so just push NEW_RANGE
-                       onto RANGELIST. */
-                    APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) =
-                      svn_merge_range_dup(new_range, result_pool);
-                    break;
-
-                  case svn__overlapping_intersection:
-                    /* They ranges overlap but neither is a proper subset of
-                       the other.  We'll end up pusing two new ranges onto
-                       RANGELIST, the intersecting part and the part unique to
-                       NEW_RANGE.*/
+                  svn_merge_range_t *r1 = svn_merge_range_dup(lastrange,
+                                                              result_pool);
+                  svn_merge_range_t *r2 = svn_merge_range_dup(new_range,
+                                                              result_pool);
+
+                  /* Pop off *LASTRANGE to make our manipulations
+                     easier. */
+                  apr_array_pop(rangelist);
+
+                  /* Ensure R1 is the older range. */
+                  if (r2->start < r1->start)
                     {
-                      svn_merge_range_t *r1 = svn_merge_range_dup(lastrange,
-                                                                  result_pool);
-                      svn_merge_range_t *r2 = svn_merge_range_dup(new_range,
-                                                                  result_pool);
-
-                      /* Pop off *LASTRANGE to make our manipulations
-                         easier. */
-                      apr_array_pop(rangelist);
+                      /* Swap R1 and R2. */
+                      *r2 = *r1;
+                      *r1 = *new_range;
+                    }
 
-                      /* Ensure R1 is the older range. */
-                      if (r2->start < r1->start)
-                        {
-                          /* Swap R1 and R2. */
-                          *r2 = *r1;
-                          *r1 = *new_range;
-                        }
+                  /* Absorb the intersecting ranges into the
+                     inheritable range. */
+                  if (r1->inheritable)
+                    r2->start = r1->end;
+                  else
+                    r1->end = r2->start;
 
-                      /* Absorb the intersecting ranges into the
-                         inheritable range. */
-                      if (r1->inheritable)
-                        r2->start = r1->end;
-                      else
-                        r1->end = r2->start;
+                  /* Push everything back onto RANGELIST. */
+                  APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r1;
+                  sorted = (svn_sort_compare_ranges(&lastrange,
+                                                    &r1) < 0);
+                  APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r2;
+                  if (sorted)
+                    sorted = (svn_sort_compare_ranges(&r1, &r2) < 0);
+                  break;
+                }
 
-                      /* Push everything back onto RANGELIST. */
-                      APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r1;
-                      APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r2;
+              default: /* svn__proper_subset_intersection */
+                {
+                  /* One range is a proper subset of the other. */
+                  svn_merge_range_t *r1 = svn_merge_range_dup(lastrange,
+                                                              result_pool);
+                  svn_merge_range_t *r2 = svn_merge_range_dup(new_range,
+                                                              result_pool);
+                  svn_merge_range_t *r3 = NULL;
+
+                  /* Pop off *LASTRANGE to make our manipulations
+                     easier. */
+                  apr_array_pop(rangelist);
 
-                      break;
+                  /* Ensure R1 is the superset. */
+                  if (r2->start < r1->start || r2->end > r1->end)
+                    {
+                      /* Swap R1 and R2. */
+                      *r2 = *r1;
+                      *r1 = *new_range;
                     }
 
-                  default: /* svn__proper_subset_intersection */
+                  if (r1->inheritable)
                     {
-                      /* One range is a proper subset of the other. */
-                      svn_merge_range_t *r1 = svn_merge_range_dup(lastrange,
-                                                                  result_pool);
-                      svn_merge_range_t *r2 = svn_merge_range_dup(new_range,
-                                                                  result_pool);
-                      svn_merge_range_t *r3 = NULL;
-
-                      /* Pop off *LASTRANGE to make our manipulations
-                         easier. */
-                      apr_array_pop(rangelist);
-
-                      /* Ensure R1 is the superset. */
-                      if (r2->start < r1->start || r2->end > r1->end)
-                        {
-                          /* Swap R1 and R2. */
-                          *r2 = *r1;
-                          *r1 = *new_range;
-                        }
+                      /* The simple case: The superset is inheritable, so
+                         just combine r1 and r2. */
+                      r1->start = MIN(r1->start, r2->start);
+                      r1->end = MAX(r1->end, r2->end);
+                      r2 = NULL;
+                    }
+                  else if (r1->start == r2->start)
+                    {
+                      svn_revnum_t tmp_revnum;
 
-                      if (r1->inheritable)
-                        {
-                          /* The simple case: The superset is inheritable, so
-                             just combine r1 and r2. */
-                          r1->start = MIN(r1->start, r2->start);
-                          r1->end = MAX(r1->end, r2->end);
-                          r2 = NULL;
-                        }
-                      else if (r1->start == r2->start)
-                        {
-                          svn_revnum_t tmp_revnum;
+                      /* *LASTRANGE and NEW_RANGE share an end point. */
+                      tmp_revnum = r1->end;
+                      r1->end = r2->end;
+                      r2->inheritable = r1->inheritable;
+                      r1->inheritable = TRUE;
+                      r2->start = r1->end;
+                      r2->end = tmp_revnum;
+                    }
+                  else if (r1->end == r2->end)
+                    {
+                      /* *LASTRANGE and NEW_RANGE share an end point. */
+                      r1->end = r2->start;
+                      r2->inheritable = TRUE;
+                    }
+                  else
+                    {
+                      /* NEW_RANGE and *LASTRANGE share neither start
+                         nor end points. */
+                      r3 = apr_pcalloc(result_pool, sizeof(*r3));
+                      r3->start = r2->end;
+                      r3->end = r1->end;
+                      r3->inheritable = r1->inheritable;
+                      r2->inheritable = TRUE;
+                      r1->end = r2->start;
+                    }
 
-                          /* *LASTRANGE and NEW_RANGE share an end point. */
-                          tmp_revnum = r1->end;
-                          r1->end = r2->end;
-                          r2->inheritable = r1->inheritable;
-                          r1->inheritable = TRUE;
-                          r2->start = r1->end;
-                          r2->end = tmp_revnum;
-                        }
-                      else if (r1->end == r2->end)
-                        {
-                          /* *LASTRANGE and NEW_RANGE share an end point. */
-                          r1->end = r2->start;
-                          r2->inheritable = TRUE;
-                        }
-                      else
+                  /* Push everything back onto RANGELIST. */
+                  APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r1;
+                  sorted = (svn_sort_compare_ranges(&lastrange, &r1) < 0);
+                  if (r2)
+                    {
+                      APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r2;
+                      if (sorted)
+                        sorted = (svn_sort_compare_ranges(&r1, &r2) < 0);
+                    }
+                  if (r3)
+                    {
+                      APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r3;
+                      if (sorted)
                         {
-                          /* NEW_RANGE and *LASTRANGE share neither start
-                             nor end points. */
-                          r3 = apr_pcalloc(result_pool, sizeof(*r3));
-                          r3->start = r2->end;
-                          r3->end = r1->end;
-                          r3->inheritable = r1->inheritable;
-                          r2->inheritable = TRUE;
-                          r1->end = r2->start;
+                          if (r2)
+                            sorted = (svn_sort_compare_ranges(&r2,
+                                                              &r3) < 0);
+                          else
+                            sorted = (svn_sort_compare_ranges(&r1,
+                                                              &r3) < 0);
                         }
-
-                      /* Push everything back onto RANGELIST. */
-                      APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r1;
-                      if (r2)
-                        APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r2;
-                      if (r3)
-                        APR_ARRAY_PUSH(rangelist, svn_merge_range_t *) = r3;
-
-                      break;
                     }
+                  break;
                 }
+            }
 
-              /* Some of the above cases might have put *RANGELIST out of
-                 order, so re-sort.*/
-              qsort(rangelist->elts, rangelist->nelts, rangelist->elt_size,
-                    svn_sort_compare_ranges);
+          /* Some of the above cases might have put *RANGELIST out of
+             order, so re-sort.*/
+          if (!sorted)
+            qsort(rangelist->elts, rangelist->nelts, rangelist->elt_size,
+                  svn_sort_compare_ranges);
         }
     }
 

Modified: subversion/branches/fs-py/subversion/libsvn_subr/sorts.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_subr/sorts.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_subr/sorts.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_subr/sorts.c Wed Sep 14 13:46:56 2011
@@ -140,21 +140,38 @@ svn_sort__hash(apr_hash_t *ht,
 {
   apr_hash_index_t *hi;
   apr_array_header_t *ary;
+  svn_boolean_t sorted;
+  svn_sort__item_t *prev_item;
 
   /* allocate an array with enough elements to hold all the keys. */
   ary = apr_array_make(pool, apr_hash_count(ht), sizeof(svn_sort__item_t));
 
   /* loop over hash table and push all keys into the array */
+  sorted = TRUE;
+  prev_item = NULL;
   for (hi = apr_hash_first(pool, ht); hi; hi = apr_hash_next(hi))
     {
       svn_sort__item_t *item = apr_array_push(ary);
 
       apr_hash_this(hi, &item->key, &item->klen, &item->value);
+
+      if (prev_item == NULL)
+        {
+          prev_item = item;
+          continue;
+        }
+
+      if (sorted)
+        {
+          sorted = (comparison_func(prev_item, item) < 0);
+          prev_item = item;
+        }
     }
 
-  /* now quicksort the array.  */
-  qsort(ary->elts, ary->nelts, ary->elt_size,
-        (int (*)(const void *, const void *))comparison_func);
+  /* quicksort the array if it isn't already sorted.  */
+  if (!sorted)
+    qsort(ary->elts, ary->nelts, ary->elt_size,
+          (int (*)(const void *, const void *))comparison_func);
 
   return ary;
 }

Modified: subversion/branches/fs-py/subversion/libsvn_subr/svn_string.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_subr/svn_string.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_subr/svn_string.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_subr/svn_string.c Wed Sep 14 13:46:56 2011
@@ -725,7 +725,7 @@ svn_cstring_join(const apr_array_header_
                  apr_pool_t *pool)
 {
   svn_stringbuf_t *new_str = svn_stringbuf_create("", pool);
-  int sep_len = strlen(separator);
+  size_t sep_len = strlen(separator);
   int i;
 
   for (i = 0; i < strings->nelts; i++)

Modified: subversion/branches/fs-py/subversion/libsvn_subr/target.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_subr/target.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_subr/target.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_subr/target.c Wed Sep 14 13:46:56 2011
@@ -46,7 +46,7 @@ svn_path_condense_targets(const char **p
   int i, j, num_condensed = targets->nelts;
   svn_boolean_t *removed;
   apr_array_header_t *abs_targets;
-  int basedir_len;
+  size_t basedir_len;
   const char *first_target;
   svn_boolean_t first_target_is_url;
 

Modified: subversion/branches/fs-py/subversion/libsvn_wc/copy.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/copy.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/copy.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/copy.c Wed Sep 14 13:46:56 2011
@@ -446,14 +446,14 @@ copy_versioned_dir(svn_wc__db_t *db,
               svn_boolean_t skip = FALSE;
 
               /* We should skip this node if this child is a file external
-                 (issue #3589) */
+                 (issues #3589, #4000) */
               if (child_status == svn_wc__db_status_normal)
                 {
                   SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, NULL,
                                                    NULL, NULL, NULL, NULL,
                                                    NULL, NULL, NULL, NULL,
                                                    NULL, NULL, &skip,
-                                                   db, src_abspath,
+                                                   db, child_src_abspath,
                                                    scratch_pool,
                                                    scratch_pool));
                 }

Modified: subversion/branches/fs-py/subversion/libsvn_wc/diff_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/diff_editor.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/diff_editor.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/diff_editor.c Wed Sep 14 13:46:56 2011
@@ -1923,11 +1923,16 @@ svn_wc_get_diff_editor6(const svn_delta_
                                                 inner_baton,
                                                 result_pool));
 
-  return svn_delta_get_cancellation_editor(cancel_func,
-                                           cancel_baton,
-                                           inner_editor,
-                                           inner_baton,
-                                           editor,
-                                           edit_baton,
-                                           result_pool);
+  SVN_ERR(svn_delta_get_cancellation_editor(cancel_func,
+                                            cancel_baton,
+                                            inner_editor,
+                                            inner_baton,
+                                            editor,
+                                            edit_baton,
+                                            result_pool));
+
+  SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
+                                   result_pool, scratch_pool));
+
+  return SVN_NO_ERROR;
 }

Modified: subversion/branches/fs-py/subversion/libsvn_wc/entries.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/entries.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/entries.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/entries.c Wed Sep 14 13:46:56 2011
@@ -1979,6 +1979,9 @@ write_entry(struct write_baton **entry_n
       base_node->changed_date = entry->cmt_date;
       base_node->changed_author = entry->cmt_author;
 
+      if (entry->file_external_path)
+        base_node->file_external = TRUE;
+
       SVN_ERR(insert_node(sdb, base_node, scratch_pool));
 
       /* We have to insert the lock after the base node, because the node
@@ -1996,12 +1999,6 @@ write_entry(struct write_baton **entry_n
           SVN_ERR(svn_wc__db_lock_add(db, tmp_entry_abspath, &lock,
                                       scratch_pool));
         }
-
-      /* Now, update the file external information. */
-      if (entry->file_external_path)
-        {
-          base_node->file_external = TRUE;
-        }
     }
 
   if (below_working_node)

Modified: subversion/branches/fs-py/subversion/libsvn_wc/info.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/info.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/info.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/info.c Wed Sep 14 13:46:56 2011
@@ -447,9 +447,8 @@ svn_wc__get_info(svn_wc_context_t *wc_ct
                  apr_pool_t *scratch_pool)
 {
   struct found_entry_baton fe_baton;
-  const svn_wc_conflict_description2_t *root_tree_conflict;
   svn_error_t *err;
-  apr_pool_t *iterpool;
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_hash_index_t *hi;
 
   fe_baton.receiver = receiver;
@@ -460,39 +459,46 @@ svn_wc__get_info(svn_wc_context_t *wc_ct
   fe_baton.tree_conflicts = apr_hash_make(scratch_pool);
   fe_baton.pool = scratch_pool;
 
-  if (fetch_actual_only)
-    {
-      SVN_ERR(svn_wc__db_op_read_tree_conflict(&root_tree_conflict,
-                                               wc_ctx->db, local_abspath,
-                                               scratch_pool, scratch_pool));
-      if (root_tree_conflict)
-        {
-          apr_hash_set(fe_baton.tree_conflicts, local_abspath,
-                       APR_HASH_KEY_STRING, root_tree_conflict);
-        }
-    }
-  else
-    root_tree_conflict = FALSE;
-
   err = svn_wc__internal_walk_children(wc_ctx->db, local_abspath,
                                        fetch_excluded,
                                        changelist_filter,
                                        info_found_node_callback,
                                        &fe_baton, depth,
                                        cancel_func, cancel_baton,
-                                       scratch_pool);
+                                       iterpool);
 
   /* If the target root node is not present, svn_wc__internal_walk_children()
      returns a PATH_NOT_FOUND error and doesn't call the callback.  If there
      is a tree conflict on this node, that is not an error. */
-  if (err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND && root_tree_conflict)
-    svn_error_clear(err);
-  else if (err)
-    return svn_error_trace(err);
+  if (fe_baton.first /* not visited by walk_children */
+      && fetch_actual_only
+      && err && err->apr_err == SVN_ERR_WC_PATH_NOT_FOUND)
+    {
+      const svn_wc_conflict_description2_t *root_tree_conflict;
+      svn_error_t *err2;
+
+      err2 = svn_wc__db_op_read_tree_conflict(&root_tree_conflict,
+                                              wc_ctx->db, local_abspath,
+                                              scratch_pool, iterpool);
+
+      if ((err2 && err2->apr_err == SVN_ERR_WC_PATH_NOT_FOUND))
+        {
+          svn_error_clear(err2);
+          return svn_error_trace(err);
+        }
+      else if (err2 || !root_tree_conflict)
+        return svn_error_compose_create(err, err2);
+
+      svn_error_clear(err);
+
+      apr_hash_set(fe_baton.tree_conflicts, local_abspath,
+                   APR_HASH_KEY_STRING, root_tree_conflict);
+    }
+  else
+    SVN_ERR(err);
 
   /* If there are any tree conflicts that we have found but have not reported,
    * send a minimal info struct for each one now. */
-  iterpool = svn_pool_create(scratch_pool);
   for (hi = apr_hash_first(scratch_pool, fe_baton.tree_conflicts); hi;
        hi = apr_hash_next(hi))
     {

Modified: subversion/branches/fs-py/subversion/libsvn_wc/status.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/status.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/status.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/status.c Wed Sep 14 13:46:56 2011
@@ -266,14 +266,24 @@ read_info(const struct svn_wc__db_info_t
      happy... (It might be completely unrelated, but...) */
   if (mtb->have_base
       && (mtb->status == svn_wc__db_status_added
-         || mtb->status == svn_wc__db_status_deleted))
+          || mtb->status == svn_wc__db_status_deleted
+          || mtb->kind == svn_wc__db_kind_file))
     {
+      svn_boolean_t update_root;
+      svn_wc__db_lock_t **lock_arg = NULL;
+
+      if (mtb->status == svn_wc__db_status_added
+          || mtb->status == svn_wc__db_status_deleted)
+        lock_arg = &mtb->lock;
+
       SVN_ERR(svn_wc__db_base_get_info(NULL, NULL, NULL, NULL, NULL, NULL,
                                        NULL, NULL, NULL, NULL, NULL, NULL,
-                                       &mtb->lock, NULL, NULL,
+                                       lock_arg, NULL, &update_root,
                                        db, local_abspath,
                                        result_pool, scratch_pool));
 
+      mtb->file_external = (update_root && mtb->kind == svn_wc__db_kind_file);
+
       if (mtb->status == svn_wc__db_status_deleted)
         {
           const char *moved_to_abspath;
@@ -772,6 +782,8 @@ assemble_status(svn_wc_status3_t **statu
   stat->moved_from_abspath = moved_from_abspath;
   stat->moved_to_abspath = info->moved_to_abspath;
 
+  stat->file_external = info->file_external;
+
   *status = stat;
 
   return SVN_NO_ERROR;
@@ -2352,6 +2364,9 @@ svn_wc_get_status_editor5(const svn_delt
   if (set_locks_baton)
     *set_locks_baton = eb;
 
+  SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
+                                   result_pool, scratch_pool));
+
   return SVN_NO_ERROR;
 }
 

Modified: subversion/branches/fs-py/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/update_editor.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/update_editor.c Wed Sep 14 13:46:56 2011
@@ -4802,13 +4802,18 @@ make_editor(svn_revnum_t *target_revisio
                                                 inner_baton,
                                                 result_pool));
 
-  return svn_delta_get_cancellation_editor(cancel_func,
-                                           cancel_baton,
-                                           inner_editor,
-                                           inner_baton,
-                                           editor,
-                                           edit_baton,
-                                           result_pool);
+  SVN_ERR(svn_delta_get_cancellation_editor(cancel_func,
+                                            cancel_baton,
+                                            inner_editor,
+                                            inner_baton,
+                                            editor,
+                                            edit_baton,
+                                            result_pool));
+
+  SVN_ERR(svn_editor__insert_shims(editor, edit_baton, *editor, *edit_baton,
+                                   result_pool, scratch_pool));
+
+  return SVN_NO_ERROR;
 }
 
 

Modified: subversion/branches/fs-py/subversion/libsvn_wc/wc-queries.sql
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/wc-queries.sql?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/wc-queries.sql (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/wc-queries.sql Wed Sep 14 13:46:56 2011
@@ -127,20 +127,17 @@ WHERE wc_id = ?1 AND local_relpath = ?2 
 SELECT op_depth, nodes.repos_id, nodes.repos_path, presence, kind, revision,
   checksum, translated_size, changed_revision, changed_date, changed_author,
   depth, symlink_target, last_mod_time, properties, lock_token, lock_owner,
-  lock_comment, lock_date, local_relpath, moved_here, moved_to
+  lock_comment, lock_date, local_relpath, moved_here, moved_to, 
+  file_external IS NOT NULL
 FROM nodes
 LEFT OUTER JOIN lock ON nodes.repos_id = lock.repos_id
   AND nodes.repos_path = lock.repos_relpath
 WHERE wc_id = ?1 AND parent_relpath = ?2
 
 -- STMT_SELECT_NODE_CHILDREN_WALKER_INFO
-/* ### See comment at STMT_SELECT_NODE_CHILDREN_INFO.
-   ### Should C code handle GROUP BY local_relpath ORDER BY op_depths DESC? */
 SELECT local_relpath, op_depth, presence, kind
-FROM nodes
+FROM nodes_current
 WHERE wc_id = ?1 AND parent_relpath = ?2
-GROUP BY local_relpath
-ORDER BY op_depth DESC
 
 -- STMT_SELECT_ACTUAL_CHILDREN_INFO
 SELECT prop_reject, changelist, conflict_old, conflict_new,
@@ -173,6 +170,7 @@ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, 
 -- STMT_SELECT_OP_DEPTH_CHILDREN
 SELECT local_relpath FROM nodes
 WHERE wc_id = ?1 AND parent_relpath = ?2 AND op_depth = ?3
+  AND (?3 != 0 OR file_external is NULL)
 
 -- STMT_SELECT_GE_OP_DEPTH_CHILDREN
 SELECT 1 FROM nodes
@@ -794,14 +792,19 @@ WHERE wc_id = ?1
 
 -- STMT_APPLY_CHANGES_TO_BASE_NODE
 /* translated_size and last_mod_time are not mentioned here because they will
-   be tweaked after the working-file is installed.
-   ### what to do about file_external?  */
+   be tweaked after the working-file is installed. When we replace an existing
+   BASE node (read: bump), preserve its file_external status. */
 INSERT OR REPLACE INTO nodes (
   wc_id, local_relpath, op_depth, parent_relpath, repos_id, repos_path,
   revision, presence, depth, kind, changed_revision, changed_date,
-  changed_author, checksum, properties, dav_cache, symlink_target )
+  changed_author, checksum, properties, dav_cache, symlink_target,
+  file_external )
 VALUES (?1, ?2, 0,
-        ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16)
+        ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16,
+        (SELECT file_external FROM nodes
+          WHERE wc_id = ?1
+            AND local_relpath = ?2
+            AND op_depth = 0))
 
 -- STMT_INSTALL_WORKING_NODE_FOR_DELETE
 INSERT OR REPLACE INTO nodes (
@@ -947,16 +950,22 @@ INSERT OR REPLACE INTO externals (
     repos_id, def_repos_relpath, def_operational_revision, def_revision)
 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)
 
+-- STMT_INSERT_EXTERNAL_UPGRADE
+INSERT OR REPLACE INTO externals (
+    wc_id, local_relpath, parent_relpath, presence, kind, def_local_relpath,
+    repos_id, def_repos_relpath, def_operational_revision, def_revision)
+VALUES (?1, ?2, ?3, ?4,
+        CASE WHEN (SELECT file_external FROM nodes
+                   WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = 0)
+             IS NOT NULL THEN 'file' ELSE 'unknown' END,
+        ?5, ?6, ?7, ?8, ?9)
+
 -- STMT_SELECT_EXTERNAL_INFO
 SELECT presence, kind, def_local_relpath, repos_id,
-    def_repos_relpath, def_operational_revision, def_revision, presence
+    def_repos_relpath, def_operational_revision, def_revision
 FROM externals WHERE wc_id = ?1 AND local_relpath = ?2
 LIMIT 1
 
--- STMT_SELECT_EXTERNAL_CHILDREN
-SELECT local_relpath
-FROM externals WHERE wc_id = ?1 AND parent_relpath = ?2
-
 -- STMT_SELECT_EXTERNALS_DEFINED
 SELECT local_relpath, def_local_relpath
 FROM externals
@@ -1376,7 +1385,7 @@ WHERE wc_id = ?1 AND op_depth = 0
 /* Queries for verification. */
 
 -- STMT_SELECT_ALL_NODES
-SELECT op_depth, local_relpath, parent_relpath FROM nodes
+SELECT op_depth, local_relpath, parent_relpath, file_external FROM nodes
 WHERE wc_id == ?1
 
 /* ------------------------------------------------------------------------- */

Modified: subversion/branches/fs-py/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_wc/wc_db.c?rev=1170622&r1=1170621&r2=1170622&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_wc/wc_db.c Wed Sep 14 13:46:56 2011
@@ -7005,7 +7005,8 @@ struct read_children_info_baton_t
   apr_pool_t *result_pool;
 };
 
-/* What we really want to store about a node */
+/* What we really want to store about a node.  This relies on the
+   offset of svn_wc__db_info_t being zero. */
 struct read_children_info_item_t
 {
   struct svn_wc__db_info_t info;
@@ -7173,6 +7174,10 @@ read_children_info(void *baton,
           if (moved_to_relpath)
             child_item->info.moved_to_abspath =
               svn_dirent_join(wcroot->abspath, moved_to_relpath, result_pool);
+
+          /* FILE_EXTERNAL flag only on op_depth 0. */
+          child_item->info.file_external = svn_sqlite__column_boolean(stmt,
+                                                                      22);
         }
       else
         {
@@ -7442,7 +7447,6 @@ svn_wc__db_read_children_walker_info(apr
   const char *dir_relpath;
   svn_sqlite__stmt_t *stmt;
   svn_boolean_t have_row;
-  apr_int64_t op_depth;
 
   SVN_ERR_ASSERT(svn_dirent_is_absolute(dir_abspath));
 
@@ -7462,13 +7466,10 @@ svn_wc__db_read_children_walker_info(apr
       struct svn_wc__db_walker_info_t *child;
       const char *child_relpath = svn_sqlite__column_text(stmt, 0, NULL);
       const char *name = svn_relpath_basename(child_relpath, NULL);
+      apr_int64_t op_depth = svn_sqlite__column_int(stmt, 1);
       svn_error_t *err;
 
-      child = apr_hash_get(*nodes, name, APR_HASH_KEY_STRING);
-      if (child == NULL)
-        child = apr_palloc(result_pool, sizeof(*child));
-
-      op_depth = svn_sqlite__column_int(stmt, 1);
+      child = apr_palloc(result_pool, sizeof(*child));
       child->status = svn_sqlite__column_token(stmt, 2, presence_map);
       if (op_depth > 0)
         {
@@ -9916,7 +9917,7 @@ scan_deletion_txn(void *baton,
                          || base_presence == svn_wc__db_status_incomplete
                          );
 
-#if 1
+#if 0
           /* ### see above comment  */
           if (base_presence == svn_wc__db_status_incomplete)
             base_presence = svn_wc__db_status_normal;
@@ -10378,7 +10379,8 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
           int i;
           apr_array_header_t *ext;
 
-          SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_INSERT_EXTERNAL));
+          SVN_ERR(svn_sqlite__get_statement(&stmt, sdb,
+                                            STMT_INSERT_EXTERNAL_UPGRADE));
 
           SVN_ERR(svn_wc_parse_externals_description3(
                             &ext, svn_dirent_join(dir_abspath, local_relpath,
@@ -10393,13 +10395,12 @@ svn_wc__db_upgrade_apply_props(svn_sqlit
               item_relpath = svn_relpath_join(local_relpath, item->target_dir,
                                               scratch_pool);
 
-              SVN_ERR(svn_sqlite__bindf(stmt, "isssssis",
+              SVN_ERR(svn_sqlite__bindf(stmt, "issssis",
                                         wc_id,
                                         item_relpath,
                                         svn_relpath_dirname(item_relpath,
                                                             scratch_pool),
                                         "normal",
-                                        "unknown",
                                         local_relpath,
                                         (apr_int64_t)1, /* repos_id */
                                         "" /* repos_relpath */));
@@ -12772,7 +12773,7 @@ verify_wcroot(svn_wc__db_wcroot_t *wcroo
       /* Verify parent_relpath refers to a row that exists */
       /* TODO: Verify there is a suitable parent row - e.g. has op_depth <=
        * the child's and a suitable presence */
-      if (parent_relpath)
+      if (parent_relpath && svn_sqlite__column_is_null(stmt, 3))
         {
           svn_sqlite__stmt_t *stmt2;
           svn_boolean_t have_a_parent_row;