subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1409732 - in /subversion/trunk/subversion/libsvn_client: client.h info.c list.c
Date Thu, 15 Nov 2012 11:08:37 GMT
Author: rhuijben
Date: Thu Nov 15 11:08:35 2012
New Revision: 1409732

URL: http://svn.apache.org/viewvc?rev=1409732&view=rev
Log:
Use a single copy of a duplicated static function. This makes 'svn info'
report some otherwise unavailable values (such as last author, etc.)
when used against a pre 1.2 svnserve repository root.

* subversion/libsvn_client/client.h
  (svn_client__ra_stat_compatible): New prototype.

* subversion/libsvn_client/info.c
  (ra_stat_compatible): Remove function.
  (svn_client_info3): Update caller. Remove pre-1.2 handling as we can now get
    everything we need.

* subversion/libsvn_client/list.c
  (ra_stat_compatible): Rename to ...
  (svn_client__ra_stat_compatible): ... this and make library public.
    Use subpool for temp ra session.
  (svn_client_list2): Update caller.

Modified:
    subversion/trunk/subversion/libsvn_client/client.h
    subversion/trunk/subversion/libsvn_client/info.c
    subversion/trunk/subversion/libsvn_client/list.c

Modified: subversion/trunk/subversion/libsvn_client/client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/client.h?rev=1409732&r1=1409731&r2=1409732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/client.h (original)
+++ subversion/trunk/subversion/libsvn_client/client.h Thu Nov 15 11:08:35 2012
@@ -901,6 +901,16 @@ svn_client__condense_commit_items(const 
                                   apr_pool_t *pool);
 
 
+/* Like svn_ra_stat() but with a compatibility hack for pre-1.2 svnserve. */
+svn_error_t *
+svn_client__ra_stat_compatible(svn_ra_session_t *ra_session,
+                               svn_revnum_t rev,
+                               svn_dirent_t **dirent_p,
+                               apr_uint32_t dirent_fields,
+                               svn_client_ctx_t *ctx,
+                               apr_pool_t *result_pool);
+
+
 /* Commit the items in the COMMIT_ITEMS array using EDITOR/EDIT_BATON
    to describe the committed local mods.  Prior to this call,
    COMMIT_ITEMS should have been run through (and BASE_URL generated

Modified: subversion/trunk/subversion/libsvn_client/info.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/info.c?rev=1409732&r1=1409731&r2=1409732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/info.c (original)
+++ subversion/trunk/subversion/libsvn_client/info.c Thu Nov 15 11:08:35 2012
@@ -248,75 +248,6 @@ wc_info_receiver(void *baton,
                                  abspath_or_url, &client_info, scratch_pool);
 }
 
-/* Like svn_ra_stat() but with a compatibility hack for pre-1.2 svnserve. */
-static svn_error_t *
-ra_stat_compatible(svn_ra_session_t *ra_session,
-                   svn_revnum_t rev,
-                   svn_dirent_t **dirent_p,
-                   apr_uint32_t dirent_fields,
-                   svn_client_ctx_t *ctx,
-                   apr_pool_t *pool)
-{
-  const char *repos_root_URL, *url;
-  svn_error_t *err;
-  svn_dirent_t *the_ent;
-
-  SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_URL, pool));
-  SVN_ERR(svn_ra_get_session_url(ra_session, &url, pool));
-
-  err = svn_ra_stat(ra_session, "", rev, &the_ent, pool);
-
-  /* svn_ra_stat() will work against old versions of mod_dav_svn, but
-     not old versions of svnserve.  In the case of a pre-1.2 svnserve,
-     catch the specific error it throws:*/
-  if (err && err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED)
-    {
-      /* Fall back to pre-1.2 strategy for fetching dirent's URL. */
-      svn_node_kind_t url_kind;
-      svn_ra_session_t *parent_ra_session;
-      apr_hash_t *parent_ents;
-      const char *parent_url, *base_name;
-
-      if (strcmp(url, repos_root_URL) == 0)
-        {
-          /* In this universe, there's simply no way to fetch
-             information about the repository's root directory! */
-          return err;
-        }
-
-      svn_error_clear(err);
-
-      SVN_ERR(svn_ra_check_path(ra_session, "", rev, &url_kind, pool));
-      if (url_kind == svn_node_none)
-        return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
-                                 _("URL '%s' non-existent in revision %ld"),
-                                 url, rev);
-
-      /* Open a new RA session to the item's parent. */
-      svn_uri_split(&parent_url, &base_name, url, pool);
-      SVN_ERR(svn_client__open_ra_session_internal(&parent_ra_session, NULL,
-                                                   parent_url, NULL,
-                                                   NULL, FALSE, TRUE,
-                                                   ctx, pool));
-
-      /* Get all parent's entries, and find the item's dirent in the hash. */
-      SVN_ERR(svn_ra_get_dir2(parent_ra_session, &parent_ents, NULL, NULL,
-                              "", rev, dirent_fields, pool));
-      the_ent = apr_hash_get(parent_ents, base_name, APR_HASH_KEY_STRING);
-      if (the_ent == NULL)
-        return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
-                                 _("URL '%s' non-existent in revision %ld"),
-                                 url, rev);
-    }
-  else if (err)
-    {
-      return svn_error_trace(err);
-    }
-
-  *dirent_p = the_ent;
-  return SVN_NO_ERROR;
-}
-
 svn_error_t *
 svn_client_info3(const char *abspath_or_url,
                  const svn_opt_revision_t *peg_revision,
@@ -371,28 +302,8 @@ svn_client_info3(const char *abspath_or_
   svn_uri_split(NULL, &base_name, pathrev->url, pool);
 
   /* Get the dirent for the URL itself. */
-  err = ra_stat_compatible(ra_session, pathrev->rev, &the_ent, DIRENT_FIELDS,
-                           ctx, pool);
-  if (err && err->apr_err == SVN_ERR_RA_NOT_IMPLEMENTED)
-    {
-      svn_error_clear(err);
-
-      /* If we're recursing, degrade gracefully: rather than
-         throw an error, return no information about the
-         repos root. */
-      if (depth > svn_depth_empty)
-        goto pre_1_2_recurse;
-
-      /* Otherwise, we really are stuck.  Better tell the user
-         what's going on. */
-      return svn_error_createf(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
-                               _("Server does not support retrieving "
-                                 "information about the repository root"));
-    }
-  else if (err)
-    {
-      return svn_error_trace(err);
-    }
+  SVN_ERR(svn_client__ra_stat_compatible(ra_session, pathrev->rev, &the_ent,
+                                         DIRENT_FIELDS, ctx, pool));
 
   if (! the_ent)
     return svn_error_createf(SVN_ERR_RA_ILLEGAL_URL, NULL,
@@ -436,7 +347,6 @@ svn_client_info3(const char *abspath_or_
     {
       apr_hash_t *locks;
 
-pre_1_2_recurse:
       if (peg_revision->kind == svn_opt_revision_head)
         {
           err = svn_ra_get_locks2(ra_session, &locks, "", depth,

Modified: subversion/trunk/subversion/libsvn_client/list.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/list.c?rev=1409732&r1=1409731&r2=1409732&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/list.c (original)
+++ subversion/trunk/subversion/libsvn_client/list.c Thu Nov 15 11:08:35 2012
@@ -123,13 +123,14 @@ get_dir_contents(apr_uint32_t dirent_fie
 }
 
 /* Like svn_ra_stat() but with a compatibility hack for pre-1.2 svnserve. */
-static svn_error_t *
-ra_stat_compatible(svn_ra_session_t *ra_session,
-                   svn_revnum_t rev,
-                   svn_dirent_t **dirent_p,
-                   apr_uint32_t dirent_fields,
-                   svn_client_ctx_t *ctx,
-                   apr_pool_t *pool)
+/* ### Maybe we should move this behavior into the svn_ra_stat wrapper? */
+svn_error_t *
+svn_client__ra_stat_compatible(svn_ra_session_t *ra_session,
+                               svn_revnum_t rev,
+                               svn_dirent_t **dirent_p,
+                               apr_uint32_t dirent_fields,
+                               svn_client_ctx_t *ctx,
+                               apr_pool_t *pool)
 {
   const char *repos_root, *url;
   svn_error_t *err;
@@ -157,15 +158,16 @@ ra_stat_compatible(svn_ra_session_t *ra_
               svn_ra_session_t *parent_session;
               apr_hash_t *parent_ents;
               const char *parent_url, *base_name;
+              apr_pool_t *subpool = svn_pool_create(pool);
 
               /* Open another session to the path's parent.  This server
                  doesn't support svn_ra_reparent anyway, so don't try it. */
-              svn_uri_split(&parent_url, &base_name, url, pool);
+              svn_uri_split(&parent_url, &base_name, url, subpool);
 
               SVN_ERR(svn_client__open_ra_session_internal(&parent_session,
                                                            NULL, parent_url,
                                                            NULL, NULL, FALSE,
-                                                           TRUE, ctx, pool));
+                                                           TRUE, ctx, subpool));
 
               /* Get all parent's entries, no props. */
               SVN_ERR(svn_ra_get_dir2(parent_session, &parent_ents, NULL,
@@ -174,6 +176,8 @@ ra_stat_compatible(svn_ra_session_t *ra_
               /* Get the relevant entry. */
               dirent = apr_hash_get(parent_ents, base_name,
                                     APR_HASH_KEY_STRING);
+
+              svn_pool_destroy(subpool); /* Close RA session */
             }
           else
             {
@@ -183,7 +187,7 @@ ra_stat_compatible(svn_ra_session_t *ra_
                  be rev. */
               dirent = apr_palloc(pool, sizeof(*dirent));
               dirent->kind = kind;
-              dirent->size = 0;
+              dirent->size = SVN_INVALID_FILESIZE;
               if (dirent_fields & SVN_DIRENT_HAS_PROPS)
                 {
                   apr_hash_t *props;
@@ -217,8 +221,8 @@ ra_stat_compatible(svn_ra_session_t *ra_
       else
         dirent = NULL;
     }
-  else if (err)
-    return svn_error_trace(err);
+  else
+    SVN_ERR(err);
 
   *dirent_p = dirent;
   return SVN_NO_ERROR;
@@ -255,8 +259,8 @@ svn_client_list2(const char *path_or_url
 
   fs_path = svn_client__pathrev_fspath(loc, pool);
 
-  SVN_ERR(ra_stat_compatible(ra_session, loc->rev, &dirent, dirent_fields,
-                             ctx, pool));
+  SVN_ERR(svn_client__ra_stat_compatible(ra_session, loc->rev, &dirent,
+                                         dirent_fields, ctx, pool));
   if (! dirent)
     return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
                              _("URL '%s' non-existent in revision %ld"),



Mime
View raw message