Author: cmpilato
Date: Mon Dec 17 22:11:29 2012
New Revision: 1423188

URL: http://svn.apache.org/viewvc?rev=1423188&view=rev
Log:
Follow-up to r1422206, aiming for more code clarity.

* subversion/svnrdump/svnrdump.h
  (svn_rdump__get_dump_editor): Rename 'edit_root_relpath' parameter
    to 'update_anchor_relpath' and tweak description for clarify.

* subversion/svnrdump/dump_editor.c
  (struct dump_edit_baton): Rename 'edit_root_relpath' to
    'update_anchor_relpath' and tweak description for clarify.
    Consumers throughout updated.
  (dump_mkdir): Lose 'include_props' parameter, and always include the
    (empty set of) props.
  (dump_pending): Move this higher in the source file.  No changes.
  (open_root): Rework this a bit to be a touch less obscure, and to
    make use of other preexisting plumbing functions where possible.
    Track renamed baton member.
  (svn_rdump__get_dump_editor): Rename 'edit_root_relpath' parameter
    to 'update_anchor_relpath'.

Modified:
    subversion/trunk/subversion/svnrdump/dump_editor.c
    subversion/trunk/subversion/svnrdump/svnrdump.h

Modified: subversion/trunk/subversion/svnrdump/dump_editor.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/dump_editor.c?rev=1423188&r1=1423187&r2=1423188&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/dump_editor.c (original)
+++ subversion/trunk/subversion/svnrdump/dump_editor.c Mon Dec 17 22:11:29 2012
@@ -101,8 +101,13 @@ struct dump_edit_baton {
   /* A backdoor ra session to fetch additional information during the edit. */
   svn_ra_session_t *ra_session;
 
-  /* The relative repository path of the root of the editor drive. */
-  const char *edit_root_relpath;
+  /* The repository relpath of the anchor of the editor when driven
+     via the RA update mechanism; NULL otherwise. (When the editor is
+     driven via the RA "replay" mechanism instead, the editor is
+     always anchored at the repository, we don't need to prepend an
+     anchor path to the dumped node paths, and open_root() doesn't
+     need to manufacture directory additions.)  */
+  const char *update_anchor_relpath;
 
   /* Pool for per-revision allocations */
   apr_pool_t *pool;
@@ -317,8 +322,8 @@ dump_node(struct dump_edit_baton *eb,
   assert(!copyfrom_path || svn_relpath_is_canonical(copyfrom_path));
 
   /* Add the edit root relpath prefix if necessary. */
-  if (eb->edit_root_relpath)
-    node_relpath = svn_relpath_join(eb->edit_root_relpath, node_relpath, pool);
+  if (eb->update_anchor_relpath)
+    node_relpath = svn_relpath_join(eb->update_anchor_relpath, node_relpath, 
pool);
 
   /* Node-path: commons/STATUS */
   SVN_ERR(svn_stream_printf(eb->stream, pool,
@@ -427,7 +432,6 @@ dump_node(struct dump_edit_baton *eb,
 static svn_error_t *
 dump_mkdir(struct dump_edit_baton *eb,
            const char *repos_relpath,
-           svn_boolean_t include_props,
            apr_pool_t *pool)
 {
   svn_stringbuf_t *prop_header, *prop_content;
@@ -446,24 +450,39 @@ dump_mkdir(struct dump_edit_baton *eb,
   SVN_ERR(svn_stream_puts(eb->stream,
                           SVN_REPOS_DUMPFILE_NODE_ACTION ": add\n"));
 
-  if (include_props)
-    {
-      /* Dump the (empty) property block. */
-      SVN_ERR(get_props_content(&prop_header, &prop_content,
-                                apr_hash_make(pool), apr_hash_make(pool),
-                                pool, pool));
-      len = prop_header->len;
-      SVN_ERR(svn_stream_write(eb->stream, prop_header->data, &len));
-      len = prop_content->len;
-      buf = apr_psprintf(pool, SVN_REPOS_DUMPFILE_CONTENT_LENGTH
-                         ": %" APR_SIZE_T_FMT "\n", len);
-      SVN_ERR(svn_stream_puts(eb->stream, buf));
-      SVN_ERR(svn_stream_puts(eb->stream, "\n"));
-      SVN_ERR(svn_stream_write(eb->stream, prop_content->data, &len));
-      
-      /* Newlines to tie it all off. */
-      SVN_ERR(svn_stream_puts(eb->stream, "\n\n"));
-    }
+  /* Dump the (empty) property block. */
+  SVN_ERR(get_props_content(&prop_header, &prop_content,
+                            apr_hash_make(pool), apr_hash_make(pool),
+                            pool, pool));
+  len = prop_header->len;
+  SVN_ERR(svn_stream_write(eb->stream, prop_header->data, &len));
+  len = prop_content->len;
+  buf = apr_psprintf(pool, SVN_REPOS_DUMPFILE_CONTENT_LENGTH
+                     ": %" APR_SIZE_T_FMT "\n", len);
+  SVN_ERR(svn_stream_puts(eb->stream, buf));
+  SVN_ERR(svn_stream_puts(eb->stream, "\n"));
+  SVN_ERR(svn_stream_write(eb->stream, prop_content->data, &len));
+
+  /* Newlines to tie it all off. */
+  SVN_ERR(svn_stream_puts(eb->stream, "\n\n"));
+
+  return SVN_NO_ERROR;
+}
+
+/* Dump pending items from the specified node, to allow starting the dump
+   of a child node */
+static svn_error_t *
+dump_pending(struct dir_baton *pb,
+             apr_pool_t *scratch_pool)
+{
+  /* Some pending properties to dump? */
+  SVN_ERR(do_dump_props(&pb->eb->propstring, pb->eb->stream,
+                        pb->eb->props, pb->eb->deleted_props,
+                        &(pb->eb->dump_props), TRUE,
+                        pb->pool, scratch_pool));
+
+  /* Some pending newlines to dump? */
+  SVN_ERR(do_dump_newlines(pb->eb, &(pb->eb->dump_newlines), scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -475,7 +494,8 @@ open_root(void *edit_baton,
           void **root_baton)
 {
   struct dump_edit_baton *eb = edit_baton;
-
+  struct dir_baton *new_db = NULL;
+  
   /* Clear the per-revision pool after each revision */
   svn_pool_clear(eb->pool);
 
@@ -483,17 +503,12 @@ open_root(void *edit_baton,
   eb->deleted_props = apr_hash_make(eb->pool);
   eb->propstring = svn_stringbuf_create_empty(eb->pool);
 
-  *root_baton = make_dir_baton(NULL, NULL, SVN_INVALID_REVNUM,
-                               edit_baton, NULL, FALSE, eb->pool);
   LDR_DBG(("open_root %p\n", *root_baton));
 
-  /* If our editor is not describing changes relative to the
-     repository root, we need to manufacture the add of that path and
-     its parents in our dump output. */
-  if (eb->edit_root_relpath)
+  if (eb->update_anchor_relpath)
     {
       int i;
-      const char *parent_path = eb->edit_root_relpath;
+      const char *parent_path = eb->update_anchor_relpath;
       apr_array_header_t *dirs_to_add =
         apr_array_make(pool, 4, sizeof(const char *));
       apr_pool_t *iterpool = svn_pool_create(pool);
@@ -504,36 +519,42 @@ open_root(void *edit_baton,
           parent_path = svn_relpath_dirname(parent_path, pool);
         }
 
-      for (i = dirs_to_add->nelts; i > 0; --i)
+      for (i = dirs_to_add->nelts; i; --i)
         {
           const char *dir_to_add =
             APR_ARRAY_IDX(dirs_to_add, i - 1, const char *);
 
           svn_pool_clear(iterpool);
-          eb->dump_props = TRUE;
-          SVN_ERR(dump_mkdir(eb, dir_to_add, i > 1, iterpool));
+
+          /* For parents of the source directory, we just manufacture
+             the adds ourselves. */
+          if (i > 1)
+            {
+              SVN_ERR(dump_mkdir(eb, dir_to_add, iterpool));
+            }
+          else
+            {
+              /* ... but for the source directory itself, we'll defer
+                 to letting the typical plumbing handle this task. */
+              new_db = make_dir_baton(NULL, NULL, SVN_INVALID_REVNUM,
+                                      edit_baton, NULL, TRUE, pool);
+              SVN_ERR(dump_node(eb, new_db->repos_relpath, svn_node_dir,
+                                svn_node_action_add, FALSE, NULL, 
SVN_INVALID_REVNUM,
+                                pool));
+              new_db->written_out = TRUE;
+            }
         }
       svn_pool_destroy(iterpool);
     }
-    
-  return SVN_NO_ERROR;
-}
 
-/* Dump pending items from the specified node, to allow starting the dump
-   of a child node */
-static svn_error_t *
-dump_pending(struct dir_baton *pb,
-             apr_pool_t *scratch_pool)
-{
-  /* Some pending properties to dump? */
-  SVN_ERR(do_dump_props(&pb->eb->propstring, pb->eb->stream,
-                        pb->eb->props, pb->eb->deleted_props,
-                        &(pb->eb->dump_props), TRUE,
-                        pb->pool, scratch_pool));
-
-  /* Some pending newlines to dump? */
-  SVN_ERR(do_dump_newlines(pb->eb, &(pb->eb->dump_newlines), scratch_pool));
+  if (! new_db)
+    {
+      new_db = make_dir_baton(NULL, NULL, SVN_INVALID_REVNUM,
+                              edit_baton, NULL, FALSE, pool);
+    }
 
+  *root_baton = new_db;
+    
   return SVN_NO_ERROR;
 }
 
@@ -1096,7 +1117,7 @@ svn_rdump__get_dump_editor(const svn_del
                            svn_revnum_t revision,
                            svn_stream_t *stream,
                            svn_ra_session_t *ra_session,
-                           const char *edit_root_relpath,
+                           const char *update_anchor_relpath,
                            svn_cancel_func_t cancel_func,
                            void *cancel_baton,
                            apr_pool_t *pool)
@@ -1109,7 +1130,7 @@ svn_rdump__get_dump_editor(const svn_del
   eb = apr_pcalloc(pool, sizeof(struct dump_edit_baton));
   eb->stream = stream;
   eb->ra_session = ra_session;
-  eb->edit_root_relpath = edit_root_relpath;
+  eb->update_anchor_relpath = update_anchor_relpath;
   eb->current_revision = revision;
 
   /* Create a special per-revision pool */

Modified: subversion/trunk/subversion/svnrdump/svnrdump.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.h?rev=1423188&r1=1423187&r2=1423188&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.h (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.h Mon Dec 17 22:11:29 2012
@@ -41,8 +41,10 @@ extern "C" {
  * Get a dump editor @a editor along with a @a edit_baton allocated in
  * @a pool.  The editor will write output to @a stream.
  *
- * @a edit_root_relpath is the relative repository path of the drive
- * which will happen on @a *editor.
+ * @a update_anchor_relpath is the repository relative path of the
+ * anchor of the update-style drive which will happen on @a *editor;
+ * if a replay-style drive will instead be used, it should be passed
+ * as @c NULL.
  *
  * Use @a cancel_func and @a cancel_baton to check for user
  * cancellation of the operation (for timely-but-safe termination).
@@ -53,7 +55,7 @@ svn_rdump__get_dump_editor(const svn_del
                            svn_revnum_t revision,
                            svn_stream_t *stream,
                            svn_ra_session_t *ra_session,
-                           const char *edit_root_relpath,
+                           const char *update_anchor_relpath,
                            svn_cancel_func_t cancel_func,
                            void *cancel_baton,
                            apr_pool_t *pool);


Reply via email to