You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ar...@apache.org on 2010/09/22 06:53:10 UTC

svn commit: r999755 - in /subversion/trunk/subversion: svnrdump/dump_editor.c tests/cmdline/svnrdump_tests.py

Author: artagnon
Date: Wed Sep 22 04:53:09 2010
New Revision: 999755

URL: http://svn.apache.org/viewvc?rev=999755&view=rev
Log:
svnrdump: Fix a bug related to dumping the properties of a directory
copied from a previous revision.

* subversion/svnrdump/dump_editor.c

  (dump_edit_baton): Add a new dump_newlines_pending boolean.

  (dump_node): If a directory is copied from a previous revision, set
  dump_newlines_pending so we can write blank lines if change_dir_prop
  isn't called.

  (dump_newlines): Create a function that resembles dump_props to
  print couple of blank lines.

  (add_directory, open_directory, delete_entry, close_directory,
  add_file, open_file): Add a call to dump_newlines trigger by
  dump_newlines_pending.

  (change_dir_prop): Trigger dumping props whether or not the
  directory has already been written out, and unset
  dump_newlines_pending because dump_props takes care of that.

* subversion/tests/cmdline/svnrdump_tests.py

  (test_list): Pass the move_and_modify_in_the_same_revision_dump
  test.

Modified:
    subversion/trunk/subversion/svnrdump/dump_editor.c
    subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py

Modified: subversion/trunk/subversion/svnrdump/dump_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/dump_editor.c?rev=999755&r1=999754&r2=999755&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/dump_editor.c (original)
+++ subversion/trunk/subversion/svnrdump/dump_editor.c Wed Sep 22 04:53:09 2010
@@ -69,6 +69,7 @@ struct dump_edit_baton {
   svn_boolean_t dump_props;
   svn_boolean_t dump_text;
   svn_boolean_t dump_props_pending;
+  svn_boolean_t dump_newlines_pending;
 };
 
 /* Make a directory baton to represent the directory at path (relative
@@ -179,6 +180,19 @@ dump_props(struct dump_edit_baton *eb,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+dump_newlines(struct dump_edit_baton *eb,
+           svn_boolean_t *trigger_var,
+           apr_pool_t *pool)
+{
+  if (trigger_var && *trigger_var)
+    {
+      SVN_ERR(svn_stream_printf(eb->stream, pool, "\n\n"));
+      *trigger_var = FALSE;
+    }
+  return SVN_NO_ERROR;
+}
+
 /*
  * Write out a node record for PATH of type KIND under EB->FS_ROOT.
  * ACTION describes what is happening to the node (see enum
@@ -294,12 +308,15 @@ dump_node(struct dump_edit_baton *eb,
                                 ": %s\n",
                                 copyfrom_rev, copyfrom_path));
 
-      /* Ugly hack: If a directory was copied from a previous revision,
-         nothing else can be done, and close_file won't be called to
-         write two blank lines. Write them here otherwise the `svnadmin
-         load` parser will fail. */
+      /* Ugly hack: If a directory was copied from a previous
+         revision, nothing like close_file will be called to write two
+         blank lines. If change_dir_prop is called, props are dumped
+         (along with the necessary PROPS-END\n\n and we're good. So
+         set a dump_newlines_pending here to print the newlines unless
+         change_dir_prop is called next otherwise the `svnadmin load`
+         parser will fail.  */ 
       if (kind == svn_node_dir)
-        SVN_ERR(svn_stream_printf(eb->stream, pool, "\n\n"));
+        eb->dump_newlines_pending = TRUE;
 
       break;
     }
@@ -345,6 +362,9 @@ delete_entry(const char *path,
   /* Some pending properties to dump? */
   SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
 
+  /* Some pending newlines to dump? */
+  SVN_ERR(dump_newlines(pb->eb, &(pb->eb->dump_newlines_pending), pool));
+
   /* Add this path to the deleted_entries of the parent directory
      baton. */
   apr_hash_set(pb->deleted_entries, apr_pstrdup(pb->eb->pool, path),
@@ -372,6 +392,9 @@ add_directory(const char *path,
   /* Some pending properties to dump? */
   SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
 
+  /* Some pending newlines to dump? */
+  SVN_ERR(dump_newlines(pb->eb, &(pb->eb->dump_newlines_pending), pool));
+
   /* This might be a replacement -- is the path already deleted? */
   val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);
 
@@ -414,6 +437,9 @@ open_directory(const char *path,
   /* Some pending properties to dump? */
   SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
 
+  /* Some pending newlines to dump? */
+  SVN_ERR(dump_newlines(pb->eb, &(pb->eb->dump_newlines_pending), pool));
+
   /* If the parent directory has explicit comparison path and rev,
      record the same for this one. */
   if (pb && ARE_VALID_COPY_ARGS(pb->copyfrom_path, pb->copyfrom_rev))
@@ -441,12 +467,15 @@ close_directory(void *dir_baton,
 
   LDR_DBG(("close_directory %p\n", dir_baton));
 
-  /* Create a pool just for iterations to allocate a loop variable */
-  iterpool = svn_pool_create(pool);
-
   /* Some pending properties to dump? */
   SVN_ERR(dump_props(eb, &(eb->dump_props_pending), TRUE, pool));
 
+  /* Some pending newlines to dump? */
+  SVN_ERR(dump_newlines(eb, &(eb->dump_newlines_pending), pool));
+
+  /* Create a pool just for iterations to allocate a loop variable */
+  iterpool = svn_pool_create(pool);
+
   /* Dump the deleted directory entries */
   for (hi = apr_hash_first(iterpool, db->deleted_entries); hi;
        hi = apr_hash_next(hi))
@@ -482,6 +511,9 @@ add_file(const char *path,
   /* Some pending properties to dump? */
   SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
 
+  /* Some pending newlines to dump? */
+  SVN_ERR(dump_newlines(pb->eb, &(pb->eb->dump_newlines_pending), pool));
+
   /* This might be a replacement -- is the path already deleted? */
   val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);
 
@@ -524,6 +556,9 @@ open_file(const char *path,
   /* Some pending properties to dump? */
   SVN_ERR(dump_props(pb->eb, &(pb->eb->dump_props_pending), TRUE, pool));
 
+  /* Some pending newlines to dump? */
+  SVN_ERR(dump_newlines(pb->eb, &(pb->eb->dump_newlines_pending), pool));
+
   /* If the parent directory has explicit copyfrom path and rev,
      record the same for this one. */
   if (pb && ARE_VALID_COPY_ARGS(pb->copyfrom_path, pb->copyfrom_rev))
@@ -574,10 +609,14 @@ change_dir_prop(void *parent_baton,
       SVN_ERR(dump_node(db->eb, db->abspath, svn_node_dir,
                         svn_node_action_change, FALSE, db->copyfrom_path,
                         db->copyfrom_rev, pool));
-
-      SVN_ERR(dump_props(db->eb, NULL, TRUE, pool));
       db->written_out = TRUE;
     }
+
+  /* Dump props whether or not the directory has been written
+     out. Then disable printing a couple of extra newlines */
+  SVN_ERR(dump_props(db->eb, NULL, TRUE, pool));
+  db->eb->dump_newlines_pending = FALSE;
+
   return SVN_NO_ERROR;
 }
 
@@ -757,6 +796,8 @@ close_file(void *file_baton,
       eb->dump_text = FALSE;
     }
 
+  /* Write a couple of blank lines for matching output with `svnadmin
+     dump` */
   SVN_ERR(svn_stream_printf(eb->stream, pool, "\n\n"));
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py?rev=999755&r1=999754&r2=999755&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnrdump_tests.py Wed Sep 22 04:53:09 2010
@@ -279,7 +279,7 @@ test_list = [ None,
               copy_revprops_load,
               no_author_dump,
               no_author_load,
-              Wimp("TODO", move_and_modify_in_the_same_revision_dump),
+              move_and_modify_in_the_same_revision_dump,
               Wimp("TODO", move_and_modify_in_the_same_revision_load,
                    svntest.main.is_ra_type_file),
              ]