subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1694225 - in /subversion/trunk/subversion: bindings/javahl/native/SVNRepos.cpp include/svn_repos.h libsvn_repos/deprecated.c libsvn_repos/dump.c svnadmin/svnadmin.c tests/libsvn_repos/dump-load-test.c
Date Wed, 05 Aug 2015 14:15:51 GMT
Author: stefan2
Date: Wed Aug  5 14:15:51 2015
New Revision: 1694225

URL: http://svn.apache.org/r1694225
Log:
Implement the new 'svnadmin dump-revprops' sub-command.

The implementation uses a bumped version of svn_repos_dump_fs that can now
be told what kind of information to include in the dump.  These new flags
are "positive" and non-restrictive, e.g. INCLUDE_REVPROPS instead of
REVPROPS_ONLY.  That way, future revisions may easily extend this scheme.

* subversion/include/svn_repos.h
  (svn_repos_dump_fs4): Declared API revision.
  (svn_repos_dump_fs3): Deprecate the old one.

* subversion/libsvn_repos/dump.c
  (write_revision_record): Make dumping revprops an option.
  (svn_repos_dump_fs3): Replaced by ...
  (svn_repos_dump_fs4): ... the new API revision. Dump contents depending on
                        the two new flag parameters.

* subversion/libsvn_repos/deprecated.c
  (svn_repos_dump_fs3): Implement here now as forwarding to the latest API.

* subversion/bindings/javahl/native/SVNRepos.cpp
  (dump): Call latest API version.

* subversion/tests/libsvn_repos/dump-load-test.c
  (test_dump_bad_props): Same.

* subversion/svnadmin/svnadmin.c
  (svn_opt_subcommand_t): Declare new sub-command.
  (cmd_table): Define its UI.
  (get_dump_range): Factored out from ...
  (subcommand_dump): ... this.
  (subcommand_dump_revprops): Implement new sub-command. Code taken from
                              subcommand_dump.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/SVNRepos.cpp
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_repos/deprecated.c
    subversion/trunk/subversion/libsvn_repos/dump.c
    subversion/trunk/subversion/svnadmin/svnadmin.c
    subversion/trunk/subversion/tests/libsvn_repos/dump-load-test.c

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNRepos.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNRepos.cpp?rev=1694225&r1=1694224&r2=1694225&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNRepos.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNRepos.cpp Wed Aug  5 14:15:51 2015
@@ -240,8 +240,9 @@ void SVNRepos::dump(File &path, OutputSt
                      " (%ld)"), youngest), );
     }
 
-  SVN_JNI_ERR(svn_repos_dump_fs3(repos, dataOut.getStream(requestPool),
+  SVN_JNI_ERR(svn_repos_dump_fs4(repos, dataOut.getStream(requestPool),
                                  lower, upper, incremental, useDeltas,
+                                 true, true,
                                  notifyCallback != NULL
                                     ? ReposNotifyCallback::notify
                                     : NULL,

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1694225&r1=1694224&r2=1694225&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Wed Aug  5 14:15:51 2015
@@ -2989,6 +2989,12 @@ svn_repos_verify_fs(svn_repos_t *repos,
  * be done with full plain text.  A dump with @a use_deltas set cannot
  * be loaded by Subversion 1.0.x.
  *
+ * If @a include_revprops is @c TRUE, output the revision properties as
+ * well, otherwise omit them.
+ *
+ * If @a include_changes is @c TRUE, output the revision contents, i.e.
+ * tree and node changes.
+ *
  * If @a notify_func is not null, then call it with @a notify_baton and
  * with a notification structure in which the fields are set as follows.
  * (For a warning or error notification that does not apply to a specific
@@ -3020,8 +3026,31 @@ svn_repos_verify_fs(svn_repos_t *repos,
  *
  * Use @a scratch_pool for temporary allocation.
  *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_repos_dump_fs4(svn_repos_t *repos,
+                   svn_stream_t *stream,
+                   svn_revnum_t start_rev,
+                   svn_revnum_t end_rev,
+                   svn_boolean_t incremental,
+                   svn_boolean_t use_deltas,
+                   svn_boolean_t include_revprops,
+                   svn_boolean_t include_changes,
+                   svn_repos_notify_func_t notify_func,
+                   void *notify_baton,
+                   svn_cancel_func_t cancel_func,
+                   void *cancel_baton,
+                   apr_pool_t *pool);
+
+/**
+ * Similar to svn_repos_dump_fs4(), but with @a include_revprops and 
+ * @a include_changes both set to @c TRUE.
+ *
  * @since New in 1.7.
+ * @deprecated Provided for backward compatibility with the 1.9 API.
  */
+SVN_DEPRECATED
 svn_error_t *
 svn_repos_dump_fs3(svn_repos_t *repos,
                    svn_stream_t *dumpstream,

Modified: subversion/trunk/subversion/libsvn_repos/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/deprecated.c?rev=1694225&r1=1694224&r2=1694225&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_repos/deprecated.c Wed Aug  5 14:15:51 2015
@@ -731,6 +731,33 @@ repos_notify_handler(void *baton,
   }
 }
 
+svn_error_t *
+svn_repos_dump_fs3(svn_repos_t *repos,
+                   svn_stream_t *stream,
+                   svn_revnum_t start_rev,
+                   svn_revnum_t end_rev,
+                   svn_boolean_t incremental,
+                   svn_boolean_t use_deltas,
+                   svn_repos_notify_func_t notify_func,
+                   void *notify_baton,
+                   svn_cancel_func_t cancel_func,
+                   void *cancel_baton,
+                   apr_pool_t *pool)
+{
+  return svn_error_trace(svn_repos_dump_fs4(repos,
+                                            stream,
+                                            start_rev,
+                                            end_rev,
+                                            incremental,
+                                            use_deltas,
+                                            TRUE,
+                                            TRUE,
+                                            notify_func,
+                                            notify_baton,
+                                            cancel_func,
+                                            cancel_baton,
+                                            pool));
+}
 
 svn_error_t *
 svn_repos_dump_fs2(svn_repos_t *repos,

Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1694225&r1=1694224&r2=1694225&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Wed Aug  5 14:15:51 2015
@@ -1919,33 +1919,44 @@ get_dump_editor(const svn_delta_editor_t
 /* Helper for svn_repos_dump_fs.
 
    Write a revision record of REV in FS to writable STREAM, using POOL.
+   Dump revision properties as well if INCLUDE_REVPROPS has been set.
  */
 static svn_error_t *
 write_revision_record(svn_stream_t *stream,
                       svn_fs_t *fs,
                       svn_revnum_t rev,
+                      svn_boolean_t include_revprops,
                       apr_pool_t *pool)
 {
   apr_hash_t *props;
   apr_time_t timetemp;
   svn_string_t *datevalue;
 
-  SVN_ERR(svn_fs_revision_proplist(&props, fs, rev, pool));
+  if (include_revprops)
+    {
+      SVN_ERR(svn_fs_revision_proplist(&props, fs, rev, pool));
 
-  /* Run revision date properties through the time conversion to
-     canonicalize them. */
-  /* ### Remove this when it is no longer needed for sure. */
-  datevalue = svn_hash_gets(props, SVN_PROP_REVISION_DATE);
-  if (datevalue)
+      /* Run revision date properties through the time conversion to
+        canonicalize them. */
+      /* ### Remove this when it is no longer needed for sure. */
+      datevalue = svn_hash_gets(props, SVN_PROP_REVISION_DATE);
+      if (datevalue)
+        {
+          SVN_ERR(svn_time_from_cstring(&timetemp, datevalue->data, pool));
+          datevalue = svn_string_create(svn_time_to_cstring(timetemp, pool),
+                                        pool);
+          svn_hash_sets(props, SVN_PROP_REVISION_DATE, datevalue);
+        }
+    }
+   else
     {
-      SVN_ERR(svn_time_from_cstring(&timetemp, datevalue->data, pool));
-      datevalue = svn_string_create(svn_time_to_cstring(timetemp, pool),
-                                    pool);
-      svn_hash_sets(props, SVN_PROP_REVISION_DATE, datevalue);
+      /* Although we won't use it, we still need this container for the
+         call below. */
+      props = apr_hash_make(pool);
     }
 
   SVN_ERR(svn_repos__dump_revision_record(stream, rev, NULL, props,
-                                          TRUE /*props_section_always*/,
+                                          include_revprops,
                                           pool));
   return SVN_NO_ERROR;
 }
@@ -1954,12 +1965,14 @@ write_revision_record(svn_stream_t *stre
 
 /* The main dumper. */
 svn_error_t *
-svn_repos_dump_fs3(svn_repos_t *repos,
+svn_repos_dump_fs4(svn_repos_t *repos,
                    svn_stream_t *stream,
                    svn_revnum_t start_rev,
                    svn_revnum_t end_rev,
                    svn_boolean_t incremental,
                    svn_boolean_t use_deltas,
+                   svn_boolean_t include_revprops,
+                   svn_boolean_t include_changes,
                    svn_repos_notify_func_t notify_func,
                    void *notify_baton,
                    svn_cancel_func_t cancel_func,
@@ -2036,11 +2049,13 @@ svn_repos_dump_fs3(svn_repos_t *repos,
         SVN_ERR(cancel_func(cancel_baton));
 
       /* Write the revision record. */
-      SVN_ERR(write_revision_record(stream, fs, rev, subpool));
+      SVN_ERR(write_revision_record(stream, fs, rev, include_revprops,
+                                    subpool));
 
       /* When dumping revision 0, we just write out the revision record.
-         The parser might want to use its properties. */
-      if (rev == 0)
+         The parser might want to use its properties.
+         If we don't want revision changes at all, skip in any case. */
+      if (rev == 0 || !include_changes)
         goto loop_end;
 
       /* Fetch the editor which dumps nodes to a file.  Regardless of

Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1694225&r1=1694224&r2=1694225&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Wed Aug  5 14:15:51 2015
@@ -166,6 +166,7 @@ static svn_opt_subcommand_t
   subcommand_delrevprop,
   subcommand_deltify,
   subcommand_dump,
+  subcommand_dump_revprops,
   subcommand_freeze,
   subcommand_help,
   subcommand_hotcopy,
@@ -393,6 +394,15 @@ static const svn_opt_subcommand_desc2_t
     "changed in those revisions.)\n"),
   {'r', svnadmin__incremental, svnadmin__deltas, 'q', 'M'} },
 
+  {"dump-revprops", subcommand_dump_revprops, {0}, N_
+   ("usage: svnadmin dump-revprops REPOS_PATH [-r LOWER[:UPPER]]\n\n"
+    "Dump the revision properties of filesystem to stdout in a 'dumpfile'\n"
+    "portable format, sending feedback to stderr.  Dump revisions\n"
+    "LOWER rev through UPPER rev.  If no revisions are given, dump the\n"
+    "properties for all revisions.  If only LOWER is given, dump the\n"
+    "properties for that one revision.\n"),
+  {'r', 'q'} },
+
   {"freeze", subcommand_freeze, {0}, N_
    ("usage: 1. svnadmin freeze REPOS_PATH PROGRAM [ARG...]\n"
     "               2. svnadmin freeze -F FILE PROGRAM [ARG...]\n\n"
@@ -1200,55 +1210,104 @@ recode_stream_create(FILE *std_stream, a
   return rw_stream;
 }
 
-
-/* This implements `svn_opt_subcommand_t'. */
+/* Read the min / max revision from the OPT_STATE, verify them against REPOS
+   and return them in *LOWER and *UPPER, respectively.  Use SCRATCH_POOL
+   for temporary allocations. */
 static svn_error_t *
-subcommand_dump(apr_getopt_t *os, void *baton, apr_pool_t *pool)
+get_dump_range(svn_revnum_t *lower,
+               svn_revnum_t *upper,
+               svn_repos_t *repos,
+               struct svnadmin_opt_state *opt_state,
+               apr_pool_t *scratch_pool)
 {
-  struct svnadmin_opt_state *opt_state = baton;
-  svn_repos_t *repos;
   svn_fs_t *fs;
-  svn_stream_t *stdout_stream;
-  svn_revnum_t lower = SVN_INVALID_REVNUM, upper = SVN_INVALID_REVNUM;
   svn_revnum_t youngest;
-  svn_stream_t *feedback_stream = NULL;
 
-  /* Expect no more arguments. */
-  SVN_ERR(parse_args(NULL, os, 0, 0, pool));
+  *lower = SVN_INVALID_REVNUM;
+  *upper = SVN_INVALID_REVNUM;
 
-  SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
   fs = svn_repos_fs(repos);
-  SVN_ERR(svn_fs_youngest_rev(&youngest, fs, pool));
+  SVN_ERR(svn_fs_youngest_rev(&youngest, fs, scratch_pool));
 
   /* Find the revision numbers at which to start and end. */
-  SVN_ERR(get_revnum(&lower, &opt_state->start_revision,
-                     youngest, repos, pool));
-  SVN_ERR(get_revnum(&upper, &opt_state->end_revision,
-                     youngest, repos, pool));
+  SVN_ERR(get_revnum(lower, &opt_state->start_revision,
+                     youngest, repos, scratch_pool));
+  SVN_ERR(get_revnum(upper, &opt_state->end_revision,
+                     youngest, repos, scratch_pool));
 
   /* Fill in implied revisions if necessary. */
-  if (lower == SVN_INVALID_REVNUM)
+  if (*lower == SVN_INVALID_REVNUM)
     {
-      lower = 0;
-      upper = youngest;
+      *lower = 0;
+      *upper = youngest;
     }
-  else if (upper == SVN_INVALID_REVNUM)
+  else if (*upper == SVN_INVALID_REVNUM)
     {
-      upper = lower;
+      *upper = *lower;
     }
 
-  if (lower > upper)
+  if (*lower > *upper)
     return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
        _("First revision cannot be higher than second"));
 
+  return SVN_NO_ERROR;
+}
+
+/* This implements `svn_opt_subcommand_t'. */
+static svn_error_t *
+subcommand_dump(apr_getopt_t *os, void *baton, apr_pool_t *pool)
+{
+  struct svnadmin_opt_state *opt_state = baton;
+  svn_repos_t *repos;
+  svn_stream_t *stdout_stream;
+  svn_revnum_t lower, upper;
+  svn_stream_t *feedback_stream = NULL;
+
+  /* Expect no more arguments. */
+  SVN_ERR(parse_args(NULL, os, 0, 0, pool));
+
+  SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
+  SVN_ERR(get_dump_range(&lower, &upper, repos, opt_state, pool));
+
   SVN_ERR(svn_stream_for_stdout(&stdout_stream, pool));
 
   /* Progress feedback goes to STDERR, unless they asked to suppress it. */
   if (! opt_state->quiet)
     feedback_stream = recode_stream_create(stderr, pool);
 
-  SVN_ERR(svn_repos_dump_fs3(repos, stdout_stream, lower, upper,
+  SVN_ERR(svn_repos_dump_fs4(repos, stdout_stream, lower, upper,
                              opt_state->incremental, opt_state->use_deltas,
+                             TRUE, TRUE,
+                             !opt_state->quiet ? repos_notify_handler : NULL,
+                             feedback_stream, check_cancel, NULL, pool));
+
+  return SVN_NO_ERROR;
+}
+
+/* This implements `svn_opt_subcommand_t'. */
+static svn_error_t *
+subcommand_dump_revprops(apr_getopt_t *os, void *baton, apr_pool_t *pool)
+{
+  struct svnadmin_opt_state *opt_state = baton;
+  svn_repos_t *repos;
+  svn_stream_t *stdout_stream;
+  svn_revnum_t lower, upper;
+  svn_stream_t *feedback_stream = NULL;
+
+  /* Expect no more arguments. */
+  SVN_ERR(parse_args(NULL, os, 0, 0, pool));
+
+  SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
+  SVN_ERR(get_dump_range(&lower, &upper, repos, opt_state, pool));
+
+  SVN_ERR(svn_stream_for_stdout(&stdout_stream, pool));
+
+  /* Progress feedback goes to STDERR, unless they asked to suppress it. */
+  if (! opt_state->quiet)
+    feedback_stream = recode_stream_create(stderr, pool);
+
+  SVN_ERR(svn_repos_dump_fs4(repos, stdout_stream, lower, upper,
+                             FALSE, FALSE, TRUE, FALSE,
                              !opt_state->quiet ? repos_notify_handler : NULL,
                              feedback_stream, check_cancel, NULL, pool));
 

Modified: subversion/trunk/subversion/tests/libsvn_repos/dump-load-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_repos/dump-load-test.c?rev=1694225&r1=1694224&r2=1694225&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_repos/dump-load-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_repos/dump-load-test.c Wed Aug  5 14:15:51 2015
@@ -76,8 +76,8 @@ test_dump_bad_props(svn_stringbuf_t **du
   SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
 
   /* Test that a dump completes without error. */
-  SVN_ERR(svn_repos_dump_fs3(repos, stream, start_rev, end_rev,
-                             FALSE, FALSE,
+  SVN_ERR(svn_repos_dump_fs4(repos, stream, start_rev, end_rev,
+                             FALSE, FALSE, TRUE, TRUE,
                              notify_func, notify_baton,
                              NULL, NULL,
                              pool));



Mime
View raw message