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

[PATCH] Disambiguate (de)translation; followup (v3)

From: Erik Huelsmann <ehuels_at_gmail.com>
Date: 2005-11-20 14:59:20 CET

Ok, I think I addressed all concerns in the patch below. If we're 99%
there, I think I can commit and work from there.

Looking forward to your comments :-)

bye,

Erik.

Log:
[[[
Followup to r17362.

Suggested by: julianfoad
                     malcolm

* subversion/include/svn_subst.h:
  Doc string expansions, including elimination 'detranslate'-like words.

* subversion/include/svn_wc.h
 (SVN_WC_TRANSLATE_FROM_NF,
  SVN_WC_TRANSLATE_TO_NF): Expand docstrings. Renumber too.
 (SVN_WC_TRANSLATE_SPECIAL_ONLY): Remove. It exposes too
  much internal detail - and adds next to no optimization as soon as
  wc-propcaching is merged.
 (SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP): Replaces (and inverts) the
  SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP flag.
 (svn_wc_translated_file2): Expand doc string.

* subversion/libsvn_wc/translate.c
 (svn_wc_translated_file2): Support new and changed flags.

* subversion/libsvn_wc/merge.c
* subversion/libsvn_wc/diff.c
* subversion/libsvn_wc/adm_crawler.c
* subversion/libsvn_wc/update_editor.c
* subversion/libsvn_wc/questions.c
 Update callers.
]]]

Index: subversion/include/svn_subst.h
===================================================================
--- subversion/include/svn_subst.h (revision 17455)
+++ subversion/include/svn_subst.h (working copy)
@@ -260,8 +260,9 @@

 /**
  * Convenience routine: a variant of svn_subst_translate_stream3()
- * which operates on files. In addition, it will create/detranslate a special
- * file if @a special is @c TRUE.
+ * which operates on files. In addition, it will create a special file
+ * from normal form or translate one toto normal form if @a special
+ * is @c TRUE.
  *
  * Copy the contents of file-path @a src to file-path @a dst atomically,
  * either creating @a dst (or overwriting @a dst if it exists), possibly
@@ -356,7 +357,9 @@
                              apr_pool_t *pool);

 /** Convenience routine (wrapper around svn_subst_copy_and_translate3)
- * which detranslates the given @a src into @a dst.
+ * which translates a normal form @a src into a working copy form @a dst.
+ * The parameters specified should be those immediately taken from the files'
+ * properties.
  *
  * The values specified for @a eol_style, @a *eol_str, @a keywords and
  * @a special, should be the ones used to translate the file to its
@@ -368,6 +371,10 @@
  * returned. By setting @a always_repair_eols to @c TRUE, eols will be
  * made consistent even for those styles which don't have it by default.
  *
+ * @note The API doesn't provide a svn_subst_translate_from_normal_form
+ * because it would look too much like
+ * svn_subst_copy_and_translate3.
+ *
  * @since New in 1.4
  *
  */
Index: subversion/include/svn_wc.h
===================================================================
--- subversion/include/svn_wc.h (revision 17455)
+++ subversion/include/svn_wc.h (working copy)
@@ -64,15 +64,24 @@
  * @{
  */

- /** Translate from Normal Format; excludes SVN_WC_TRANSLATE_TO_NF */
-#define SVN_WC_TRANSLATE_FROM_NF 0x00000000
+ /** Translate from Normal Form.
+ *
+ * The working copy text bases and repository files are stored
+ * in normal form if they have any svn: properties set which
+ * require translation.
+ *
+ * Either this flag or @c SVN_WC_TRANSLATE_FROM_NF should be specified,
+ * but not both.
+ */
+#define SVN_WC_TRANSLATE_FROM_NF 0x00000001

- /** Translate to Normal Format; excludes SVN_WC_TRANSLATE_FROM_NF */
-#define SVN_WC_TRANSLATE_TO_NF 0x00000001
+ /** Translate to Normal Form.
+ *
+ * Either this flag or @c SVN_WC_TRANSLATE_FROM_NF should be specified,
+ * but not both.
+ */
+#define SVN_WC_TRANSLATE_TO_NF 0x00000002

- /** Only do translation associated with the svn:special property only */
-#define SVN_WC_TRANSLATE_SPECIAL_ONLY 0x00000002
-
   /** Force repair of eol styles, making sure the output file consistently
    * contains the one eol style as specified by the svn:eol-style
    * property and the required translation direction.
@@ -80,8 +89,8 @@
    */
 #define SVN_WC_TRANSLATE_FORCE_EOL_REPAIR 0x00000004

- /** Translate the special property only */
-#define SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP 0x00000008
+ /** Don't register a pool cleanup to delete the output file */
+#define SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP 0x00000008

   /** Guarantee a new file is created on successful return.
    * The default shortcuts translation by returning the path
@@ -3168,14 +3177,20 @@
 
 /* EOL conversion and keyword expansion. */

-/** Set @a *xlated_path to a path to translated copy of @src
+/** Set @a *xlated_path to a path to a translated copy of @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
  * whose newlines and keywords are converted using the translation
  * as requested by @a flags.
  *
- * Caller can explicitly request a new file to be returned by setting the
+ * When translating to the normal form, inconsistent eol styles will be
+ * repaired when appropriate for the given setting. When translating
+ * from normal form, no EOL repair is performed (consistency is assumed).
+ * These behaviours can be overridden by specifying either
+ * @c SVN_WC_TRANSLATE_NO_EOL_REPAIR or @c SVN_WC_TRANSLATE_FORCE_EOL_REPAIR.
+ *
+ * The caller can explicitly request a new file to be returned by setting the
  * @c SVN_WC_TRANSLATE_FORCE_COPY flag in @a flags.
  *
  * This function is generally used to get a file that can be compared
@@ -3183,14 +3198,13 @@
  * @c SVN_WC_TRANSLATE_TO_NF is specified, against @a versioned_file itself
  * if @c SVN_WC_TRANSLATE_FROM_NF is specified.
  *
- * Temporary files are created in the temp file area belonging to
- * @a versioned_file.
+ * Output files are created in the temp file area belonging to
+ * @a versioned_file. By default they will be deleted at pool cleanup.
  *
- * If @c SVN_WC_TRANSLATE_DEL_TEMP_ON_POOL_CLEANUP is specified,
- * a pool cleanup handler is registered on *xlated_p if it points to a
- * temporary file.
+ * 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_p is undefined.
+ * If an error is returned, the effect on @a *xlated_path is undefined.
  *
  * @since New in 1.4
  */
Index: subversion/libsvn_wc/merge.c
===================================================================
--- subversion/libsvn_wc/merge.c (revision 17455)
+++ subversion/libsvn_wc/merge.c (working copy)
@@ -75,7 +75,6 @@
                (&tmp_target, merge_target,
                 merge_target, adm_access,
                 SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP
                 | SVN_WC_TRANSLATE_FORCE_COPY, pool));

       /* Open a second temporary file for writing; this is where diff3
Index: subversion/libsvn_wc/diff.c
===================================================================
--- subversion/libsvn_wc/diff.c (revision 17455)
+++ subversion/libsvn_wc/diff.c (working copy)
@@ -565,8 +565,7 @@

       SVN_ERR (svn_wc_translated_file2
                (&translated, path, path, adm_access,
- SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,
+ SVN_WC_TRANSLATE_TO_NF,
                 pool));

       SVN_ERR (dir_baton->edit_baton->callbacks->file_added
@@ -594,8 +593,7 @@
           SVN_ERR (svn_wc_translated_file2
                    (&translated, path,
                     path, adm_access,
- SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,
+ SVN_WC_TRANSLATE_TO_NF,
                     pool));
         }

@@ -1223,8 +1221,7 @@
             SVN_ERR (svn_wc_translated_file2
                      (&localfile, b->path,
                       b->path, adm_access,
- SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP ,
+ SVN_WC_TRANSLATE_TO_NF,
                       pool));

           temp_file_path = b->temp_file_path;
Index: subversion/libsvn_wc/adm_crawler.c
===================================================================
--- subversion/libsvn_wc/adm_crawler.c (revision 17455)
+++ subversion/libsvn_wc/adm_crawler.c (working copy)
@@ -74,7 +74,6 @@
   SVN_ERR (svn_wc_translated_file2 (&tmp_file,
                                     text_base_path, file_path, adm_access,
                                     SVN_WC_TRANSLATE_FROM_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP
                                     | SVN_WC_TRANSLATE_FORCE_COPY, pool));

   SVN_ERR (svn_io_file_rename (tmp_file, file_path, pool));
@@ -720,8 +719,7 @@
      the new text base anyway. */
   SVN_ERR (svn_wc_translated_file2 (&tmpf, path, path,
                                     adm_access,
- SVN_WC_TRANSLATE_TO_NF
- |
SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,+
       SVN_WC_TRANSLATE_TO_NF,
                                     pool));

   /* If the translation didn't create a new file then we need an explicit
Index: subversion/libsvn_wc/log.c
===================================================================
--- subversion/libsvn_wc/log.c (revision 17455)
+++ subversion/libsvn_wc/log.c (working copy)
@@ -237,7 +237,7 @@
           svn_error_clear (err);
         }
       break;
-
+
     case svn_wc__xfer_cp:
       return svn_io_copy_file (full_from_path, full_dest_path, FALSE, pool);

@@ -246,14 +246,11 @@
         const char *tmp_file;

         err = svn_wc_translated_file2
- (&tmp_file,
- full_from_path,
- full_dest_path, adm_access,
- SVN_WC_TRANSLATE_FROM_NF
- | SVN_WC_TRANSLATE_FORCE_COPY
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP
- | (special_only ? SVN_WC_TRANSLATE_SPECIAL_ONLY : 0),
- pool);
+ (&tmp_file,
+ full_from_path, full_dest_path, adm_access,
+ SVN_WC_TRANSLATE_FROM_NF
+ | SVN_WC_TRANSLATE_FORCE_COPY,
+ pool);
         if (err)
           {
             if (! rerun || ! APR_STATUS_IS_ENOENT(err->apr_err))
@@ -280,9 +277,7 @@
                   full_from_path,
                   full_from_path, adm_access,
                   SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_FORCE_COPY
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP
- | (special_only ? SVN_WC_TRANSLATE_SPECIAL_ONLY : 0),
+ | SVN_WC_TRANSLATE_FORCE_COPY,
                   pool));
         SVN_ERR (svn_io_file_rename (tmp_file, full_dest_path, pool));

@@ -371,7 +366,6 @@
                                        ? tmp_text_base : filepath,
                                     filepath, adm_access,
                                     SVN_WC_TRANSLATE_FROM_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP
                                     | SVN_WC_TRANSLATE_FORCE_COPY,
                                     pool));

Index: subversion/libsvn_wc/update_editor.c
===================================================================
--- subversion/libsvn_wc/update_editor.c (revision 17455)
+++ subversion/libsvn_wc/update_editor.c (working copy)
@@ -2008,7 +2008,8 @@
          to a tmp-text-base. */
       SVN_ERR (svn_wc_translated_file2 (&tmptext, file_path, file_path,
                                         adm_access,
- SVN_WC_TRANSLATE_TO_NF,
+ SVN_WC_TRANSLATE_TO_NF
+ | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
                                         pool));

       tmptext = svn_path_is_child (parent_dir, tmptext, pool);
Index: subversion/libsvn_wc/questions.c
===================================================================
--- subversion/libsvn_wc/questions.c (revision 17455)
+++ subversion/libsvn_wc/questions.c (working copy)
@@ -230,15 +230,13 @@
     SVN_ERR (svn_wc_translated_file2
              (&tmp_vfile, versioned_file,
               versioned_file, adm_access,
- SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,
+ SVN_WC_TRANSLATE_TO_NF,
               pool));
   else
     SVN_ERR (svn_wc_translated_file2
              (&tmp_vfile, base_file,
               versioned_file, adm_access,
- SVN_WC_TRANSLATE_FROM_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,
+ SVN_WC_TRANSLATE_FROM_NF,
               pool));

   SVN_ERR (svn_io_files_contents_same_p (&same, tmp_vfile,
@@ -277,15 +275,13 @@
     SVN_ERR (svn_wc_translated_file2
              (&tmp_vfile, versioned_file,
               versioned_file, adm_access,
- SVN_WC_TRANSLATE_TO_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,
+ SVN_WC_TRANSLATE_TO_NF,
               pool));
   else
     SVN_ERR (svn_wc_translated_file2
              (&tmp_vfile, base_file,
               versioned_file, adm_access,
- SVN_WC_TRANSLATE_FROM_NF
- | SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP,
+ SVN_WC_TRANSLATE_FROM_NF,
               pool));

Index: subversion/libsvn_wc/translate.c
===================================================================
--- subversion/libsvn_wc/translate.c (revision 17455)
+++ subversion/libsvn_wc/translate.c (working copy)
@@ -49,24 +49,17 @@
                          apr_uint32_t flags,
                          apr_pool_t *pool)
 {
- svn_subst_eol_style_t style = svn_subst_eol_style_none;
- const char *eol = NULL;
- apr_hash_t *keywords = NULL;
+ svn_subst_eol_style_t style;
+ const char *eol;
+ apr_hash_t *keywords;
   svn_boolean_t special;
- const char *tmp_dir, *tmp_vfile;
- svn_boolean_t special_only = flags & SVN_WC_TRANSLATE_SPECIAL_ONLY;

- svn_path_split (versioned_file, &tmp_dir, &tmp_vfile, pool);
+ assert (flags & (SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_FROM_NF));

- tmp_vfile = svn_wc__adm_path (tmp_dir, 1, pool, tmp_vfile, NULL);
-
- if (! special_only)
- {
- SVN_ERR (svn_wc__get_eol_style (&style, &eol, versioned_file,
- adm_access, pool));
- SVN_ERR (svn_wc__get_keywords (&keywords, versioned_file,
- adm_access, NULL, pool));
- }
+ SVN_ERR (svn_wc__get_eol_style (&style, &eol, versioned_file,
+ adm_access, pool));
+ SVN_ERR (svn_wc__get_keywords (&keywords, versioned_file,
+ adm_access, NULL, pool));
   SVN_ERR (svn_wc__get_special (&special, versioned_file, adm_access, pool));

@@ -79,26 +72,34 @@
     }
   else /* some translation (or copying) is necessary */
     {
+ const char *tmp_dir, *tmp_vfile;
+ svn_boolean_t repair_forced = flags & SVN_WC_TRANSLATE_FORCE_EOL_REPAIR;
+
+ svn_path_split (versioned_file, &tmp_dir, &tmp_vfile, pool);
+ tmp_vfile = svn_wc__adm_path (tmp_dir, 1, pool, tmp_vfile, NULL);
+
       SVN_ERR (svn_io_open_unique_file2
                (NULL, &tmp_vfile,
                 tmp_vfile,
                 SVN_WC__TMP_EXT,
- (flags & SVN_WC_TRANSLATE_DEL_TMP_ON_POOL_CLEANUP)
- ? svn_io_file_del_on_pool_cleanup : svn_io_file_del_none,
+ (flags & SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP)
+ ? svn_io_file_del_none : svn_io_file_del_on_pool_cleanup,
                 pool));

       if (flags & SVN_WC_TRANSLATE_TO_NF)
+ /* to normal form */
         SVN_ERR (svn_subst_translate_to_normal_form
                  (src, tmp_vfile, style, eol,
- flags & SVN_WC_TRANSLATE_FORCE_EOL_REPAIR,
+ repair_forced,
                   keywords, special, pool));
- else /* translate */
+ else /* from normal form */
         SVN_ERR (svn_subst_copy_and_translate3
                  (src, tmp_vfile,
- eol, flags & SVN_WC_TRANSLATE_FORCE_EOL_REPAIR,
+ eol, repair_forced,
                   keywords, TRUE,
                   special,
                   pool));
+
       *xlated_path = tmp_vfile;
     }
Received on Sun Nov 20 15:00:12 2005

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

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