You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2015/03/09 20:39:47 UTC

svn commit: r1665328 - in /subversion/trunk/subversion: libsvn_fs_base/bdb/rev-table.c libsvn_ra_local/ra_plugin.c mod_dav_svn/reports/inherited-props.c svnserve/serve.c tests/libsvn_ra/ra-test.c

Author: rhuijben
Date: Mon Mar  9 19:39:46 2015
New Revision: 1665328

URL: http://svn.apache.org/r1665328
Log:
Make al ra layers consistently handle invalid revisions when retrieving
inherited properties: add errors in a few cases that worked before, but
used to provide results that couldn't be trusted.

* subversion/libsvn_fs_base/bdb/rev-table.c
  (svn_fs_bdb__get_rev): Show understandable error on SVN_INVALID_REVNUM instead
    of a raw database error.

* subversion/libsvn_ra_local/ra_plugin.c
  (svn_ra_local__get_inherited_props): Remove invalid->youngest handling.

* subversion/mod_dav_svn/reports/inherited-props.c
  (dav_svn__get_inherited_props_report): Retrieving iprops on a not existing
    path is an error.

* subversion/svnserve/serve.c
  (get_inherited_props): Remove invalid->youngest handling. Retrieving iprops
    on a not existing path is an error.

* subversion/tests/libsvn_ra/ra-test.c
  (ra_revision_errors): Extend tests.

Modified:
    subversion/trunk/subversion/libsvn_fs_base/bdb/rev-table.c
    subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c
    subversion/trunk/subversion/mod_dav_svn/reports/inherited-props.c
    subversion/trunk/subversion/svnserve/serve.c
    subversion/trunk/subversion/tests/libsvn_ra/ra-test.c

Modified: subversion/trunk/subversion/libsvn_fs_base/bdb/rev-table.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/bdb/rev-table.c?rev=1665328&r1=1665327&r2=1665328&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/bdb/rev-table.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/bdb/rev-table.c Mon Mar  9 19:39:46 2015
@@ -79,6 +79,9 @@ svn_fs_bdb__get_rev(revision_t **revisio
      numbers begin with one.  */
   db_recno_t recno = (db_recno_t) rev + 1;
 
+  if (!SVN_IS_VALID_REVNUM(rev))
+    return svn_fs_base__err_dangling_rev(fs, rev);
+
   svn_fs_base__trail_debug(trail, "revisions", "get");
   db_err = bfd->revisions->get(bfd->revisions, trail->db_txn,
                                svn_fs_base__set_dbt(&key, &recno,

Modified: subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c?rev=1665328&r1=1665327&r2=1665328&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c (original)
+++ subversion/trunk/subversion/libsvn_ra_local/ra_plugin.c Mon Mar  9 19:39:46 2015
@@ -1696,23 +1696,13 @@ svn_ra_local__get_inherited_props(svn_ra
                                   apr_pool_t *scratch_pool)
 {
   svn_fs_root_t *root;
-  svn_revnum_t youngest_rev;
   svn_ra_local__session_baton_t *sess = session->priv;
   const char *abs_path = svn_fspath__join(sess->fs_path->data, path,
                                           scratch_pool);
   svn_node_kind_t node_kind;
 
   /* Open the revision's root. */
-  if (! SVN_IS_VALID_REVNUM(revision))
-    {
-      SVN_ERR(svn_fs_youngest_rev(&youngest_rev, sess->fs, scratch_pool));
-      SVN_ERR(svn_fs_revision_root(&root, sess->fs, youngest_rev,
-                                   scratch_pool));
-    }
-  else
-    {
-      SVN_ERR(svn_fs_revision_root(&root, sess->fs, revision, scratch_pool));
-    }
+  SVN_ERR(svn_fs_revision_root(&root, sess->fs, revision, scratch_pool));
 
   SVN_ERR(svn_fs_check_path(&node_kind, root, abs_path, scratch_pool));
   if (node_kind == svn_node_none)

Modified: subversion/trunk/subversion/mod_dav_svn/reports/inherited-props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/reports/inherited-props.c?rev=1665328&r1=1665327&r2=1665328&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/inherited-props.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/inherited-props.c Mon Mar  9 19:39:46 2015
@@ -61,6 +61,7 @@ dav_svn__get_inherited_props_report(cons
   int i;
   svn_revnum_t rev = SVN_INVALID_REVNUM;
   apr_pool_t *iterpool;
+  svn_node_kind_t kind;
 
   /* Sanity check. */
   if (!resource->info->repos_path)
@@ -114,6 +115,20 @@ dav_svn__get_inherited_props_report(cons
                                 "couldn't retrieve revision root",
                                 resource->pool);
 
+  serr = svn_fs_check_path(&kind, root, path, resource->pool);
+  if (!serr && kind == svn_node_none)
+    {
+      serr = svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
+                               "'%s' path not found", path);
+    }
+
+  if (serr)
+    {
+      derr = dav_svn__convert_err(serr, HTTP_BAD_REQUEST, NULL,
+                                  resource->pool);
+      goto cleanup;
+    }
+
   serr = svn_repos_fs_get_inherited_props(&inherited_props, root, path, NULL,
                                           dav_svn__authz_read_func(&arb),
                                           &arb, resource->pool, iterpool);

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1665328&r1=1665327&r2=1665328&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Mon Mar  9 19:39:46 2015
@@ -3296,6 +3296,7 @@ get_inherited_props(svn_ra_svn_conn_t *c
   int i;
   apr_pool_t *iterpool = svn_pool_create(pool);
   authz_baton_t ab;
+  svn_node_kind_t node_kind;
 
   ab.server = b;
   ab.conn = conn;
@@ -3311,15 +3312,18 @@ get_inherited_props(svn_ra_svn_conn_t *c
   SVN_ERR(must_have_access(conn, iterpool, b, svn_authz_read,
                            full_path, FALSE));
 
-  if (!SVN_IS_VALID_REVNUM(rev))
-    SVN_CMD_ERR(svn_fs_youngest_rev(&rev, b->repository->fs, pool));
-
   SVN_ERR(log_command(b, conn, pool, "%s",
                       svn_log__get_inherited_props(full_path, rev,
                                                    iterpool)));
 
   /* Fetch the properties and a stream for the contents. */
   SVN_CMD_ERR(svn_fs_revision_root(&root, b->repository->fs, rev, iterpool));
+  SVN_CMD_ERR(svn_fs_check_path(&node_kind, root, full_path, pool));
+  if (node_kind == svn_node_none)
+    {
+      SVN_CMD_ERR(svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
+                                    _("'%s' path not found"), full_path));
+    }
   SVN_CMD_ERR(get_props(NULL, &inherited_props, &ab, root, full_path, pool));
 
   /* Send successful command response with revision and props. */

Modified: subversion/trunk/subversion/tests/libsvn_ra/ra-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_ra/ra-test.c?rev=1665328&r1=1665327&r2=1665328&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_ra/ra-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_ra/ra-test.c Mon Mar  9 19:39:46 2015
@@ -1205,6 +1205,41 @@ ra_revision_errors(const svn_test_opts_t
     SVN_TEST_ASSERT(lock == NULL);
   }
 
+  /* ### TODO: Replay and replay range */
+
+  {
+    svn_revnum_t del_rev;
+
+    /* ### Explicitly documented to not return an FS or RA error???? */
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_deleted_rev(ra_session, "Z", 2, 1,
+                                                 &del_rev, pool),
+                          SVN_ERR_CLIENT_BAD_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_deleted_rev(ra_session, "Z",
+                                                 SVN_INVALID_REVNUM, 2,
+                                                 &del_rev, pool),
+                          SVN_ERR_CLIENT_BAD_REVISION);
+
+  }
+
+  {
+    apr_array_header_t *iprops;
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_inherited_props(ra_session, &iprops,
+                                                     "A", 2, pool, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_inherited_props(ra_session, &iprops,
+                                                     "A", SVN_INVALID_REVNUM,
+                                                     pool, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_inherited_props(ra_session, &iprops,
+                                                     "Z", 1,
+                                                     pool, pool),
+                          SVN_ERR_FS_NOT_FOUND);
+  }
+
   return SVN_NO_ERROR;
 }