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 18:21:09 UTC

svn commit: r1665308 - in /subversion/trunk/subversion: libsvn_repos/rev_hunt.c tests/libsvn_ra/ra-test.c

Author: rhuijben
Date: Mon Mar  9 17:21:08 2015
New Revision: 1665308

URL: http://svn.apache.org/r1665308
Log:
Add a few more boundary revision checks on the ra_revision_errors test.

* subversion/libsvn_repos/rev_hunt.c
  (svn_repos_node_location_segments): Make sanity checks more explicit,
    instead of relying on later fs calls to produce similar results.

* subversion/tests/libsvn_ra/ra-test.c
  (stub_log_receiver,
   stub_segment_receiver): New function.
  (ra_revision_errors): Extend function.

Modified:
    subversion/trunk/subversion/libsvn_repos/rev_hunt.c
    subversion/trunk/subversion/tests/libsvn_ra/ra-test.c

Modified: subversion/trunk/subversion/libsvn_repos/rev_hunt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/rev_hunt.c?rev=1665308&r1=1665307&r2=1665308&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/rev_hunt.c (original)
+++ subversion/trunk/subversion/libsvn_repos/rev_hunt.c Mon Mar  9 17:21:08 2015
@@ -837,27 +837,32 @@ svn_repos_node_location_segments(svn_rep
 {
   svn_fs_t *fs = svn_repos_fs(repos);
   svn_stringbuf_t *current_path;
-  svn_revnum_t youngest_rev = SVN_INVALID_REVNUM, current_rev;
+  svn_revnum_t youngest_rev, current_rev;
   apr_pool_t *subpool;
 
+  SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool));
+
   /* No PEG_REVISION?  We'll use HEAD. */
   if (! SVN_IS_VALID_REVNUM(peg_revision))
-    {
-      SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool));
-      peg_revision = youngest_rev;
-    }
+    peg_revision = youngest_rev;
+
+  if (peg_revision > youngest_rev)
+    return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
+                             _("No such revision %ld"), peg_revision);
 
-  /* No START_REV?  We'll use HEAD (which we may have already fetched). */
+  /* No START_REV?  We'll use peg rev. */
   if (! SVN_IS_VALID_REVNUM(start_rev))
-    {
-      if (SVN_IS_VALID_REVNUM(youngest_rev))
-        start_rev = youngest_rev;
-      else
-        SVN_ERR(svn_fs_youngest_rev(&start_rev, fs, pool));
-    }
+    start_rev = peg_revision;
+  else if (start_rev > peg_revision)
+    return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
+                             _("No such revision %ld"), start_rev);
 
   /* No END_REV?  We'll use 0. */
-  end_rev = SVN_IS_VALID_REVNUM(end_rev) ? end_rev : 0;
+  if (! SVN_IS_VALID_REVNUM(end_rev))
+    end_rev = 0;
+  else if (end_rev > start_rev)
+    return svn_error_createf(SVN_ERR_FS_NO_SUCH_REVISION, NULL,
+                             _("No such revision %ld"), end_rev);
 
   /* Are the revision properly ordered?  They better be -- the API
      demands it. */

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=1665308&r1=1665307&r2=1665308&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_ra/ra-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_ra/ra-test.c Mon Mar  9 17:21:08 2015
@@ -756,6 +756,24 @@ delete_revision_above_youngest(const svn
   return SVN_NO_ERROR;
 }
 
+/* Stub svn_log_entry_receiver_t */
+static svn_error_t *
+stub_log_receiver(void *baton,
+                  svn_log_entry_t *entry,
+                  apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
+/* Stub svn_location_segment_receiver_t */
+static svn_error_t *
+stub_segment_receiver(svn_location_segment_t *segment,
+                      void *baton,
+                      apr_pool_t *scratch_pool)
+{
+  return SVN_NO_ERROR;
+}
+
 static svn_error_t *
 ra_revision_errors(const svn_test_opts_t *opts,
                    apr_pool_t *pool)
@@ -922,6 +940,11 @@ ra_revision_errors(const svn_test_opts_t
                                           &props, pool),
                           SVN_ERR_FS_NO_SUCH_REVISION);
 
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_file(ra_session, "Z", 1,
+                                          svn_stream_empty(pool), &fetched,
+                                          &props, pool),
+                          SVN_ERR_FS_NOT_FOUND);
+
     SVN_ERR(svn_ra_get_file(ra_session, "A/iota", SVN_INVALID_REVNUM,
                             svn_stream_empty(pool), &fetched,
                             &props, pool));
@@ -939,10 +962,15 @@ ra_revision_errors(const svn_test_opts_t
                           SVN_ERR_FS_NOT_DIRECTORY);
 
     SVN_TEST_ASSERT_ERROR(svn_ra_get_dir2(ra_session, &dirents, &fetched,
-                                          &props, "A", 3,
+                                          &props, "A", 2,
                                           SVN_DIRENT_ALL, pool),
                           SVN_ERR_FS_NO_SUCH_REVISION);
 
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_dir2(ra_session, &dirents, &fetched,
+                                          &props, "Z", 1,
+                                          SVN_DIRENT_ALL, pool),
+                          SVN_ERR_FS_NOT_FOUND);
+
     SVN_ERR(svn_ra_get_dir2(ra_session, &dirents, &fetched,
                             &props, "A", SVN_INVALID_REVNUM,
                             SVN_DIRENT_ALL, pool));
@@ -950,6 +978,132 @@ ra_revision_errors(const svn_test_opts_t
     SVN_TEST_ASSERT(apr_hash_count(dirents) == 1);
   }
 
+  {
+    svn_mergeinfo_catalog_t catalog;
+    apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*));
+    APR_ARRAY_PUSH(paths, const char *) = "A";
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_mergeinfo(ra_session, &catalog, paths,
+                                               2, svn_mergeinfo_inherited,
+                                               FALSE, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_mergeinfo(ra_session, &catalog, paths,
+                                               0, svn_mergeinfo_inherited,
+                                               FALSE, pool),
+                          SVN_ERR_FS_NOT_FOUND);
+
+    SVN_ERR(svn_ra_get_mergeinfo(ra_session, &catalog, paths,
+                                 SVN_INVALID_REVNUM, svn_mergeinfo_inherited,
+                                 FALSE, pool));
+  }
+
+  {
+    apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*));
+    APR_ARRAY_PUSH(paths, const char *) = "A";
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, 0, 2, -1,
+                                          FALSE, FALSE, FALSE, NULL,
+                                          stub_log_receiver, NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, 2, 0, -1,
+                                          FALSE, FALSE, FALSE, NULL,
+                                          stub_log_receiver, NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths,
+                                          SVN_INVALID_REVNUM, 2, -1,
+                                          FALSE, FALSE, FALSE, NULL,
+                                          stub_log_receiver, NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths,
+                                          2, SVN_INVALID_REVNUM, -1,
+                                          FALSE, FALSE, FALSE, NULL,
+                                          stub_log_receiver, NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+  }
+
+  {
+    svn_node_kind_t kind;
+    SVN_TEST_ASSERT_ERROR(svn_ra_check_path(ra_session, "A", 2, &kind, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_ERR(svn_ra_check_path(ra_session, "A", SVN_INVALID_REVNUM, &kind,
+                              pool));
+
+    SVN_TEST_ASSERT(kind == svn_node_dir);
+  }
+
+  {
+    svn_dirent_t *dirent;
+    apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*));
+    APR_ARRAY_PUSH(paths, const char *) = "A";
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_stat(ra_session, "A", 2, &dirent, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_ERR(svn_ra_stat(ra_session, "A", SVN_INVALID_REVNUM, &dirent,
+                              pool));
+
+    SVN_TEST_ASSERT(dirent->kind == svn_node_dir);
+  }
+
+  {
+    apr_hash_t *locations;
+    apr_array_header_t *revisions = apr_array_make(pool, 2, sizeof(svn_revnum_t));
+    APR_ARRAY_PUSH(revisions, svn_revnum_t) = 1;
+
+    /* SVN_INVALID_REVNUM as passed revision doesn't work */
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_locations(ra_session, &locations, "A", 2,
+                                               revisions, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    APR_ARRAY_PUSH(revisions, svn_revnum_t) = 7;
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_locations(ra_session, &locations, "A", 1,
+                                               revisions, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    /* Putting SVN_INVALID_REVNUM in the array doesn't marshal properly in svn://
+     */
+  }
+
+  {
+    /* peg_rev   -> SVN_INVALID_REVNUM -> youngest
+       start_rev -> SVN_INVALID_REVNUM -> peg_rev
+       end_rev   -> SVN_INVALID_REVNUM -> 0 */
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A",
+                                                       2, 1, 0,
+                                                       stub_segment_receiver,
+                                                       NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A",
+                                                       SVN_INVALID_REVNUM,
+                                                       2, 0,
+                                                       stub_segment_receiver,
+                                                       NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+
+    SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A",
+                                                       SVN_INVALID_REVNUM,
+                                                       SVN_INVALID_REVNUM,
+                                                       2,
+                                                       stub_segment_receiver,
+                                                       NULL, pool),
+                          SVN_ERR_FS_NO_SUCH_REVISION);
+
+    SVN_ERR(svn_ra_get_location_segments(ra_session, "A",
+                                         SVN_INVALID_REVNUM,
+                                         SVN_INVALID_REVNUM,
+                                         SVN_INVALID_REVNUM,
+                                         stub_segment_receiver,
+                                         NULL, pool));
+  }
+
   return SVN_NO_ERROR;
 }