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

Re: Keywords as hash

From: John Peacock <jpeacock_at_rowman.com>
Date: 2005-09-21 03:34:44 CEST

Julian Foad wrote:
> Throughout this patch (except for one instance) you initialise the
> pointer to NULL, but in all cases it is being passed to
> svn_wc__get_keywords() which doesn't require it.

Right, because most of this predates Max's choice to handle NULL as a special
case in svn_subst_copy_and_translate3() and I didn't clean that usage up.

> Because of these, I recommend that svn_wc__get_keywords set *KEYWORDS to
> NULL if there are none (like it did before).

OK, here's a new patch (same log) which doesn't initialize the variables and has
svn_wc__get_keywords() set *KEYWORDS to NULL if there are no keywords. As soon
as I get a first pass log entry, I'll send along the libsvn_client patch.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

=== subversion/libsvn_wc/merge.c
==================================================================
--- subversion/libsvn_wc/merge.c (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/merge.c (/local/kwhash2) (revision 15743)
@@ -48,7 +48,7 @@
   const char *mt_pt, *mt_bn;
   apr_file_t *tmp_f, *result_f;
   svn_boolean_t is_binary;
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
   const char *eol;
   const svn_wc_entry_t *entry;
   svn_boolean_t contains_conflicts, special;
@@ -235,12 +235,12 @@
                                           pool));
           SVN_ERR (svn_wc__get_special (&special, merge_target, adm_access,
                                         pool));
- SVN_ERR (svn_subst_copy_and_translate2 (left,
+ SVN_ERR (svn_subst_copy_and_translate3 (left,
                                                   left_copy,
                                                   eol, eol ? TRUE : FALSE,
                                                   keywords, TRUE, special,
                                                   pool));
- SVN_ERR (svn_subst_copy_and_translate2 (right,
+ SVN_ERR (svn_subst_copy_and_translate3 (right,
                                                   right_copy,
                                                   eol, eol ? TRUE : FALSE,
                                                   keywords, TRUE, special,
@@ -294,7 +294,7 @@
                                           pool));
           SVN_ERR (svn_wc__get_special (&special, merge_target, adm_access,
                                         pool));
- SVN_ERR (svn_subst_copy_and_translate2 (result_target, merge_target,
+ SVN_ERR (svn_subst_copy_and_translate3 (result_target, merge_target,
                                                   eol, eol ? TRUE : FALSE,
                                                   keywords, TRUE, special,
                                                   pool));
=== subversion/libsvn_wc/translate.h
==================================================================
--- subversion/libsvn_wc/translate.h (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/translate.h (/local/kwhash2) (revision 15743)
@@ -67,19 +67,20 @@
                                     const char *eol);
 
 /* Expand keywords for the file at PATH, by parsing a
- whitespace-delimited list of keywords. If any keywords are found
- in the list, allocate *KEYWORDS from POOL, and then populate its
- entries with the related keyword values (also allocated in POOL).
- If no keywords are found in the list, or if there is no list, set
- *KEYWORDS to NULL. ADM_ACCESS must be an access baton for PATH.
+ whitespace-delimited list of keywords. The KEYWORDS hash will be
+ allocated from POOL. If any keywords are found in the list, then
+ populate the KEYWORDS hash entries with the related keyword values
+ (also allocated in POOL). If no keywords are found in the list, or
+ if there is no list, set KEYWORDS to NULL. ADM_ACCESS must be an
+ access baton for PATH.
 
    If FORCE_LIST is non-null, use it as the list; else use the
    SVN_PROP_KEYWORDS property for PATH. In either case, use PATH to
    expand keyword values. If a keyword is in the list, but no
- corresponding value is available, set that element of *KEYWORDS to
- the empty string ("").
+ corresponding value is available, set that hash element of KEYWORDS
+ to NULL.
 */
-svn_error_t *svn_wc__get_keywords (svn_subst_keywords_t **keywords,
+svn_error_t *svn_wc__get_keywords (apr_hash_t **keywords,
                                    const char *path,
                                    svn_wc_adm_access_t *adm_access,
                                    const char *force_list,
=== subversion/libsvn_wc/props.c
==================================================================
--- subversion/libsvn_wc/props.c (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/props.c (/local/kwhash2) (revision 15743)
@@ -1452,7 +1452,7 @@
      here is whether or not the function fails on inconsistent line
      endings. The function is "translating" to an empty stream. This
      is sneeeeeeeeeeeaky. */
- err = svn_subst_translate_stream2 (read_stream, write_stream,
+ err = svn_subst_translate_stream3 (read_stream, write_stream,
                                      "", FALSE, NULL, FALSE, pool);
   if (err && err->apr_err == SVN_ERR_IO_INCONSISTENT_EOL)
     return svn_error_createf (SVN_ERR_ILLEGAL_TARGET, err,
@@ -1477,7 +1477,7 @@
   svn_error_t *err;
   apr_hash_t *prophash;
   apr_file_t *fp = NULL;
- svn_subst_keywords_t *old_keywords;
+ apr_hash_t *old_keywords;
   svn_stringbuf_t *new_value = NULL;
   svn_node_kind_t kind;
   enum svn_prop_kind prop_kind = svn_property_kind (NULL, name);
@@ -1637,11 +1637,11 @@
 
   if (kind == svn_node_file && strcmp (name, SVN_PROP_KEYWORDS) == 0)
     {
- svn_subst_keywords_t *new_keywords;
+ apr_hash_t *new_keywords;
       SVN_ERR (svn_wc__get_keywords (&new_keywords, path, adm_access, NULL,
                                      pool));
 
- if (svn_subst_keywords_differ (old_keywords, new_keywords, FALSE))
+ if (svn_subst_keywords_differ2 (old_keywords, new_keywords, FALSE, pool))
         {
           const char *base_name;
           svn_wc_entry_t tmp_entry;
=== subversion/libsvn_wc/adm_crawler.c
==================================================================
--- subversion/libsvn_wc/adm_crawler.c (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/adm_crawler.c (/local/kwhash2) (revision 15743)
@@ -61,7 +61,7 @@
               apr_pool_t *pool)
 {
   const char *text_base_path, *tmp_text_base_path;
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
   const char *eol;
   const svn_wc_entry_t *entry;
   svn_wc_entry_t newentry;
@@ -87,7 +87,7 @@
      sure to do any eol translations or keyword substitutions,
      as dictated by the property values. If these properties
      are turned off, then this is just a normal copy. */
- SVN_ERR (svn_subst_copy_and_translate2 (tmp_text_base_path,
+ SVN_ERR (svn_subst_copy_and_translate3 (tmp_text_base_path,
                                           file_path,
                                           eol, FALSE, /* don't repair */
                                           keywords,
=== subversion/libsvn_wc/log.c
==================================================================
--- subversion/libsvn_wc/log.c (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/log.c (/local/kwhash2) (revision 15743)
@@ -113,7 +113,7 @@
 
     case svn_wc__xfer_cp_and_translate:
       {
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
         const char *eol_str;
         svn_boolean_t special;
 
@@ -125,7 +125,7 @@
         SVN_ERR (svn_wc__get_special (&special, full_dest_path, adm_access,
                                       pool));
 
- SVN_ERR (svn_subst_copy_and_translate2 (full_from_path,
+ SVN_ERR (svn_subst_copy_and_translate3 (full_from_path,
                                                 full_dest_path,
                                                 eol_str,
                                                 TRUE,
@@ -144,7 +144,7 @@
 
     case svn_wc__xfer_cp_and_detranslate:
       {
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
         const char *eol_str;
         svn_boolean_t special;
 
@@ -159,7 +159,7 @@
         /* If any specific eol style was indicated, then detranslate
            back to repository normal form ("\n"), repairingly. But if
            no style indicated, don't touch line endings at all. */
- return svn_subst_copy_and_translate2 (full_from_path,
+ return svn_subst_copy_and_translate3 (full_from_path,
                                               full_dest_path,
                                               (eol_str ? "\n" : NULL),
                                               (eol_str ? TRUE : FALSE),
@@ -218,7 +218,7 @@
   const char *filepath;
   const char *tmp_text_base;
   svn_node_kind_t kind;
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
   apr_file_t *ignored;
   svn_boolean_t same, did_set;
   const char *tmp_wfile, *pdir, *bname;
@@ -265,7 +265,7 @@
   SVN_ERR (svn_io_check_path (tmp_text_base, &kind, pool));
 
   if (kind == svn_node_file)
- SVN_ERR (svn_subst_copy_and_translate2 (tmp_text_base,
+ SVN_ERR (svn_subst_copy_and_translate3 (tmp_text_base,
                                             tmp_wfile,
                                             eol_str,
                                             FALSE, /* don't repair eol */
@@ -274,7 +274,7 @@
                                             special,
                                             pool));
   else
- SVN_ERR (svn_subst_copy_and_translate2 (filepath,
+ SVN_ERR (svn_subst_copy_and_translate3 (filepath,
                                             tmp_wfile,
                                             eol_str,
                                             FALSE, /* don't repair eol */
=== subversion/libsvn_wc/adm_ops.c
==================================================================
--- subversion/libsvn_wc/adm_ops.c (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/adm_ops.c (/local/kwhash2) (revision 15743)
@@ -1381,7 +1381,7 @@
              missing altogether), copy the text-base out into
              the working copy, and update the timestamp in the entries
              file. */
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
           const char *eol;
           svn_boolean_t special;
           
@@ -1395,7 +1395,7 @@
              sure to do any eol translations or keyword substitutions,
              as dictated by the property values. If these properties
              are turned off, then this is just a normal copy. */
- if ((err = svn_subst_copy_and_translate2 (base_thing,
+ if ((err = svn_subst_copy_and_translate3 (base_thing,
                                                     fullpath,
                                                     eol,
                                                     FALSE, /* don't repair */
=== subversion/libsvn_wc/translate.c
==================================================================
--- subversion/libsvn_wc/translate.c (/mirror/trunk) (revision 15743)
+++ subversion/libsvn_wc/translate.c (/local/kwhash2) (revision 15743)
@@ -49,7 +49,7 @@
 {
   svn_subst_eol_style_t style;
   const char *eol;
- svn_subst_keywords_t *keywords;
+ apr_hash_t *keywords;
   svn_boolean_t special;
   
   SVN_ERR (svn_wc__get_eol_style (&style, &eol, vfile, adm_access, pool));
@@ -86,7 +86,7 @@
       
       if (style == svn_subst_eol_style_fixed)
         {
- SVN_ERR (svn_subst_copy_and_translate2 (vfile,
+ SVN_ERR (svn_subst_copy_and_translate3 (vfile,
                                                   tmp_vfile,
                                                   eol,
                                                   TRUE,
@@ -97,7 +97,7 @@
         }
       else if (style == svn_subst_eol_style_native)
         {
- SVN_ERR (svn_subst_copy_and_translate2 (vfile,
+ SVN_ERR (svn_subst_copy_and_translate3 (vfile,
                                                   tmp_vfile,
                                                   SVN_WC__DEFAULT_EOL_MARKER,
                                                   force_repair,
@@ -108,7 +108,7 @@
         }
       else if (style == svn_subst_eol_style_none)
         {
- SVN_ERR (svn_subst_copy_and_translate2 (vfile,
+ SVN_ERR (svn_subst_copy_and_translate3 (vfile,
                                                   tmp_vfile,
                                                   NULL,
                                                   force_repair,
@@ -169,19 +169,15 @@
 
 
 svn_error_t *
-svn_wc__get_keywords (svn_subst_keywords_t **keywords,
+svn_wc__get_keywords (apr_hash_t **keywords,
                       const char *path,
                       svn_wc_adm_access_t *adm_access,
                       const char *force_list,
                       apr_pool_t *pool)
 {
   const char *list;
- svn_subst_keywords_t tmp_keywords = { 0 };
   const svn_wc_entry_t *entry = NULL;
 
- /* Start by assuming no keywords. */
- *keywords = NULL;
-
   /* Choose a property list to parse: either the one that came into
      this function, or the one attached to PATH. */
   if (force_list == NULL)
@@ -198,21 +194,22 @@
 
   /* The easy answer. */
   if (list == NULL)
- return SVN_NO_ERROR;
+ {
+ keywords = NULL;
+ return SVN_NO_ERROR;
+ }
 
   SVN_ERR (svn_wc_entry (&entry, path, adm_access, FALSE, pool));
 
- SVN_ERR (svn_subst_build_keywords (&tmp_keywords,
- list,
- apr_psprintf (pool, "%ld",
- entry->cmt_rev),
- entry->url,
- entry->cmt_date,
- entry->cmt_author,
- pool));
+ SVN_ERR (svn_subst_build_keywords2 (keywords,
+ list,
+ apr_psprintf (pool, "%ld",
+ entry->cmt_rev),
+ entry->url,
+ entry->cmt_date,
+ entry->cmt_author,
+ pool));
 
- *keywords = apr_pmemdup (pool, &tmp_keywords, sizeof (tmp_keywords));
-
   return SVN_NO_ERROR;
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Sep 21 03:35:20 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.