diff options
Diffstat (limited to 'subversion/libsvn_delta/deprecated.c')
-rw-r--r-- | subversion/libsvn_delta/deprecated.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/subversion/libsvn_delta/deprecated.c b/subversion/libsvn_delta/deprecated.c index 4171244..f00c410 100644 --- a/subversion/libsvn_delta/deprecated.c +++ b/subversion/libsvn_delta/deprecated.c @@ -30,6 +30,79 @@ #include "svn_sorts.h" +struct path_driver_2_to_3_baton_t +{ + svn_delta_path_driver_cb_func_t callback_func; + void *callback_baton; + svn_boolean_t slash_prefix; +}; + +/* Convert from a newer to older callback + */ +static svn_error_t * +path_driver_2_to_3_func(void **dir_baton, + const svn_delta_editor_t *editor, + void *edit_baton, + void *parent_baton, + void *callback_baton, + const char *path, + apr_pool_t *pool) +{ + struct path_driver_2_to_3_baton_t *b = callback_baton; + + if (b->slash_prefix) + path = apr_pstrcat(pool, "/", path, SVN_VA_NULL); + + /* Just drop the 'editor' parameters */ + SVN_ERR(b->callback_func(dir_baton, parent_baton, + b->callback_baton, + path, pool)); + return SVN_NO_ERROR; +} + +svn_error_t * +svn_delta_path_driver2(const svn_delta_editor_t *editor, + void *edit_baton, + const apr_array_header_t *paths, + svn_boolean_t sort_paths, + svn_delta_path_driver_cb_func_t callback_func, + void *callback_baton, + apr_pool_t *pool) +{ + struct path_driver_2_to_3_baton_t b; + int i; + + b.callback_func = callback_func; + b.callback_baton = callback_baton; + b.slash_prefix = FALSE; + + /* Remove any '/' prefix from incoming paths. Arrange to add a '/' + prefix to all paths for the callback, if any incoming path had one. */ + for (i = 0; i < paths->nelts; i++) + { + const char *path = APR_ARRAY_IDX(paths, i, const char *); + + if (path[0] == '/') + { + /* Re-allocate the array and note that we found a '/' prefix. */ + if (!b.slash_prefix) + { + paths = apr_array_copy(pool, paths); + b.slash_prefix = TRUE; + } + + /* Modify each array element that had a '/' prefix */ + APR_ARRAY_IDX(paths, i, const char *) = path + 1; + } + } + + SVN_ERR(svn_delta_path_driver3(editor, edit_baton, + paths, sort_paths, + path_driver_2_to_3_func, &b, + pool)); + return SVN_NO_ERROR; +} + svn_error_t * svn_delta_path_driver(const svn_delta_editor_t *editor, void *edit_baton, |