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

Re: [PATCH]svn_wc__find_wc_root

From: HuiHuang <yellow.flying_at_yahoo.com.cn>
Date: Fri, 26 Jun 2009 20:31:15 +0800

Hey,

I tweak some some spot, but I do not know whether it is a little clear now.

Several have mentioned wc-ng to us, but I do not think our work can base
on wc-ng right now, because we all are not very clear what wc-ng is exactly
like. If it is possible I will try to solve this problem base on wc-ng in the
future.

Someone also have mentioned performance, but I do not have better ideas
when it is based on wc-1. So maybe we can solve this problem when wc-ng
is ok.

Index: subversion/include/private/svn_wc_private.h
===================================================================
--- subversion/include/private/svn_wc_private.h (revision 38192)
+++ subversion/include/private/svn_wc_private.h (working copy)
@@ -219,6 +219,19 @@
                             svn_wc_adm_access_t *adm_access,
                             apr_pool_t *pool);
 
+/** Given @a path, find its working copy root path @a wc_root_path.
+ * Allocate the result in @a result_pool.
+ * Use @a scratch_pool for temporary allocations.
+ * If path is relative, we will convert it to absolute path.
+ * The error @c SVN_ERR_WC_NOT_DIRECTORY will be returned if @a path is
+ * not a versioned directory but file is Ok.
+ * If @a path is not found, return the error @c SVN_ERR_ENTRY_NOT_FOUND.*/
+svn_error_t *
+svn_wc__find_wc_root(const char **wc_root_path,
+ const char *path,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c (revision 38192)
+++ subversion/libsvn_wc/update_editor.c (working copy)
@@ -5324,6 +5324,57 @@
 }
 
 
+svn_error_t *
+svn_wc__find_wc_root(const char **wc_root_path, const char *path,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ svn_wc_adm_access_t *adm_access;
+ svn_boolean_t wc_root;
+ apr_pool_t *iterpool;
+ svn_node_kind_t kind;
+ const char *absolute;
+ iterpool = svn_pool_create(scratch_pool);
+
+ path = svn_dirent_internal_style(path, scratch_pool);
+ path = svn_dirent_canonicalize(path, scratch_pool);
+
+ /* If path is relative, we have to get its absolute path. Otherwise
+ * we can not find its wc root. eg. path '/C' is subdir of a wc, if
+ * will return '' as wc_root_path, that is not we expect. */
+ SVN_ERR(svn_dirent_get_absolute(&absolute, path, scratch_pool));
+
+ SVN_ERR(svn_io_check_path(absolute, &kind, scratch_pool));
+ if (kind == svn_node_file)
+ absolute = svn_dirent_dirname(absolute, scratch_pool);
+
+ while(1)
+ {
+ svn_pool_clear(iterpool);
+ SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, absolute,
+ FALSE, /* Write lock */
+ 0, /* lock levels */
+ NULL, NULL, iterpool));
+
+ SVN_ERR(svn_wc_is_wc_root(&wc_root, absolute, adm_access,
+ iterpool));
+ SVN_ERR(svn_wc_adm_close2(adm_access, iterpool));
+
+ if (wc_root)
+ {
+ *wc_root_path = apr_pstrdup(result_pool, absolute);
+ break;
+ }
+
+ /* absolute points to its parent now */
+ absolute = svn_dirent_dirname(absolute, result_pool);
+ }
+ svn_pool_destroy(iterpool);
+
+ return SVN_NO_ERROR;
+}
+
+
 svn_error_t*
 svn_wc__strictly_is_wc_root(svn_boolean_t *wc_root,
                            const char *path,

log message:
     
    [[[
      
       * subversion/include/private/svn_wc_private.h
         (svn_wc__find_wc_root): New API. Given a path, it return the
         working copy root path.
       * subversion/libsvn_wc/update_editor.c
         ((svn_wc__find_wc_root): New function. It is implement of
         API svn_wc__find_wc_root in svn_wc_private.h
    ]]]

Best Regards~
                                 
--------------
yellow.flying
2009-06-26

__________________________________________________
赶快注册雅虎超大容量免费邮箱?
http://cn.mail.yahoo.com

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2365659
Received on 2009-06-26 14:31:43 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.