subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r1332744 [1/2] - in /subversion/branches/ev2-export: ./ subversion/include/ subversion/libsvn_delta/ subversion/libsvn_subr/ subversion/po/
Date Tue, 01 May 2012 16:35:42 GMT
Author: hwright
Date: Tue May  1 16:35:41 2012
New Revision: 1332744

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

Added:
    subversion/branches/ev2-export/subversion/libsvn_delta/deprecated.c
      - copied unchanged from r1332743, subversion/trunk/subversion/libsvn_delta/deprecated.c
Modified:
    subversion/branches/ev2-export/   (props changed)
    subversion/branches/ev2-export/subversion/include/svn_delta.h
    subversion/branches/ev2-export/subversion/include/svn_props.h
    subversion/branches/ev2-export/subversion/libsvn_delta/compat.c
    subversion/branches/ev2-export/subversion/libsvn_delta/debug_editor.c
    subversion/branches/ev2-export/subversion/libsvn_delta/path_driver.c
    subversion/branches/ev2-export/subversion/libsvn_subr/properties.c
    subversion/branches/ev2-export/subversion/po/fr.po

Propchange: subversion/branches/ev2-export/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1332510-1332743

Modified: subversion/branches/ev2-export/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/include/svn_delta.h?rev=1332744&r1=1332743&r2=1332744&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/include/svn_delta.h (original)
+++ subversion/branches/ev2-export/subversion/include/svn_delta.h Tue May  1 16:35:41 2012
@@ -1285,27 +1285,48 @@ typedef svn_error_t *(*svn_delta_path_dr
   apr_pool_t *pool);
 
 
-/** Drive @a editor (with its @a edit_baton) in such a way that
- * each path in @a paths is traversed in a depth-first fashion.  As
- * each path is hit as part of the editor drive, use @a
- * callback_func and @a callback_baton to allow the caller to handle
+/** Drive @a editor (with its @a edit_baton) to visit each path in @a paths.
+ * As each path is hit as part of the editor drive, use
+ * @a callback_func and @a callback_baton to allow the caller to handle
  * the portion of the editor drive related to that path.
  *
- * Use @a revision as the revision number passed to intermediate
- * directory openings.
+ * Each path in @a paths is a const char *. The editor drive will be
+ * performed in the same order as @a paths. The paths should be sorted
+ * using something like svn_sort_compare_paths to ensure that a depth-first
+ * pattern is observed for directory/file baton creation. Some callers may
+ * need further customization of the order (ie. libsvn_delta/compat.c).
  *
- * Each path in @a paths is a const char *.
+ * Use @a scratch_pool for all necessary allocations.
  *
- * Use @a pool for all necessary allocations.
+ * @since New in 1.8.
  */
 svn_error_t *
+svn_delta_path_driver2(const svn_delta_editor_t *editor,
+                       void *edit_baton,
+                       const apr_array_header_t *paths,
+                       svn_delta_path_driver_cb_func_t callback_func,
+                       void *callback_baton,
+                       apr_pool_t *scratch_pool);
+
+
+/** Similar to svn_delta_path_driver2, but takes an (unused) revision,
+ * and will sort the provided @a paths using svn_sort_compare_paths.
+ *
+ * @note In versions prior to 1.8, this function would modify the order
+ * of elements in @a paths, despite the 'const' marker on the parameter.
+ * This has been fixed in 1.8.
+ *
+ * @deprecated Provided for backward compatibility with the 1.7 API.
+ */
+SVN_DEPRECATED
+svn_error_t *
 svn_delta_path_driver(const svn_delta_editor_t *editor,
                       void *edit_baton,
                       svn_revnum_t revision,
                       const apr_array_header_t *paths,
                       svn_delta_path_driver_cb_func_t callback_func,
                       void *callback_baton,
-                      apr_pool_t *pool);
+                      apr_pool_t *scratch_pool);
 
 /** @} */
 

Modified: subversion/branches/ev2-export/subversion/include/svn_props.h
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/include/svn_props.h?rev=1332744&r1=1332743&r2=1332744&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/include/svn_props.h (original)
+++ subversion/branches/ev2-export/subversion/include/svn_props.h Tue May  1 16:35:41 2012
@@ -111,7 +111,7 @@ svn_prop_array_to_hash(const apr_array_h
 
 /**
  * Creates a deep copy of @a hash (keys <tt>const char *</tt> and
- * values <tt>const svn_string_t</tt>) in @a pool.
+ * values <tt>const svn_string_t *</tt>) in @a pool.
  *
  * @since New in 1.6.
  */

Modified: subversion/branches/ev2-export/subversion/libsvn_delta/compat.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_delta/compat.c?rev=1332744&r1=1332743&r2=1332744&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_delta/compat.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_delta/compat.c Tue May  1 16:35:41 2012
@@ -1065,7 +1065,7 @@ add_directory_cb(void *baton,
   change->action = RESTRUCTURE_ADD;
   change->kind = svn_kind_dir;
   change->deleting = replaces_rev;
-  change->props = apr_hash_copy(eb->edit_pool, props);
+  change->props = svn_prop_hash_dup(props, eb->edit_pool);
 
   return SVN_NO_ERROR;
 }
@@ -1102,7 +1102,7 @@ add_file_cb(void *baton,
   change->action = RESTRUCTURE_ADD;
   change->kind = svn_kind_file;
   change->deleting = replaces_rev;
-  change->props = apr_hash_copy(eb->edit_pool, props);
+  change->props = svn_prop_hash_dup(props, eb->edit_pool);
   change->contents_abspath = tmp_filename;
   change->checksum = svn_checksum_dup(md5_checksum, eb->edit_pool);
 
@@ -1125,7 +1125,7 @@ add_symlink_cb(void *baton,
   change->action = RESTRUCTURE_ADD;
   change->kind = svn_kind_symlink;
   change->deleting = replaces_rev;
-  change->props = apr_hash_copy(eb->edit_pool, props);
+  change->props = svn_prop_hash_dup(props, eb->edit_pool);
   /* ### target  */
 #endif
 
@@ -1168,7 +1168,7 @@ alter_directory_cb(void *baton,
      of an earlier copy/move operation.  */
   change->kind = svn_kind_dir;
   change->changing = revision;
-  change->props = apr_hash_copy(eb->edit_pool, props);
+  change->props = svn_prop_hash_dup(props, eb->edit_pool);
 
   return SVN_NO_ERROR;
 }
@@ -1215,7 +1215,7 @@ alter_file_cb(void *baton,
   change->kind = svn_kind_file;
   change->changing = revision;
   if (props != NULL)
-    change->props = apr_hash_copy(eb->edit_pool, props);
+    change->props = svn_prop_hash_dup(props, eb->edit_pool);
   if (contents != NULL)
     {
       change->contents_abspath = tmp_filename;
@@ -1339,6 +1339,98 @@ rotate_cb(void *baton,
 }
 
 
+static int
+sort_deletes_first(const svn_sort__item_t *item1,
+                   const svn_sort__item_t *item2)
+{
+  const char *relpath1 = item1->key;
+  const char *relpath2 = item2->key;
+  const char *slash1;
+  const char *slash2;
+  int len1;
+  int len2;
+
+  /* Are these two items siblings? The 'if' statement tests if they are
+     siblings in the root directory, or that slashes were found in both
+     paths, that the length of the paths to those slashes match, and that
+     the path contents up to those slashes also match.  */
+  slash1 = strrchr(relpath1, '/');
+  slash2 = strrchr(relpath2, '/');
+  if ((slash1 == NULL && slash2 == NULL)
+      || (slash1 != NULL
+          && slash2 != NULL
+          && (len1 = slash1 - relpath1) == (len2 = slash2 - relpath2)
+          && memcmp(relpath1, relpath2, len1) == 0))
+    {
+      const struct change_node *change1 = item1->value;
+      const struct change_node *change2 = item2->value;
+
+      if (change1->action == RESTRUCTURE_DELETE)
+        {
+          if (change2->action == RESTRUCTURE_DELETE)
+            {
+              /* If both items are being deleted, then we don't care about
+                 the order. State they are equal.  */
+              return 0;
+            }
+
+          /* ITEM1 is being deleted. Sort it before the surviving item.  */
+          return -1;
+        }
+      if (change2->action == RESTRUCTURE_DELETE)
+        /* ITEM2 is being deleted. Sort it before the surviving item.  */
+        return 1;
+
+      /* Normally, we don't care about the ordering of two siblings. However,
+         if these siblings are directories, then we need to provide an
+         ordering so that the quicksort algorithm will further sort them
+         relative to the maybe-directory's children.
+
+         Without this additional ordering, we could see that A/B/E and A/B/F
+         are equal. And then A/B/E/child is sorted before A/B/F. But since
+         E and F are "equal", A/B/E could arrive *after* A/B/F and after the
+         A/B/E/child node.  */
+
+      /* FALLTHROUGH */
+    }
+
+  /* Use svn_path_compare_paths() to get correct depth-based ordering.  */
+  return svn_path_compare_paths(relpath1, relpath2);
+}
+
+
+static const apr_array_header_t *
+get_sorted_paths(apr_hash_t *changes,
+                 const char *base_relpath,
+                 apr_pool_t *scratch_pool)
+{
+  const apr_array_header_t *items;
+  apr_array_header_t *paths;
+  int i;
+
+  /* Construct a sorted array of svn_sort__item_t structs. Within a given
+     directory, nodes that are to be deleted will appear first.  */
+  items = svn_sort__hash(changes, sort_deletes_first, scratch_pool);
+
+  /* Build a new array with just the paths, trimmed to relative paths for
+     the Ev1 drive.  */
+  paths = apr_array_make(scratch_pool, items->nelts, sizeof(const char *));
+  for (i = items->nelts; i--; )
+    {
+      const svn_sort__item_t *item;
+
+      item = &APR_ARRAY_IDX(items, i, const svn_sort__item_t);
+      APR_ARRAY_IDX(paths, i, const char *)
+        = svn_relpath_skip_ancestor(base_relpath, item->key);
+    }
+
+  /* We didn't use PUSH, so set the proper number of elements.  */
+  paths->nelts = items->nelts;
+
+  return paths;
+}
+
+
 static svn_error_t *
 drive_ev1_props(const struct editor_baton *eb,
                 const char *repos_relpath,
@@ -1566,9 +1658,7 @@ drive_changes(const struct editor_baton 
               apr_pool_t *scratch_pool)
 {
   struct change_node *change;
-  apr_array_header_t *paths = apr_array_make(scratch_pool, 10,
-                                             sizeof(const char *));
-  apr_hash_index_t *hi;
+  const apr_array_header_t *paths;
 
   /* If we never opened a root baton, then the caller aborted the editor
      before it even began. There is nothing to do. Bail.  */
@@ -1583,14 +1673,13 @@ drive_changes(const struct editor_baton 
   change->kind = svn_kind_dir;
   /* No property changes (tho they might exist from a real change).  */
 
-  for (hi = apr_hash_first(scratch_pool, eb->changes); hi;
-       hi = apr_hash_next(hi))
-    {
-      const char *relpath = svn__apr_hash_index_key(hi);
-      const char *ev1_relpath = svn_relpath_skip_ancestor(eb->base_relpath,
-                                                          relpath);
-      APR_ARRAY_PUSH(paths, const char *) = ev1_relpath;
-    }
+  /* Get a sorted list of Ev1-relative paths.  */
+  paths = get_sorted_paths(eb->changes, eb->base_relpath, scratch_pool);
+
+#if 1
+  /* ### something is still broken. sort the paths normally for now.  */
+  qsort(paths->elts, paths->nelts, paths->elt_size, svn_sort_compare_paths);
+#endif
 
   /* We need to pass SVN_INVALID_REVNUM to the path_driver. It uses this
      revision whenever it opens directory batons. If we specified a "real"
@@ -1610,10 +1699,9 @@ drive_changes(const struct editor_baton 
      SVN_INVALID_REVNUM, so we can't be the only goofball.
 
      Note: dropping const on the callback_baton.  */
-  SVN_ERR(svn_delta_path_driver(eb->deditor, eb->dedit_baton,
-                                SVN_INVALID_REVNUM, paths,
-                                apply_change, (void *)eb,
-                                scratch_pool));
+  SVN_ERR(svn_delta_path_driver2(eb->deditor, eb->dedit_baton, paths,
+                                 apply_change, (void *)eb,
+                                 scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ev2-export/subversion/libsvn_delta/debug_editor.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_delta/debug_editor.c?rev=1332744&r1=1332743&r2=1332744&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_delta/debug_editor.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_delta/debug_editor.c Tue May  1 16:35:41
2012
@@ -21,6 +21,8 @@
  * ====================================================================
  */
 
+#include "svn_io.h"
+
 #include "debug_editor.h"
 
 struct edit_baton

Modified: subversion/branches/ev2-export/subversion/libsvn_delta/path_driver.c
URL: http://svn.apache.org/viewvc/subversion/branches/ev2-export/subversion/libsvn_delta/path_driver.c?rev=1332744&r1=1332743&r2=1332744&view=diff
==============================================================================
--- subversion/branches/ev2-export/subversion/libsvn_delta/path_driver.c (original)
+++ subversion/branches/ev2-export/subversion/libsvn_delta/path_driver.c Tue May  1 16:35:41
2012
@@ -44,15 +44,13 @@ typedef struct dir_stack_t
 } dir_stack_t;
 
 
-/* Call EDITOR's open_directory() function with the PATH and REVISION
- * arguments, and then add the resulting dir baton to the dir baton
- * stack.
+/* Call EDITOR's open_directory() function with the PATH argument, then
+ * add the resulting dir baton to the dir baton stack.
  */
 static svn_error_t *
 open_dir(apr_array_header_t *db_stack,
          const svn_delta_editor_t *editor,
          const char *path,
-         svn_revnum_t revision,
          apr_pool_t *pool)
 {
   void *parent_db, *db;
@@ -69,7 +67,8 @@ open_dir(apr_array_header_t *db_stack,
   /* Call the EDITOR's open_directory function to get a new directory
      baton. */
   subpool = svn_pool_create(pool);
-  SVN_ERR(editor->open_directory(path, parent_db, revision, subpool, &db));
+  SVN_ERR(editor->open_directory(path, parent_db, SVN_INVALID_REVNUM, subpool,
+                                 &db));
 
   /* Now add the dir baton to the stack. */
   item = apr_pcalloc(subpool, sizeof(*item));
@@ -131,13 +130,12 @@ count_components(const char *path)
 
 /*** Public interfaces ***/
 svn_error_t *
-svn_delta_path_driver(const svn_delta_editor_t *editor,
-                      void *edit_baton,
-                      svn_revnum_t revision,
-                      const apr_array_header_t *paths,
-                      svn_delta_path_driver_cb_func_t callback_func,
-                      void *callback_baton,
-                      apr_pool_t *pool)
+svn_delta_path_driver2(const svn_delta_editor_t *editor,
+                       void *edit_baton,
+                       const apr_array_header_t *paths,
+                       svn_delta_path_driver_cb_func_t callback_func,
+                       void *callback_baton,
+                       apr_pool_t *pool)
 {
   apr_array_header_t *db_stack = apr_array_make(pool, 4, sizeof(void *));
   const char *last_path = NULL;
@@ -155,9 +153,6 @@ svn_delta_path_driver(const svn_delta_ed
   iterpool = svn_pool_create(pool);
   item = apr_pcalloc(subpool, sizeof(*item));
 
-  /* Sort the paths in a depth-first directory-ish order. */
-  qsort(paths->elts, paths->nelts, paths->elt_size, svn_sort_compare_paths);
-
   /* If the root of the edit is also a target path, we want to call
      the callback function to let the user open the root directory and
      do what needs to be done.  Otherwise, we'll do the open_root()
@@ -171,7 +166,7 @@ svn_delta_path_driver(const svn_delta_ed
     }
   else
     {
-      SVN_ERR(editor->open_root(edit_baton, revision, subpool, &db));
+      SVN_ERR(editor->open_root(edit_baton, SVN_INVALID_REVNUM, subpool, &db));
     }
   item->pool = subpool;
   item->dir_baton = db;
@@ -238,7 +233,7 @@ svn_delta_path_driver(const svn_delta_ed
                 rel = apr_pstrmemdup(iterpool, pdir, piece - pdir);
 
               /* Open the subdirectory. */
-              SVN_ERR(open_dir(db_stack, editor, rel, revision, pool));
+              SVN_ERR(open_dir(db_stack, editor, rel, pool));
 
               /* If we found a '/', advance our PIECE pointer to
                  character just after that '/'.  Otherwise, we're

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



Mime
View raw message