[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]svn_wc_walk_entries4

From: HuiHuang <yellow.flying_at_yahoo.com.cn>
Date: Fri, 21 Aug 2009 23:00:08 +0800

Hey,
  
These days I am trying to remove usage of adm_access from
svn_wc_walk_entries3(), But I find it is difficult because adm_access
and entry are closely related. I think it is better to create adm_access
inside the function, so other modules who call svn_wc_walk_entries3()
can avoid adm_access batons.

Log:
[[[
Add a new function svn_wc_walk_entries4() which is similar to
svn_wc_walk_entries3() but taking svn_wc_context_t as parameter.

* subversion/include/svn_wc.h
  (svn_wc_walk_entries4): New.
  (svn_wc_walk_entries3): Deprecated.

* subversion/libsvn_wc/deprecated.c
  (svn_wc_walk_entries3): Reimplement as a wrapper.

* subversion/libsvn_wc/entries.c
  (svn_wc_walk_entries4): New.
  (svn_wc_walk_entries3): Remove.
]]]

Modified:
  trunk/subversion/include/svn_wc.h
  trunk/subversion/libsvn_wc/deprecated.c
  trunk/subversion/libsvn_wc/entries.c

Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (版本 38903)
+++ subversion/include/svn_wc.h (工作副本)
@@ -2847,8 +2847,8 @@
  * @a path, which can be a file or dir. Call callbacks in
  * @a walk_callbacks, passing @a walk_baton to each. Use @a pool for
  * looping, recursion, and to allocate all entries returned.
- * @a adm_access must be an access baton for @a path. The pool
- * passed to @a walk_callbacks is a temporary subpool of @a pool.
+ * @a access_abspath must be the absolute path of an access baton for
@a path.
+ * The pool passed to @a walk_callbacks is a temporary subpool of @a
pool.
  *
  * If @a depth is @c svn_depth_empty, invoke the callbacks on @a path
  * and return without recursing further. If @c svn_depth_files, do
@@ -2874,8 +2874,28 @@
  * distinguished by looking for @c SVN_WC_ENTRY_THIS_DIR in the 'name'
  * field of the entry.
  *
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_wc_walk_entries4(const char *path,
+ svn_wc_context_t *wc_ctx,
+ const char *access_abspath,
+ const svn_wc_entry_callbacks2_t *walk_callbacks,
+ void *walk_baton,
+ svn_depth_t walk_depth,
+ svn_boolean_t show_hidden,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+/**
+ * Similar to svn_wc_walk_entries4(), but take adm_access as parameter.
+ *
+ * @deprecated Provided for backward compatibility with the 1.4 API.
  * @since New in 1.5.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_wc_walk_entries3(const char *path,
                      svn_wc_adm_access_t *adm_access,
Index: subversion/libsvn_wc/deprecated.c
===================================================================
--- subversion/libsvn_wc/deprecated.c (版本 38903)
+++ subversion/libsvn_wc/deprecated.c (工作副本)
@@ -1419,6 +1419,30 @@
 
 /*** From entries.c ***/
 svn_error_t *
+svn_wc_walk_entries3(const char *path,
+ svn_wc_adm_access_t *adm_access,
+ const svn_wc_entry_callbacks2_t *walk_callbacks,
+ void *walk_baton,
+ svn_depth_t walk_depth,
+ svn_boolean_t show_hidden,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *pool)
+{
+ svn_wc_context_t *wc_ctx;
+
+ SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
+
svn_wc__adm_get_db(adm_access),
+ pool));
+ SVN_ERR(svn_wc_walk_entries4(path, wc_ctx,
+ svn_wc__adm_access_abspath(adm_access),
+ walk_callbacks, walk_baton,
+ walk_depth, show_hidden, cancel_func,
+ cancel_baton, pool, pool));
+ return svn_error_return(svn_wc_context_destroy(wc_ctx));
+}
+
+svn_error_t *
 svn_wc_walk_entries2(const char *path,
                      svn_wc_adm_access_t *adm_access,
                      const svn_wc_entry_callbacks_t *walk_callbacks,
Index: subversion/libsvn_wc/entries.c
===================================================================
--- subversion/libsvn_wc/entries.c (版本 38903)
+++ subversion/libsvn_wc/entries.c (工作副本)
@@ -3294,26 +3294,29 @@
   return svn_error_return(err);
 }
 
-
 /* The public API. */
 svn_error_t *
-svn_wc_walk_entries3(const char *path,
- svn_wc_adm_access_t *adm_access,
+svn_wc_walk_entries4(const char *path,
+ svn_wc_context_t *wc_ctx,
+ const char *access_abspath,
                      const svn_wc_entry_callbacks2_t *walk_callbacks,
                      void *walk_baton,
                      svn_depth_t walk_depth,
                      svn_boolean_t show_hidden,
                      svn_cancel_func_t cancel_func,
                      void *cancel_baton,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
 {
   const char *abspath;
- svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
   svn_error_t *err;
   svn_wc__db_kind_t kind;
   svn_depth_t depth;
+ svn_wc_adm_access_t *adm_access;
 
- SVN_ERR(svn_dirent_get_absolute(&abspath, path, pool));
+ SVN_ERR(svn_dirent_get_absolute(&abspath, path, scratch_pool));
+ adm_access = svn_wc__adm_retrieve_internal2(wc_ctx->db,
access_abspath,
+ scratch_pool);
   err = svn_wc__db_read_info(NULL, &kind, NULL,
                              NULL, NULL, NULL,
                              NULL, NULL, NULL,
@@ -3323,8 +3326,8 @@
                              NULL, NULL, NULL, NULL,
                              NULL, NULL, NULL, NULL, NULL,
                              NULL, NULL, NULL, NULL,
- db, abspath,
- pool, pool);
+ wc_ctx->db, abspath,
+ scratch_pool, scratch_pool);
   if (err)
     {
       if (err->apr_err != SVN_ERR_WC_PATH_NOT_FOUND)
@@ -3334,8 +3337,8 @@
       return walk_callbacks->handle_error(
         path, svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
                                 _("'%s' is not under version control"),
- svn_dirent_local_style(path, pool)),
- walk_baton, pool);
+ svn_dirent_local_style(path,
scratch_pool)),
+ walk_baton, result_pool);
     }
 
   if (kind == svn_wc__db_kind_file || depth == svn_depth_exclude)
@@ -3349,7 +3352,7 @@
          ### gave us. let it deal with the problem before returning.
*/
 
       /* This entry should be present. */
- SVN_ERR(svn_wc_entry(&entry, path, adm_access, TRUE, pool));
+ SVN_ERR(svn_wc_entry(&entry, path, adm_access, TRUE,
scratch_pool));
       SVN_ERR_ASSERT(entry != NULL);
       SVN_ERR(svn_wc__entry_is_hidden(&hidden, entry));
       if (!show_hidden && hidden)
@@ -3364,13 +3367,14 @@
           return walk_callbacks->handle_error(
             path, svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
                                     _("'%s' is not under version
control"),
- svn_dirent_local_style(path,
pool)),
- walk_baton, pool);
+ svn_dirent_local_style(path,
scratch_pool)),
+ walk_baton, result_pool);
         }
 
- err = walk_callbacks->found_entry(path, entry, walk_baton, pool);
+ err = walk_callbacks->found_entry(path, entry, walk_baton,
result_pool);
       if (err)
- return walk_callbacks->handle_error(path, err, walk_baton,
pool);
+ return walk_callbacks->handle_error(path, err, walk_baton,
+ result_pool);
 
       return SVN_NO_ERROR;
     }
@@ -3378,13 +3382,13 @@
   if (kind == svn_wc__db_kind_dir)
     return walker_helper(path, adm_access, walk_callbacks, walk_baton,
                          walk_depth, show_hidden, cancel_func,
cancel_baton,
- pool);
+ result_pool);
 
   return walk_callbacks->handle_error(
        path, svn_error_createf(SVN_ERR_NODE_UNKNOWN_KIND, NULL,
                                _("'%s' has an unrecognized node kind"),
- svn_dirent_local_style(path, pool)),
- walk_baton, pool);
+ svn_dirent_local_style(path,
scratch_pool)),
+ walk_baton, result_pool);
 }
 
  
 Best~
Huihuang

__________________________________________________
�Ͽ�ע���Ż��������������?
http://cn.mail.yahoo.com

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2386033
Received on 2009-08-21 17:01:16 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.