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

[PATCH] r/w props in ra_dav

From: Joe Orton <jorton_at_btconnect.com>
Date: 2001-07-07 04:29:16 CEST

I've had time to think about this now too. The big problem with trying
to map *all* DAV properties onto SVN WC props is that DAV properties are
uniquely identified by a (namespace, name) pair and SVN props are
identified by a flat string.

I see these choices for doing that mapping:

1) map the pair into a flat string using some special syntax e.g. the
"{namespace}name" convention, allow all defined properties to be
accessed via the WC.

2) map SVN props into a specific namespaces, e.g. "SVN:custom:". Ignore
any props on the server which aren't in this namespace.

I think I favour (2): patch below is all that is needed to implement
this scheme going both ways (Greg has done all the grunt work already
for the server-side). I think it can be done slightly cleaner too but
the current code just concatenates the namespace/name pair and pretends
this isn't a problem, so that needs a workaround.

I have a feeling Greg won't like (2) though. ;) Something I hadn't
realized also is that mod_dav_svn already has to work round this
problem, so properties on a repos accessed using ra_dav don't come out
right if you access the same repos via ra_local. Hmmmmm... maybe
mod_dav_svn can do the same mapping in reverse before going to the fs.

Index: commit.c
===================================================================
RCS file: /usr/local/tigris/data/helm/cvs/repository/subversion/subversion/libsvn_ra_dav/commit.c,v
retrieving revision 1.59
diff -u -p -r1.59 commit.c
--- commit.c 2001/07/06 23:12:41 1.59
+++ commit.c 2001/07/07 01:40:25
@@ -445,7 +445,8 @@ static svn_error_t * do_proppatch(svn_ra
   body = ne_buffer_create();
 
   ne_buffer_zappend(body, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" EOL
- "<D:propertyupdate xmlns:D=\"DAV:\" xmlns:S=\"SVN:custom\">");
+ "<D:propertyupdate xmlns:D=\"DAV:\" xmlns:S=\""
+ SVN_RA_DAV__CUSTOM_NAMESPACE "\">");
 
   if (rb->prop_changes != NULL)
     {
Index: fetch.c
===================================================================
RCS file: /usr/local/tigris/data/helm/cvs/repository/subversion/subversion/libsvn_ra_dav/fetch.c,v
retrieving revision 1.62
diff -u -p -r1.62 fetch.c
--- fetch.c 2001/07/04 12:12:21 1.62
+++ fetch.c 2001/07/07 01:40:26
@@ -215,6 +215,35 @@ static svn_error_t *store_vsn_url(const
   return simple_store_vsn_url(vsn_url, baton, setter, vuh);
 }
 
+static void add_props(const svn_ra_dav_resource_t *r,
+ prop_setter_t setter,
+ void *baton,
+ apr_pool_t *pool)
+{
+ apr_hash_index_t *hi;
+
+ for (hi = apr_hash_first(r->propset); hi != NULL; hi = apr_hash_next(hi))
+ {
+ const char *key;
+ char *val;
+
+ apr_hash_this(hi, (const void **)&key, NULL, (void *)&val);
+
+#define NSLEN (strlen(SVN_RA_DAV__CUSTOM_NAMESPACE))
+
+ if (strncmp(key, SVN_RA_DAV__CUSTOM_NAMESPACE, NSLEN) == 0)
+ {
+ svn_stringbuf_t *skey, *sval;
+ skey = svn_stringbuf_create(key + NSLEN, pool);
+ sval = svn_stringbuf_create(val, pool);
+
+ (*setter)(baton, skey, sval);
+ }
+#undef NSLEN
+ }
+}
+
+
 static svn_error_t * fetch_dirents(svn_ra_session_t *ras,
                                    const char *url,
                                    void *dir_baton,
@@ -228,8 +257,10 @@ static svn_error_t * fetch_dirents(svn_r
   struct uri parsed_url;
   apr_hash_index_t *hi;
 
+ /* Fetch all properties so we can snarf ones out of the SVN:custom
+ * namspace. */
   SVN_ERR( svn_ra_dav__get_props(&dirents, ras, url, NE_DEPTH_ONE, NULL,
- fetch_props, pool) );
+ NULL /* allprop */, pool) );
 
   uri_parse(url, &parsed_url, NULL);
 
@@ -370,7 +401,8 @@ static svn_error_t *fetch_file(svn_ra_se
       goto error;
     }
 
- /* ### fetch properties */
+ /* Add the properties. */
+ add_props(rsrc, editor->change_file_prop, file_baton, pool);
 
   /* store the version URL as a property */
   err = store_vsn_url(rsrc, file_baton, editor->change_file_prop, vuh);
Index: props.c
===================================================================
RCS file: /usr/local/tigris/data/helm/cvs/repository/subversion/subversion/libsvn_ra_dav/props.c,v
retrieving revision 1.8
diff -u -p -r1.8 props.c
--- props.c 2001/07/06 22:34:21 1.8
+++ props.c 2001/07/07 01:40:26
@@ -103,6 +103,8 @@ static void *create_private(void *userda
   svn_ra_dav_resource_t *r = apr_pcalloc(pc->pool, sizeof(*r));
   apr_size_t len;
 
+ r->pool = pc->pool;
+
   /* parse the PATH element out of the URL
 
      Note: mod_dav does not (currently) use an absolute URL, but simply a
@@ -127,20 +129,29 @@ static void *create_private(void *userda
   return r;
 }
 
+static int add_to_hash(void *userdata, const ne_propname *pname,
+ const char *value, const ne_status *status)
+{
+ svn_ra_dav_resource_t *r = userdata;
+ const char *name;
+
+ name = apr_pstrcat(r->pool, pname->nspace, pname->name, NULL);
+ value = apr_pstrdup(r->pool, value);
+
+ apr_hash_set(r->propset, name, APR_HASH_KEY_STRING, value);
+
+ return 0;
+}
+
 static void process_results(void *userdata, const char *uri,
                             const ne_prop_result_set *rset)
 {
-#if 0
   prop_ctx_t *pc = userdata;
   svn_ra_dav_resource_t *r = ne_propset_private(rset);
-#endif
 
   /* ### should use ne_propset_status(rset) to determine whether the
    * ### PROPFIND failed for the properties we're interested in. */
-
- /* ### use ne_propset_iterate(rset) to copy unhandled properties into
- ### the resource's hash table of props.
- ### maybe we need a special namespace for user props? */
+ (void) ne_propset_iterate(rset, add_to_hash, r);
 }
 
 static int validate_element(ne_xml_elmid parent, ne_xml_elmid child)
@@ -274,7 +285,15 @@ svn_error_t * svn_ra_dav__get_props(apr_
       ne_add_request_header(req, "Label", label);
     }
   
- rv = ne_propfind_named(pc.dph, which_props, process_results, &pc);
+ if (which_props)
+ {
+ rv = ne_propfind_named(pc.dph, which_props, process_results, &pc);
+ }
+ else
+ {
+ rv = ne_propfind_allprop(pc.dph, process_results, &pc);
+ }
+
   ne_propfind_destroy(pc.dph);
 
   if (rv != NE_OK)
Index: ra_dav.h
===================================================================
RCS file: /usr/local/tigris/data/helm/cvs/repository/subversion/subversion/libsvn_ra_dav/ra_dav.h,v
retrieving revision 1.30
diff -u -p -r1.30 ra_dav.h
--- ra_dav.h 2001/07/06 22:24:22 1.30
+++ ra_dav.h 2001/07/07 01:40:26
@@ -90,6 +90,9 @@ svn_error_t * svn_ra_dav__do_update(
 #define SVN_RA_DAV__LP_NAMESPACE \
         "svn:wc:http://subversion.tigris.org/props/ra/dav/local/"
 
+#define SVN_RA_DAV__CUSTOM_NAMESPACE \
+ "SVN:custom:"
+
 /* store the URL where Activities can be created */
 #define SVN_RA_DAV__LP_ACTIVITY_URL SVN_RA_DAV__LP_NAMESPACE "activity-url"
 

---------------------------------------------------------------------
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:33 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.