[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: Thu, 25 Jun 2009 21:05:57 +0800

Hey Stefan,

I have tested this function and make a new patch.

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,17 @@
                             svn_wc_adm_access_t *adm_access,
                             apr_pool_t *pool);
 
+/** Given @a *path, find its strictly working copy root path @a **wc_root_path
+ Allocate the result in @a result_pool.
+ Use @a scratch_pool for temporary allocations.
+ The error @c SVN_ERR_WC_NOT_DIRECTORY will be returned if
+ * @a path is not a versioned directory.*/
+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,59 @@
 }
 
 
+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);
+
+ /* convert path from local style to internal style */
+ path = svn_dirent_internal_style(path, scratch_pool);
+ path = svn_dirent_canonicalize(path, scratch_pool);
+ /* if path is a relative path, get its absolute path */
+ SVN_ERR(svn_dirent_get_absolute(&absolute, path, scratch_pool));
+ path = absolute;
+
+ /* check path's kind */
+ SVN_ERR(svn_io_check_path(path, &kind, scratch_pool));
+ /* If path is a file, we get its parent dir */
+ if (kind == svn_node_file)
+ path = svn_dirent_dirname(path, scratch_pool);
+
+ while(1)
+ {
+ svn_pool_clear(iterpool);
+ SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, path,
+ FALSE, /* Write lock */
+ 0, /* lock levels */
+ NULL, NULL, iterpool));
+
+ /* Here, ADM_ACCESS refers to PATH. */
+ SVN_ERR(svn_wc_is_wc_root(&wc_root, path, adm_access,
+ iterpool));
+ svn_wc_adm_close2(adm_access, iterpool);
+
+ if (wc_root)
+ {
+ *wc_root_path = apr_pstrdup(result_pool, path);
+ break;
+ }
+
+ /* path point to its parent now*/
+ path = svn_dirent_dirname(path, 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. If path is not a versioned directory,
         The error SVN_ERR_WC_NOT_DIRECTORY will be returned.
       * 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~

Huihuang

------------------
yellow.flying
2009-06-25

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2365261
Received on 2009-06-25 15:06:21 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.