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

Re: [PATCH] fix for issue #591

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2002-01-21 02:52:04 CET

On Sun, Jan 20, 2002 at 05:49:13PM -0800, Greg Stein wrote:

> > Existing code generally avoids the casts and declares
> >
> > const void *key;
> > apr_ssize_t klen;
> > void *val;
> > apr_hash_this (hi, &key, &klen, &val);
>
> Agreed. Code that doesn't, should be changed. If a cast is required to
> access the key or value, then it should come later. A lot of code will also
> do something like:
>
> void *val;
> some_struct_t *something;
>
> apr_hash_this(&hi, &key, &klen, &val);
> something = val;
> whatever(something->foo);
>
> The assignment does the implicit void* -> some_struct_t* cast.

as this seems to be the only thing anyone had a real problem with (and
rightly so), i have changed it. here's the current version of the
patch. (the log message is the same as in my previous message)

-garrett

Index: ./subversion/include/svn_ra.h
===================================================================
--- ./subversion/include/svn_ra.h
+++ ./subversion/include/svn_ra.h Sat Jan 19 19:24:06 2002
@@ -351,12 +351,15 @@
      If REVISION is SVN_INVALID_REVNUM (meaning 'head') and
      *FETCHED_REV is not NULL, then this function will set
      *FETCHED_REV to the actual revision that was retrieved. (Some
- callers want to know, and some don't.) */
+ callers want to know, and some don't.)
+
+ If PROPS is non NULL, it will contain the properties of the file. */
   svn_error_t *(*get_file) (void *session_baton,
                             const char *path,
                             svn_revnum_t revision,
                             svn_stream_t *stream,
- svn_revnum_t *fetched_rev);
+ svn_revnum_t *fetched_rev,
+ apr_hash_t **props);
 
 
   /* Check out revision REVISION of the url specified in
Index: ./subversion/libsvn_ra_local/ra_plugin.c
===================================================================
--- ./subversion/libsvn_ra_local/ra_plugin.c
+++ ./subversion/libsvn_ra_local/ra_plugin.c Sat Jan 19 19:25:19 2002
@@ -519,7 +519,8 @@
           const char *path,
           svn_revnum_t revision,
           svn_stream_t *stream,
- svn_revnum_t *fetched_rev)
+ svn_revnum_t *fetched_rev,
+ apr_hash_t **props)
 {
   svn_fs_root_t *root;
   svn_stream_t *contents;
@@ -589,6 +590,9 @@
           break;
         }
     }
+
+ if (props)
+ SVN_ERR (svn_fs_node_proplist (props, root, abs_path->data, sbaton->pool));
 
   return SVN_NO_ERROR;
 }
Index: ./subversion/libsvn_client/copy.c
===================================================================
--- ./subversion/libsvn_client/copy.c
+++ ./subversion/libsvn_client/copy.c Sun Jan 20 15:17:49 2002
@@ -534,6 +534,8 @@
       svn_stream_t *fstream;
       apr_file_t *fp;
       svn_revnum_t fetched_rev = 0;
+ apr_hash_t *props;
+ apr_hash_index_t *hi;
       
       /* Open DST_PATH for writing. */
       status = apr_file_open (&fp, dst_path->data, (APR_CREATE | APR_WRITE),
@@ -549,7 +551,18 @@
       /* Have the RA layer 'push' data at this stream. We pass a
          relative path of "", because we opened SRC_URL, which is
          already the full URL to the file. */
- SVN_ERR (ra_lib->get_file (sess, "", src_rev, fstream, &fetched_rev));
+ SVN_ERR (ra_lib->get_file (sess, "", src_rev, fstream,
+ &fetched_rev, &props));
+
+ for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi))
+ {
+ const void *key;
+ void *val;
+
+ apr_hash_this (hi, &key, NULL, &val);
+
+ SVN_ERR (svn_wc_prop_set (key, val, dst_path->data, pool));
+ }
 
       /* Close the file. */
       status = apr_file_close (fp);
Index: ./subversion/libsvn_client/repos_diff.c
===================================================================
--- ./subversion/libsvn_client/repos_diff.c
+++ ./subversion/libsvn_client/repos_diff.c Sat Jan 19 19:29:12 2002
@@ -254,7 +254,7 @@
   SVN_ERR (b->edit_baton->ra_lib->get_file (b->edit_baton->ra_session,
                                             b->path->data,
                                             b->edit_baton->revision,
- fstream, NULL));
+ fstream, NULL, NULL));
 
   status = apr_file_close (file);
   if (status)
Index: ./subversion/libsvn_ra_dav/ra_dav.h
===================================================================
--- ./subversion/libsvn_ra_dav/ra_dav.h
+++ ./subversion/libsvn_ra_dav/ra_dav.h Sat Jan 19 19:27:46 2002
@@ -85,7 +85,8 @@
   const char *path,
   svn_revnum_t revision,
   svn_stream_t *stream,
- svn_revnum_t *fetched_rev);
+ svn_revnum_t *fetched_rev,
+ apr_hash_t **props);
 
 svn_error_t * svn_ra_dav__abort_commit(
  void *session_baton,
Index: ./subversion/libsvn_ra_dav/fetch.c
===================================================================
--- ./subversion/libsvn_ra_dav/fetch.c
+++ ./subversion/libsvn_ra_dav/fetch.c Sun Jan 20 17:16:27 2002
@@ -785,8 +785,11 @@
                                   const char *path,
                                   svn_revnum_t revision,
                                   svn_stream_t *stream,
- svn_revnum_t *fetched_rev)
+ svn_revnum_t *fetched_rev,
+ apr_hash_t **props)
 {
+ svn_ra_dav_resource_t *rsrc;
+ apr_hash_index_t *hi;
   svn_stringbuf_t *url_str;
   const char *final_url;
   svn_ra_session_t *ras = (svn_ra_session_t *) session_baton;
@@ -828,6 +831,32 @@
                               get_file_reader, stream,
                               ras->callbacks->get_wc_prop,
                               ras->callback_baton, ras->pool) );
+
+ if (props)
+ {
+ SVN_ERR( svn_ra_dav__get_props_resource(&rsrc, ras->sess, final_url,
+ NULL, NULL /* all props */,
+ ras->pool) );
+
+ *props = apr_hash_make(ras->pool);
+
+ for (hi = apr_hash_first(ras->pool, rsrc->propset);
+ hi;
+ hi = apr_hash_next(hi))
+ {
+ const void *key;
+ void *val;
+
+ apr_hash_this(hi, &key, NULL, &val);
+
+#define NSLEN (sizeof(SVN_PROP_CUSTOM_PREFIX) - 1)
+ if (strncmp(key, SVN_PROP_CUSTOM_PREFIX, NSLEN) == 0)
+ apr_hash_set(*props, &((const char *)key)[NSLEN],
+ APR_HASH_KEY_STRING,
+ svn_string_create(val, ras->pool));
+#undef NSLEN
+ }
+ }
 
   return SVN_NO_ERROR;
 }

-- 
garrett rooney                     Unix was not designed to stop you from 
rooneg@electricjellyfish.net       doing stupid things, because that would  
http://electricjellyfish.net/      stop you from doing clever things.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:57 2006

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.