You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by HuiHuang <ye...@yahoo.com.cn> on 2009/08/06 08:36:33 UTC

[PATCH]remove adm_access in svn_wc_translated_file3

Hey,

When I try to modify some callers to svn_wc_transmit_prop_deltas2(), I find
many functions also refer to svn_wc_translated_file2(). So I remove
adm_access batons in svn_wc_translated_file2() first. 

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.
]]]

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



Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h	(revision 38574)
+++ subversion/include/svn_wc.h	(working copy)
@@ -5842,8 +5842,8 @@
 
 /** Set @a xlated_path 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_path to a copy of @a src
  * whose newlines and keywords are converted using the translation
  * as requested by @a flags.
  *
@@ -5857,20 +5857,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.
+ * @a versioned_abspath. By default they will be deleted at scratch_pool cleanup.
  *
  * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
- * pool cleanup handler to remove @a *xlated_path is not registered.
+ * result_pool cleanup handler to remove @a *xlated_path is not registered.
  *
  * If an error is returned, the effect on @a *xlated_path is undefined.
  *
- * @since New in 1.4
+ * @since New in 1.7.
+ */ 
+svn_error_t *
+svn_wc_translated_file3(const char **xlated_path,
+                        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.
+ * @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	(revision 38574)
+++ subversion/libsvn_wc/deprecated.c	(working copy)
@@ -2100,6 +2100,28 @@
   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;
+  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 /* config */,
+                                         svn_wc__adm_get_db(adm_access),
+                                         pool));
+
+  SVN_ERR(svn_wc_translated_file3(xlated_path, src, wc_ctx, versioned_abspath, 
+                                  flags, pool, 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	(revision 38574)
+++ subversion/libsvn_wc/translate.c	(working copy)
@@ -169,26 +169,27 @@
 
 
 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_path,
+                                 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;
   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));
+                                result_pool, scratch_pool));
+  SVN_ERR(svn_wc__get_keywords(&keywords, db, versioned_abspath, NULL, 
+                               result_pool, scratch_pool));
+  SVN_ERR(svn_wc__get_special(&special, db, versioned_abspath, result_pool));
 
   if (! svn_subst_translation_required(style, eol, keywords, special, TRUE)
       && (! (flags & SVN_WC_TRANSLATE_FORCE_COPY)))
@@ -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, result_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,7 +246,7 @@
                                             keywords,
                                             expand,
                                             special,
-                                            pool));
+                                            result_pool));
 
       *xlated_path = tmp_vfile;
     }
@@ -252,7 +254,21 @@
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc_translated_file3(const char **xlated_path,
+                        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_path, 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	(revision 38574)
+++ subversion/libsvn_wc/translate.h	(working copy)
@@ -133,7 +133,17 @@
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);
 
+/* Internal version of svn_wc_translated_file3(). */
+svn_error_t *
+svn_wc__internal_translated_file(const char **xlated_path,
+                                 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 */

Best Wishes!
Huihuang
 				
--------------
yellow.flying
2009-08-06

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2380739

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by Stefan Sperling <st...@elego.de>.
On Fri, Aug 07, 2009 at 09:45:28PM +0800, HuiHuang wrote:
> >Let me just second this, especially when working with wc-ng.  Almost  
> >every test hits the working copy, and most exercise it in different  
> >ways.  We currently have 1145 tests that expected to pass, and some of  
> >my initial patches only fail on one or two of them.  Running the  
> >entire test suite means I get lots of testing on my patch, and I don't  
> >have to guess where the 0.2% of tests that fail might be.
> Some times it takes more than one hour or even longer. And it is strange that
> When I run all tests together some tests fail, but when I run them seperately,
> they will be passed.

Why do they fail? You can check tests.log in the top-most directory
of the source tree for possible reasons.
Maybe you are running out of disk space?

Stefan

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381328

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by Branko Cibej <br...@xbc.nu>.
Stefan Sperling wrote:
[...]
> Yes! Please run *all* tests before submitting a patch.
>   
[...]
> The test suite also takes about an hour to run for me. But as long as
> it is just my computer spending the time and not myself, I don't really
> care. I can do something else while the tests are running, e.g. read
> mail or put up the laundry or something.
>   

When you're *fixing* test failures, it's perfectly find to run just
individual tests, or small subsets. But definitely run the whole
testcase before submitting a patch, yes.

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381249

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by Branko Cibej <br...@xbc.nu>.
yellow.flying wrote:
>> Let me just second this, especially when working with wc-ng.  Almost  
>> every test hits the working copy, and most exercise it in different  
>> ways.  We currently have 1145 tests that expected to pass, and some of  
>> my initial patches only fail on one or two of them.  Running the  
>> entire test suite means I get lots of testing on my patch, and I don't  
>> have to guess where the 0.2% of tests that fail might be.
>>     
> Some times it takes more than one hour or even longer.

There are ways to speed up tests, using RAM disks for repository
storage. It's all in the README.

>  And it is strange that
> When I run all tests together some tests fail, but when I run them seperately,
> they will be passed.
>   

That is most likely a bug in one of the previous tests that doesn't
properly clean up after itself. Finding these is one of the reasons that
it's a good idea to run all the tests every once in a while.

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381327

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by HuiHuang <ye...@yahoo.com.cn>.
>Let me just second this, especially when working with wc-ng.  Almost  
>every test hits the working copy, and most exercise it in different  
>ways.  We currently have 1145 tests that expected to pass, and some of  
>my initial patches only fail on one or two of them.  Running the  
>entire test suite means I get lots of testing on my patch, and I don't  
>have to guess where the 0.2% of tests that fail might be.
Some times it takes more than one hour or even longer. And it is strange that
When I run all tests together some tests fail, but when I run them seperately,
they will be passed.

>I can usually run the entire test suite in about 35 minutes, but I've  
>got multiple working copies, so that while one is running tests, I can  
>be hacking something (usually unrelated) else in the other.
That is good idea, I will try:)

And Stefan, Brane, I will try to run all tests before sending patch.

Thank you!
Huihuang

------------------				 
yellow.flying
2009-08-07


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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381302

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

Posted by Julian Foad <ju...@btopenworld.com>.
Here are just a couple of comments; this is not a review.

On Mon, 2009-08-10, HuiHuang wrote:
> Index: subversion/include/svn_wc.h
> ===================================================================
[...]
>   * Output files are created in the temp file area belonging to
> - * @a versioned_file.  By default they will be deleted at pool cleanup.
> + * @a versioned_abspath. By default they will be deleted at scratch_pool cleanup.
>   *
>   * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
> - * pool cleanup handler to remove @a *xlated_path is not registered.
> + * result_pool cleanup handler to remove @a *xlated_path is not registered.

The first of these two paragraphs refers to "scratch_pool cleanup" and
the second to "result_pool cleanup". Shouldn't they both refer to the
same pool?

[...]
> Index: subversion/libsvn_wc/translate.h
> ===================================================================
[...]
>  
> +/* Internal version of svn_wc_translated_file3(). */

Saying "Internal version of ..." does not communicate any useful
information. Instead, say how this function differs from
svn_wc_translated_file3(). For example:

/* 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_path,
> +                                 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);

Thanks.
- Julian

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382076

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

Posted by HuiHuang <ye...@yahoo.com.cn>.
>Are they both output values?  I believe so, and if that's the case  
>then they should both go in result_pool.

>(This is actually a bit tricky, since the file isn't strictly an  
>output parameter, but it is instead a tangible side-effect of the  
>function, which we want to persist for some amount of time.  Stuff  
>allocated in scratch_pool isn't guaranteed to exist beyond the scope  
>of the function.)

I see... I will make both of them use result_pool.

Best
huihuang
------------------				 
yellow.flying
2009-08-11

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382280

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

Posted by Julian Foad <ju...@btopenworld.com>.
On Wed, 2009-08-12 at 13:58 +0800, yellow.flying wrote:
> Hey Hyrum, Julian,
> 
> I rewrite the patch as you like and have tested it, see below:

Thanks, Huihuang.

I have now reviewed the whole patch and it all looks good to me except
for one thing: the "loggy_path" change.

> 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.
> ]]]


> Index: subversion/libsvn_wc/deprecated.c
> ===================================================================
[...]
> +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));
> +}

I wasn't sure at first whether this big "if ()" block really produces
the desired relative path. To check that this wrapper function really
does produce the same result as the previous version, I added some
debugging code to output the result of each call to
svn_wc_translated_file2(), and I compared these results with and without
your patch. They were identical. That's good.

(I compared the results produced during all the tests in diff_tests.py,
log_tests.py, update_tests.py, merge_tests.py.)

> 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;

This function should never return NULL. To catch the possible errors
from "..._get_absolute()" I think you will have to change the function's
prototype to return an error, and provide the result through an output
argument.

Don't initialize variables to NULL when they are going to be initialized
to the correct value later. Doing so prevents compilers and "valgrind"
from detecting use before initialization.

This comment at the top of the file should be updated to mention that
the paths can now be absolute:

/* The svn_wc__loggy_* functions in this section take path arguments
   with the same base as with which the adm_access was opened.
*/

This whole "loggy_path()" change is big enough and independent enough
that it could usefully be a separate patch.


Thanks.
- Julian

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382865


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

Posted by HuiHuang <ye...@yahoo.com.cn>.
Great!! Thank you:)

在 2009-08-12三的 18:37 +0100,Julian Foad写道:
> On Wed, 2009-08-12, Julian Foad wrote:
> > Unfortunately it looks like you attached the wrong patch in this
> > message.
> 
> It doesn't matter: I extracted it from your previous patch.
> 
> Committed in r38699.
> 
> Thanks!
> - Julian
> 
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382962

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2383226


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

Posted by Julian Foad <ju...@btopenworld.com>.
On Wed, 2009-08-12, Julian Foad wrote:
> Unfortunately it looks like you attached the wrong patch in this
> message.

It doesn't matter: I extracted it from your previous patch.

Committed in r38699.

Thanks!
- Julian

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382962

[PATCH]svn_wc_walk_entries4

Posted by HuiHuang <ye...@yahoo.com.cn>.
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


Re: [PATCH]Use the library-internal version of translated_file()

Posted by HuiHuang <ye...@yahoo.com.cn>.
Hey,

I have fixed the issue and make a new patch, see below:
Thanks:)

Log:

[[[
Use the library-internal version of translated_file() and tweak 
diff_external_diffcmd test to use absolute path.

 * subversion/tests/cmdline/diff_tests.py
   (diff_external_diffcmd): Modify expected output as absolute path.

 * subversion/libsvn_wc/diff.c
   (file_diff, report_wc_file_as_added, close_file): Call  
    svn_wc__internal_translated_file() in favor of 
    svn_wc_translated_file2().

 * subversion/libsvn_wc/log.c
   (install_committed_file): Call svn_wc__internal_translated_file()   
    in favor of svn_wc_translated_file2().

 * subversion/libsvn_wc/merge.c
   (preserve_pre_merge_files): Call svn_wc__internal_translated_file()  
    in favor of svn_wc_translated_file2().

 * subversion/libsvn_wc/update_editor.c
   (merge_file): Call svn_wc__internal_translated_file() in favor of  
    svn_wc_translated_file2().
]]]

Modified:
    trunk/subversion/tests/cmdline/diff_tests.py
    trunk/subversion/libsvn_wc/diff.c
    trunk/subversion/libsvn_wc/log.c
    trunk/subversion/libsvn_wc/merge.c
    trunk/subversion/libsvn_wc/update_editor.c




Index: subversion/tests/cmdline/diff_tests.py
===================================================================
--- subversion/tests/cmdline/diff_tests.py	(版本 38767)
+++ subversion/tests/cmdline/diff_tests.py	(工作副本)
@@ -2954,7 +2954,7 @@
     "-L\n",
     "iota\t(working copy)\n",
     os.path.join('.svn', 'text-base', 'iota.svn-base') + "\n",
-    "iota\n"])
+    os.path.abspath("iota") + "\n"])
 
   # Check that the output of diff corresponds with the expected
arguments,
   # in the correct order.
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(版本 38767)
+++ subversion/libsvn_wc/update_editor.c	(工作副本)
@@ -4452,11 +4452,10 @@
 
           /* Copy and DEtranslate the working file to a temp text-base.
              Note that detranslation is done according to the old
props. */
-          SVN_ERR(svn_wc_translated_file2(&tmptext, fb->path, fb->path,
-                                          adm_access,
-                                          SVN_WC_TRANSLATE_TO_NF
-                                          |
SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
-                                          pool));
+          SVN_ERR(svn_wc__internal_translated_file
+                  (&tmptext, local_abspath, eb->db, local_abspath,
+                   SVN_WC_TRANSLATE_TO_NF |
SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
+                   pool, pool));
 
           /* A log command that copies the tmp-text-base and
REtranslates
              it back to the working file.
Index: subversion/libsvn_wc/merge.c
===================================================================
--- subversion/libsvn_wc/merge.c	(版本 38767)
+++ subversion/libsvn_wc/merge.c	(工作副本)
@@ -564,8 +564,12 @@
   const char *parent, *target_base;
   svn_wc_adm_access_t *parent_access;
   const char *adm_path = svn_wc_adm_access_path(adm_access);
+  const char *merge_abstarget;
+  svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
   svn_wc_entry_t tmp_entry;
 
+  SVN_ERR(svn_dirent_get_absolute(&merge_abstarget, merge_target,
pool));
+
   /* I miss Lisp. */
 
   SVN_ERR(svn_io_open_uniquely_named(NULL,
@@ -654,13 +658,10 @@
 
   /* Back up MERGE_TARGET through detranslation/retranslation:
      the new translation properties may not match the current ones */
-  SVN_ERR(svn_wc_translated_file2(&detranslated_target_copy,
-                                  merge_target,
-                                  merge_target,
-                                  adm_access,
-                                  SVN_WC_TRANSLATE_TO_NF
-                                  | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
-                                  pool));
+  SVN_ERR(svn_wc__internal_translated_file
+          (&detranslated_target_copy, merge_abstarget, db,
merge_abstarget,
+           SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
+           pool, pool));
   SVN_ERR(svn_wc__loggy_translated_file
           (log_accum, adm_access,
            target_copy, detranslated_target_copy, merge_target, pool));
Index: subversion/libsvn_wc/diff.c
===================================================================
--- subversion/libsvn_wc/diff.c	(版本 38767)
+++ subversion/libsvn_wc/diff.c	(工作副本)
@@ -678,11 +678,10 @@
       SVN_ERR(get_working_mimetype(&working_mimetype, NULL,
local_abspath,
                                    eb->db, pool, pool));
 
-      SVN_ERR(svn_wc_translated_file2
-              (&translated, path, path, adm_access,
-               SVN_WC_TRANSLATE_TO_NF
-               | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-               pool));
+      SVN_ERR(svn_wc__internal_translated_file
+              (&translated, local_abspath, eb->db, local_abspath,
+              SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+              pool, pool));
 
       SVN_ERR(dir_baton->edit_baton->callbacks->file_added
               (NULL, NULL, NULL, NULL, path,
@@ -710,12 +709,10 @@
              tmp translated copy too.  But what the heck, diff is
              already expensive, translating twice for the sake of code
              modularity is liveable. */
-          SVN_ERR(svn_wc_translated_file2
-                  (&translated, path,
-                   path, adm_access,
-                   SVN_WC_TRANSLATE_TO_NF
-                   | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-                   pool));
+          SVN_ERR(svn_wc__internal_translated_file
+                  (&translated, local_abspath, eb->db, local_abspath,
+                   SVN_WC_TRANSLATE_TO_NF |
SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+                   pool, pool));
         }
 
       if (modified || propchanges->nelts > 0)
@@ -1150,12 +1147,10 @@
   else
     source_file = path;
 
-  SVN_ERR(svn_wc_translated_file2
-          (&translated_file,
-           source_file, path, adm_access,
-           SVN_WC_TRANSLATE_TO_NF
-           | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-           pool));
+  SVN_ERR(svn_wc__internal_translated_file
+          (&translated_file, source_file, eb->db, local_abspath,
+           SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+           pool, pool));
 
   SVN_ERR(eb->callbacks->file_added
           (adm_access, NULL, NULL, NULL,
@@ -2428,12 +2423,10 @@
         localfile = svn_wc__text_base_path(b->path, FALSE, b->pool);
       else
         /* a detranslated version of the working file */
-        SVN_ERR(svn_wc_translated_file2
-                (&localfile, b->path,
-                 b->path, adm_access,
-                 SVN_WC_TRANSLATE_TO_NF
-                 | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-                 pool));
+        SVN_ERR(svn_wc__internal_translated_file
+                (&localfile, local_abspath, eb->db, local_abspath,
+                 SVN_WC_TRANSLATE_TO_NF |
SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+                 pool, pool));
     }
   else
     localfile = temp_file_path = NULL;
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c	(版本 38767)
+++ subversion/libsvn_wc/log.c	(工作副本)
@@ -363,11 +363,10 @@
   {
     const char *tmp = (kind == svn_node_file) ? tmp_text_base :
filepath;
 
-    SVN_ERR(svn_wc_translated_file2(&tmp_wfile,
-                                    tmp,
-                                    filepath, adm_access,
-                                    SVN_WC_TRANSLATE_FROM_NF,
-                                    pool));
+    SVN_ERR(svn_wc__internal_translated_file(&tmp_wfile, tmp, db,
+                                             file_abspath,
+                                             SVN_WC_TRANSLATE_FROM_NF,
+                                             pool, pool));
 
     /* If the translation is a no-op, the text base and the working
copy
      * file contain the same content, because we use the same props
here


Best~
Huihuang

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2384206


Re: [PATCH]Use the library-internal version of translated_file()

Posted by "Hyrum K. Wright" <hy...@hyrumwright.org>.
On Aug 14, 2009, at 10:55 PM, HuiHuang wrote:

> Hey,
>
> Log:
> [[[
> Use the library-internal version of translated_file().
>
> * subversion/libsvn_wc/diff.c
>  (file_diff, report_wc_file_as_added, close_file): Call  
> svn_wc__internal_translated_file()
>    in favor of svn_wc_translated_file2().
>
> * subversion/libsvn_wc/log.c
>  (install_committed_file): Call svn_wc__internal_translated_file()   
> in favor of
>    svn_wc_translated_file2().
>
> * subversion/libsvn_wc/merge.c
>  (preserve_pre_merge_files): Call  
> svn_wc__internal_translated_file()  in favor of
>     svn_wc_translated_file2().
>
> * subversion/libsvn_wc/update_editor.c
>  (merge_file): Call svn_wc__internal_translated_file() in favor of  
> svn_wc_translated_file2().
> ]]]

Haven't thoroughly reviewed the patch yet, but diff test 48 fails  
after I apply it.  I suspect it's just an absolute path that the  
expected output of the test isn't smart enough to deal with, but this  
failure needs to be fixed before the patch can be applied.

Thanks,
-Hyrum

>
> Modified:
>    trunk/subversion/libsvn_wc/diff.c
>    trunk/subversion/libsvn_wc/log.c
>    trunk/subversion/libsvn_wc/merge.c
>    trunk/subversion/libsvn_wc/update_editor.c
>
> Index: subversion/libsvn_wc/diff.c
> ===================================================================
> --- subversion/libsvn_wc/diff.c	(版本 38761)
> +++ subversion/libsvn_wc/diff.c	(工作副本)
> @@ -678,11 +678,10 @@
>       SVN_ERR(get_working_mimetype(&working_mimetype, NULL,  
> local_abspath,
>                                    eb->db, pool, pool));
>
> -      SVN_ERR(svn_wc_translated_file2
> -              (&translated, path, path, adm_access,
> -               SVN_WC_TRANSLATE_TO_NF
> -               | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> -               pool));
> +      SVN_ERR(svn_wc__internal_translated_file
> +              (&translated, local_abspath, eb->db, local_abspath,
> +              SVN_WC_TRANSLATE_TO_NF |  
> SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> +              pool, pool));
>
>       SVN_ERR(dir_baton->edit_baton->callbacks->file_added
>               (NULL, NULL, NULL, NULL, path,
> @@ -710,12 +709,10 @@
>              tmp translated copy too.  But what the heck, diff is
>              already expensive, translating twice for the sake of code
>              modularity is liveable. */
> -          SVN_ERR(svn_wc_translated_file2
> -                  (&translated, path,
> -                   path, adm_access,
> -                   SVN_WC_TRANSLATE_TO_NF
> -                   | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> -                   pool));
> +          SVN_ERR(svn_wc__internal_translated_file
> +                  (&translated, local_abspath, eb->db, local_abspath,
> +                   SVN_WC_TRANSLATE_TO_NF |  
> SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> +                   pool, pool));
>         }
>
>       if (modified || propchanges->nelts > 0)
> @@ -1150,12 +1147,10 @@
>   else
>     source_file = path;
>
> -  SVN_ERR(svn_wc_translated_file2
> -          (&translated_file,
> -           source_file, path, adm_access,
> -           SVN_WC_TRANSLATE_TO_NF
> -           | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> -           pool));
> +  SVN_ERR(svn_wc__internal_translated_file
> +          (&translated_file, source_file, eb->db, local_abspath,
> +           SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> +           pool, pool));
>
>   SVN_ERR(eb->callbacks->file_added
>           (adm_access, NULL, NULL, NULL,
> @@ -2428,12 +2423,10 @@
>         localfile = svn_wc__text_base_path(b->path, FALSE, b->pool);
>       else
>         /* a detranslated version of the working file */
> -        SVN_ERR(svn_wc_translated_file2
> -                (&localfile, b->path,
> -                 b->path, adm_access,
> -                 SVN_WC_TRANSLATE_TO_NF
> -                 | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> -                 pool));
> +        SVN_ERR(svn_wc__internal_translated_file
> +                (&localfile, local_abspath, eb->db, local_abspath,
> +                 SVN_WC_TRANSLATE_TO_NF |  
> SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
> +                 pool, pool));
>     }
>   else
>     localfile = temp_file_path = NULL;
> Index: subversion/libsvn_wc/log.c
> ===================================================================
> --- subversion/libsvn_wc/log.c	(版本 38761)
> +++ subversion/libsvn_wc/log.c	(工作副本)
> @@ -363,11 +363,10 @@
>   {
>     const char *tmp = (kind == svn_node_file) ? tmp_text_base :  
> filepath;
>
> -    SVN_ERR(svn_wc_translated_file2(&tmp_wfile,
> -                                    tmp,
> -                                    filepath, adm_access,
> -                                    SVN_WC_TRANSLATE_FROM_NF,
> -                                    pool));
> +    SVN_ERR(svn_wc__internal_translated_file(&tmp_wfile, tmp, db,
> +                                             file_abspath,
> +                                              
> SVN_WC_TRANSLATE_FROM_NF,
> +                                             pool, pool));
>
>     /* If the translation is a no-op, the text base and the working  
> copy
>      * file contain the same content, because we use the same props  
> here
> Index: subversion/libsvn_wc/merge.c
> ===================================================================
> --- subversion/libsvn_wc/merge.c	(版本 38761)
> +++ subversion/libsvn_wc/merge.c	(工作副本)
> @@ -564,8 +564,12 @@
>   const char *parent, *target_base;
>   svn_wc_adm_access_t *parent_access;
>   const char *adm_path = svn_wc_adm_access_path(adm_access);
> +  const char *merge_abstarget;
> +  svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
>   svn_wc_entry_t tmp_entry;
>
> +  SVN_ERR(svn_dirent_get_absolute(&merge_abstarget, merge_target,  
> pool));
> +
>   /* I miss Lisp. */
>
>   SVN_ERR(svn_io_open_uniquely_named(NULL,
> @@ -654,13 +658,10 @@
>
>   /* Back up MERGE_TARGET through detranslation/retranslation:
>      the new translation properties may not match the current ones */
> -  SVN_ERR(svn_wc_translated_file2(&detranslated_target_copy,
> -                                  merge_target,
> -                                  merge_target,
> -                                  adm_access,
> -                                  SVN_WC_TRANSLATE_TO_NF
> -                                  |  
> SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
> -                                  pool));
> +  SVN_ERR(svn_wc__internal_translated_file
> +          (&detranslated_target_copy, merge_abstarget, db,  
> merge_abstarget,
> +           SVN_WC_TRANSLATE_TO_NF |  
> SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
> +           pool, pool));
>   SVN_ERR(svn_wc__loggy_translated_file
>           (log_accum, adm_access,
>            target_copy, detranslated_target_copy, merge_target,  
> pool));
> Index: subversion/libsvn_wc/update_editor.c
> ===================================================================
> --- subversion/libsvn_wc/update_editor.c	(版本 38761)
> +++ subversion/libsvn_wc/update_editor.c	(工作副本)
> @@ -4452,11 +4452,10 @@
>
>           /* Copy and DEtranslate the working file to a temp text- 
> base.
>              Note that detranslation is done according to the old  
> props. */
> -          SVN_ERR(svn_wc_translated_file2(&tmptext, fb->path, fb- 
> >path,
> -                                          adm_access,
> -                                          SVN_WC_TRANSLATE_TO_NF
> -                                          |  
> SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
> -                                          pool));
> +          SVN_ERR(svn_wc__internal_translated_file
> +                  (&tmptext, local_abspath, eb->db, local_abspath,
> +                   SVN_WC_TRANSLATE_TO_NF |  
> SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
> +                   pool, pool));
>
>           /* A log command that copies the tmp-text-base and  
> REtranslates
>              it back to the working file.
>
> Best
> Huihuang
> ------------------				
> yellow.flying
> 2009-08-15
> ��i��'�ē扫h∈&
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2383814

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2383964


[PATCH]Use the library-internal version of translated_file()

Posted by HuiHuang <ye...@yahoo.com.cn>.
Hey,

Log:
[[[
Use the library-internal version of translated_file().

* subversion/libsvn_wc/diff.c
  (file_diff, report_wc_file_as_added, close_file): Call svn_wc__internal_translated_file() 
    in favor of svn_wc_translated_file2().

* subversion/libsvn_wc/log.c
  (install_committed_file): Call svn_wc__internal_translated_file()  in favor of 
    svn_wc_translated_file2().

* subversion/libsvn_wc/merge.c
  (preserve_pre_merge_files): Call svn_wc__internal_translated_file()  in favor of 
     svn_wc_translated_file2().

* subversion/libsvn_wc/update_editor.c
  (merge_file): Call svn_wc__internal_translated_file() in favor of svn_wc_translated_file2().
]]]

Modified:
    trunk/subversion/libsvn_wc/diff.c
    trunk/subversion/libsvn_wc/log.c
    trunk/subversion/libsvn_wc/merge.c
    trunk/subversion/libsvn_wc/update_editor.c

Index: subversion/libsvn_wc/diff.c
===================================================================
--- subversion/libsvn_wc/diff.c	(版本 38761)
+++ subversion/libsvn_wc/diff.c	(工作副本)
@@ -678,11 +678,10 @@
       SVN_ERR(get_working_mimetype(&working_mimetype, NULL, local_abspath,
                                    eb->db, pool, pool));
 
-      SVN_ERR(svn_wc_translated_file2
-              (&translated, path, path, adm_access,
-               SVN_WC_TRANSLATE_TO_NF
-               | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-               pool));
+      SVN_ERR(svn_wc__internal_translated_file
+              (&translated, local_abspath, eb->db, local_abspath,
+              SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+              pool, pool));
 
       SVN_ERR(dir_baton->edit_baton->callbacks->file_added
               (NULL, NULL, NULL, NULL, path,
@@ -710,12 +709,10 @@
              tmp translated copy too.  But what the heck, diff is
              already expensive, translating twice for the sake of code
              modularity is liveable. */
-          SVN_ERR(svn_wc_translated_file2
-                  (&translated, path,
-                   path, adm_access,
-                   SVN_WC_TRANSLATE_TO_NF
-                   | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-                   pool));
+          SVN_ERR(svn_wc__internal_translated_file
+                  (&translated, local_abspath, eb->db, local_abspath,
+                   SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+                   pool, pool));
         }
 
       if (modified || propchanges->nelts > 0)
@@ -1150,12 +1147,10 @@
   else
     source_file = path;
 
-  SVN_ERR(svn_wc_translated_file2
-          (&translated_file,
-           source_file, path, adm_access,
-           SVN_WC_TRANSLATE_TO_NF
-           | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-           pool));
+  SVN_ERR(svn_wc__internal_translated_file
+          (&translated_file, source_file, eb->db, local_abspath,
+           SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+           pool, pool));
 
   SVN_ERR(eb->callbacks->file_added
           (adm_access, NULL, NULL, NULL,
@@ -2428,12 +2423,10 @@
         localfile = svn_wc__text_base_path(b->path, FALSE, b->pool);
       else
         /* a detranslated version of the working file */
-        SVN_ERR(svn_wc_translated_file2
-                (&localfile, b->path,
-                 b->path, adm_access,
-                 SVN_WC_TRANSLATE_TO_NF
-                 | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
-                 pool));
+        SVN_ERR(svn_wc__internal_translated_file
+                (&localfile, local_abspath, eb->db, local_abspath,
+                 SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP,
+                 pool, pool));
     }
   else
     localfile = temp_file_path = NULL;
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c	(版本 38761)
+++ subversion/libsvn_wc/log.c	(工作副本)
@@ -363,11 +363,10 @@
   {
     const char *tmp = (kind == svn_node_file) ? tmp_text_base : filepath;
 
-    SVN_ERR(svn_wc_translated_file2(&tmp_wfile,
-                                    tmp,
-                                    filepath, adm_access,
-                                    SVN_WC_TRANSLATE_FROM_NF,
-                                    pool));
+    SVN_ERR(svn_wc__internal_translated_file(&tmp_wfile, tmp, db,
+                                             file_abspath,
+                                             SVN_WC_TRANSLATE_FROM_NF,
+                                             pool, pool));
 
     /* If the translation is a no-op, the text base and the working copy
      * file contain the same content, because we use the same props here
Index: subversion/libsvn_wc/merge.c
===================================================================
--- subversion/libsvn_wc/merge.c	(版本 38761)
+++ subversion/libsvn_wc/merge.c	(工作副本)
@@ -564,8 +564,12 @@
   const char *parent, *target_base;
   svn_wc_adm_access_t *parent_access;
   const char *adm_path = svn_wc_adm_access_path(adm_access);
+  const char *merge_abstarget;
+  svn_wc__db_t *db = svn_wc__adm_get_db(adm_access);
   svn_wc_entry_t tmp_entry;
 
+  SVN_ERR(svn_dirent_get_absolute(&merge_abstarget, merge_target, pool));
+
   /* I miss Lisp. */
 
   SVN_ERR(svn_io_open_uniquely_named(NULL,
@@ -654,13 +658,10 @@
 
   /* Back up MERGE_TARGET through detranslation/retranslation:
      the new translation properties may not match the current ones */
-  SVN_ERR(svn_wc_translated_file2(&detranslated_target_copy,
-                                  merge_target,
-                                  merge_target,
-                                  adm_access,
-                                  SVN_WC_TRANSLATE_TO_NF
-                                  | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
-                                  pool));
+  SVN_ERR(svn_wc__internal_translated_file
+          (&detranslated_target_copy, merge_abstarget, db, merge_abstarget,
+           SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
+           pool, pool));
   SVN_ERR(svn_wc__loggy_translated_file
           (log_accum, adm_access,
            target_copy, detranslated_target_copy, merge_target, pool));
Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c	(版本 38761)
+++ subversion/libsvn_wc/update_editor.c	(工作副本)
@@ -4452,11 +4452,10 @@
 
           /* Copy and DEtranslate the working file to a temp text-base.
              Note that detranslation is done according to the old props. */
-          SVN_ERR(svn_wc_translated_file2(&tmptext, fb->path, fb->path,
-                                          adm_access,
-                                          SVN_WC_TRANSLATE_TO_NF
-                                          | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
-                                          pool));
+          SVN_ERR(svn_wc__internal_translated_file
+                  (&tmptext, local_abspath, eb->db, local_abspath,
+                   SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
+                   pool, pool));
 
           /* A log command that copies the tmp-text-base and REtranslates
              it back to the working file.

Best
Huihuang
------------------				 
yellow.flying
2009-08-15
��i��'�ē扫h∈&

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2383814

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

Posted by Julian Foad <ju...@btopenworld.com>.
On Wed, 2009-08-12, yellow.flying wrote:
> I put "loggy_path()" changes into another patch. So you should  apply
> "Make loggy_path able to deal with absolute path" patch before 
> apply this patch. Thank you:)
[...]

Thanks!

Unfortunately it looks like you attached the wrong patch in this
message.

- Julian


> Modified:
>    trunk/subversion/include/svn_wc.h
>    trunk/subversion/libsvn_wc/deprecated.c
>    trunk/subversion/libsvn_wc/translate.c
>    trunk/subversion/libsvn_wc/translate.h
> 
> 
> 
> 
> Index: subversion/libsvn_wc/log.c
> ===================================================================
[...]

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382946

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

Posted by HuiHuang <ye...@yahoo.com.cn>.
Hey,

I put "loggy_path()" changes into another patch. So you should  apply
"Make loggy_path able to deal with absolute path" patch before 
apply this patch. Thank you:)

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.
]]]

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




Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c	(版本 38693)
+++ subversion/libsvn_wc/log.c	(工作副本)
@@ -1727,17 +1727,24 @@
 /* Return the portion of PATH that is relative to the working copy directory
  * to which ADM_ACCESS belongs, or SVN_WC_ENTRY_THIS_DIR if PATH is that
  * directory. PATH must not be outside that directory. */
-static const char *
-loggy_path(const char *path,
-           svn_wc_adm_access_t *adm_access)
+static svn_error_t *
+loggy_path(const char **loggy_path,
+           const char *path,
+           svn_wc_adm_access_t *adm_access, 
+           apr_pool_t *pool)
 {
+  const char *adm_abspath;
+  const char *abspath;
   const char *adm_path = svn_wc_adm_access_path(adm_access);
-  const char *local_path = svn_dirent_is_child(adm_path, path, NULL);
 
-  if (! local_path && strcmp(path, adm_path) == 0)
-    local_path = SVN_WC_ENTRY_THIS_DIR;
+  SVN_ERR(svn_dirent_get_absolute(&adm_abspath, adm_path, pool));
+  SVN_ERR(svn_dirent_get_absolute(&abspath, path, pool));
+  *loggy_path = svn_dirent_is_child(adm_abspath, abspath, NULL);
 
-  return local_path;
+  if (! (*loggy_path) && strcmp(abspath, adm_abspath) == 0)
+    *loggy_path = SVN_WC_ENTRY_THIS_DIR;
+
+  return SVN_NO_ERROR;
 }
 
 svn_error_t *
@@ -1746,14 +1753,15 @@
                      const char *src, const char *dst,
                      apr_pool_t *pool)
 {
-  svn_xml_make_open_tag(log_accum,
-                        pool,
-                        svn_xml_self_closing,
-                        SVN_WC__LOG_APPEND,
-                        SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(src, adm_access),
-                        SVN_WC__LOG_ATTR_DEST,
-                        loggy_path(dst, adm_access),
+  const char *loggy_path1;
+  const char *loggy_path2;
+
+  SVN_ERR(loggy_path(&loggy_path1, src, adm_access, pool));
+  SVN_ERR(loggy_path(&loggy_path2, dst, adm_access, pool));
+  svn_xml_make_open_tag(log_accum, pool,
+                        svn_xml_self_closing, SVN_WC__LOG_APPEND,
+                        SVN_WC__LOG_ATTR_NAME, loggy_path1,
+                        SVN_WC__LOG_ATTR_DEST, loggy_path2,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1766,9 +1774,12 @@
                         const char *path, svn_revnum_t revnum,
                         apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   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_path1,
                         SVN_WC__LOG_ATTR_REVISION,
                         apr_psprintf(pool, "%ld", revnum),
                         NULL);
@@ -1782,10 +1793,13 @@
                    const char *src_path, const char *dst_path,
                    apr_pool_t *pool)
 {
+  const char *loggy_path1;
+  const char *loggy_path2;
+  
+  SVN_ERR(loggy_path(&loggy_path1, src_path, adm_access, pool));
+  SVN_ERR(loggy_path(&loggy_path2, dst_path, adm_access, pool));
   return loggy_move_copy_internal(log_accum, FALSE, adm_access,
-                                  loggy_path(src_path, adm_access),
-                                  loggy_path(dst_path, adm_access),
-                                  pool);
+                                  loggy_path1, loggy_path2, pool);
 }
 
 svn_error_t *
@@ -1796,12 +1810,19 @@
                               const char *versioned,
                               apr_pool_t *pool)
 {
+  const char *loggy_path1;
+  const char *loggy_path2;
+  const char *loggy_path3;
+
+  SVN_ERR(loggy_path(&loggy_path1, src, adm_access, pool));
+  SVN_ERR(loggy_path(&loggy_path2, dst, adm_access, pool));
+  SVN_ERR(loggy_path(&loggy_path3, versioned, adm_access, pool));
   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_path1,
+     SVN_WC__LOG_ATTR_DEST, loggy_path2,
+     SVN_WC__LOG_ATTR_ARG_2, loggy_path3,
      NULL);
 
   return SVN_NO_ERROR;
@@ -1813,9 +1834,12 @@
                            const char *path,
                            apr_pool_t *pool)
 {
+  const char * loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   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_path1,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1827,9 +1851,12 @@
                           const char *path,
                           apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   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_path1,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1841,9 +1868,12 @@
                                 const char *path,
                                 apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   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_path1,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -1857,6 +1887,7 @@
                            apr_uint64_t modify_flags,
                            apr_pool_t *pool)
 {
+  const char *loggy_path1;
   apr_hash_t *prop_hash = apr_hash_make(pool);
   static const char *kind_str[] =
     { "none",
@@ -1987,8 +2018,9 @@
   if (apr_hash_count(prop_hash) == 0)
     return SVN_NO_ERROR;
 
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   apr_hash_set(prop_hash, SVN_WC__LOG_ATTR_NAME,
-               APR_HASH_KEY_STRING, loggy_path(path, adm_access));
+               APR_HASH_KEY_STRING, loggy_path1);
 
   svn_xml_make_open_tag_hash(log_accum, pool,
                              svn_xml_self_closing,
@@ -2007,14 +2039,14 @@
                             const char *propval,
                             apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   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),
-                        SVN_WC__LOG_ATTR_PROPNAME,
-                        propname,
-                        SVN_WC__LOG_ATTR_PROPVAL,
-                        propval,
+                        SVN_WC__LOG_ATTR_NAME, loggy_path1,
+                        SVN_WC__LOG_ATTR_PROPNAME, propname,
+                        SVN_WC__LOG_ATTR_PROPVAL, propval,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2026,10 +2058,13 @@
                    const char *src_path, const char *dst_path,
                    apr_pool_t *pool)
 {
+  const char *loggy_path1;
+  const char *loggy_path2;
+
+  SVN_ERR(loggy_path(&loggy_path1, src_path, adm_access, pool));
+  SVN_ERR(loggy_path(&loggy_path2, dst_path, adm_access, pool));
   return loggy_move_copy_internal(log_accum, TRUE, adm_access,
-                                  loggy_path(src_path, adm_access),
-                                  loggy_path(dst_path, adm_access),
-                                  pool);
+                                  loggy_path1, loggy_path2, pool);
 }
 
 svn_error_t *
@@ -2038,11 +2073,14 @@
                                    const char *path,
                                    apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   svn_xml_make_open_tag(log_accum,
                         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_path1,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2054,12 +2092,15 @@
                                  const char *path,
                                  apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   svn_xml_make_open_tag(log_accum,
                         pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_MAYBE_READONLY,
                         SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(path, adm_access),
+                        loggy_path1,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2071,12 +2112,15 @@
                                           const char *path,
                                           apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   svn_xml_make_open_tag(log_accum,
                         pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_MODIFY_ENTRY,
                         SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(path, adm_access),
+                        loggy_path1,
                         SVN_WC__ENTRY_ATTR_TEXT_TIME,
                         SVN_WC__TIMESTAMP_WC,
                         NULL);
@@ -2090,12 +2134,15 @@
                                                 const char *path,
                                                 apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   svn_xml_make_open_tag(log_accum,
                         pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_MODIFY_ENTRY,
                         SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(path, adm_access),
+                        loggy_path1,
                         SVN_WC__ENTRY_ATTR_WORKING_SIZE,
                         SVN_WC__WORKING_SIZE_WC,
                         NULL);
@@ -2109,12 +2156,15 @@
                            const char *path,
                            apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   svn_xml_make_open_tag(log_accum,
                         pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_READONLY,
                         SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(path, adm_access),
+                        loggy_path1,
                         NULL);
 
   return SVN_NO_ERROR;
@@ -2127,12 +2177,15 @@
                             const char *timestr,
                             apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   svn_xml_make_open_tag(log_accum,
                         pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_SET_TIMESTAMP,
                         SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(path, adm_access),
+                        loggy_path1,
                         SVN_WC__LOG_ATTR_TIMESTAMP,
                         timestr,
                         NULL);
@@ -2146,13 +2199,16 @@
                      const char *path,
                      apr_pool_t *pool)
 {
+  const char *loggy_path1;
+
+  SVN_ERR(loggy_path(&loggy_path1, path, adm_access, pool));
   /* No need to check whether BASE_NAME exists: ENOENT is ignored
      by the log-runner */
   svn_xml_make_open_tag(log_accum, pool,
                         svn_xml_self_closing,
                         SVN_WC__LOG_RM,
                         SVN_WC__LOG_ATTR_NAME,
-                        loggy_path(path, adm_access),
+                        loggy_path1,
                         NULL);
 
   return SVN_NO_ERROR;
Index: subversion/libsvn_wc/log.h
===================================================================
--- subversion/libsvn_wc/log.h	(版本 38693)
+++ subversion/libsvn_wc/log.h	(工作副本)
@@ -47,8 +47,8 @@
  */
 
 /* The svn_wc__loggy_* functions in this section take path arguments
-   with the same base as with which the adm_access was opened.
-
+   with the same base as with which the adm_access was opened except
+   that loggy_path function can take absolute path as argument.
 */
 
 /* Extend **LOG_ACCUM with log instructions to append the contents


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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382923

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

Posted by HuiHuang <ye...@yahoo.com.cn>.
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

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

Posted by Julian Foad <ju...@btopenworld.com>.
On Mon, 2009-08-10, Hyrum K. Wright wrote:
> On Aug 10, 2009, at 8:08 PM, HuiHuang wrote:
> >>>   * Output files are created in the temp file area belonging to
> >>> - * @a versioned_file.  By default they will be deleted at pool cleanup.
> >>> + * @a versioned_abspath. By default they will be deleted at scratch_pool cleanup.
> >>>   *
> >>>   * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
> >>> - * pool cleanup handler to remove @a *xlated_path is not registered.
> >>> + * result_pool cleanup handler to remove @a *xlated_path is not registered.
> >
> >> The first of these two paragraphs refers to "scratch_pool cleanup" and
> >> the second to "result_pool cleanup". Shouldn't they both refer to the
> >> same pool?
> > 
> > Originally the function use a single pool for memory allocation  
> > while now we use result_pool
> > for output variables and scratch_pool for the temp.
> >
> > The temp files are allocated from scratch_pool and xlated_path is  
> > allocated from result_pool,
> > that is why there is difference.
> >
> > That is what I think about it, is that right?
> 
> Are they both output values?  I believe so, and if that's the case  
> then they should both go in result_pool.

This function creates only ONE output file, which is the file named by
*xlated_path. (The plural wording, "Output files are created..." is
misleading and should be changed to "The output file is created...".)

Both of those paragraphs in the doc string are talking about this same
file. Therefore they MUST talk about the same pool. (And they should be
joined together as a single paragraph.)

So here is a re-write of that part of the doc string:

  * 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_path is
  * not registered.


> (This is actually a bit tricky, since the file isn't strictly an  
> output parameter, but it is instead a tangible side-effect of the  
> function, which we want to persist for some amount of time.  Stuff  
> allocated in scratch_pool isn't guaranteed to exist beyond the scope  
> of the function.)

I would say the generated file, and its name, together are the output of
this function. The result_pool is intended to be used for storing
results which have to be allocated somewhere in order to survive beyond
the end of the function. Although we most often use pools just for
storing data in memory, it is perfectly valid to use the pool also to
control the persistence of a file that has been created as an output of
the function.

- Julian

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382419

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

Posted by "Hyrum K. Wright" <hy...@hyrumwright.org>.
On Aug 10, 2009, at 8:08 PM, HuiHuang wrote:

> Hey Julian,
>
>>>  * Output files are created in the temp file area belonging to
>>> - * @a versioned_file.  By default they will be deleted at pool  
>>> cleanup.
>>> + * @a versioned_abspath. By default they will be deleted at  
>>> scratch_pool cleanup.
>>>  *
>>>  * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the  
>>> default
>>> - * pool cleanup handler to remove @a *xlated_path is not  
>>> registered.
>>> + * result_pool cleanup handler to remove @a *xlated_path is not  
>>> registered.
>
>> The first of these two paragraphs refers to "scratch_pool cleanup"  
>> and
>> the second to "result_pool cleanup". Shouldn't they both refer to the
>> same pool?
> Originally the function use a single pool for memory allocation  
> while now we use result_pool
> for output variables and scratch_pool for the temp.
>
> The temp files are allocated from scratch_pool and xlated_path is  
> allocated from result_pool,
> that is why there is difference.
>
> That is what I think about it, is that right?

Are they both output values?  I believe so, and if that's the case  
then they should both go in result_pool.

(This is actually a bit tricky, since the file isn't strictly an  
output parameter, but it is instead a tangible side-effect of the  
function, which we want to persist for some amount of time.  Stuff  
allocated in scratch_pool isn't guaranteed to exist beyond the scope  
of the function.)

-Hyrum

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382276

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

Posted by HuiHuang <ye...@yahoo.com.cn>.
Hey Julian,

>>   * Output files are created in the temp file area belonging to
>> - * @a versioned_file.  By default they will be deleted at pool cleanup.
>> + * @a versioned_abspath. By default they will be deleted at scratch_pool cleanup.
>>   *
>>   * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
>> - * pool cleanup handler to remove @a *xlated_path is not registered.
>> + * result_pool cleanup handler to remove @a *xlated_path is not registered.

>The first of these two paragraphs refers to "scratch_pool cleanup" and
>the second to "result_pool cleanup". Shouldn't they both refer to the
>same pool?
Originally the function use a single pool for memory allocation while now we use result_pool
for output variables and scratch_pool for the temp. 

The temp files are allocated from scratch_pool and xlated_path is allocated from result_pool,
that is why there is difference. 

That is what I think about it, is that right?

Thanks for you comment:)
Huihuang
------------------				 
yellow.flying
2009-08-11

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382273

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

Posted by "Hyrum K. Wright" <hy...@hyrumwright.org>.
On Aug 10, 2009, at 1:48 AM, HuiHuang wrote:

> Hey,
>
> My previous patch *remove adm_access in svn_wc_translated_file3*  
> cause several
> tests failed. I fix the issue and put them together in this patch. I  
> have run the whole
> tests and it fails in the following tests:
> db_tests.exe
> patch_tests.py
> svnlook_tests.py
> switch_tests.py
>
> But these tests also fail when I run tests without the patch. It  
> seems some
> Windows-special error happened:
> WindowsError: [Error 32] : 'svn-test-work\\local_tmp\\tmp3ncn20'
>
> Maybe it is not the fault of this patch. Would you mind to review  
> this patch
> and test it again on Linux? Thank you!

I get three test failures on OS X with and without your patch, so it  
doesn't look like it creates any new ones.

>
> 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	(revision 38658)
> +++ subversion/include/svn_wc.h	(working copy)
> @@ -5842,8 +5842,8 @@
>
> /** Set @a xlated_path 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_path to a copy of @a src
>  * whose newlines and keywords are converted using the translation
>  * as requested by @a flags.
>  *
> @@ -5857,20 +5857,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.
> + * @a versioned_abspath. By default they will be deleted at  
> scratch_pool cleanup.

Below, you create the tempfile in result_pool, so this comment should  
reflect that.

>  *
>  * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
> - * pool cleanup handler to remove @a *xlated_path is not registered.
> + * result_pool cleanup handler to remove @a *xlated_path is not  
> registered.
>  *
>  * If an error is returned, the effect on @a *xlated_path is  
> undefined.
>  *
> - * @since New in 1.4
> + * @since New in 1.7.
> + */
> +svn_error_t *
> +svn_wc_translated_file3(const char **xlated_path,
> +                        const char *src,

Are src and xlated_path absolute or relative?  If relative, relative  
to what?

I personally think we should make them absolute, since that better  
fits in with our goal of using absolute paths within the working copy  
library.

> +                        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.
> + * @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	(revision 38658)
> +++ subversion/libsvn_wc/deprecated.c	(working copy)
> @@ -2100,6 +2100,28 @@
>   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;
> +  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_wc_translated_file3() does return an absolute path, we may need  
to adjust it here before returning it to callers of  
svn_wc_translated_file2().

> +
> +  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/log.c
> ===================================================================
> --- subversion/libsvn_wc/log.c	(revision 38658)
> +++ subversion/libsvn_wc/log.c	(working copy)
> @@ -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;
> Index: subversion/libsvn_wc/translate.c
> ===================================================================
> --- subversion/libsvn_wc/translate.c	(revision 38658)
> +++ subversion/libsvn_wc/translate.c	(working copy)
> @@ -169,26 +169,27 @@
>
>
> 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_path,
> +                                 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;
>   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));
> +

Unneeded extra vertical whitespace.

> +  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));
> +                                result_pool, scratch_pool));

The result doesn't need to be available beyond this function, so use  
scratch_pool for both pool parameters here.

> +  SVN_ERR(svn_wc__get_keywords(&keywords, db, versioned_abspath,  
> NULL,
> +                               result_pool, scratch_pool));

Same.

> +  SVN_ERR(svn_wc__get_special(&special, db, versioned_abspath,  
> result_pool));

Again, you can use scratch_pool here.

>
>   if (! svn_subst_translation_required(style, eol, keywords,  
> special, TRUE)
>       && (! (flags & SVN_WC_TRANSLATE_FORCE_COPY)))
> @@ -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,  
> result_pool),

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,7 +246,7 @@
>                                             keywords,
>                                             expand,
>                                             special,
> -                                            pool));
> +                                            result_pool));
>
>       *xlated_path = tmp_vfile;
>     }
> @@ -252,7 +254,21 @@
>   return SVN_NO_ERROR;
> }
>
> +svn_error_t *
> +svn_wc_translated_file3(const char **xlated_path,
> +                        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_path, 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	(revision 38658)
> +++ subversion/libsvn_wc/translate.h	(working copy)
> @@ -133,7 +133,17 @@
>                                    apr_pool_t *result_pool,
>                                    apr_pool_t *scratch_pool);
>
> +/* Internal version of svn_wc_translated_file3(). */
> +svn_error_t *
> +svn_wc__internal_translated_file(const char **xlated_path,
> +                                 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 */

-Hyrum

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2382095

[PATCH]remove adm_access batons in svn_wc_translated_file3()

Posted by HuiHuang <ye...@yahoo.com.cn>.
Hey,

My previous patch *remove adm_access in svn_wc_translated_file3* cause several
tests failed. I fix the issue and put them together in this patch. I have run the whole
tests and it fails in the following tests:
db_tests.exe
patch_tests.py
svnlook_tests.py
switch_tests.py

But these tests also fail when I run tests without the patch. It seems some
Windows-special error happened:
WindowsError: [Error 32] : 'svn-test-work\\local_tmp\\tmp3ncn20'

Maybe it is not the fault of this patch. Would you mind to review this patch
and test it again on Linux? Thank you!

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	(revision 38658)
+++ subversion/include/svn_wc.h	(working copy)
@@ -5842,8 +5842,8 @@
 
 /** Set @a xlated_path 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_path to a copy of @a src
  * whose newlines and keywords are converted using the translation
  * as requested by @a flags.
  *
@@ -5857,20 +5857,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.
+ * @a versioned_abspath. By default they will be deleted at scratch_pool cleanup.
  *
  * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
- * pool cleanup handler to remove @a *xlated_path is not registered.
+ * result_pool cleanup handler to remove @a *xlated_path is not registered.
  *
  * If an error is returned, the effect on @a *xlated_path is undefined.
  *
- * @since New in 1.4
+ * @since New in 1.7.
+ */ 
+svn_error_t *
+svn_wc_translated_file3(const char **xlated_path,
+                        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.
+ * @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	(revision 38658)
+++ subversion/libsvn_wc/deprecated.c	(working copy)
@@ -2100,6 +2100,28 @@
   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;
+  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));
+
+  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/log.c
===================================================================
--- subversion/libsvn_wc/log.c	(revision 38658)
+++ subversion/libsvn_wc/log.c	(working copy)
@@ -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;
Index: subversion/libsvn_wc/translate.c
===================================================================
--- subversion/libsvn_wc/translate.c	(revision 38658)
+++ subversion/libsvn_wc/translate.c	(working copy)
@@ -169,26 +169,27 @@
 
 
 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_path,
+                                 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;
   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));
+                                result_pool, scratch_pool));
+  SVN_ERR(svn_wc__get_keywords(&keywords, db, versioned_abspath, NULL, 
+                               result_pool, scratch_pool));
+  SVN_ERR(svn_wc__get_special(&special, db, versioned_abspath, result_pool));
 
   if (! svn_subst_translation_required(style, eol, keywords, special, TRUE)
       && (! (flags & SVN_WC_TRANSLATE_FORCE_COPY)))
@@ -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, result_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,7 +246,7 @@
                                             keywords,
                                             expand,
                                             special,
-                                            pool));
+                                            result_pool));
 
       *xlated_path = tmp_vfile;
     }
@@ -252,7 +254,21 @@
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_wc_translated_file3(const char **xlated_path,
+                        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_path, 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	(revision 38658)
+++ subversion/libsvn_wc/translate.h	(working copy)
@@ -133,7 +133,17 @@
                                    apr_pool_t *result_pool,
                                    apr_pool_t *scratch_pool);
 
+/* Internal version of svn_wc_translated_file3(). */
+svn_error_t *
+svn_wc__internal_translated_file(const char **xlated_path,
+                                 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 */

Best~
Huihuang
------------------				 
yellow.flying
2009-08-10

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381981

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by "Hyrum K. Wright" <hy...@hyrumwright.org>.
On Aug 7, 2009, at 5:21 AM, Stefan Sperling wrote:

> On Fri, Aug 07, 2009 at 09:55:36AM +0800, HuiHuang wrote:
>>> Did you run the regression tests on this patch?  I get the following
>>> errors:
>>
>>> At least one test FAILED, checking /Users/Hyrum/dev/svn-trunk2/ 
>>> tests.log
>>> FAIL:  merge_tests.py 40: conflict markers should match the file's  
>>> eol
>>> style
>>> FAIL:  special_tests.py 8: merge file into symlink
>>> FAIL:  trans_tests.py 2: update modified file with eol-style  
>>> 'native'
>>> FAIL:  update_tests.py 27: conflict markers should match the file's
>>> eol style
>>> FAIL:  update_tests.py 28: handle eol-style propchange during update
>> Sorry for the failures.
>>
>> hmm...I want to know how do you run the tests?
>
> On Linux, you can run 'make check'.
> On windows, there is a script called win-tests.py. Run that script
> to run all tests.
>
>> Should I run the entire test everytime I make a new patch?
>
> Yes! Please run *all* tests before submitting a patch.
>
>> There are more than 70 tests and it would take a lot of time to
>> run all tests.
>
> Test failures often pop up in unexpected places. For example,
> your last patch broke copy test 66 and because none of us tested
> the copy tests before commit (I just ran the commit tests) this
> wasn't noticed at first. So I, too, should have run the entire
> test suite...

Let me just second this, especially when working with wc-ng.  Almost  
every test hits the working copy, and most exercise it in different  
ways.  We currently have 1145 tests that expected to pass, and some of  
my initial patches only fail on one or two of them.  Running the  
entire test suite means I get lots of testing on my patch, and I don't  
have to guess where the 0.2% of tests that fail might be.

> We are trying to keep the entire test suite running for everyone,
> all the time. Because when you make a change and you see a test
> failure, you have to go and figure out if your own change broke
> the test of if some other change broke it. When too many tests keep
> failing, it is very hard and time-consuming to verify your own changes
> and the test suite becomes useless. We were in such a situation
> sometimes and it really, really sucked.
>
> The test suite also takes about an hour to run for me. But as long as
> it is just my computer spending the time and not myself, I don't  
> really
> care. I can do something else while the tests are running, e.g. read
> mail or put up the laundry or something.

I can usually run the entire test suite in about 35 minutes, but I've  
got multiple working copies, so that while one is running tests, I can  
be hacking something (usually unrelated) else in the other.

-Hyrum

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381259

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by Stefan Sperling <st...@elego.de>.
On Fri, Aug 07, 2009 at 09:55:36AM +0800, HuiHuang wrote:
> >Did you run the regression tests on this patch?  I get the following  
> >errors:
> 
> >At least one test FAILED, checking /Users/Hyrum/dev/svn-trunk2/tests.log
> >FAIL:  merge_tests.py 40: conflict markers should match the file's eol  
> >style
> >FAIL:  special_tests.py 8: merge file into symlink
> >FAIL:  trans_tests.py 2: update modified file with eol-style 'native'
> >FAIL:  update_tests.py 27: conflict markers should match the file's  
> >eol style
> >FAIL:  update_tests.py 28: handle eol-style propchange during update
> Sorry for the failures.
> 
> hmm...I want to know how do you run the tests?

On Linux, you can run 'make check'.
On windows, there is a script called win-tests.py. Run that script
to run all tests.

> Should I run the entire test everytime I make a new patch?

Yes! Please run *all* tests before submitting a patch.

> There are more than 70 tests and it would take a lot of time to
> run all tests.

Test failures often pop up in unexpected places. For example,
your last patch broke copy test 66 and because none of us tested
the copy tests before commit (I just ran the commit tests) this
wasn't noticed at first. So I, too, should have run the entire
test suite...

We are trying to keep the entire test suite running for everyone,
all the time. Because when you make a change and you see a test
failure, you have to go and figure out if your own change broke
the test of if some other change broke it. When too many tests keep
failing, it is very hard and time-consuming to verify your own changes
and the test suite becomes useless. We were in such a situation
sometimes and it really, really sucked.

The test suite also takes about an hour to run for me. But as long as
it is just my computer spending the time and not myself, I don't really
care. I can do something else while the tests are running, e.g. read
mail or put up the laundry or something.

Stefan

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381243

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by Branko Cibej <br...@xbc.nu>.
HuiHuang wrote:
>> Did you run the regression tests on this patch?  I get the following  
>> errors:
>>     
>
>   
>> At least one test FAILED, checking /Users/Hyrum/dev/svn-trunk2/tests.log
>> FAIL:  merge_tests.py 40: conflict markers should match the file's eol  
>> style
>> FAIL:  special_tests.py 8: merge file into symlink
>> FAIL:  trans_tests.py 2: update modified file with eol-style 'native'
>> FAIL:  update_tests.py 27: conflict markers should match the file's  
>> eol style
>> FAIL:  update_tests.py 28: handle eol-style propchange during update
>>     
> Sorry for the failures.
>
> hmm...I want to know how do you run the tests? Should I run the entire
> test everytime I make a new patch? There are more than 70 tests and it
> would take a lot of time to run all tests.
>   

You can run each Python test module separately, and even pick individual
tests; see subversion/tests/cmdline/README for details.

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381212

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by HuiHuang <ye...@yahoo.com.cn>.
>Did you run the regression tests on this patch?  I get the following  
>errors:

>At least one test FAILED, checking /Users/Hyrum/dev/svn-trunk2/tests.log
>FAIL:  merge_tests.py 40: conflict markers should match the file's eol  
>style
>FAIL:  special_tests.py 8: merge file into symlink
>FAIL:  trans_tests.py 2: update modified file with eol-style 'native'
>FAIL:  update_tests.py 27: conflict markers should match the file's  
>eol style
>FAIL:  update_tests.py 28: handle eol-style propchange during update
Sorry for the failures.

hmm...I want to know how do you run the tests? Should I run the entire
test everytime I make a new patch? There are more than 70 tests and it
would take a lot of time to run all tests.


Best 
Huihuang
------------------				 
yellow.flying
2009-08-07

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

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2381140

Re: [PATCH]remove adm_access in svn_wc_translated_file3

Posted by "Hyrum K. Wright" <hy...@hyrumwright.org>.
On Aug 6, 2009, at 3:36 AM, HuiHuang wrote:

> Hey,
>
> When I try to modify some callers to svn_wc_transmit_prop_deltas2(),  
> I find
> many functions also refer to svn_wc_translated_file2(). So I remove
> adm_access batons in svn_wc_translated_file2() first.

Did you run the regression tests on this patch?  I get the following  
errors:

At least one test FAILED, checking /Users/Hyrum/dev/svn-trunk2/tests.log
FAIL:  merge_tests.py 40: conflict markers should match the file's eol  
style
FAIL:  special_tests.py 8: merge file into symlink
FAIL:  trans_tests.py 2: update modified file with eol-style 'native'
FAIL:  update_tests.py 27: conflict markers should match the file's  
eol style
FAIL:  update_tests.py 28: handle eol-style propchange during update

>
> 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.
> ]]]
>
> Modified:
>   trunk/subversion/include/svn_wc.h
>   trunk/subversion/libsvn_wc/deprecated.c
>   trunk/subversion/libsvn_wc/translate.c
>   trunk/subversion/libsvn_wc/translate.h
>
>
>
> Index: subversion/include/svn_wc.h
> ===================================================================
> --- subversion/include/svn_wc.h	(revision 38574)
> +++ subversion/include/svn_wc.h	(working copy)
> @@ -5842,8 +5842,8 @@
>
> /** Set @a xlated_path 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_path to a copy of @a src
>  * whose newlines and keywords are converted using the translation
>  * as requested by @a flags.
>  *
> @@ -5857,20 +5857,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.
> + * @a versioned_abspath. By default they will be deleted at  
> scratch_pool cleanup.
>  *
>  * If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the default
> - * pool cleanup handler to remove @a *xlated_path is not registered.
> + * result_pool cleanup handler to remove @a *xlated_path is not  
> registered.
>  *
>  * If an error is returned, the effect on @a *xlated_path is  
> undefined.
>  *
> - * @since New in 1.4
> + * @since New in 1.7.
> + */
> +svn_error_t *
> +svn_wc_translated_file3(const char **xlated_path,
> +                        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.
> + * @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	(revision 38574)
> +++ subversion/libsvn_wc/deprecated.c	(working copy)
> @@ -2100,6 +2100,28 @@
>   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;
> +  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 /* config */,
> +                                          
> svn_wc__adm_get_db(adm_access),
> +                                         pool));
> +
> +  SVN_ERR(svn_wc_translated_file3(xlated_path, src, wc_ctx,  
> versioned_abspath,
> +                                  flags, pool, 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	(revision 38574)
> +++ subversion/libsvn_wc/translate.c	(working copy)
> @@ -169,26 +169,27 @@
>
>
> 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_path,
> +                                 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;
>   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));
> +                                result_pool, scratch_pool));
> +  SVN_ERR(svn_wc__get_keywords(&keywords, db, versioned_abspath,  
> NULL,
> +                               result_pool, scratch_pool));
> +  SVN_ERR(svn_wc__get_special(&special, db, versioned_abspath,  
> result_pool));
>
>   if (! svn_subst_translation_required(style, eol, keywords,  
> special, TRUE)
>       && (! (flags & SVN_WC_TRANSLATE_FORCE_COPY)))
> @@ -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,  
> result_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,7 +246,7 @@
>                                             keywords,
>                                             expand,
>                                             special,
> -                                            pool));
> +                                            result_pool));
>
>       *xlated_path = tmp_vfile;
>     }
> @@ -252,7 +254,21 @@
>   return SVN_NO_ERROR;
> }
>
> +svn_error_t *
> +svn_wc_translated_file3(const char **xlated_path,
> +                        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_path, 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	(revision 38574)
> +++ subversion/libsvn_wc/translate.h	(working copy)
> @@ -133,7 +133,17 @@
>                                    apr_pool_t *result_pool,
>                                    apr_pool_t *scratch_pool);
>
> +/* Internal version of svn_wc_translated_file3(). */
> +svn_error_t *
> +svn_wc__internal_translated_file(const char **xlated_path,
> +                                 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 */
>
> Best Wishes!
> Huihuang
> 				
> --------------
> yellow.flying
> 2009-08-06
>
> __________________________________________________
> 赶快注册雅虎超大容量免费邮箱?
> http://cn.mail.yahoo.com
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2380739

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2380962