Author: stefan2 Date: Sat Nov 25 15:21:45 2017 New Revision: 1816307 URL: http://svn.apache.org/viewvc?rev=1816307&view=rev Log: Refactoring in ra_serf: Move the DIRENT_FIELDS to property names mapping into a separate function.
* subversion/libsvn_ra_serf/ra_serf.h (svn_ra_serf__get_dirent_props): Declare new utility function. * subversion/libsvn_ra_serf/util.c (svn_ra_serf__get_dirent_props): Implement using code from ... * subversion/libsvn_ra_serf/stat.c (get_dirent_props): ..., which now just calls the new utility. Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h subversion/trunk/subversion/libsvn_ra_serf/stat.c subversion/trunk/subversion/libsvn_ra_serf/util.c Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1816307&r1=1816306&r2=1816307&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original) +++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sat Nov 25 15:21:45 2017 @@ -1590,6 +1590,16 @@ svn_ra_serf__setup_svndiff_accept_encodi svn_boolean_t svn_ra_serf__is_low_latency_connection(svn_ra_serf__session_t *session); +/* Return an APR array of svn_ra_serf__dav_props_t containing the + * properties (names and namespaces) corresponding to the flegs set + * in DIRENT_FIELDS. If SESSION does not support deadprops, only + * the generic "DAV:allprop" will be returned. Allocate the result + * in RESULT_POOL. */ +apr_array_header_t * +svn_ra_serf__get_dirent_props(apr_uint32_t dirent_fields, + svn_ra_serf__session_t *session, + apr_pool_t *result_pool); + /* Default limit for in-memory size of a request body. */ #define SVN_RA_SERF__REQUEST_BODY_IN_MEM_SIZE 256 * 1024 Modified: subversion/trunk/subversion/libsvn_ra_serf/stat.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/stat.c?rev=1816307&r1=1816306&r2=1816307&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/stat.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/stat.c Sat Nov 25 15:21:45 2017 @@ -216,64 +216,8 @@ get_dirent_props(apr_uint32_t dirent_fie apr_pool_t *pool) { svn_ra_serf__dav_props_t *prop; - apr_array_header_t *props = apr_array_make - (pool, 7, sizeof(svn_ra_serf__dav_props_t)); - - if (session->supports_deadprop_count != svn_tristate_false - || ! (dirent_fields & SVN_DIRENT_HAS_PROPS)) - { - if (dirent_fields & SVN_DIRENT_KIND) - { - prop = apr_array_push(props); - prop->xmlns = "DAV:"; - prop->name = "resourcetype"; - } - - if (dirent_fields & SVN_DIRENT_SIZE) - { - prop = apr_array_push(props); - prop->xmlns = "DAV:"; - prop->name = "getcontentlength"; - } - - if (dirent_fields & SVN_DIRENT_HAS_PROPS) - { - prop = apr_array_push(props); - prop->xmlns = SVN_DAV_PROP_NS_DAV; - prop->name = "deadprop-count"; - } - - if (dirent_fields & SVN_DIRENT_CREATED_REV) - { - svn_ra_serf__dav_props_t *p = apr_array_push(props); - p->xmlns = "DAV:"; - p->name = SVN_DAV__VERSION_NAME; - } - - if (dirent_fields & SVN_DIRENT_TIME) - { - prop = apr_array_push(props); - prop->xmlns = "DAV:"; - prop->name = SVN_DAV__CREATIONDATE; - } - - if (dirent_fields & SVN_DIRENT_LAST_AUTHOR) - { - prop = apr_array_push(props); - prop->xmlns = "DAV:"; - prop->name = "creator-displayname"; - } - } - else - { - /* We found an old subversion server that can't handle - the deadprop-count property in the way we expect. - - The neon behavior is to retrieve all properties in this case */ - prop = apr_array_push(props); - prop->xmlns = "DAV:"; - prop->name = "allprop"; - } + apr_array_header_t *props = svn_ra_serf__get_dirent_props(dirent_fields, + session, pool); prop = apr_array_push(props); prop->xmlns = NULL; Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1816307&r1=1816306&r2=1816307&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/util.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sat Nov 25 15:21:45 2017 @@ -2065,3 +2065,72 @@ svn_ra_serf__is_low_latency_connection(s return session->conn_latency >= 0 && session->conn_latency < apr_time_from_msec(5); } + +apr_array_header_t * +svn_ra_serf__get_dirent_props(apr_uint32_t dirent_fields, + svn_ra_serf__session_t *session, + apr_pool_t *result_pool) +{ + svn_ra_serf__dav_props_t *prop; + apr_array_header_t *props = apr_array_make + (result_pool, 7, sizeof(svn_ra_serf__dav_props_t)); + + if (session->supports_deadprop_count != svn_tristate_false + || ! (dirent_fields & SVN_DIRENT_HAS_PROPS)) + { + if (dirent_fields & SVN_DIRENT_KIND) + { + prop = apr_array_push(props); + prop->xmlns = "DAV:"; + prop->name = "resourcetype"; + } + + if (dirent_fields & SVN_DIRENT_SIZE) + { + prop = apr_array_push(props); + prop->xmlns = "DAV:"; + prop->name = "getcontentlength"; + } + + if (dirent_fields & SVN_DIRENT_HAS_PROPS) + { + prop = apr_array_push(props); + prop->xmlns = SVN_DAV_PROP_NS_DAV; + prop->name = "deadprop-count"; + } + + if (dirent_fields & SVN_DIRENT_CREATED_REV) + { + svn_ra_serf__dav_props_t *p = apr_array_push(props); + p->xmlns = "DAV:"; + p->name = SVN_DAV__VERSION_NAME; + } + + if (dirent_fields & SVN_DIRENT_TIME) + { + prop = apr_array_push(props); + prop->xmlns = "DAV:"; + prop->name = SVN_DAV__CREATIONDATE; + } + + if (dirent_fields & SVN_DIRENT_LAST_AUTHOR) + { + prop = apr_array_push(props); + prop->xmlns = "DAV:"; + prop->name = "creator-displayname"; + } + } + else + { + /* We found an old subversion server that can't handle + the deadprop-count property in the way we expect. + + The neon behavior is to retrieve all properties in this case */ + prop = apr_array_push(props); + prop->xmlns = "DAV:"; + prop->name = "allprop"; + } + + return props; +} +