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

svn commit: r1680476 - in /subversion/trunk/subversion: libsvn_fs_fs/low_level.c tests/svn_test_fs.c

Author: stefan2
Date: Wed May 20 07:53:12 2015
New Revision: 1680476

URL: http://svn.apache.org/r1680476
Log:
Include the revision number into FSFS format 7 footer error messages.

* subversion/libsvn_fs_fs/low_level.c
  (wrap_footer_error): New utility function, replacing SVN_ERR_W in ...
  (svn_fs_fs__parse_footer): ... this one. Include the REV in the other
                             error messages as well.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/low_level.c
    subversion/trunk/subversion/tests/svn_test_fs.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/low_level.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/low_level.c?rev=1680476&r1=1680475&r2=1680476&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/low_level.c Wed May 20 07:53:12 2015
@@ -189,6 +189,19 @@ svn_fs_fs__unparse_revision_trailer(apr_
                                changes_offset);
 }
 
+/* If ERR is not NULL, wrap it MESSAGE.  The latter must have an %ld
+ * format parameter that will be filled with REV. */
+static svn_error_t *
+wrap_footer_error(svn_error_t *err,
+                  const char *message,
+                  svn_revnum_t rev)
+{
+  if (err)
+    return svn_error_quick_wrapf(err, message, rev);
+
+  return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_fs_fs__parse_footer(apr_off_t *l2p_offset,
                         svn_checksum_t **l2p_checksum,
@@ -205,18 +218,20 @@ svn_fs_fs__parse_footer(apr_off_t *l2p_o
   /* Get the L2P offset. */
   const char *str = svn_cstring_tokenize(" ", &last_str);
   if (str == NULL)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Invalid revision footer"));
+    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
+                             "Invalid r%ld footer", rev);
 
-  SVN_ERR_W(svn_cstring_strtoi64(&val, str, 0, footer_offset - 1, 10),
-            "Invalid L2P offset in revision footer");
+  SVN_ERR(wrap_footer_error(svn_cstring_strtoi64(&val, str, 0,
+                                                 footer_offset - 1, 10),
+                            "Invalid L2P offset in r%ld footer",
+                            rev));
   *l2p_offset = (apr_off_t)val;
 
   /* Get the L2P checksum. */
   str = svn_cstring_tokenize(" ", &last_str);
   if (str == NULL)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Invalid revision footer"));
+    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
+                             "Invalid r%ld footer", rev);
 
   SVN_ERR(svn_checksum_parse_hex(l2p_checksum, svn_checksum_md5, str,
                                  result_pool));
@@ -224,30 +239,33 @@ svn_fs_fs__parse_footer(apr_off_t *l2p_o
   /* Get the P2L offset. */
   str = svn_cstring_tokenize(" ", &last_str);
   if (str == NULL)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Invalid revision footer"));
+    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
+                             "Invalid r%ld footer", rev);
 
-  SVN_ERR_W(svn_cstring_strtoi64(&val, str, 0, footer_offset - 1, 10),
-            "Invalid P2L offset in revision footer");
+  SVN_ERR(wrap_footer_error(svn_cstring_strtoi64(&val, str, 0,
+                                                 footer_offset - 1, 10),
+                            "Invalid P2L offset in r%ld footer",
+                            rev));
   *p2l_offset = (apr_off_t)val;
 
   /* The P2L indes follows the L2P index */
   if (*p2l_offset <= *l2p_offset)
     return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                              "P2L offset %s must be larger than L2P offset %s"
-                             " in revision footer",
+                             " in r%ld footer",
                              apr_psprintf(result_pool,
                                           "%" APR_UINT64_T_HEX_FMT,
                                           (apr_uint64_t)*p2l_offset),
                              apr_psprintf(result_pool,
                                           "%" APR_UINT64_T_HEX_FMT,
-                                          (apr_uint64_t)*l2p_offset));
+                                          (apr_uint64_t)*l2p_offset),
+                             rev);
 
   /* Get the P2L checksum. */
   str = svn_cstring_tokenize(" ", &last_str);
   if (str == NULL)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Invalid revision footer"));
+    return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
+                             "Invalid r%ld footer", rev);
 
   SVN_ERR(svn_checksum_parse_hex(p2l_checksum, svn_checksum_md5, str,
                                  result_pool));

Modified: subversion/trunk/subversion/tests/svn_test_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_fs.c?rev=1680476&r1=1680475&r2=1680476&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_fs.c (original)
+++ subversion/trunk/subversion/tests/svn_test_fs.c Wed May 20 07:53:12 2015
@@ -399,27 +399,30 @@ static svn_error_t *
 get_dir_entries(apr_hash_t *tree_entries,
                 svn_fs_root_t *root,
                 const char *path,
-                apr_pool_t *pool)
+                apr_pool_t *scratch_pool)
 {
   apr_hash_t *entries;
   apr_hash_index_t *hi;
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+  apr_pool_t *result_pool = apr_hash_pool_get(tree_entries);
 
-  SVN_ERR(svn_fs_dir_entries(&entries, root, path, pool));
+  SVN_ERR(svn_fs_dir_entries(&entries, root, path, scratch_pool));
 
   /* Copy this list to the master list with the path prepended to the
      names */
-  for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
+  for (hi = apr_hash_first(scratch_pool, entries); hi; hi = apr_hash_next(hi))
     {
       void *val;
       svn_fs_dirent_t *dirent;
       const char *full_path;
+      svn_pool_clear(iterpool);
 
       apr_hash_this(hi, NULL, NULL, &val);
       dirent = val;
 
       /* Calculate the full path of this entry (by appending the name
          to the path thus far) */
-      full_path = svn_path_join(path, dirent->name, pool);
+      full_path = svn_path_join(path, dirent->name, result_pool);
 
       /* Now, copy this dirent to the master hash, but this time, use
          the full path for the key */
@@ -427,7 +430,7 @@ get_dir_entries(apr_hash_t *tree_entries
 
       /* If this entry is a directory, recurse into the tree. */
       if (dirent->kind == svn_node_dir)
-        SVN_ERR(get_dir_entries(tree_entries, root, full_path, pool));
+        SVN_ERR(get_dir_entries(tree_entries, root, full_path, iterpool));
     }
 
   return SVN_NO_ERROR;
@@ -500,6 +503,7 @@ svn_test__validate_tree(svn_fs_root_t *r
 {
   apr_hash_t *tree_entries, *expected_entries;
   apr_pool_t *subpool = svn_pool_create(pool);
+  apr_pool_t *iterpool = svn_pool_create(pool);
   svn_stringbuf_t *extra_entries = NULL;
   svn_stringbuf_t *missing_entries = NULL;
   svn_stringbuf_t *corrupt_entries = NULL;
@@ -509,6 +513,13 @@ svn_test__validate_tree(svn_fs_root_t *r
   /* There should be no entry with this name. */
   const char *na_name = "es-vee-en";
 
+  /* Create our master hash for storing the entries */
+  tree_entries = apr_hash_make(subpool);
+
+  /* Recursively get the whole tree */
+  SVN_ERR(get_dir_entries(tree_entries, root, "", iterpool));
+  svn_pool_clear(iterpool);
+
   /* Create a hash for storing our expected entries */
   expected_entries = apr_hash_make(subpool);
 
@@ -517,12 +528,6 @@ svn_test__validate_tree(svn_fs_root_t *r
     apr_hash_set(expected_entries, entries[i].path,
                  APR_HASH_KEY_STRING, &(entries[i]));
 
-  /* Create our master hash for storing the entries */
-  tree_entries = apr_hash_make(pool);
-
-  /* Begin the recursive directory entry dig */
-  SVN_ERR(get_dir_entries(tree_entries, root, "", subpool));
-
   /* For each entry in our EXPECTED_ENTRIES hash, try to find that
      entry in the TREE_ENTRIES hash given us by the FS.  If we find
      that object, remove it from the TREE_ENTRIES.  If we don't find
@@ -536,6 +541,7 @@ svn_test__validate_tree(svn_fs_root_t *r
       void *val;
       svn_test__tree_entry_t *entry;
 
+      svn_pool_clear(iterpool);
       apr_hash_this(hi, &key, &keylen, &val);
       entry = val;
 
@@ -546,7 +552,7 @@ svn_test__validate_tree(svn_fs_root_t *r
           svn_error_t *err;
 
           if ((err = validate_tree_entry(root, entry->path,
-                                         entry->contents, subpool)))
+                                         entry->contents, iterpool)))
             {
               /* If we don't have a corrupt entries string, make one. */
               if (! corrupt_entries)
@@ -627,6 +633,7 @@ svn_test__validate_tree(svn_fs_root_t *r
          extra_entries ? extra_entries->data : "");
     }
 
+  svn_pool_destroy(iterpool);
   svn_pool_destroy(subpool);
   return SVN_NO_ERROR;
 }
@@ -675,6 +682,7 @@ svn_test__txn_script_exec(svn_fs_root_t
                           apr_pool_t *pool)
 {
   int i;
+  apr_pool_t *iterpool = svn_pool_create(pool);
 
   /* Run through the list of edits, making the appropriate edit on
      that entry in the TXN_ROOT. */
@@ -685,18 +693,19 @@ svn_test__txn_script_exec(svn_fs_root_t
       int cmd = script[i].cmd;
       svn_boolean_t is_dir = (param1 == 0);
 
+      svn_pool_clear(iterpool);
       switch (cmd)
         {
         case 'a':
           if (is_dir)
             {
-              SVN_ERR(svn_fs_make_dir(txn_root, path, pool));
+              SVN_ERR(svn_fs_make_dir(txn_root, path, iterpool));
             }
           else
             {
-              SVN_ERR(svn_fs_make_file(txn_root, path, pool));
+              SVN_ERR(svn_fs_make_file(txn_root, path, iterpool));
               SVN_ERR(svn_test__set_file_contents(txn_root, path,
-                                                  param1, pool));
+                                                  param1, iterpool));
             }
           break;
 
@@ -706,21 +715,21 @@ svn_test__txn_script_exec(svn_fs_root_t
             svn_fs_root_t *rev_root;
             svn_fs_t *fs = svn_fs_root_fs(txn_root);
 
-            SVN_ERR(svn_fs_youngest_rev(&youngest, fs, pool));
-            SVN_ERR(svn_fs_revision_root(&rev_root, fs, youngest, pool));
-            SVN_ERR(svn_fs_copy(rev_root, path, txn_root, param1, pool));
+            SVN_ERR(svn_fs_youngest_rev(&youngest, fs, iterpool));
+            SVN_ERR(svn_fs_revision_root(&rev_root, fs, youngest, iterpool));
+            SVN_ERR(svn_fs_copy(rev_root, path, txn_root, param1, iterpool));
           }
           break;
 
         case 'd':
-          SVN_ERR(svn_fs_delete(txn_root, path, pool));
+          SVN_ERR(svn_fs_delete(txn_root, path, iterpool));
           break;
 
         case 'e':
           if (! is_dir)
             {
               SVN_ERR(svn_test__set_file_contents(txn_root, path,
-                                                  param1, pool));
+                                                  param1, iterpool));
             }
           break;
 
@@ -729,6 +738,7 @@ svn_test__txn_script_exec(svn_fs_root_t
         }
     }
 
+  svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }
 
@@ -765,21 +775,26 @@ svn_test__check_greek_tree(svn_fs_root_t
   svn_stringbuf_t *rstring;
   svn_stringbuf_t *content;
   const struct svn_test__tree_entry_t *node;
+  apr_pool_t *iterpool = svn_pool_create(pool);
 
   /* Loop through the list of files, checking for matching content. */
   for (node = svn_test__greek_tree_nodes; node->path; node++)
     {
       if (node->contents)
         {
-          SVN_ERR(svn_fs_file_contents(&rstream, root, node->path, pool));
-          SVN_ERR(svn_test__stream_to_string(&rstring, rstream, pool));
-          content = svn_stringbuf_create(node->contents, pool);
+          svn_pool_clear(iterpool);
+
+          SVN_ERR(svn_fs_file_contents(&rstream, root, node->path, iterpool));
+          SVN_ERR(svn_test__stream_to_string(&rstring, rstream, iterpool));
+          content = svn_stringbuf_create(node->contents, iterpool);
           if (! svn_stringbuf_compare(rstring, content))
             return svn_error_createf(SVN_ERR_FS_GENERAL, NULL,
                                      "data read != data written in file '%s'.",
                                      node->path);
         }
     }
+
+  svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }
 
@@ -789,22 +804,28 @@ svn_test__create_greek_tree_at(svn_fs_ro
                                apr_pool_t *pool)
 {
   const struct svn_test__tree_entry_t *node;
+  apr_pool_t *iterpool = svn_pool_create(pool);
 
   for (node = svn_test__greek_tree_nodes; node->path; node++)
     {
-      const char *path = svn_relpath_join(root_dir, node->path, pool);
+      const char *path;
+      svn_pool_clear(iterpool);
+
+      path = svn_relpath_join(root_dir, node->path, iterpool);
 
       if (node->contents)
         {
-          SVN_ERR(svn_fs_make_file(txn_root, path, pool));
+          SVN_ERR(svn_fs_make_file(txn_root, path, iterpool));
           SVN_ERR(svn_test__set_file_contents(txn_root, path, node->contents,
-                                              pool));
+                                              iterpool));
         }
       else
         {
-          SVN_ERR(svn_fs_make_dir(txn_root, path, pool));
+          SVN_ERR(svn_fs_make_dir(txn_root, path, iterpool));
         }
     }
+
+  svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }