Author: julianfoad
Date: Mon Oct 15 15:40:20 2018
New Revision: 1843919

URL: http://svn.apache.org/viewvc?rev=1843919&view=rev
Log:
Factor out the dump-stream header writing functions.

Although these are small functions, consistency is nice.

* subversion/include/private/svn_repos_private.h,
  subversion/libsvn_repos/dump.c
  (svn_repos__dump_magic_header_record,
   svn_repos__dump_uuid_header_record): New.
  (svn_repos_dump_fs4): Use them.

* subversion/svndumpfilter/svndumpfilter.c
  (magic_header_record,
   uuid_record): Use them.

* subversion/svnrdump/svnrdump.c
  (replay_revisions): Use them.

Modified:
    subversion/trunk/subversion/include/private/svn_repos_private.h
    subversion/trunk/subversion/libsvn_repos/dump.c
    subversion/trunk/subversion/svndumpfilter/svndumpfilter.c
    subversion/trunk/subversion/svnrdump/svnrdump.c

Modified: subversion/trunk/subversion/include/private/svn_repos_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_repos_private.h?rev=1843919&r1=1843918&r2=1843919&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_repos_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_repos_private.h Mon Oct 15 
15:40:20 2018
@@ -297,6 +297,23 @@ svn_repos__dump_headers(svn_stream_t *st
                         svn_repos__dumpfile_headers_t *headers,
                         apr_pool_t *scratch_pool);
 
+/* Write a magic header record to DUMP_STREAM specifying format version
+ * VERSION.
+ */
+svn_error_t *
+svn_repos__dump_magic_header_record(svn_stream_t *dump_stream,
+                                    int version,
+                                    apr_pool_t *pool);
+
+/* Write a UUID record to DUMP_STREAM.
+ *
+ * If UUID is NULL then write nothing at all.
+ */
+svn_error_t *
+svn_repos__dump_uuid_header_record(svn_stream_t *dump_stream,
+                                   const char *uuid,
+                                   apr_pool_t *pool);
+
 /* Write a revision record to DUMP_STREAM for revision REVISION with revision
  * properies REVPROPS, creating appropriate headers.
  *

Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1843919&r1=1843918&r2=1843919&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Mon Oct 15 15:40:20 2018
@@ -512,6 +512,30 @@ svn_repos__dump_headers(svn_stream_t *st
 }
 
 svn_error_t *
+svn_repos__dump_magic_header_record(svn_stream_t *dump_stream,
+                                    int version,
+                                    apr_pool_t *pool)
+{
+  SVN_ERR(svn_stream_printf(dump_stream, pool,
+                            SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n\n",
+                            version));
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_repos__dump_uuid_header_record(svn_stream_t *dump_stream,
+                                   const char *uuid,
+                                   apr_pool_t *pool)
+{
+  if (uuid)
+    {
+      SVN_ERR(svn_stream_printf(dump_stream, pool, SVN_REPOS_DUMPFILE_UUID
+                                ": %s\n\n", uuid));
+    }
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_repos__dump_revision_record(svn_stream_t *dump_stream,
                                 svn_revnum_t revision,
                                 apr_hash_t *extra_headers,
@@ -2062,11 +2086,8 @@ svn_repos_dump_fs4(svn_repos_t *repos,
 
   /* Write out "general" metadata for the dumpfile.  In this case, a
      magic header followed by a dumpfile format version. */
-  SVN_ERR(svn_stream_printf(stream, pool,
-                            SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n\n",
-                            version));
-  SVN_ERR(svn_stream_printf(stream, pool, SVN_REPOS_DUMPFILE_UUID
-                            ": %s\n\n", uuid));
+  SVN_ERR(svn_repos__dump_magic_header_record(stream, version, pool));
+  SVN_ERR(svn_repos__dump_uuid_header_record(stream, uuid, pool));
 
   /* Create a notify object that we can reuse in the loop. */
   if (notify_func)

Modified: subversion/trunk/subversion/svndumpfilter/svndumpfilter.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svndumpfilter/svndumpfilter.c?rev=1843919&r1=1843918&r2=1843919&view=diff
==============================================================================
--- subversion/trunk/subversion/svndumpfilter/svndumpfilter.c (original)
+++ subversion/trunk/subversion/svndumpfilter/svndumpfilter.c Mon Oct 15 
15:40:20 2018
@@ -271,9 +271,7 @@ magic_header_record(int version, void *p
   if (version >= SVN_REPOS_DUMPFILE_FORMAT_VERSION_DELTAS)
     pb->allow_deltas = TRUE;
 
-  SVN_ERR(svn_stream_printf(pb->out_stream, pool,
-                            SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n\n",
-                            version));
+  SVN_ERR(svn_repos__dump_magic_header_record(pb->out_stream, version, pool));
 
   return SVN_NO_ERROR;
 }
@@ -446,8 +444,8 @@ static svn_error_t *
 uuid_record(const char *uuid, void *parse_baton, apr_pool_t *pool)
 {
   struct parse_baton_t *pb = parse_baton;
-  SVN_ERR(svn_stream_printf(pb->out_stream, pool,
-                            SVN_REPOS_DUMPFILE_UUID ": %s\n\n", uuid));
+
+  SVN_ERR(svn_repos__dump_uuid_header_record(pb->out_stream, uuid, pool));
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/svnrdump/svnrdump.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.c?rev=1843919&r1=1843918&r2=1843919&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.c (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.c Mon Oct 15 15:40:20 2018
@@ -497,12 +497,11 @@ replay_revisions(svn_ra_session_t *sessi
   replay_baton->quiet = quiet;
 
   /* Write the magic header and UUID */
-  SVN_ERR(svn_stream_printf(output_stream, pool,
-                            SVN_REPOS_DUMPFILE_MAGIC_HEADER ": %d\n\n",
-                            SVN_REPOS_DUMPFILE_FORMAT_VERSION));
+  SVN_ERR(svn_repos__dump_magic_header_record(output_stream,
+                                              
SVN_REPOS_DUMPFILE_FORMAT_VERSION,
+                                              pool));
   SVN_ERR(svn_ra_get_uuid2(session, &uuid, pool));
-  SVN_ERR(svn_stream_printf(output_stream, pool,
-                            SVN_REPOS_DUMPFILE_UUID ": %s\n\n", uuid));
+  SVN_ERR(svn_repos__dump_uuid_header_record(output_stream, uuid, pool));
 
   /* Fake revision 0 if necessary */
   if (start_revision == 0)


Reply via email to