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

Re: [PATCH]remove adm_access batons in svn_wc_translated_file3()

From: HuiHuang <yellow.flying_at_yahoo.com.cn>
Date: Wed, 12 Aug 2009 13:58:45 +0800

Hey Hyrum, Julian,

I rewrite the patch as you like and have tested it, see below:

Log:
[[[
Rip out some adm_access usage in svn_wc_translated_file3().

* subversion/include/svn_wc.h
  (svn_wc_translated_file3): New.
  (svn_wc_translated_file2): Deprecate.

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

* subversion/libsvn_wc/translate.c
  (svn_wc__internal_translated_file): New.
  (svn_wc_translated_file3): New.
  (svn_wc_translated_file2): Remove.

* subversion/libsvn_wc/translate.h
  (svn_wc__internal_translated_file): New.

* subversion/libsvn_wc/log.c
  (loggy_path): Add a apr_pool_t * parameter and make it able to deal with absolute paths.
]]]

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

Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (版本 38693)
+++ subversion/include/svn_wc.h (工作副本)
@@ -5855,10 +5855,10 @@
 

 /* EOL conversion and keyword expansion. */
 
-/** Set @a xlated_path to a translated copy of @a src
+/** Set @a xlated_abspath to a translated copy of @a src
  * or to @a src itself if no translation is necessary.
- * That is, if @a versioned_file's properties indicate newline conversion or
- * keyword expansion, point @a *xlated_path to a copy of @a src
+ * That is, if @a versioned_abspath's properties indicate newline conversion
+ * or keyword expansion, point @a *xlated_abspath to a copy of @a src
  * whose newlines and keywords are converted using the translation
  * as requested by @a flags.
  *
@@ -5872,20 +5872,37 @@
  * @c SVN_WC_TRANSLATE_FORCE_COPY flag in @a flags.
  *
  * This function is generally used to get a file that can be compared
- * meaningfully against @a versioned_file's text base, if
- * @c SVN_WC_TRANSLATE_TO_NF is specified, against @a versioned_file itself
+ * meaningfully against @a versioned_abspath's text base, if
+ * @c SVN_WC_TRANSLATE_TO_NF is specified, against @a versioned_abspath itself
  * if @c SVN_WC_TRANSLATE_FROM_NF is specified.
  *
- * Output files are created in the temp file area belonging to
- * @a versioned_file. By default they will be deleted at pool cleanup.
+ * The output file is created in the temp file area belonging to
+ * @a versioned_abspath. By default it will be deleted at result_pool
+ * cleanup. If @a flags includes @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
+ * the default result_pool cleanup handler to remove @a *xlated_abspath is
+ * not registered.
  *
- * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
- * pool cleanup handler to remove @a *xlated_path is not registered.
+ * If an error is returned, the effect on @a *xlated_abspath is undefined.
  *
- * If an error is returned, the effect on @a *xlated_path is undefined.
+ * @since New in 1.7.
+ */
+svn_error_t *
+svn_wc_translated_file3(const char **xlated_abspath,
+ const char *src,
+ svn_wc_context_t *wc_ctx,
+ const char *versioned_abspath,
+ apr_uint32_t flags,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+
+/** Similar to svn_wc_translated_file3(), but with an adm_access baton
+ * and relative paths instead of a wc_context and absolute paths.
  *
- * @since New in 1.4
+ * @since New in 1.4.
+ * @deprecated Provided for compatibility with the 1.6 API
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_wc_translated_file2(const char **xlated_path,
                         const char *src,
Index: subversion/libsvn_wc/deprecated.c
===================================================================
--- subversion/libsvn_wc/deprecated.c (版本 38693)
+++ subversion/libsvn_wc/deprecated.c (工作副本)
@@ -2126,6 +2126,39 @@
   return svn_error_return(svn_wc_context_destroy(wc_ctx));
 }
 
+svn_error_t *
+svn_wc_translated_file2(const char **xlated_path,
+ const char *src,
+ const char *versioned_file,
+ svn_wc_adm_access_t *adm_access,
+ apr_uint32_t flags,
+ apr_pool_t *pool)
+{
+ const char *versioned_abspath;
+ const char *root;
+ const char *tmp_root;
+ svn_wc_context_t *wc_ctx;
+
+ SVN_ERR(svn_dirent_get_absolute(&versioned_abspath, versioned_file, pool));
+ SVN_ERR(svn_wc__context_create_with_db(&wc_ctx, NULL,
+ svn_wc__adm_get_db(adm_access),
+ pool));
+
+ SVN_ERR(svn_wc_translated_file3(xlated_path, src, wc_ctx, versioned_abspath,
+ flags, pool, pool));
+ if (! svn_dirent_is_absolute(versioned_file))
+ {
+ SVN_ERR(svn_io_temp_dir(&tmp_root, pool));
+ if (! svn_dirent_is_child(tmp_root, *xlated_path, pool))
+ {
+ SVN_ERR(svn_dirent_get_absolute(&root, "", pool));
+ *xlated_path = svn_dirent_is_child(root, *xlated_path, pool);
+ }
+ }
+
+ return svn_error_return(svn_wc_context_destroy(wc_ctx));
+}
+
 /*** From relocate.c ***/
 svn_error_t *
 svn_wc_relocate3(const char *path,
Index: subversion/libsvn_wc/translate.c
===================================================================
--- subversion/libsvn_wc/translate.c (版本 38693)
+++ subversion/libsvn_wc/translate.c (工作副本)
@@ -169,32 +169,33 @@
 
 
 svn_error_t *
-svn_wc_translated_file2(const char **xlated_path,
- const char *src,
- const char *versioned_file,
- svn_wc_adm_access_t *adm_access,
- apr_uint32_t flags,
- apr_pool_t *pool)
+svn_wc__internal_translated_file(const char **xlated_abspath,
+ const char *src,
+ svn_wc__db_t *db,
+ const char *versioned_abspath,
+ apr_uint32_t flags,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
 {
   svn_subst_eol_style_t style;
   const char *eol;
+ const char *xlated_path;
   apr_hash_t *keywords;
   svn_boolean_t special;
- svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
- const char *versioned_abspath;
 
- SVN_ERR(svn_dirent_get_absolute(&versioned_abspath, versioned_file, pool));
+
+ SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_abspath));
   SVN_ERR(svn_wc__get_eol_style(&style, &eol, db, versioned_abspath,
- pool, pool));
- SVN_ERR(svn_wc__get_keywords(&keywords, db, versioned_abspath, NULL, pool,
- pool));
- SVN_ERR(svn_wc__get_special(&special, db, versioned_abspath, pool));
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_wc__get_keywords(&keywords, db, versioned_abspath, NULL,
+ scratch_pool, scratch_pool));
+ SVN_ERR(svn_wc__get_special(&special, db, versioned_abspath, scratch_pool));
 
   if (! svn_subst_translation_required(style, eol, keywords, special, TRUE)
       && (! (flags & SVN_WC_TRANSLATE_FORCE_COPY)))
     {
       /* Translation would be a no-op, so return the original file. */
- *xlated_path = src;
+ xlated_path = src;
     }
   else /* some translation (or copying) is necessary */
     {
@@ -207,14 +208,15 @@
       if (flags & SVN_WC_TRANSLATE_USE_GLOBAL_TMP)
         tmp_dir = NULL;
       else
- tmp_dir = svn_wc__adm_child(svn_dirent_dirname(versioned_file, pool),
- SVN_WC__ADM_TMP, pool);
+ tmp_dir = svn_wc__adm_child(
+ svn_dirent_dirname(versioned_abspath, scratch_pool),
+ SVN_WC__ADM_TMP, scratch_pool);
 
       SVN_ERR(svn_io_open_unique_file3(NULL, &tmp_vfile, tmp_dir,
                 (flags & SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP)
                   ? svn_io_file_del_none
                   : svn_io_file_del_on_pool_cleanup,
- pool, pool));
+ result_pool, scratch_pool));
 
       /* ### ugh. the repair behavior does NOT match the docstring. bleah.
          ### all of these translation functions are crap and should go
@@ -244,15 +246,30 @@
                                             keywords,
                                             expand,
                                             special,
- pool));
+ result_pool));
 
- *xlated_path = tmp_vfile;
+ xlated_path = tmp_vfile;
     }
+ SVN_ERR(svn_dirent_get_absolute(xlated_abspath, xlated_path, result_pool));
 
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc_translated_file3(const char **xlated_abspath,
+ const char *src,
+ svn_wc_context_t *wc_ctx,
+ const char *versioned_abspath,
+ apr_uint32_t flags,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ return svn_wc__internal_translated_file(xlated_abspath, src, wc_ctx->db,
+ versioned_abspath, flags,
+ result_pool,scratch_pool);
+}
 
+
 svn_error_t *
 svn_wc__get_eol_style(svn_subst_eol_style_t *style,
                       const char **eol,
Index: subversion/libsvn_wc/translate.h
===================================================================
--- subversion/libsvn_wc/translate.h (版本 38693)
+++ subversion/libsvn_wc/translate.h (工作副本)
@@ -133,7 +133,19 @@
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);
 
+/* Like svn_wc_translated_file3(), except the working copy database
+ * is specified directly by DB instead of indirectly through a
+ * svn_wc_context_t parameter. */
+svn_error_t *
+svn_wc__internal_translated_file(const char **xlated_abspath,
+ const char *src,
+ svn_wc__db_t *db,
+ const char *versioned_abspath,
+ apr_uint32_t flags,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
 
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c (版本 38693)
+++ subversion/libsvn_wc/log.c (工作副本)
@@ -1729,12 +1729,31 @@
  * directory. PATH must not be outside that directory. */
 static const char *
 loggy_path(const char *path,
- svn_wc_adm_access_t *adm_access)
+ svn_wc_adm_access_t *adm_access,
+ apr_pool_t *pool)
 {
+ const char *adm_abspath = NULL;
+ const char *abspath = NULL;
   const char *adm_path = svn_wc_adm_access_path(adm_access);
- const char *local_path = svn_dirent_is_child(adm_path, path, NULL);
+ const char *local_path = NULL;
+ svn_error_t *err1 = NULL, *err2 = NULL;
 
- if (! local_path && strcmp(path, adm_path) == 0)
+ err1 = svn_dirent_get_absolute(&adm_abspath, adm_path, pool);
+ if (err1)
+ {
+ svn_error_clear(err1);
+ return NULL;
+ }
+ err2 = svn_dirent_get_absolute(&abspath, path, pool);
+ if (err2)
+ {
+ svn_error_clear(err2);
+ return NULL;
+ }
+
+ local_path = svn_dirent_is_child(adm_abspath, abspath, NULL);
+
+ if (! local_path && strcmp(abspath, adm_abspath) == 0)
     local_path = SVN_WC_ENTRY_THIS_DIR;
 
   return local_path;
@@ -1751,9 +1770,9 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_APPEND,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(src, adm_access),
+ loggy_path(src, adm_access, pool),
                         SVN_WC__LOG_ATTR_DEST,
- loggy_path(dst, adm_access),
+ loggy_path(dst, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1768,7 +1787,7 @@
 {
   svn_xml_make_open_tag(log_accum, pool, svn_xml_self_closing,
                         SVN_WC__LOG_COMMITTED,
- SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access),
+ SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access, pool),
                         SVN_WC__LOG_ATTR_REVISION,
                         apr_psprintf(pool, "%ld", revnum),
                         NULL);
@@ -1783,8 +1802,8 @@
                    apr_pool_t *pool)
 {
   return loggy_move_copy_internal(log_accum, FALSE, adm_access,
- loggy_path(src_path, adm_access),
- loggy_path(dst_path, adm_access),
+ loggy_path(src_path, adm_access, pool),
+ loggy_path(dst_path, adm_access, pool),
                                   pool);
 }
 
@@ -1799,9 +1818,9 @@
   svn_xml_make_open_tag
     (log_accum, pool, svn_xml_self_closing,
      SVN_WC__LOG_CP_AND_TRANSLATE,
- SVN_WC__LOG_ATTR_NAME, loggy_path(src, adm_access),
- SVN_WC__LOG_ATTR_DEST, loggy_path(dst, adm_access),
- SVN_WC__LOG_ATTR_ARG_2, loggy_path(versioned, adm_access),
+ SVN_WC__LOG_ATTR_NAME, loggy_path(src, adm_access, pool),
+ SVN_WC__LOG_ATTR_DEST, loggy_path(dst, adm_access, pool),
+ SVN_WC__LOG_ATTR_ARG_2, loggy_path(versioned, adm_access, pool),
      NULL);
 
   return SVN_NO_ERROR;
@@ -1815,7 +1834,7 @@
 {
   svn_xml_make_open_tag(log_accum, pool, svn_xml_self_closing,
                         SVN_WC__LOG_DELETE_ENTRY,
- SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access),
+ SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1829,7 +1848,7 @@
 {
   svn_xml_make_open_tag(log_accum, pool, svn_xml_self_closing,
                         SVN_WC__LOG_DELETE_LOCK,
- SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access),
+ SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1843,7 +1862,7 @@
 {
   svn_xml_make_open_tag(log_accum, pool, svn_xml_self_closing,
                         SVN_WC__LOG_DELETE_CHANGELIST,
- SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access),
+ SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1988,7 +2007,7 @@
     return SVN_NO_ERROR;
 
   apr_hash_set(prop_hash, SVN_WC__LOG_ATTR_NAME,
- APR_HASH_KEY_STRING, loggy_path(path, adm_access));
+ APR_HASH_KEY_STRING, loggy_path(path, adm_access, pool));
 
   svn_xml_make_open_tag_hash(log_accum, pool,
                              svn_xml_self_closing,
@@ -2010,7 +2029,7 @@
   svn_xml_make_open_tag(log_accum, pool, svn_xml_self_closing,
                         SVN_WC__LOG_MODIFY_WCPROP,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         SVN_WC__LOG_ATTR_PROPNAME,
                         propname,
                         SVN_WC__LOG_ATTR_PROPVAL,
@@ -2027,8 +2046,8 @@
                    apr_pool_t *pool)
 {
   return loggy_move_copy_internal(log_accum, TRUE, adm_access,
- loggy_path(src_path, adm_access),
- loggy_path(dst_path, adm_access),
+ loggy_path(src_path, adm_access, pool),
+ loggy_path(dst_path, adm_access, pool),
                                   pool);
 }
 
@@ -2042,7 +2061,7 @@
                         pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_MAYBE_EXECUTABLE,
- SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access),
+ SVN_WC__LOG_ATTR_NAME, loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2059,7 +2078,7 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_MAYBE_READONLY,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2076,7 +2095,7 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_MODIFY_ENTRY,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         SVN_WC__ENTRY_ATTR_TEXT_TIME,
                         SVN_WC__TIMESTAMP_WC,
                         NULL);
@@ -2095,7 +2114,7 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_MODIFY_ENTRY,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         SVN_WC__ENTRY_ATTR_WORKING_SIZE,
                         SVN_WC__WORKING_SIZE_WC,
                         NULL);
@@ -2114,7 +2133,7 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_READONLY,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2132,7 +2151,7 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_SET_TIMESTAMP,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         SVN_WC__LOG_ATTR_TIMESTAMP,
                         timestr,
                         NULL);
@@ -2152,7 +2171,7 @@
                         svn_xml_self_closing,
                         SVN_WC__LOG_RM,
                         SVN_WC__LOG_ATTR_NAME,
- loggy_path(path, adm_access),
+ loggy_path(path, adm_access, pool),
                         NULL);
 
   return SVN_NO_ERROR;

Best
Huihuang

------------------
yellow.flying
2009-08-12
��i��'�ē扫h∈&

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382790
Received on 2009-08-12 08:01:12 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.