You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2012/05/01 06:54:31 UTC

svn commit: r1332523 - in /subversion/trunk/subversion: include/svn_delta.h libsvn_delta/deprecated.c libsvn_delta/path_driver.c

Author: gstein
Date: Tue May  1 04:54:31 2012
New Revision: 1332523

URL: http://svn.apache.org/viewvc?rev=1332523&view=rev
Log:
Add a new revision of svn_delta_path_driver that omits the (unused)
REVISION parameter, and does not sort the input paths. The current
implementation would actually alter the PATHS array(!). The revised
API allows the caller to create a specialized ordering of paths.

* subversion/include/svn_delta.h:
  (svn_delta_path_driver2): new declaration as replace for ...
  (svn_delta_path_driver): ... this.

* subversion/libsvn_delta/deprecated.c:
  (...): new file
  (svn_delta_path_driver): backwards-compat implementation

* subversion/libsvn_delta/path_driver.c:
  (open_dir): removed REVISION parameter and just always pass
    SVN_INVALID_REVNUM to the open_directory() delta callback.
  (svn_delta_path_driver): renamed to ...
  (svn_delta_path_driver2): ... this. REVISION param dropped. sorting
    of input paths removed.

Added:
    subversion/trunk/subversion/libsvn_delta/deprecated.c
Modified:
    subversion/trunk/subversion/include/svn_delta.h
    subversion/trunk/subversion/libsvn_delta/path_driver.c

Modified: subversion/trunk/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_delta.h?rev=1332523&r1=1332522&r2=1332523&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_delta.h (original)
+++ subversion/trunk/subversion/include/svn_delta.h Tue May  1 04:54:31 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);
 
 /** @} */
 

Added: subversion/trunk/subversion/libsvn_delta/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/deprecated.c?rev=1332523&view=auto
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/deprecated.c (added)
+++ subversion/trunk/subversion/libsvn_delta/deprecated.c Tue May  1 04:54:31 2012
@@ -0,0 +1,53 @@
+/*
+ * deprecated.c:  holding file for all deprecated APIs.
+ *                "we can't lose 'em, but we can shun 'em!"
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+/* We define this here to remove any further warnings about the usage of
+   deprecated functions in this file. */
+#define SVN_DEPRECATED
+
+#include "svn_delta.h"
+#include "svn_sorts.h"
+
+
+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 *scratch_pool)
+{
+  apr_array_header_t *sorted;
+
+  /* REVISION is dropped on the floor.  */
+
+  /* Construct a copy of PATHS, then sort them in a depth-first order.  */
+  sorted = apr_array_copy(scratch_pool, paths);
+  qsort(sorted->elts, sorted->nelts, sorted->elt_size, svn_sort_compare_paths);
+
+  return svn_error_trace(svn_delta_path_driver2(editor, edit_baton, sorted,
+                                                callback_func, callback_baton,
+                                                scratch_pool));
+}

Modified: subversion/trunk/subversion/libsvn_delta/path_driver.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/path_driver.c?rev=1332523&r1=1332522&r2=1332523&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/path_driver.c (original)
+++ subversion/trunk/subversion/libsvn_delta/path_driver.c Tue May  1 04:54:31 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