{"thread":{"id":"24333","subject":"[PATCH] Add svnrdump","startedAt":"2010-07-08T08:17:53Z","lastAt":"2010-07-09T16:51:12Z","messageCount":11,"participants":["Ramkumar Ramachandra","Bert Huijben","Daniel Shahaf","Blair Zajac","Michael J Gruber","Sverre Rabbelier","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"145112","messageId":"alpine.561.2.00.1007081113210.3936@daniel2.local","threadId":"24333","inReplyTo":"002d01cb1e7f$e0ff03c0$a2fd0b40$@nl","subject":"RE: [PATCH] Add svnrdump","fromName":"Daniel Shahaf","fromEmail":"d.s@daniel.shahaf.name","sentAt":"2010-07-08T08:17:53Z","receivedAt":"2010-07-08T08:17:53Z","isPatch":true,"sender":{"key":"d.s@daniel.shahaf.name","avatar":null},"body":"@Bert: could you please trim quoted patches to only the relevant parts?\nScrolling is tedious when I don't have have line folding available...\n\nBert Huijben wrote on Thu, 8 Jul 2010 at 12:28 -0000:\n> > -----Original Message-----\n> > From: Ramkumar Ramachandra [mailto:artagnon@gmail.com]\n> > Sent: donderdag 8 juli 2010 10:35\n> > To: dev@subversion.apache.org\n> > Cc: Jonathan Nieder; Sverre Rabbelier; Git Mailing List\n> > Subject: [PATCH] Add svnrdump\n> > \n> > +  /* Use a temporary file to measure the text-content-length */\n> > +  apr_err = apr_temp_dir_get(&tempdir, hb->pool);\n\nsvn_io_temp_dir()\n\n> > +  if (apr_err != APR_SUCCESS)\n> > +    SVN_ERR(svn_error_wrap_apr(apr_err, NULL));\n> > +\n> > +  hb->temp_filepath = apr_psprintf(eb->pool, \"%s/svn-fe-XXXXXX\",\n> > tempdir);\n> \n\nos.path.join()\n\nErr, I mean, svn_dirent_join().\n"},{"id":"145099","messageId":"20100708083516.GD29267@debian","threadId":"24333","inReplyTo":null,"subject":"[PATCH] Add svnrdump","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-07-08T08:35:16Z","receivedAt":"2010-07-08T08:35:16Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nKindly find the diff for svnrdump in the later part of this email. I\nhaven't written a build.conf rule or manpage, but I suppose I can do\nthem in another patch.\n\nThanks.\n\n-- Ram\n\n--------------------8<--------------->8-----------------------------\n\nIndex: subversion/svnrdump/dump_editor.c\n===================================================================\n--- subversion/svnrdump/dump_editor.c\t(revision 0)\n+++ subversion/svnrdump/dump_editor.c\t(working copy)\n@@ -0,0 +1,689 @@\n+/*\n+ * ====================================================================\n+ *    Licensed to the Apache Software Foundation (ASF) under one\n+ *    or more contributor license agreements.  See the NOTICE file\n+ *    distributed with this work for additional information\n+ *    regarding copyright ownership.  The ASF licenses this file\n+ *    to you under the Apache License, Version 2.0 (the\n+ *    \"License\"); you may not use this file except in compliance\n+ *    with the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *    Unless required by applicable law or agreed to in writing,\n+ *    software distributed under the License is distributed on an\n+ *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ *    KIND, either express or implied.  See the License for the\n+ *    specific language governing permissions and limitations\n+ *    under the License.\n+ * ====================================================================\n+ */\n+\n+#include \"svn_pools.h\"\n+#include \"svn_repos.h\"\n+#include \"svn_path.h\"\n+#include \"svn_props.h\"\n+\n+#include \"svnrdump.h\"\n+#include \"dump_editor.h\"\n+\n+#define ARE_VALID_COPY_ARGS(p,r) ((p) && SVN_IS_VALID_REVNUM(r))\n+\n+svn_boolean_t must_dump_props = FALSE, must_dump_text = FALSE,\n+  dump_props_pending = FALSE;\n+\n+/* Make a directory baton to represent the directory was path\n+   (relative to EDIT_BATON's path) is PATH.\n+\n+   CMP_PATH/CMP_REV are the path/revision against which this directory\n+   should be compared for changes.  If either is omitted (NULL for the\n+   path, SVN_INVALID_REVNUM for the rev), just compare this directory\n+   PATH against itself in the previous revision.\n+\n+   PARENT_DIR_BATON is the directory baton of this directory's parent,\n+   or NULL if this is the top-level directory of the edit.  ADDED\n+   indicated if this directory is newly added in this revision.\n+   Perform all allocations in POOL.  */\n+static struct dir_baton *\n+make_dir_baton(const char *path,\n+               const char *cmp_path,\n+               svn_revnum_t cmp_rev,\n+               void *edit_baton,\n+               void *parent_dir_baton,\n+               svn_boolean_t added,\n+               apr_pool_t *pool)\n+{\n+  struct dump_edit_baton *eb = edit_baton;\n+  struct dir_baton *pb = parent_dir_baton;\n+  struct dir_baton *new_db = apr_pcalloc(pool, sizeof(*new_db));\n+  const char *full_path;\n+  apr_array_header_t *compose_path = apr_array_make(pool, 2, sizeof(const char *));\n+\n+  /* A path relative to nothing?  I don't think so. */\n+  SVN_ERR_ASSERT_NO_RETURN(!path || pb);\n+\n+  /* Construct the full path of this node. */\n+  if (pb) {\n+    APR_ARRAY_PUSH(compose_path, const char *) = \"/\";\n+    APR_ARRAY_PUSH(compose_path, const char *) = path;\n+    full_path = svn_path_compose(compose_path, pool);\n+  }\n+  else\n+    full_path = apr_pstrdup(pool, \"/\");\n+\n+  /* Remove leading slashes from copyfrom paths. */\n+  if (cmp_path)\n+    cmp_path = ((*cmp_path == '/') ? cmp_path + 1 : cmp_path);\n+\n+  new_db->eb = eb;\n+  new_db->parent_dir_baton = pb;\n+  new_db->path = full_path;\n+  new_db->cmp_path = cmp_path ? apr_pstrdup(pool, cmp_path) : NULL;\n+  new_db->cmp_rev = cmp_rev;\n+  new_db->added = added;\n+  new_db->written_out = FALSE;\n+  new_db->deleted_entries = apr_hash_make(pool);\n+  new_db->pool = pool;\n+\n+  return new_db;\n+}\n+/*\n+ * Write out a node record for PATH of type KIND under EB->FS_ROOT.\n+ * ACTION describes what is happening to the node (see enum svn_node_action).\n+ * Write record to writable EB->STREAM, using EB->BUFFER to write in chunks.\n+ *\n+ * If the node was itself copied, IS_COPY is TRUE and the\n+ * path/revision of the copy source are in CMP_PATH/CMP_REV.  If\n+ * IS_COPY is FALSE, yet CMP_PATH/CMP_REV are valid, this node is part\n+ * of a copied subtree.\n+ */\n+static svn_error_t *\n+dump_node(struct dump_edit_baton *eb,\n+          const char *path,    /* an absolute path. */\n+          svn_node_kind_t kind,\n+          enum svn_node_action action,\n+          const char *cmp_path,\n+          svn_revnum_t cmp_rev,\n+          apr_pool_t *pool)\n+{\n+  /* Write out metadata headers for this file node. */\n+  SVN_ERR(svn_stream_printf(eb->stream, pool,\n+          SVN_REPOS_DUMPFILE_NODE_PATH \": %s\\n\",\n+          (*path == '/') ? path + 1 : path));\n+\n+  if (kind == svn_node_file)\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_KIND \": file\\n\"));\n+  else if (kind == svn_node_dir)\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_KIND \": dir\\n\"));\n+\n+  /* Remove leading slashes from copyfrom paths. */\n+  if (cmp_path)\n+    cmp_path = ((*cmp_path == '/') ? cmp_path + 1 : cmp_path);\n+\n+  switch (action) {\n+    /* Appropriately handle the four svn_node_action actions */\n+\n+  case svn_node_action_change:\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_ACTION\n+                              \": change\\n\"));\n+    break;\n+\n+  case svn_node_action_replace:\n+    if (!eb->is_copy) {\n+      /* a simple delete+add, implied by a single 'replace' action. */\n+      SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                                SVN_REPOS_DUMPFILE_NODE_ACTION\n+                                \": replace\\n\"));\n+\n+      dump_props_pending = TRUE;\n+      break;\n+    }\n+    /* More complex case: eb->is_copy is true, and\n+       cmp_path/ cmp_rev are present: delete the original,\n+       and then re-add it */\n+\n+    /* the path & kind headers have already been printed;  just\n+       add a delete action, and end the current record.*/\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_ACTION\n+                              \": delete\\n\\n\"));\n+\n+    /* recurse:  print an additional add-with-history record. */\n+    SVN_ERR(dump_node(eb, path, kind, svn_node_action_add,\n+                      cmp_path, cmp_rev, pool));\n+\n+    /* we can leave this routine quietly now, don't need to dump\n+       any content;  that was already done in the second record. */\n+    must_dump_props = FALSE;\n+    eb->is_copy = FALSE;\n+    break;\n+\n+  case svn_node_action_delete:\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_ACTION\n+                              \": delete\\n\"));\n+\n+    /* we can leave this routine quietly now, don't need to dump\n+       any content. */\n+    SVN_ERR(svn_stream_printf(eb->stream, pool, \"\\n\\n\"));\n+    must_dump_props = FALSE;\n+    break;\n+\n+  case svn_node_action_add:\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_ACTION \": add\\n\"));\n+\n+    if (!eb->is_copy) {\n+      /* dump_props_pending for files is handled in\n+         close_file which is called immediately.\n+         However, directories are not closed until\n+         all the work inside them have been done;\n+         dump_props_pending for directories is\n+         handled in all the functions that can\n+         possibly be called after add_directory:\n+         add_directory, open_directory,\n+         delete_entry, close_directory, add_file,\n+         open_file and change_dir_prop;\n+         change_dir_prop is a special case\n+         ofcourse */\n+\n+      dump_props_pending = TRUE;\n+      break;\n+    }\n+\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+                              SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV\n+                              \": %ld\\n\"\n+                              SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH\n+                              \": %s\\n\",\n+                              cmp_rev, cmp_path));\n+\n+    /* Dump the text only if apply_textdelta sets\n+       must_dump_text */\n+\n+    /* UGLY hack: If a directory was copied from a\n+       previous revision, nothing else can be done, and\n+       close_file won't be called to write two blank\n+       lines; write them here */\n+    if (kind == svn_node_dir)\n+      SVN_ERR(svn_stream_printf(eb->stream, pool, \"\\n\\n\"));\n+\n+    eb->is_copy = FALSE;\n+\n+    break;\n+  }\n+\n+  /* Dump property headers */\n+  SVN_ERR(dump_props(eb, &must_dump_props, FALSE, pool));\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+svn_error_t *open_root(void *edit_baton,\n+                       svn_revnum_t base_revision,\n+                       apr_pool_t *pool,\n+                       void **root_baton)\n+{\n+  /* Allocate a special pool for the edit_baton to avoid pool\n+     lifetime issues */\n+  struct dump_edit_baton *eb = edit_baton;\n+  eb->pool = svn_pool_create(pool);\n+  eb->properties = apr_hash_make(eb->pool);\n+  eb->del_properties = apr_hash_make(eb->pool);\n+  eb->propstring = svn_stringbuf_create(\"\", eb->pool);\n+  eb->is_copy = FALSE;\n+\n+  *root_baton = make_dir_baton(NULL, NULL, SVN_INVALID_REVNUM,\n+                               edit_baton, NULL, FALSE, pool);\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+delete_entry(const char *path,\n+             svn_revnum_t revision,\n+             void *parent_baton,\n+             apr_pool_t *pool)\n+{\n+  struct dir_baton *pb = parent_baton;\n+  const char *mypath = apr_pstrdup(pb->pool, path);\n+\n+  /* Some pending properties to dump? */\n+  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n+\n+  /* remember this path needs to be deleted */\n+  apr_hash_set(pb->deleted_entries, mypath, APR_HASH_KEY_STRING, pb);\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+add_directory(const char *path,\n+              void *parent_baton,\n+              const char *copyfrom_path,\n+              svn_revnum_t copyfrom_rev,\n+              apr_pool_t *pool,\n+              void **child_baton)\n+{\n+  struct dir_baton *pb = parent_baton;\n+  void *val;\n+  struct dir_baton *new_db\n+    = make_dir_baton(path, copyfrom_path, copyfrom_rev, pb->eb, pb, TRUE, pool);\n+\n+  /* Some pending properties to dump? */\n+  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n+\n+  /* This might be a replacement -- is the path already deleted? */\n+  val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);\n+\n+  /* Detect an add-with-history */\n+  pb->eb->is_copy = ARE_VALID_COPY_ARGS(copyfrom_path, copyfrom_rev);\n+\n+  /* Dump the node */\n+  SVN_ERR(dump_node(pb->eb, path,\n+                    svn_node_dir,\n+                    val ? svn_node_action_replace : svn_node_action_add,\n+                    pb->eb->is_copy ? copyfrom_path : NULL,\n+                    pb->eb->is_copy ? copyfrom_rev : SVN_INVALID_REVNUM,\n+                    pool));\n+\n+  if (val)\n+    /* Delete the path, it's now been dumped */\n+    apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING, NULL);\n+\n+  new_db->written_out = TRUE;\n+\n+  *child_baton = new_db;\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+open_directory(const char *path,\n+               void *parent_baton,\n+               svn_revnum_t base_revision,\n+               apr_pool_t *pool,\n+               void **child_baton)\n+{\n+  struct dir_baton *pb = parent_baton;\n+  struct dir_baton *new_db;\n+  const char *cmp_path = NULL;\n+  svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;\n+  apr_array_header_t *compose_path = apr_array_make(pool, 2, sizeof(const char *));\n+\n+  /* Some pending properties to dump? */\n+  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n+\n+  /* If the parent directory has explicit comparison path and rev,\n+     record the same for this one. */\n+  if (pb && ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev)) {\n+    APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path;\n+    APR_ARRAY_PUSH(compose_path, const char *) = svn_dirent_basename(path, pool);\n+    cmp_path = svn_path_compose(compose_path, pool);\n+    cmp_rev = pb->cmp_rev;\n+  }\n+\n+  new_db = make_dir_baton(path, cmp_path, cmp_rev, pb->eb, pb, FALSE, pool);\n+  *child_baton = new_db;\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+close_directory(void *dir_baton,\n+                apr_pool_t *pool)\n+{\n+  struct dir_baton *db = dir_baton;\n+  struct dump_edit_baton *eb = db->eb;\n+  apr_hash_index_t *hi;\n+  apr_pool_t *subpool = svn_pool_create(pool);\n+\n+  /* Some pending properties to dump? */\n+  SVN_ERR(dump_props(eb, &dump_props_pending, TRUE, pool));\n+\n+  /* Dump the directory entries */\n+  for (hi = apr_hash_first(pool, db->deleted_entries); hi;\n+       hi = apr_hash_next(hi)) {\n+    const void *key;\n+    const char *path;\n+    apr_hash_this(hi, &key, NULL, NULL);\n+    path = key;\n+\n+    svn_pool_clear(subpool);\n+\n+    SVN_ERR(dump_node(db->eb, path,\n+                      svn_node_unknown, svn_node_action_delete,\n+                      NULL, SVN_INVALID_REVNUM, subpool));\n+  }\n+\n+  svn_pool_destroy(subpool);\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+add_file(const char *path,\n+         void *parent_baton,\n+         const char *copyfrom_path,\n+         svn_revnum_t copyfrom_rev,\n+         apr_pool_t *pool,\n+         void **file_baton)\n+{\n+  struct dir_baton *pb = parent_baton;\n+  void *val;\n+\n+  /* Some pending properties to dump? */\n+  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n+\n+  /* This might be a replacement -- is the path already deleted? */\n+  val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);\n+\n+  /* Detect add-with-history. */\n+  pb->eb->is_copy = ARE_VALID_COPY_ARGS(copyfrom_path, copyfrom_rev);\n+\n+  /* Dump the node. */\n+  SVN_ERR(dump_node(pb->eb, path,\n+                    svn_node_file,\n+                    val ? svn_node_action_replace : svn_node_action_add,\n+                    pb->eb->is_copy ? copyfrom_path : NULL,\n+                    pb->eb->is_copy ? copyfrom_rev : SVN_INVALID_REVNUM,\n+                    pool));\n+\n+  if (val)\n+    /* delete the path, it's now been dumped. */\n+    apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING, NULL);\n+\n+  /* Build a nice file baton to pass to change_file_prop and apply_textdelta */\n+  pb->eb->changed_path = path;\n+  *file_baton = pb->eb;\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+open_file(const char *path,\n+          void *parent_baton,\n+          svn_revnum_t ancestor_revision,\n+          apr_pool_t *pool,\n+          void **file_baton)\n+{\n+  struct dir_baton *pb = parent_baton;\n+  const char *cmp_path = NULL;\n+  svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;\n+\n+  /* Some pending properties to dump? */\n+  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n+\n+  apr_array_header_t *compose_path = apr_array_make(pool, 2, sizeof(const char *));\n+  /* If the parent directory has explicit comparison path and rev,\n+     record the same for this one. */\n+  if (pb && ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev)) {\n+    APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path;\n+    APR_ARRAY_PUSH(compose_path, const char *) = svn_dirent_basename(path, pool);\n+    cmp_path = svn_path_compose(compose_path, pool);\n+    cmp_rev = pb->cmp_rev;\n+  }\n+\n+  SVN_ERR(dump_node(pb->eb, path,\n+                    svn_node_file, svn_node_action_change,\n+                    cmp_path, cmp_rev, pool));\n+\n+  /* Build a nice file baton to pass to change_file_prop and apply_textdelta */\n+  pb->eb->changed_path = path;\n+  *file_baton = pb->eb;\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+change_dir_prop(void *parent_baton,\n+                const char *name,\n+                const svn_string_t *value,\n+                apr_pool_t *pool)\n+{\n+  struct dir_baton *db = parent_baton;\n+\n+  if (svn_property_kind(NULL, name) != svn_prop_regular_kind)\n+    return SVN_NO_ERROR;\n+\n+  value ? apr_hash_set(db->eb->properties, apr_pstrdup(pool, name),\n+                       APR_HASH_KEY_STRING, svn_string_dup(value, pool)) :\n+    apr_hash_set(db->eb->del_properties, apr_pstrdup(pool, name),\n+                 APR_HASH_KEY_STRING, (void *)0x1);\n+\n+  /* This function is what distinguishes between a directory that is\n+     opened to merely get somewhere, vs. one that is opened because it\n+     actually changed by itself  */\n+  if (! db->written_out) {\n+    /* If dump_props_pending was set, it means that the\n+       node information corresponding to add_directory has already\n+       been written; just don't unset it and dump_node will dump\n+       the properties before doing anything else. If it wasn't\n+       set, node information hasn't been written yet: so dump the\n+       node itself before dumping the props */\n+\n+    SVN_ERR(dump_node(db->eb, db->path,\n+                      svn_node_dir, svn_node_action_change,\n+                      db->cmp_path, db->cmp_rev, pool));\n+\n+    SVN_ERR(dump_props(db->eb, NULL, TRUE, pool));\n+    db->written_out = TRUE;\n+  }\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+change_file_prop(void *file_baton,\n+                 const char *name,\n+                 const svn_string_t *value,\n+                 apr_pool_t *pool)\n+{\n+  struct dump_edit_baton *eb = file_baton;\n+\n+  if (svn_property_kind(NULL, name) != svn_prop_regular_kind)\n+    return SVN_NO_ERROR;\n+\n+  apr_hash_set(eb->properties, apr_pstrdup(pool, name),\n+               APR_HASH_KEY_STRING, value ?\n+               svn_string_dup(value, pool): (void *)0x1);\n+\n+  /* Dump the property headers and wait; close_file might need\n+     to write text headers too depending on whether\n+     apply_textdelta is called */\n+  dump_props_pending = TRUE;\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+window_handler(svn_txdelta_window_t *window, void *baton)\n+{\n+  struct handler_baton *hb = baton;\n+  struct dump_edit_baton *eb = hb->eb;\n+  svn_error_t *err;\n+\n+  err = hb->apply_handler(window, hb->apply_baton);\n+  if (window != NULL && !err)\n+    return SVN_NO_ERROR;\n+\n+  if (err)\n+    SVN_ERR(err);\n+\n+  /* Write information about the filepath to hb->eb */\n+  eb->temp_filepath = apr_pstrdup(eb->pool,\n+          hb->temp_filepath);\n+\n+  /* Cleanup */\n+  SVN_ERR(svn_io_file_close(hb->temp_file, hb->pool));\n+  SVN_ERR(svn_stream_close(hb->temp_filestream));\n+  svn_pool_destroy(hb->pool);\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+apply_textdelta(void *file_baton, const char *base_checksum,\n+                apr_pool_t *pool,\n+                svn_txdelta_window_handler_t *handler,\n+                void **handler_baton)\n+{\n+  struct dump_edit_baton *eb = file_baton;\n+  apr_status_t apr_err;\n+  const char *tempdir;\n+\n+  /* Custom handler_baton allocated in a separate pool */\n+  apr_pool_t *handler_pool = svn_pool_create(pool);\n+  struct handler_baton *hb = apr_pcalloc(handler_pool, sizeof(*hb));\n+  hb->pool = handler_pool;\n+  hb->eb = eb;\n+\n+  /* Use a temporary file to measure the text-content-length */\n+  apr_err = apr_temp_dir_get(&tempdir, hb->pool);\n+  if (apr_err != APR_SUCCESS)\n+    SVN_ERR(svn_error_wrap_apr(apr_err, NULL));\n+\n+  hb->temp_filepath = apr_psprintf(eb->pool, \"%s/svn-fe-XXXXXX\", tempdir);\n+  apr_err = apr_file_mktemp(&(hb->temp_file), hb->temp_filepath,\n+          APR_CREATE | APR_READ | APR_WRITE | APR_EXCL,\n+          hb->pool);\n+  if (apr_err != APR_SUCCESS)\n+    SVN_ERR(svn_error_wrap_apr(apr_err, NULL));\n+\n+  hb->temp_filestream = svn_stream_from_aprfile2(hb->temp_file, TRUE, hb->pool);\n+\n+  /* Prepare to write the delta to the temporary file */\n+  svn_txdelta_to_svndiff2(&(hb->apply_handler), &(hb->apply_baton),\n+                          hb->temp_filestream, 0, hb->pool);\n+  must_dump_text = TRUE;\n+\n+  /* The actual writing takes place when this function has finished */\n+  /* Set the handler and handler_baton */\n+  *handler = window_handler;\n+  *handler_baton = hb;\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+svn_error_t *\n+close_file(void *file_baton,\n+           const char *text_checksum,\n+           apr_pool_t *pool)\n+{\n+  struct dump_edit_baton *eb = file_baton;\n+  apr_file_t *temp_file;\n+  svn_stream_t *temp_filestream;\n+  apr_finfo_t *info = apr_pcalloc(pool, sizeof(apr_finfo_t));\n+\n+  /* We didn't write the property headers because we were\n+     waiting for file_prop_change; write them now */\n+  SVN_ERR(dump_props(eb, &dump_props_pending, FALSE, pool));\n+\n+  /* The prop headers have already been dumped in dump_node */\n+  /* Dump the text headers */\n+  if (must_dump_text) {\n+    /* text-delta header */\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+            SVN_REPOS_DUMPFILE_TEXT_DELTA\n+            \": true\\n\"));\n+\n+    /* Measure the length */\n+    SVN_ERR(svn_io_stat(info, eb->temp_filepath, APR_FINFO_SIZE, pool));\n+\n+    /* text-content-length header */\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+            SVN_REPOS_DUMPFILE_TEXT_CONTENT_LENGTH\n+            \": %lu\\n\",\n+            (unsigned long)info->size));\n+    /* text-content-md5 header */\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+            SVN_REPOS_DUMPFILE_TEXT_CONTENT_MD5\n+             \": %s\\n\",\n+            text_checksum));\n+  }\n+\n+  /* content-length header: if both text and props are absent,\n+     skip this block */\n+  if (must_dump_props || dump_props_pending)\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+            SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n+            \": %ld\\n\\n\",\n+            (unsigned long)info->size + eb->propstring->len));\n+  else if (must_dump_text)\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+            SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n+            \": %ld\\n\\n\",\n+            (unsigned long)info->size));\n+\n+  /* Dump the props; the propstring should have already been\n+     written in dump_node or above */\n+  if (must_dump_props || dump_props_pending) {\n+    SVN_ERR(svn_stream_write(eb->stream, eb->propstring->data,\n+           &(eb->propstring->len)));\n+\n+    /* Cleanup */\n+    must_dump_props = dump_props_pending = FALSE;\n+    apr_hash_clear(eb->properties);\n+    apr_hash_clear(eb->del_properties);\n+  }\n+\n+  /* Dump the text */\n+  if (must_dump_text) {\n+\n+    /* Open the temporary file, map it to a stream, copy\n+       the stream to eb->stream, close and delete the\n+       file */\n+    SVN_ERR(svn_io_file_open(&temp_file, eb->temp_filepath, APR_READ, 0600, pool));\n+    temp_filestream = svn_stream_from_aprfile2(temp_file, TRUE, pool);\n+    SVN_ERR(svn_stream_copy3(temp_filestream, eb->stream, NULL, NULL, pool));\n+\n+    /* Cleanup */\n+    SVN_ERR(svn_io_file_close(temp_file, pool));\n+    SVN_ERR(svn_stream_close(temp_filestream));\n+    SVN_ERR(svn_io_remove_file2(eb->temp_filepath, TRUE, pool));\n+    must_dump_text = FALSE;\n+  }\n+\n+  SVN_ERR(svn_stream_printf(eb->stream, pool, \"\\n\\n\"));\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+close_edit(void *edit_baton, apr_pool_t *pool)\n+{\n+  struct dump_edit_baton *eb = edit_baton;\n+  svn_pool_destroy(eb->pool);\n+  (eb->current_rev) ++;\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+svn_error_t *\n+get_dump_editor(const svn_delta_editor_t **editor,\n+                void **edit_baton,\n+                svn_revnum_t from_rev,\n+                apr_pool_t *pool)\n+{\n+  struct dump_edit_baton *eb = apr_pcalloc(pool, sizeof(struct dump_edit_baton));\n+  eb->current_rev = from_rev;\n+  SVN_ERR(svn_stream_for_stdout(&(eb->stream), pool));\n+  svn_delta_editor_t *de = svn_delta_default_editor(pool);\n+\n+  de->open_root = open_root;\n+  de->delete_entry = delete_entry;\n+  de->add_directory = add_directory;\n+  de->open_directory = open_directory;\n+  de->close_directory = close_directory;\n+  de->change_dir_prop = change_dir_prop;\n+  de->change_file_prop = change_file_prop;\n+  de->apply_textdelta = apply_textdelta;\n+  de->add_file = add_file;\n+  de->open_file = open_file;\n+  de->close_file = close_file;\n+  de->close_edit = close_edit;\n+\n+  /* Set the edit_baton and editor */\n+  *edit_baton = eb;\n+  *editor = de;\n+\n+  return SVN_NO_ERROR;\n+}\n+ \nIndex: subversion/svnrdump/dump_editor.h\n===================================================================\n--- subversion/svnrdump/dump_editor.h\t(revision 0)\n+++ subversion/svnrdump/dump_editor.h\t(working copy)\n@@ -0,0 +1,99 @@\n+/*\n+ * ====================================================================\n+ *    Licensed to the Apache Software Foundation (ASF) under one\n+ *    or more contributor license agreements.  See the NOTICE file\n+ *    distributed with this work for additional information\n+ *    regarding copyright ownership.  The ASF licenses this file\n+ *    to you under the Apache License, Version 2.0 (the\n+ *    \"License\"); you may not use this file except in compliance\n+ *    with the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *    Unless required by applicable law or agreed to in writing,\n+ *    software distributed under the License is distributed on an\n+ *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ *    KIND, either express or implied.  See the License for the\n+ *    specific language governing permissions and limitations\n+ *    under the License.\n+ * ====================================================================\n+ */\n+\n+#ifndef DUMP_EDITOR_H_\n+#define DUMP_EDITOR_H_\n+\n+struct dump_edit_baton {\n+  svn_stream_t *stream;\n+  svn_revnum_t current_rev;\n+\n+  /* pool is for per-edit-session allocations */\n+  apr_pool_t *pool;\n+\n+  /* Store the properties that changed */\n+  apr_hash_t *properties;\n+  apr_hash_t *del_properties; /* Value is always 0x1 */\n+  svn_stringbuf_t *propstring;\n+\n+  /* Was a copy command issued? */\n+  svn_boolean_t is_copy;\n+\n+  /* Path of changed file */\n+  const char *changed_path;\n+\n+  /* Temporary file to write delta to along with its checksum */\n+  char *temp_filepath;\n+  svn_checksum_t *checksum;\n+};\n+\n+struct dir_baton {\n+  struct dump_edit_baton *eb;\n+  struct dir_baton *parent_dir_baton;\n+\n+  /* is this directory a new addition to this revision? */\n+  svn_boolean_t added;\n+\n+  /* has this directory been written to the output stream? */\n+  svn_boolean_t written_out;\n+\n+  /* the absolute path to this directory */\n+  const char *path;\n+\n+  /* the comparison path and revision of this directory.  if both of\n+     these are valid, use them as a source against which to compare\n+     the directory instead of the default comparison source of PATH in\n+     the previous revision. */\n+  const char *cmp_path;\n+  svn_revnum_t cmp_rev;\n+\n+  /* hash of paths that need to be deleted, though some -might- be\n+     replaced.  maps const char * paths to this dir_baton.  (they're\n+     full paths, because that's what the editor driver gives us.  but\n+     really, they're all within this directory.) */\n+  apr_hash_t *deleted_entries;\n+\n+  /* pool to be used for deleting the hash items */\n+  apr_pool_t *pool;\n+};\n+\n+struct handler_baton\n+{\n+  svn_txdelta_window_handler_t apply_handler;\n+  void *apply_baton;\n+  apr_pool_t *pool;\n+\n+  /* Information about the path of the tempoarary file used */\n+  char *temp_filepath;\n+  apr_file_t *temp_file;\n+  svn_stream_t *temp_filestream;\n+\n+  /* To fill in the edit baton fields */\n+  struct dump_edit_baton *eb;\n+};\n+\n+svn_error_t *\n+get_dump_editor(const svn_delta_editor_t **editor,\n+                void **edit_baton,\n+                svn_revnum_t to_rev,\n+                apr_pool_t *pool);\n+\n+#endif\nIndex: subversion/svnrdump/svnrdump.c\n===================================================================\n--- subversion/svnrdump/svnrdump.c\t(revision 0)\n+++ subversion/svnrdump/svnrdump.c\t(working copy)\n@@ -0,0 +1,198 @@\n+/*\n+ * ====================================================================\n+ *    Licensed to the Apache Software Foundation (ASF) under one\n+ *    or more contributor license agreements.  See the NOTICE file\n+ *    distributed with this work for additional information\n+ *    regarding copyright ownership.  The ASF licenses this file\n+ *    to you under the Apache License, Version 2.0 (the\n+ *    \"License\"); you may not use this file except in compliance\n+ *    with the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *    Unless required by applicable law or agreed to in writing,\n+ *    software distributed under the License is distributed on an\n+ *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ *    KIND, either express or implied.  See the License for the\n+ *    specific language governing permissions and limitations\n+ *    under the License.\n+ * ====================================================================\n+ */\n+\n+#include \"svn_pools.h\"\n+#include \"svn_cmdline.h\"\n+#include \"svn_client.h\"\n+#include \"svn_ra.h\"\n+#include \"svn_repos.h\"\n+#include \"svn_path.h\"\n+\n+#include \"svnrdump.h\"\n+#include \"dump_editor.h\"\n+\n+static apr_pool_t *pool = NULL;\n+static svn_client_ctx_t *ctx = NULL;\n+static svn_ra_session_t *session = NULL;\n+\n+static svn_error_t *\n+replay_revstart(svn_revnum_t revision,\n+                void *replay_baton,\n+                const svn_delta_editor_t **editor,\n+                void **edit_baton,\n+                apr_hash_t *rev_props,\n+                apr_pool_t *pool)\n+{\n+  /* Editing this revision has just started; dump the revprops\n+     before invoking the editor callbacks */\n+  svn_stringbuf_t *propstring = svn_stringbuf_create(\"\", pool);\n+  svn_stream_t *stdout_stream;\n+\n+  /* Create an stdout stream */\n+  svn_stream_for_stdout(&stdout_stream, pool);\n+\n+        /* Print revision number and prepare the propstring */\n+  SVN_ERR(svn_stream_printf(stdout_stream, pool,\n+          SVN_REPOS_DUMPFILE_REVISION_NUMBER\n+          \": %ld\\n\", revision));\n+  write_hash_to_stringbuf(rev_props, FALSE, &propstring, pool);\n+  svn_stringbuf_appendbytes(propstring, \"PROPS-END\\n\", 10);\n+\n+  /* prop-content-length header */\n+  SVN_ERR(svn_stream_printf(stdout_stream, pool,\n+          SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH\n+          \": %\" APR_SIZE_T_FMT \"\\n\", propstring->len));\n+\n+  /* content-length header */\n+  SVN_ERR(svn_stream_printf(stdout_stream, pool,\n+          SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n+          \": %\" APR_SIZE_T_FMT \"\\n\\n\", propstring->len));\n+\n+  /* Print the revprops now */\n+  SVN_ERR(svn_stream_write(stdout_stream, propstring->data,\n+         &(propstring->len)));\n+\n+  svn_stream_close(stdout_stream);\n+\n+  /* Extract editor and editor_baton from the replay_baton and\n+     set them so that the editor callbacks can use them */\n+  struct replay_baton *rb = replay_baton;\n+  *editor = rb->editor;\n+  *edit_baton = rb->edit_baton;\n+\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+replay_revend(svn_revnum_t revision,\n+              void *replay_baton,\n+              const svn_delta_editor_t *editor,\n+              void *edit_baton,\n+              apr_hash_t *rev_props,\n+              apr_pool_t *pool)\n+{\n+  /* Editor has finished for this revision and close_edit has\n+     been called; do nothing: just continue to the next\n+     revision */\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+open_connection(const char *url)\n+{\n+  SVN_ERR(svn_config_ensure (NULL, pool));\n+  SVN_ERR(svn_client_create_context (&ctx, pool));\n+  SVN_ERR(svn_ra_initialize(pool));\n+\n+  SVN_ERR(svn_config_get_config(&(ctx->config), NULL, pool));\n+\n+  /* Default authentication providers for non-interactive use */\n+  SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE,\n+                NULL, NULL, NULL, FALSE,\n+                FALSE, NULL, NULL, NULL,\n+                pool));\n+  SVN_ERR(svn_client_open_ra_session(&session, url, ctx, pool));\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+replay_range(svn_revnum_t start_revision, svn_revnum_t end_revision)\n+{\n+  const svn_delta_editor_t *dump_editor;\n+  void *dump_baton;\n+\n+  SVN_ERR(get_dump_editor(&dump_editor,\n+                          &dump_baton, start_revision, pool));\n+\n+  struct replay_baton *replay_baton = apr_palloc(pool, sizeof(struct replay_baton));\n+  replay_baton->editor = dump_editor;\n+  replay_baton->edit_baton = dump_baton;\n+  SVN_ERR(svn_cmdline_printf(pool, SVN_REPOS_DUMPFILE_MAGIC_HEADER \": %d\\n\",\n+           SVN_REPOS_DUMPFILE_FORMAT_VERSION));\n+  SVN_ERR(svn_ra_replay_range(session, start_revision, end_revision,\n+                              0, TRUE, replay_revstart, replay_revend,\n+                              replay_baton, pool));\n+  return SVN_NO_ERROR;\n+}\n+\n+static svn_error_t *\n+usage(FILE *out_stream)\n+{\n+  fprintf(out_stream,\n+    \"usage: svnrdump URL [-r LOWER[:UPPER]]\\n\\n\"\n+    \"Dump the contents of repository at remote URL to stdout in a 'dumpfile'\\n\"\n+    \"v3 portable format.  Dump revisions LOWER rev through UPPER rev.\\n\"\n+    \"LOWER defaults to 1 and UPPER defaults to the highest possible revision\\n\"\n+    \"if omitted.\\n\");\n+  return SVN_NO_ERROR;\n+}\n+\n+int\n+main(int argc, const char **argv)\n+{\n+  int i;\n+  const char *url = NULL;\n+  char *revision_cut = NULL;\n+  svn_revnum_t start_revision = svn_opt_revision_unspecified;\n+  svn_revnum_t end_revision = svn_opt_revision_unspecified;\n+\n+  if (svn_cmdline_init (\"svnrdump\", stderr) != EXIT_SUCCESS)\n+    return EXIT_FAILURE;\n+\n+  pool = svn_pool_create(NULL);\n+\n+  for (i = 1; i < argc; i++) {\n+    if (!strncmp(\"-r\", argv[i], 2)) {\n+      revision_cut = strchr(argv[i] + 2, ':');\n+      if (revision_cut) {\n+        start_revision = (svn_revnum_t) strtoul(argv[i] + 2, &revision_cut, 10);\n+        end_revision = (svn_revnum_t) strtoul(revision_cut + 1, NULL, 10);\n+      }\n+      else\n+        start_revision = (svn_revnum_t) strtoul(argv[i] + 2, NULL, 10);\n+    } else if (!strcmp(\"help\", argv[i]) || !strcmp(\"--help\", argv[i])) {\n+      SVN_INT_ERR(usage(stdout));\n+      return EXIT_SUCCESS;\n+    } else if (*argv[i] == '-' || url) {\n+      SVN_INT_ERR(usage(stderr));\n+      return EXIT_FAILURE;\n+    } else\n+      url = argv[i];\n+  }\n+\n+  if (!url || !svn_path_is_url(url)) {\n+    usage(stderr);\n+    return EXIT_FAILURE;\n+  }\n+  SVN_INT_ERR(open_connection(url));\n+\n+  /* Have sane start_revision and end_revision defaults if unspecified */\n+  if (start_revision == svn_opt_revision_unspecified)\n+    start_revision = 1;\n+  if (end_revision == svn_opt_revision_unspecified)\n+    SVN_INT_ERR(svn_ra_get_latest_revnum(session, &end_revision, pool));\n+\n+  SVN_INT_ERR(replay_range(start_revision, end_revision));\n+\n+  svn_pool_destroy(pool);\n+\n+  return 0;\n+}\nIndex: subversion/svnrdump/svnrdump.h\n===================================================================\n--- subversion/svnrdump/svnrdump.h\t(revision 0)\n+++ subversion/svnrdump/svnrdump.h\t(working copy)\n@@ -0,0 +1,44 @@\n+/*\n+ * ====================================================================\n+ *    Licensed to the Apache Software Foundation (ASF) under one\n+ *    or more contributor license agreements.  See the NOTICE file\n+ *    distributed with this work for additional information\n+ *    regarding copyright ownership.  The ASF licenses this file\n+ *    to you under the Apache License, Version 2.0 (the\n+ *    \"License\"); you may not use this file except in compliance\n+ *    with the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *    Unless required by applicable law or agreed to in writing,\n+ *    software distributed under the License is distributed on an\n+ *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ *    KIND, either express or implied.  See the License for the\n+ *    specific language governing permissions and limitations\n+ *    under the License.\n+ * ====================================================================\n+ */\n+\n+#ifndef SVNRDUMP_H_\n+#define SVNRDUMP_H_\n+\n+#include \"dump_editor.h\"\n+\n+struct replay_baton {\n+  const svn_delta_editor_t *editor;\n+  void *edit_baton;\n+};\n+\n+void\n+write_hash_to_stringbuf(apr_hash_t *properties,\n+                        svn_boolean_t deleted,\n+                        svn_stringbuf_t **strbuf,\n+                        apr_pool_t *pool);\n+\n+svn_error_t *\n+dump_props(struct dump_edit_baton *eb,\n+           svn_boolean_t *trigger_var,\n+           svn_boolean_t dump_data_too,\n+           apr_pool_t *pool);\n+\n+#endif\nIndex: subversion/svnrdump/util.c\n===================================================================\n--- subversion/svnrdump/util.c\t(revision 0)\n+++ subversion/svnrdump/util.c\t(working copy)\n@@ -0,0 +1,131 @@\n+/*\n+ * ====================================================================\n+ *    Licensed to the Apache Software Foundation (ASF) under one\n+ *    or more contributor license agreements.  See the NOTICE file\n+ *    distributed with this work for additional information\n+ *    regarding copyright ownership.  The ASF licenses this file\n+ *    to you under the Apache License, Version 2.0 (the\n+ *    \"License\"); you may not use this file except in compliance\n+ *    with the License.  You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *    Unless required by applicable law or agreed to in writing,\n+ *    software distributed under the License is distributed on an\n+ *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ *    KIND, either express or implied.  See the License for the\n+ *    specific language governing permissions and limitations\n+ *    under the License.\n+ * ====================================================================\n+ */\n+\n+#include \"svn_pools.h\"\n+#include \"svn_cmdline.h\"\n+#include \"svn_client.h\"\n+#include \"svn_ra.h\"\n+#include \"svn_repos.h\"\n+\n+#include \"svnrdump.h\"\n+\n+void\n+write_hash_to_stringbuf(apr_hash_t *properties,\n+                        svn_boolean_t deleted,\n+                        svn_stringbuf_t **strbuf,\n+                        apr_pool_t *pool)\n+{\n+  apr_hash_index_t *this;\n+  const void *key;\n+  void *val;\n+  apr_ssize_t keylen;\n+  svn_string_t *value;\n+\n+  if (!deleted) {\n+    for (this = apr_hash_first(pool, properties); this;\n+         this = apr_hash_next(this)) {\n+      /* Get this key and val. */\n+      apr_hash_this(this, &key, &keylen, &val);\n+      value = val;\n+\n+      /* Output name length, then name. */\n+      svn_stringbuf_appendcstr(*strbuf,\n+             apr_psprintf(pool, \"K %\" APR_SSIZE_T_FMT \"\\n\",\n+                    keylen));\n+\n+      svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);\n+      svn_stringbuf_appendbytes(*strbuf, \"\\n\", 1);\n+\n+      /* Output value length, then value. */\n+      svn_stringbuf_appendcstr(*strbuf,\n+             apr_psprintf(pool, \"V %\" APR_SIZE_T_FMT \"\\n\",\n+                    value->len));\n+\n+      svn_stringbuf_appendbytes(*strbuf, value->data, value->len);\n+      svn_stringbuf_appendbytes(*strbuf, \"\\n\", 1);\n+    }\n+  }\n+  else {\n+    /* Output a \"D \" entry for each deleted property */\n+    for (this = apr_hash_first(pool, properties); this;\n+         this = apr_hash_next(this)) {\n+      /* Get this key */\n+      apr_hash_this(this, &key, &keylen, NULL);\n+\n+      /* Output name length, then name */\n+      svn_stringbuf_appendcstr(*strbuf,\n+             apr_psprintf(pool, \"D %\" APR_SSIZE_T_FMT \"\\n\",\n+                    keylen));\n+\n+      svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);\n+      svn_stringbuf_appendbytes(*strbuf, \"\\n\", 1);\n+    }\n+  }\n+}\n+\n+svn_error_t *\n+dump_props(struct dump_edit_baton *eb,\n+           svn_boolean_t *trigger_var,\n+           svn_boolean_t dump_data_too,\n+           apr_pool_t *pool)\n+{\n+  if (trigger_var && !*trigger_var)\n+    return SVN_NO_ERROR;\n+\n+  /* Build a propstring to print */\n+  svn_stringbuf_setempty(eb->propstring);\n+  write_hash_to_stringbuf(eb->properties,\n+        FALSE,\n+        &(eb->propstring), eb->pool);\n+  write_hash_to_stringbuf(eb->del_properties,\n+        TRUE,\n+        &(eb->propstring), eb->pool);\n+  svn_stringbuf_appendbytes(eb->propstring, \"PROPS-END\\n\", 10);\n+\n+  /* prop-delta header */\n+  SVN_ERR(svn_stream_printf(eb->stream, pool,\n+          SVN_REPOS_DUMPFILE_PROP_DELTA\n+          \": true\\n\"));\n+\n+  /* prop-content-length header */\n+  SVN_ERR(svn_stream_printf(eb->stream, pool,\n+          SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH\n+          \": %\" APR_SIZE_T_FMT \"\\n\", eb->propstring->len));\n+\n+  if (dump_data_too) {\n+    /* content-length header */\n+    SVN_ERR(svn_stream_printf(eb->stream, pool,\n+            SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n+            \": %\" APR_SIZE_T_FMT \"\\n\\n\",\n+            eb->propstring->len));\n+\n+    /* the properties themselves */\n+    SVN_ERR(svn_stream_write(eb->stream, eb->propstring->data,\n+           &(eb->propstring->len)));\n+\n+    /* Cleanup so that data is never dumped twice */\n+    apr_hash_clear(eb->properties);\n+    apr_hash_clear(eb->del_properties);\n+    if (trigger_var)\n+      *trigger_var = FALSE;\n+  }\n+  return SVN_NO_ERROR;\n+}\n"},{"id":"145103","messageId":"002d01cb1e7f$e0ff03c0$a2fd0b40$@nl","threadId":"24333","inReplyTo":"20100708083516.GD29267@debian","subject":"RE: [PATCH] Add svnrdump","fromName":"Bert Huijben","fromEmail":"bert@qqmail.nl","sentAt":"2010-07-08T09:28:09Z","receivedAt":"2010-07-08T09:28:09Z","isPatch":true,"sender":{"key":"bert@qqmail.nl","avatar":"https://gravatar.com/avatar/3eb6d66fbca2e83b0c493dce9c96e6cc40e2d7983403900ac34453dfcc80bc05?d=mp&s=160"},"body":"\n\n> -----Original Message-----\n> From: Ramkumar Ramachandra [mailto:artagnon@gmail.com]\n> Sent: donderdag 8 juli 2010 10:35\n> To: dev@subversion.apache.org\n> Cc: Jonathan Nieder; Sverre Rabbelier; Git Mailing List\n> Subject: [PATCH] Add svnrdump\n> \n> Hi,\n> \n> Kindly find the diff for svnrdump in the later part of this email. I\n> haven't written a build.conf rule or manpage, but I suppose I can do\n> them in another patch.\n> \n> Thanks.\n> \n> -- Ram\n> \n> --------------------8<--------------->8-----------------------------\n> \n> Index: subversion/svnrdump/dump_editor.c\n> ===================================================================\n> --- subversion/svnrdump/dump_editor.c\t(revision 0)\n> +++ subversion/svnrdump/dump_editor.c\t(working copy)\n> @@ -0,0 +1,689 @@\n> +/*\n> + *\n> ====================================================================\n> + *    Licensed to the Apache Software Foundation (ASF) under one\n> + *    or more contributor license agreements.  See the NOTICE file\n> + *    distributed with this work for additional information\n> + *    regarding copyright ownership.  The ASF licenses this file\n> + *    to you under the Apache License, Version 2.0 (the\n> + *    \"License\"); you may not use this file except in compliance\n> + *    with the License.  You may obtain a copy of the License at\n> + *\n> + *      http://www.apache.org/licenses/LICENSE-2.0\n> + *\n> + *    Unless required by applicable law or agreed to in writing,\n> + *    software distributed under the License is distributed on an\n> + *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n> + *    KIND, either express or implied.  See the License for the\n> + *    specific language governing permissions and limitations\n> + *    under the License.\n> + *\n> ====================================================================\n> + */\n> +\n> +#include \"svn_pools.h\"\n> +#include \"svn_repos.h\"\n> +#include \"svn_path.h\"\n> +#include \"svn_props.h\"\n> +\n> +#include \"svnrdump.h\"\n> +#include \"dump_editor.h\"\n> +\n> +#define ARE_VALID_COPY_ARGS(p,r) ((p) && SVN_IS_VALID_REVNUM(r))\n> +\n> +svn_boolean_t must_dump_props = FALSE, must_dump_text = FALSE,\n> +  dump_props_pending = FALSE;\n\nYou should use the editor baton for this to avoid global variables.\n\n> +\n> +/* Make a directory baton to represent the directory was path\n> +   (relative to EDIT_BATON's path) is PATH.\n> +\n> +   CMP_PATH/CMP_REV are the path/revision against which this directory\n> +   should be compared for changes.  If either is omitted (NULL for the\n> +   path, SVN_INVALID_REVNUM for the rev), just compare this directory\n> +   PATH against itself in the previous revision.\n> +\n> +   PARENT_DIR_BATON is the directory baton of this directory's parent,\n> +   or NULL if this is the top-level directory of the edit.  ADDED\n> +   indicated if this directory is newly added in this revision.\n> +   Perform all allocations in POOL.  */\n> +static struct dir_baton *\n> +make_dir_baton(const char *path,\n> +               const char *cmp_path,\n> +               svn_revnum_t cmp_rev,\n> +               void *edit_baton,\n> +               void *parent_dir_baton,\n> +               svn_boolean_t added,\n> +               apr_pool_t *pool)\n> +{\n> +  struct dump_edit_baton *eb = edit_baton;\n> +  struct dir_baton *pb = parent_dir_baton;\n> +  struct dir_baton *new_db = apr_pcalloc(pool, sizeof(*new_db));\n> +  const char *full_path;\n> +  apr_array_header_t *compose_path = apr_array_make(pool, 2,\n> sizeof(const char *));\n> +\n> +  /* A path relative to nothing?  I don't think so. */\n> +  SVN_ERR_ASSERT_NO_RETURN(!path || pb);\n> +\n> +  /* Construct the full path of this node. */\n> +  if (pb) {\n> +    APR_ARRAY_PUSH(compose_path, const char *) = \"/\";\n> +    APR_ARRAY_PUSH(compose_path, const char *) = path;\n> +    full_path = svn_path_compose(compose_path, pool);\n> +  }\n> +  else\n> +    full_path = apr_pstrdup(pool, \"/\");\n> +\n> +  /* Remove leading slashes from copyfrom paths. */\n> +  if (cmp_path)\n> +    cmp_path = ((*cmp_path == '/') ? cmp_path + 1 : cmp_path);\n> +\n> +  new_db->eb = eb;\n> +  new_db->parent_dir_baton = pb;\n> +  new_db->path = full_path;\n> +  new_db->cmp_path = cmp_path ? apr_pstrdup(pool, cmp_path) : NULL;\n> +  new_db->cmp_rev = cmp_rev;\n> +  new_db->added = added;\n> +  new_db->written_out = FALSE;\n> +  new_db->deleted_entries = apr_hash_make(pool);\n> +  new_db->pool = pool;\n> +\n> +  return new_db;\n> +}\n> +/*\n> + * Write out a node record for PATH of type KIND under EB->FS_ROOT.\n> + * ACTION describes what is happening to the node (see enum\n> svn_node_action).\n> + * Write record to writable EB->STREAM, using EB->BUFFER to write in\n> chunks.\n> + *\n> + * If the node was itself copied, IS_COPY is TRUE and the\n> + * path/revision of the copy source are in CMP_PATH/CMP_REV.  If\n> + * IS_COPY is FALSE, yet CMP_PATH/CMP_REV are valid, this node is part\n> + * of a copied subtree.\n> + */\n> +static svn_error_t *\n> +dump_node(struct dump_edit_baton *eb,\n> +          const char *path,    /* an absolute path. */\n> +          svn_node_kind_t kind,\n> +          enum svn_node_action action,\n> +          const char *cmp_path,\n> +          svn_revnum_t cmp_rev,\n> +          apr_pool_t *pool)\n> +{\n> +  /* Write out metadata headers for this file node. */\n> +  SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +          SVN_REPOS_DUMPFILE_NODE_PATH \": %s\\n\",\n> +          (*path == '/') ? path + 1 : path));\n> +\n> +  if (kind == svn_node_file)\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_KIND \":\n> file\\n\"));\n> +  else if (kind == svn_node_dir)\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_KIND \":\n> dir\\n\"));\n> +\n> +  /* Remove leading slashes from copyfrom paths. */\n> +  if (cmp_path)\n> +    cmp_path = ((*cmp_path == '/') ? cmp_path + 1 : cmp_path);\n> +\n> +  switch (action) {\n> +    /* Appropriately handle the four svn_node_action actions */\n> +\n> +  case svn_node_action_change:\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_ACTION\n> +                              \": change\\n\"));\n> +    break;\n> +\n> +  case svn_node_action_replace:\n> +    if (!eb->is_copy) {\n> +      /* a simple delete+add, implied by a single 'replace' action. */\n> +      SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                                SVN_REPOS_DUMPFILE_NODE_ACTION\n> +                                \": replace\\n\"));\n> +\n> +      dump_props_pending = TRUE;\n> +      break;\n> +    }\n> +    /* More complex case: eb->is_copy is true, and\n> +       cmp_path/ cmp_rev are present: delete the original,\n> +       and then re-add it */\n> +\n> +    /* the path & kind headers have already been printed;  just\n> +       add a delete action, and end the current record.*/\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_ACTION\n> +                              \": delete\\n\\n\"));\n> +\n> +    /* recurse:  print an additional add-with-history record. */\n> +    SVN_ERR(dump_node(eb, path, kind, svn_node_action_add,\n> +                      cmp_path, cmp_rev, pool));\n> +\n> +    /* we can leave this routine quietly now, don't need to dump\n> +       any content;  that was already done in the second record. */\n> +    must_dump_props = FALSE;\n> +    eb->is_copy = FALSE;\n> +    break;\n> +\n> +  case svn_node_action_delete:\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_ACTION\n> +                              \": delete\\n\"));\n> +\n> +    /* we can leave this routine quietly now, don't need to dump\n> +       any content. */\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool, \"\\n\\n\"));\n> +    must_dump_props = FALSE;\n> +    break;\n> +\n> +  case svn_node_action_add:\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_ACTION \":\n> add\\n\"));\n> +\n> +    if (!eb->is_copy) {\n> +      /* dump_props_pending for files is handled in\n> +         close_file which is called immediately.\n> +         However, directories are not closed until\n> +         all the work inside them have been done;\n> +         dump_props_pending for directories is\n> +         handled in all the functions that can\n> +         possibly be called after add_directory:\n> +         add_directory, open_directory,\n> +         delete_entry, close_directory, add_file,\n> +         open_file and change_dir_prop;\n> +         change_dir_prop is a special case\n> +         ofcourse */\n> +\n> +      dump_props_pending = TRUE;\n> +      break;\n> +    }\n> +\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +                              SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV\n> +                              \": %ld\\n\"\n> +                              SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH\n> +                              \": %s\\n\",\n> +                              cmp_rev, cmp_path));\n> +\n> +    /* Dump the text only if apply_textdelta sets\n> +       must_dump_text */\n> +\n> +    /* UGLY hack: If a directory was copied from a\n> +       previous revision, nothing else can be done, and\n> +       close_file won't be called to write two blank\n> +       lines; write them here */\n> +    if (kind == svn_node_dir)\n> +      SVN_ERR(svn_stream_printf(eb->stream, pool, \"\\n\\n\"));\n> +\n> +    eb->is_copy = FALSE;\n> +\n> +    break;\n> +  }\n> +\n> +  /* Dump property headers */\n> +  SVN_ERR(dump_props(eb, &must_dump_props, FALSE, pool));\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +svn_error_t *open_root(void *edit_baton,\n> +                       svn_revnum_t base_revision,\n> +                       apr_pool_t *pool,\n> +                       void **root_baton)\n\nStatic and the return type on its own line.\n> +{\n> +  /* Allocate a special pool for the edit_baton to avoid pool\n> +     lifetime issues */\n> +  struct dump_edit_baton *eb = edit_baton;\n> +  eb->pool = svn_pool_create(pool);\n> +  eb->properties = apr_hash_make(eb->pool);\n> +  eb->del_properties = apr_hash_make(eb->pool);\n> +  eb->propstring = svn_stringbuf_create(\"\", eb->pool);\n> +  eb->is_copy = FALSE;\n> +\n> +  *root_baton = make_dir_baton(NULL, NULL, SVN_INVALID_REVNUM,\n> +                               edit_baton, NULL, FALSE, pool);\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +delete_entry(const char *path,\n> +             svn_revnum_t revision,\n> +             void *parent_baton,\n> +             apr_pool_t *pool)\n> +{\n> +  struct dir_baton *pb = parent_baton;\n> +  const char *mypath = apr_pstrdup(pb->pool, path);\n> +\n> +  /* Some pending properties to dump? */\n> +  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n> +\n> +  /* remember this path needs to be deleted */\n> +  apr_hash_set(pb->deleted_entries, mypath, APR_HASH_KEY_STRING, pb);\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +add_directory(const char *path,\n> +              void *parent_baton,\n> +              const char *copyfrom_path,\n> +              svn_revnum_t copyfrom_rev,\n> +              apr_pool_t *pool,\n> +              void **child_baton)\n> +{\n> +  struct dir_baton *pb = parent_baton;\n> +  void *val;\n> +  struct dir_baton *new_db\n> +    = make_dir_baton(path, copyfrom_path, copyfrom_rev, pb->eb, pb,\n> TRUE, pool);\n> +\n> +  /* Some pending properties to dump? */\n> +  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n> +\n> +  /* This might be a replacement -- is the path already deleted? */\n> +  val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);\n> +\n> +  /* Detect an add-with-history */\n> +  pb->eb->is_copy = ARE_VALID_COPY_ARGS(copyfrom_path, copyfrom_rev);\n> +\n> +  /* Dump the node */\n> +  SVN_ERR(dump_node(pb->eb, path,\n> +                    svn_node_dir,\n> +                    val ? svn_node_action_replace :\n> svn_node_action_add,\n> +                    pb->eb->is_copy ? copyfrom_path : NULL,\n> +                    pb->eb->is_copy ? copyfrom_rev :\n> SVN_INVALID_REVNUM,\n> +                    pool));\n> +\n> +  if (val)\n> +    /* Delete the path, it's now been dumped */\n> +    apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING,\n> NULL);\n> +\n> +  new_db->written_out = TRUE;\n> +\n> +  *child_baton = new_db;\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +open_directory(const char *path,\n> +               void *parent_baton,\n> +               svn_revnum_t base_revision,\n> +               apr_pool_t *pool,\n> +               void **child_baton)\n> +{\n> +  struct dir_baton *pb = parent_baton;\n> +  struct dir_baton *new_db;\n> +  const char *cmp_path = NULL;\n> +  svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;\n> +  apr_array_header_t *compose_path = apr_array_make(pool, 2,\n> sizeof(const char *));\n\nThis looks like more than 80 characters to me.\n> +\n> +  /* Some pending properties to dump? */\n> +  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n> +\n> +  /* If the parent directory has explicit comparison path and rev,\n> +     record the same for this one. */\n> +  if (pb && ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev)) {\n> +    APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path;\n> +    APR_ARRAY_PUSH(compose_path, const char *) =\n> svn_dirent_basename(path, pool);\n> +    cmp_path = svn_path_compose(compose_path, pool);\n> +    cmp_rev = pb->cmp_rev;\n> +  }\n> +\n> +  new_db = make_dir_baton(path, cmp_path, cmp_rev, pb->eb, pb, FALSE,\n> pool);\n> +  *child_baton = new_db;\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +close_directory(void *dir_baton,\n> +                apr_pool_t *pool)\n> +{\n> +  struct dir_baton *db = dir_baton;\n> +  struct dump_edit_baton *eb = db->eb;\n> +  apr_hash_index_t *hi;\n> +  apr_pool_t *subpool = svn_pool_create(pool);\n> +\n> +  /* Some pending properties to dump? */\n> +  SVN_ERR(dump_props(eb, &dump_props_pending, TRUE, pool));\n> +\n> +  /* Dump the directory entries */\n> +  for (hi = apr_hash_first(pool, db->deleted_entries); hi;\n> +       hi = apr_hash_next(hi)) {\n> +    const void *key;\n> +    const char *path;\n> +    apr_hash_this(hi, &key, NULL, NULL);\n> +    path = key;\n> +\n> +    svn_pool_clear(subpool);\n> +\n> +    SVN_ERR(dump_node(db->eb, path,\n> +                      svn_node_unknown, svn_node_action_delete,\n> +                      NULL, SVN_INVALID_REVNUM, subpool));\n> +  }\n> +\n> +  svn_pool_destroy(subpool);\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +add_file(const char *path,\n> +         void *parent_baton,\n> +         const char *copyfrom_path,\n> +         svn_revnum_t copyfrom_rev,\n> +         apr_pool_t *pool,\n> +         void **file_baton)\n> +{\n> +  struct dir_baton *pb = parent_baton;\n> +  void *val;\n> +\n> +  /* Some pending properties to dump? */\n> +  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n> +\n> +  /* This might be a replacement -- is the path already deleted? */\n> +  val = apr_hash_get(pb->deleted_entries, path, APR_HASH_KEY_STRING);\n> +\n> +  /* Detect add-with-history. */\n> +  pb->eb->is_copy = ARE_VALID_COPY_ARGS(copyfrom_path, copyfrom_rev);\n> +\n> +  /* Dump the node. */\n> +  SVN_ERR(dump_node(pb->eb, path,\n> +                    svn_node_file,\n> +                    val ? svn_node_action_replace :\n> svn_node_action_add,\n> +                    pb->eb->is_copy ? copyfrom_path : NULL,\n> +                    pb->eb->is_copy ? copyfrom_rev :\n> SVN_INVALID_REVNUM,\n> +                    pool));\n> +\n> +  if (val)\n> +    /* delete the path, it's now been dumped. */\n> +    apr_hash_set(pb->deleted_entries, path, APR_HASH_KEY_STRING,\n> NULL);\n> +\n> +  /* Build a nice file baton to pass to change_file_prop and\n> apply_textdelta */\n> +  pb->eb->changed_path = path;\n> +  *file_baton = pb->eb;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +open_file(const char *path,\n> +          void *parent_baton,\n> +          svn_revnum_t ancestor_revision,\n> +          apr_pool_t *pool,\n> +          void **file_baton)\n> +{\n> +  struct dir_baton *pb = parent_baton;\n> +  const char *cmp_path = NULL;\n> +  svn_revnum_t cmp_rev = SVN_INVALID_REVNUM;\n> +\n> +  /* Some pending properties to dump? */\n> +  SVN_ERR(dump_props(pb->eb, &dump_props_pending, TRUE, pool));\n> +\n> +  apr_array_header_t *compose_path = apr_array_make(pool, 2,\n> sizeof(const char *));\n> +  /* If the parent directory has explicit comparison path and rev,\n> +     record the same for this one. */\n> +  if (pb && ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev)) {\n> +    APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path;\n> +    APR_ARRAY_PUSH(compose_path, const char *) =\n> svn_dirent_basename(path, pool);\n\nAssuming that the path doesn't start with a '/' here, this should be\nsvn_relent_basename() to avoid platform specific path rules.\n\n> +    cmp_path = svn_path_compose(compose_path, pool);\n> +    cmp_rev = pb->cmp_rev;\n> +  }\n> +\n> +  SVN_ERR(dump_node(pb->eb, path,\n> +                    svn_node_file, svn_node_action_change,\n> +                    cmp_path, cmp_rev, pool));\n> +\n> +  /* Build a nice file baton to pass to change_file_prop and\n> apply_textdelta */\n> +  pb->eb->changed_path = path;\n> +  *file_baton = pb->eb;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +change_dir_prop(void *parent_baton,\n> +                const char *name,\n> +                const svn_string_t *value,\n> +                apr_pool_t *pool)\n> +{\n> +  struct dir_baton *db = parent_baton;\n> +\n> +  if (svn_property_kind(NULL, name) != svn_prop_regular_kind)\n> +    return SVN_NO_ERROR;\n> +\n> +  value ? apr_hash_set(db->eb->properties, apr_pstrdup(pool, name),\n> +                       APR_HASH_KEY_STRING, svn_string_dup(value,\n> pool)) :\n> +    apr_hash_set(db->eb->del_properties, apr_pstrdup(pool, name),\n> +                 APR_HASH_KEY_STRING, (void *)0x1);\n> +\n> +  /* This function is what distinguishes between a directory that is\n> +     opened to merely get somewhere, vs. one that is opened because it\n> +     actually changed by itself  */\n> +  if (! db->written_out) {\n> +    /* If dump_props_pending was set, it means that the\n> +       node information corresponding to add_directory has already\n> +       been written; just don't unset it and dump_node will dump\n> +       the properties before doing anything else. If it wasn't\n> +       set, node information hasn't been written yet: so dump the\n> +       node itself before dumping the props */\n> +\n> +    SVN_ERR(dump_node(db->eb, db->path,\n> +                      svn_node_dir, svn_node_action_change,\n> +                      db->cmp_path, db->cmp_rev, pool));\n> +\n> +    SVN_ERR(dump_props(db->eb, NULL, TRUE, pool));\n> +    db->written_out = TRUE;\n> +  }\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +change_file_prop(void *file_baton,\n> +                 const char *name,\n> +                 const svn_string_t *value,\n> +                 apr_pool_t *pool)\n> +{\n> +  struct dump_edit_baton *eb = file_baton;\n> +\n> +  if (svn_property_kind(NULL, name) != svn_prop_regular_kind)\n> +    return SVN_NO_ERROR;\n> +\n> +  apr_hash_set(eb->properties, apr_pstrdup(pool, name),\n> +               APR_HASH_KEY_STRING, value ?\n> +               svn_string_dup(value, pool): (void *)0x1);\n> +\n> +  /* Dump the property headers and wait; close_file might need\n> +     to write text headers too depending on whether\n> +     apply_textdelta is called */\n> +  dump_props_pending = TRUE;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +window_handler(svn_txdelta_window_t *window, void *baton)\n> +{\n> +  struct handler_baton *hb = baton;\n> +  struct dump_edit_baton *eb = hb->eb;\n> +  svn_error_t *err;\n> +\n> +  err = hb->apply_handler(window, hb->apply_baton);\n> +  if (window != NULL && !err)\n> +    return SVN_NO_ERROR;\n> +\n> +  if (err)\n> +    SVN_ERR(err);\n> +\n> +  /* Write information about the filepath to hb->eb */\n> +  eb->temp_filepath = apr_pstrdup(eb->pool,\n> +          hb->temp_filepath);\n> +\n> +  /* Cleanup */\n> +  SVN_ERR(svn_io_file_close(hb->temp_file, hb->pool));\n> +  SVN_ERR(svn_stream_close(hb->temp_filestream));\n\nThe standard handler already closes the stream for you and if you don't\ndisown the file on mapping, this also closes the file.\n\n> +  svn_pool_destroy(hb->pool);\n\nAnd as you clear the pool that contains the file and stream here, closing\nyourself is not necessary.\n\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +apply_textdelta(void *file_baton, const char *base_checksum,\n> +                apr_pool_t *pool,\n> +                svn_txdelta_window_handler_t *handler,\n> +                void **handler_baton)\n> +{\n> +  struct dump_edit_baton *eb = file_baton;\n> +  apr_status_t apr_err;\n> +  const char *tempdir;\n> +\n> +  /* Custom handler_baton allocated in a separate pool */\n> +  apr_pool_t *handler_pool = svn_pool_create(pool);\n> +  struct handler_baton *hb = apr_pcalloc(handler_pool, sizeof(*hb));\n> +  hb->pool = handler_pool;\n> +  hb->eb = eb;\n> +\n> +  /* Use a temporary file to measure the text-content-length */\n> +  apr_err = apr_temp_dir_get(&tempdir, hb->pool);\n> +  if (apr_err != APR_SUCCESS)\n> +    SVN_ERR(svn_error_wrap_apr(apr_err, NULL));\n> +\n> +  hb->temp_filepath = apr_psprintf(eb->pool, \"%s/svn-fe-XXXXXX\",\n> tempdir);\n\nWhy store this path in the editor pool? Do you really need this XXXX path to\nlive that long?\n\n> +  apr_err = apr_file_mktemp(&(hb->temp_file), hb->temp_filepath,\n> +          APR_CREATE | APR_READ | APR_WRITE | APR_EXCL,\n> +          hb->pool);\n> +  if (apr_err != APR_SUCCESS)\n> +    SVN_ERR(svn_error_wrap_apr(apr_err, NULL));\n> +\n> +  hb->temp_filestream = svn_stream_from_aprfile2(hb->temp_file, TRUE,\n> hb->pool);\n> +\n> +  /* Prepare to write the delta to the temporary file */\n> +  svn_txdelta_to_svndiff2(&(hb->apply_handler), &(hb->apply_baton),\n> +                          hb->temp_filestream, 0, hb->pool);\n> +  must_dump_text = TRUE;\n> +\n> +  /* The actual writing takes place when this function has finished */\n> +  /* Set the handler and handler_baton */\n> +  *handler = window_handler;\n> +  *handler_baton = hb;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +svn_error_t *\n> +close_file(void *file_baton,\n> +           const char *text_checksum,\n> +           apr_pool_t *pool)\n> +{\n> +  struct dump_edit_baton *eb = file_baton;\n> +  apr_file_t *temp_file;\n> +  svn_stream_t *temp_filestream;\n> +  apr_finfo_t *info = apr_pcalloc(pool, sizeof(apr_finfo_t));\n> +\n> +  /* We didn't write the property headers because we were\n> +     waiting for file_prop_change; write them now */\n> +  SVN_ERR(dump_props(eb, &dump_props_pending, FALSE, pool));\n> +\n> +  /* The prop headers have already been dumped in dump_node */\n> +  /* Dump the text headers */\n> +  if (must_dump_text) {\n> +    /* text-delta header */\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +            SVN_REPOS_DUMPFILE_TEXT_DELTA\n> +            \": true\\n\"));\n> +\n> +    /* Measure the length */\n> +    SVN_ERR(svn_io_stat(info, eb->temp_filepath, APR_FINFO_SIZE,\n> pool));\n> +\n> +    /* text-content-length header */\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +            SVN_REPOS_DUMPFILE_TEXT_CONTENT_LENGTH\n> +            \": %lu\\n\",\n> +            (unsigned long)info->size));\n> +    /* text-content-md5 header */\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +            SVN_REPOS_DUMPFILE_TEXT_CONTENT_MD5\n> +             \": %s\\n\",\n> +            text_checksum));\n> +  }\n> +\n> +  /* content-length header: if both text and props are absent,\n> +     skip this block */\n> +  if (must_dump_props || dump_props_pending)\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +            SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n> +            \": %ld\\n\\n\",\n> +            (unsigned long)info->size + eb->propstring->len));\n> +  else if (must_dump_text)\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +            SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n> +            \": %ld\\n\\n\",\n> +            (unsigned long)info->size));\n> +\n> +  /* Dump the props; the propstring should have already been\n> +     written in dump_node or above */\n> +  if (must_dump_props || dump_props_pending) {\n> +    SVN_ERR(svn_stream_write(eb->stream, eb->propstring->data,\n> +           &(eb->propstring->len)));\n> +\n> +    /* Cleanup */\n> +    must_dump_props = dump_props_pending = FALSE;\n> +    apr_hash_clear(eb->properties);\n> +    apr_hash_clear(eb->del_properties);\n> +  }\n> +\n> +  /* Dump the text */\n> +  if (must_dump_text) {\n> +\n> +    /* Open the temporary file, map it to a stream, copy\n> +       the stream to eb->stream, close and delete the\n> +       file */\n> +    SVN_ERR(svn_io_file_open(&temp_file, eb->temp_filepath, APR_READ,\n> 0600, pool));\n> +    temp_filestream = svn_stream_from_aprfile2(temp_file, TRUE, pool);\n> +    SVN_ERR(svn_stream_copy3(temp_filestream, eb->stream, NULL, NULL,\n> pool));\n> +\n> +    /* Cleanup */\n> +    SVN_ERR(svn_io_file_close(temp_file, pool));\n> +    SVN_ERR(svn_stream_close(temp_filestream));\n> +    SVN_ERR(svn_io_remove_file2(eb->temp_filepath, TRUE, pool));\n> +    must_dump_text = FALSE;\n> +  }\n> +\n> +  SVN_ERR(svn_stream_printf(eb->stream, pool, \"\\n\\n\"));\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +close_edit(void *edit_baton, apr_pool_t *pool)\n> +{\n> +  struct dump_edit_baton *eb = edit_baton;\n> +  svn_pool_destroy(eb->pool);\n> +  (eb->current_rev) ++;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +svn_error_t *\n> +get_dump_editor(const svn_delta_editor_t **editor,\n> +                void **edit_baton,\n> +                svn_revnum_t from_rev,\n> +                apr_pool_t *pool)\n> +{\n> +  struct dump_edit_baton *eb = apr_pcalloc(pool, sizeof(struct\n> dump_edit_baton));\n> +  eb->current_rev = from_rev;\n> +  SVN_ERR(svn_stream_for_stdout(&(eb->stream), pool));\n> +  svn_delta_editor_t *de = svn_delta_default_editor(pool);\n> +\n> +  de->open_root = open_root;\n> +  de->delete_entry = delete_entry;\n> +  de->add_directory = add_directory;\n> +  de->open_directory = open_directory;\n> +  de->close_directory = close_directory;\n> +  de->change_dir_prop = change_dir_prop;\n> +  de->change_file_prop = change_file_prop;\n> +  de->apply_textdelta = apply_textdelta;\n> +  de->add_file = add_file;\n> +  de->open_file = open_file;\n> +  de->close_file = close_file;\n> +  de->close_edit = close_edit;\n> +\n> +  /* Set the edit_baton and editor */\n> +  *edit_baton = eb;\n> +  *editor = de;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> Index: subversion/svnrdump/dump_editor.h\n> ===================================================================\n> --- subversion/svnrdump/dump_editor.h\t(revision 0)\n> +++ subversion/svnrdump/dump_editor.h\t(working copy)\n> @@ -0,0 +1,99 @@\n> +/*\n> + *\n> ====================================================================\n> + *    Licensed to the Apache Software Foundation (ASF) under one\n> + *    or more contributor license agreements.  See the NOTICE file\n> + *    distributed with this work for additional information\n> + *    regarding copyright ownership.  The ASF licenses this file\n> + *    to you under the Apache License, Version 2.0 (the\n> + *    \"License\"); you may not use this file except in compliance\n> + *    with the License.  You may obtain a copy of the License at\n> + *\n> + *      http://www.apache.org/licenses/LICENSE-2.0\n> + *\n> + *    Unless required by applicable law or agreed to in writing,\n> + *    software distributed under the License is distributed on an\n> + *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n> + *    KIND, either express or implied.  See the License for the\n> + *    specific language governing permissions and limitations\n> + *    under the License.\n> + *\n> ====================================================================\n> + */\n> +\n> +#ifndef DUMP_EDITOR_H_\n> +#define DUMP_EDITOR_H_\n> +\n> +struct dump_edit_baton {\n> +  svn_stream_t *stream;\n> +  svn_revnum_t current_rev;\n> +\n> +  /* pool is for per-edit-session allocations */\n> +  apr_pool_t *pool;\n> +\n> +  /* Store the properties that changed */\n> +  apr_hash_t *properties;\n> +  apr_hash_t *del_properties; /* Value is always 0x1 */\n> +  svn_stringbuf_t *propstring;\n> +\n> +  /* Was a copy command issued? */\n> +  svn_boolean_t is_copy;\n> +\n> +  /* Path of changed file */\n> +  const char *changed_path;\n> +\n> +  /* Temporary file to write delta to along with its checksum */\n> +  char *temp_filepath;\n> +  svn_checksum_t *checksum;\n> +};\n> +\n> +struct dir_baton {\n> +  struct dump_edit_baton *eb;\n> +  struct dir_baton *parent_dir_baton;\n> +\n> +  /* is this directory a new addition to this revision? */\n> +  svn_boolean_t added;\n> +\n> +  /* has this directory been written to the output stream? */\n> +  svn_boolean_t written_out;\n> +\n> +  /* the absolute path to this directory */\n> +  const char *path;\n> +\n> +  /* the comparison path and revision of this directory.  if both of\n> +     these are valid, use them as a source against which to compare\n> +     the directory instead of the default comparison source of PATH in\n> +     the previous revision. */\n> +  const char *cmp_path;\n> +  svn_revnum_t cmp_rev;\n> +\n> +  /* hash of paths that need to be deleted, though some -might- be\n> +     replaced.  maps const char * paths to this dir_baton.  (they're\n> +     full paths, because that's what the editor driver gives us.  but\n> +     really, they're all within this directory.) */\n> +  apr_hash_t *deleted_entries;\n> +\n> +  /* pool to be used for deleting the hash items */\n> +  apr_pool_t *pool;\n> +};\n> +\n> +struct handler_baton\n> +{\n> +  svn_txdelta_window_handler_t apply_handler;\n> +  void *apply_baton;\n> +  apr_pool_t *pool;\n> +\n> +  /* Information about the path of the tempoarary file used */\n> +  char *temp_filepath;\n> +  apr_file_t *temp_file;\n> +  svn_stream_t *temp_filestream;\n> +\n> +  /* To fill in the edit baton fields */\n> +  struct dump_edit_baton *eb;\n> +};\n> +\n> +svn_error_t *\n> +get_dump_editor(const svn_delta_editor_t **editor,\n> +                void **edit_baton,\n> +                svn_revnum_t to_rev,\n> +                apr_pool_t *pool);\n\nThese structs and this function don't follow our naming guidelines for\nlibraries. But these functions are no reusable library (yet).\n\n\n\tBert\n\n(no comments in the rest of this mail)\n\n> +\n> +#endif\n> Index: subversion/svnrdump/svnrdump.c\n> ===================================================================\n> --- subversion/svnrdump/svnrdump.c\t(revision 0)\n> +++ subversion/svnrdump/svnrdump.c\t(working copy)\n> @@ -0,0 +1,198 @@\n> +/*\n> + *\n> ====================================================================\n> + *    Licensed to the Apache Software Foundation (ASF) under one\n> + *    or more contributor license agreements.  See the NOTICE file\n> + *    distributed with this work for additional information\n> + *    regarding copyright ownership.  The ASF licenses this file\n> + *    to you under the Apache License, Version 2.0 (the\n> + *    \"License\"); you may not use this file except in compliance\n> + *    with the License.  You may obtain a copy of the License at\n> + *\n> + *      http://www.apache.org/licenses/LICENSE-2.0\n> + *\n> + *    Unless required by applicable law or agreed to in writing,\n> + *    software distributed under the License is distributed on an\n> + *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n> + *    KIND, either express or implied.  See the License for the\n> + *    specific language governing permissions and limitations\n> + *    under the License.\n> + *\n> ====================================================================\n> + */\n> +\n> +#include \"svn_pools.h\"\n> +#include \"svn_cmdline.h\"\n> +#include \"svn_client.h\"\n> +#include \"svn_ra.h\"\n> +#include \"svn_repos.h\"\n> +#include \"svn_path.h\"\n> +\n> +#include \"svnrdump.h\"\n> +#include \"dump_editor.h\"\n> +\n> +static apr_pool_t *pool = NULL;\n> +static svn_client_ctx_t *ctx = NULL;\n> +static svn_ra_session_t *session = NULL;\n> +\n> +static svn_error_t *\n> +replay_revstart(svn_revnum_t revision,\n> +                void *replay_baton,\n> +                const svn_delta_editor_t **editor,\n> +                void **edit_baton,\n> +                apr_hash_t *rev_props,\n> +                apr_pool_t *pool)\n> +{\n> +  /* Editing this revision has just started; dump the revprops\n> +     before invoking the editor callbacks */\n> +  svn_stringbuf_t *propstring = svn_stringbuf_create(\"\", pool);\n> +  svn_stream_t *stdout_stream;\n> +\n> +  /* Create an stdout stream */\n> +  svn_stream_for_stdout(&stdout_stream, pool);\n> +\n> +        /* Print revision number and prepare the propstring */\n> +  SVN_ERR(svn_stream_printf(stdout_stream, pool,\n> +          SVN_REPOS_DUMPFILE_REVISION_NUMBER\n> +          \": %ld\\n\", revision));\n> +  write_hash_to_stringbuf(rev_props, FALSE, &propstring, pool);\n> +  svn_stringbuf_appendbytes(propstring, \"PROPS-END\\n\", 10);\n> +\n> +  /* prop-content-length header */\n> +  SVN_ERR(svn_stream_printf(stdout_stream, pool,\n> +          SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH\n> +          \": %\" APR_SIZE_T_FMT \"\\n\", propstring->len));\n> +\n> +  /* content-length header */\n> +  SVN_ERR(svn_stream_printf(stdout_stream, pool,\n> +          SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n> +          \": %\" APR_SIZE_T_FMT \"\\n\\n\", propstring->len));\n> +\n> +  /* Print the revprops now */\n> +  SVN_ERR(svn_stream_write(stdout_stream, propstring->data,\n> +         &(propstring->len)));\n> +\n> +  svn_stream_close(stdout_stream);\n> +\n> +  /* Extract editor and editor_baton from the replay_baton and\n> +     set them so that the editor callbacks can use them */\n> +  struct replay_baton *rb = replay_baton;\n> +  *editor = rb->editor;\n> +  *edit_baton = rb->edit_baton;\n> +\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +replay_revend(svn_revnum_t revision,\n> +              void *replay_baton,\n> +              const svn_delta_editor_t *editor,\n> +              void *edit_baton,\n> +              apr_hash_t *rev_props,\n> +              apr_pool_t *pool)\n> +{\n> +  /* Editor has finished for this revision and close_edit has\n> +     been called; do nothing: just continue to the next\n> +     revision */\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +open_connection(const char *url)\n> +{\n> +  SVN_ERR(svn_config_ensure (NULL, pool));\n> +  SVN_ERR(svn_client_create_context (&ctx, pool));\n> +  SVN_ERR(svn_ra_initialize(pool));\n> +\n> +  SVN_ERR(svn_config_get_config(&(ctx->config), NULL, pool));\n> +\n> +  /* Default authentication providers for non-interactive use */\n> +  SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE,\n> +                NULL, NULL, NULL, FALSE,\n> +                FALSE, NULL, NULL, NULL,\n> +                pool));\n> +  SVN_ERR(svn_client_open_ra_session(&session, url, ctx, pool));\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +replay_range(svn_revnum_t start_revision, svn_revnum_t end_revision)\n> +{\n> +  const svn_delta_editor_t *dump_editor;\n> +  void *dump_baton;\n> +\n> +  SVN_ERR(get_dump_editor(&dump_editor,\n> +                          &dump_baton, start_revision, pool));\n> +\n> +  struct replay_baton *replay_baton = apr_palloc(pool, sizeof(struct\n> replay_baton));\n> +  replay_baton->editor = dump_editor;\n> +  replay_baton->edit_baton = dump_baton;\n> +  SVN_ERR(svn_cmdline_printf(pool, SVN_REPOS_DUMPFILE_MAGIC_HEADER \":\n> %d\\n\",\n> +           SVN_REPOS_DUMPFILE_FORMAT_VERSION));\n> +  SVN_ERR(svn_ra_replay_range(session, start_revision, end_revision,\n> +                              0, TRUE, replay_revstart, replay_revend,\n> +                              replay_baton, pool));\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +static svn_error_t *\n> +usage(FILE *out_stream)\n> +{\n> +  fprintf(out_stream,\n> +    \"usage: svnrdump URL [-r LOWER[:UPPER]]\\n\\n\"\n> +    \"Dump the contents of repository at remote URL to stdout in a\n> 'dumpfile'\\n\"\n> +    \"v3 portable format.  Dump revisions LOWER rev through UPPER\n> rev.\\n\"\n> +    \"LOWER defaults to 1 and UPPER defaults to the highest possible\n> revision\\n\"\n> +    \"if omitted.\\n\");\n> +  return SVN_NO_ERROR;\n> +}\n> +\n> +int\n> +main(int argc, const char **argv)\n> +{\n> +  int i;\n> +  const char *url = NULL;\n> +  char *revision_cut = NULL;\n> +  svn_revnum_t start_revision = svn_opt_revision_unspecified;\n> +  svn_revnum_t end_revision = svn_opt_revision_unspecified;\n> +\n> +  if (svn_cmdline_init (\"svnrdump\", stderr) != EXIT_SUCCESS)\n> +    return EXIT_FAILURE;\n> +\n> +  pool = svn_pool_create(NULL);\n> +\n> +  for (i = 1; i < argc; i++) {\n> +    if (!strncmp(\"-r\", argv[i], 2)) {\n> +      revision_cut = strchr(argv[i] + 2, ':');\n> +      if (revision_cut) {\n> +        start_revision = (svn_revnum_t) strtoul(argv[i] + 2,\n> &revision_cut, 10);\n> +        end_revision = (svn_revnum_t) strtoul(revision_cut + 1, NULL,\n> 10);\n> +      }\n> +      else\n> +        start_revision = (svn_revnum_t) strtoul(argv[i] + 2, NULL,\n> 10);\n> +    } else if (!strcmp(\"help\", argv[i]) || !strcmp(\"--help\", argv[i]))\n> {\n> +      SVN_INT_ERR(usage(stdout));\n> +      return EXIT_SUCCESS;\n> +    } else if (*argv[i] == '-' || url) {\n> +      SVN_INT_ERR(usage(stderr));\n> +      return EXIT_FAILURE;\n> +    } else\n> +      url = argv[i];\n> +  }\n> +\n> +  if (!url || !svn_path_is_url(url)) {\n> +    usage(stderr);\n> +    return EXIT_FAILURE;\n> +  }\n> +  SVN_INT_ERR(open_connection(url));\n> +\n> +  /* Have sane start_revision and end_revision defaults if unspecified\n> */\n> +  if (start_revision == svn_opt_revision_unspecified)\n> +    start_revision = 1;\n> +  if (end_revision == svn_opt_revision_unspecified)\n> +    SVN_INT_ERR(svn_ra_get_latest_revnum(session, &end_revision,\n> pool));\n> +\n> +  SVN_INT_ERR(replay_range(start_revision, end_revision));\n> +\n> +  svn_pool_destroy(pool);\n> +\n> +  return 0;\n> +}\n> Index: subversion/svnrdump/svnrdump.h\n> ===================================================================\n> --- subversion/svnrdump/svnrdump.h\t(revision 0)\n> +++ subversion/svnrdump/svnrdump.h\t(working copy)\n> @@ -0,0 +1,44 @@\n> +/*\n> + *\n> ====================================================================\n> + *    Licensed to the Apache Software Foundation (ASF) under one\n> + *    or more contributor license agreements.  See the NOTICE file\n> + *    distributed with this work for additional information\n> + *    regarding copyright ownership.  The ASF licenses this file\n> + *    to you under the Apache License, Version 2.0 (the\n> + *    \"License\"); you may not use this file except in compliance\n> + *    with the License.  You may obtain a copy of the License at\n> + *\n> + *      http://www.apache.org/licenses/LICENSE-2.0\n> + *\n> + *    Unless required by applicable law or agreed to in writing,\n> + *    software distributed under the License is distributed on an\n> + *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n> + *    KIND, either express or implied.  See the License for the\n> + *    specific language governing permissions and limitations\n> + *    under the License.\n> + *\n> ====================================================================\n> + */\n> +\n> +#ifndef SVNRDUMP_H_\n> +#define SVNRDUMP_H_\n> +\n> +#include \"dump_editor.h\"\n> +\n> +struct replay_baton {\n> +  const svn_delta_editor_t *editor;\n> +  void *edit_baton;\n> +};\n> +\n> +void\n> +write_hash_to_stringbuf(apr_hash_t *properties,\n> +                        svn_boolean_t deleted,\n> +                        svn_stringbuf_t **strbuf,\n> +                        apr_pool_t *pool);\n> +\n> +svn_error_t *\n> +dump_props(struct dump_edit_baton *eb,\n> +           svn_boolean_t *trigger_var,\n> +           svn_boolean_t dump_data_too,\n> +           apr_pool_t *pool);\n> +\n> +#endif\n> Index: subversion/svnrdump/util.c\n> ===================================================================\n> --- subversion/svnrdump/util.c\t(revision 0)\n> +++ subversion/svnrdump/util.c\t(working copy)\n> @@ -0,0 +1,131 @@\n> +/*\n> + *\n> ====================================================================\n> + *    Licensed to the Apache Software Foundation (ASF) under one\n> + *    or more contributor license agreements.  See the NOTICE file\n> + *    distributed with this work for additional information\n> + *    regarding copyright ownership.  The ASF licenses this file\n> + *    to you under the Apache License, Version 2.0 (the\n> + *    \"License\"); you may not use this file except in compliance\n> + *    with the License.  You may obtain a copy of the License at\n> + *\n> + *      http://www.apache.org/licenses/LICENSE-2.0\n> + *\n> + *    Unless required by applicable law or agreed to in writing,\n> + *    software distributed under the License is distributed on an\n> + *    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n> + *    KIND, either express or implied.  See the License for the\n> + *    specific language governing permissions and limitations\n> + *    under the License.\n> + *\n> ====================================================================\n> + */\n> +\n> +#include \"svn_pools.h\"\n> +#include \"svn_cmdline.h\"\n> +#include \"svn_client.h\"\n> +#include \"svn_ra.h\"\n> +#include \"svn_repos.h\"\n> +\n> +#include \"svnrdump.h\"\n> +\n> +void\n> +write_hash_to_stringbuf(apr_hash_t *properties,\n> +                        svn_boolean_t deleted,\n> +                        svn_stringbuf_t **strbuf,\n> +                        apr_pool_t *pool)\n> +{\n> +  apr_hash_index_t *this;\n> +  const void *key;\n> +  void *val;\n> +  apr_ssize_t keylen;\n> +  svn_string_t *value;\n> +\n> +  if (!deleted) {\n> +    for (this = apr_hash_first(pool, properties); this;\n> +         this = apr_hash_next(this)) {\n> +      /* Get this key and val. */\n> +      apr_hash_this(this, &key, &keylen, &val);\n> +      value = val;\n> +\n> +      /* Output name length, then name. */\n> +      svn_stringbuf_appendcstr(*strbuf,\n> +             apr_psprintf(pool, \"K %\" APR_SSIZE_T_FMT \"\\n\",\n> +                    keylen));\n> +\n> +      svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);\n> +      svn_stringbuf_appendbytes(*strbuf, \"\\n\", 1);\n> +\n> +      /* Output value length, then value. */\n> +      svn_stringbuf_appendcstr(*strbuf,\n> +             apr_psprintf(pool, \"V %\" APR_SIZE_T_FMT \"\\n\",\n> +                    value->len));\n> +\n> +      svn_stringbuf_appendbytes(*strbuf, value->data, value->len);\n> +      svn_stringbuf_appendbytes(*strbuf, \"\\n\", 1);\n> +    }\n> +  }\n> +  else {\n> +    /* Output a \"D \" entry for each deleted property */\n> +    for (this = apr_hash_first(pool, properties); this;\n> +         this = apr_hash_next(this)) {\n> +      /* Get this key */\n> +      apr_hash_this(this, &key, &keylen, NULL);\n> +\n> +      /* Output name length, then name */\n> +      svn_stringbuf_appendcstr(*strbuf,\n> +             apr_psprintf(pool, \"D %\" APR_SSIZE_T_FMT \"\\n\",\n> +                    keylen));\n> +\n> +      svn_stringbuf_appendbytes(*strbuf, (const char *) key, keylen);\n> +      svn_stringbuf_appendbytes(*strbuf, \"\\n\", 1);\n> +    }\n> +  }\n> +}\n> +\n> +svn_error_t *\n> +dump_props(struct dump_edit_baton *eb,\n> +           svn_boolean_t *trigger_var,\n> +           svn_boolean_t dump_data_too,\n> +           apr_pool_t *pool)\n> +{\n> +  if (trigger_var && !*trigger_var)\n> +    return SVN_NO_ERROR;\n> +\n> +  /* Build a propstring to print */\n> +  svn_stringbuf_setempty(eb->propstring);\n> +  write_hash_to_stringbuf(eb->properties,\n> +        FALSE,\n> +        &(eb->propstring), eb->pool);\n> +  write_hash_to_stringbuf(eb->del_properties,\n> +        TRUE,\n> +        &(eb->propstring), eb->pool);\n> +  svn_stringbuf_appendbytes(eb->propstring, \"PROPS-END\\n\", 10);\n> +\n> +  /* prop-delta header */\n> +  SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +          SVN_REPOS_DUMPFILE_PROP_DELTA\n> +          \": true\\n\"));\n> +\n> +  /* prop-content-length header */\n> +  SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +          SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH\n> +          \": %\" APR_SIZE_T_FMT \"\\n\", eb->propstring->len));\n> +\n> +  if (dump_data_too) {\n> +    /* content-length header */\n> +    SVN_ERR(svn_stream_printf(eb->stream, pool,\n> +            SVN_REPOS_DUMPFILE_CONTENT_LENGTH\n> +            \": %\" APR_SIZE_T_FMT \"\\n\\n\",\n> +            eb->propstring->len));\n> +\n> +    /* the properties themselves */\n> +    SVN_ERR(svn_stream_write(eb->stream, eb->propstring->data,\n> +           &(eb->propstring->len)));\n> +\n> +    /* Cleanup so that data is never dumped twice */\n> +    apr_hash_clear(eb->properties);\n> +    apr_hash_clear(eb->del_properties);\n> +    if (trigger_var)\n> +      *trigger_var = FALSE;\n> +  }\n> +  return SVN_NO_ERROR;\n> +}\n"},{"id":"145175","messageId":"4C36706E.7070400@orcaware.com","threadId":"24333","inReplyTo":"alpine.561.2.00.1007081113210.3936@daniel2.local","subject":"Re: [PATCH] Add svnrdump","fromName":"Blair Zajac","fromEmail":"blair@orcaware.com","sentAt":"2010-07-09T00:42:22Z","receivedAt":"2010-07-09T00:42:22Z","isPatch":true,"sender":{"key":"blair@orcaware.com","avatar":"https://gravatar.com/avatar/dcb81a871c8fcf7086dd5291aaaeb6a921dcf1b387b00e85f394f78c31e115e2?d=mp&s=160"},"body":"On 07/08/2010 01:17 AM, Daniel Shahaf wrote:\n> @Bert: could you please trim quoted patches to only the relevant parts?\n> Scrolling is tedious when I don't have have line folding available...\n\n+1 on this, in Thunderbird, it took a while to scan through the whole \nemail to see the comments.\n\nRegards,\nBlair\n"},{"id":"145198","messageId":"4C36DAF3.7090208@drmicha.warpmail.net","threadId":"24333","inReplyTo":"4C36706E.7070400@orcaware.com","subject":"Re: [PATCH] Add svnrdump","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-07-09T08:16:51Z","receivedAt":"2010-07-09T08:16:51Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Blair Zajac venit, vidit, dixit 09.07.2010 02:42:\n> On 07/08/2010 01:17 AM, Daniel Shahaf wrote:\n>> @Bert: could you please trim quoted patches to only the relevant parts?\n>> Scrolling is tedious when I don't have have line folding available...\n> \n> +1 on this, in Thunderbird, it took a while to scan through the whole \n> email to see the comments.\n\n<plug>\nThat is what the QuoteCollapse extension to Thunderbird was invented for. ;)\n</plug>\n\nIn fact, on the git list we tend to trim as little as possible.\n\nMichael\n"},{"id":"145208","messageId":"AANLkTinS2jd0HPn5I6jI4s_Wo-hIqJhNhce9DWSmOrSH@mail.gmail.com","threadId":"24333","inReplyTo":"4C36DAF3.7090208@drmicha.warpmail.net","subject":"Re: [PATCH] Add svnrdump","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-07-09T12:40:06Z","receivedAt":"2010-07-09T12:40:06Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Fri, Jul 9, 2010 at 03:16, Michael J Gruber <git@drmicha.warpmail.net> wrote:\n> In fact, on the git list we tend to trim as little as possible.\n\nHuh? Quite the opposite I thought...\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"145217","messageId":"20100709134228.GB12315@debian","threadId":"24333","inReplyTo":"002d01cb1e7f$e0ff03c0$a2fd0b40$@nl","subject":"Re: [PATCH] Add svnrdump","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-07-09T13:42:28Z","receivedAt":"2010-07-09T13:42:28Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Bert,\n\nThank you for the review.\n\nBert Huijben writes:\n> > +svn_error_t *open_root(void *edit_baton,\n> > +                       svn_revnum_t base_revision,\n> > +                       apr_pool_t *pool,\n> > +                       void **root_baton)\n> \n> Static and the return type on its own line.\n\nFixed. Sorry about the sloppy error.\n\n> This looks like more than 80 characters to me.\n\nI didn't realize that it was a strict requirement. Fixed now.\n\n> > +  if (pb && ARE_VALID_COPY_ARGS(pb->cmp_path, pb->cmp_rev)) {\n> > +    APR_ARRAY_PUSH(compose_path, const char *) = pb->cmp_path;\n> > +    APR_ARRAY_PUSH(compose_path, const char *) =\n> > svn_dirent_basename(path, pool);\n>\n> Assuming that the path doesn't start with a '/' here, this should be\n> svn_relent_basename() to avoid platform specific path rules.\n\nWhere is svn_dirent_basename defined? I can't seem to find it in the\ncodebase at all.\n\n> > +  hb->temp_filepath = apr_psprintf(eb->pool, \"%s/svn-fe-XXXXXX\",\n> > tempdir);\n> \n> Why store this path in the editor pool? Do you really need this XXXX path to\n> live that long?\n\nExcellent catch! :) Fixed now.\n\n> > +svn_error_t *\n> > +get_dump_editor(const svn_delta_editor_t **editor,\n> > +                void **edit_baton,\n> > +                svn_revnum_t to_rev,\n> > +                apr_pool_t *pool);\n> \n> These structs and this function don't follow our naming guidelines for\n> libraries. But these functions are no reusable library (yet).\n\nRight. Is it alright then? Can I re-submit the patch now? (Also fixed\na couple of things Daniel pointed out).\n\n-- Ram\n"},{"id":"145218","messageId":"20100709134318.GC12315@debian","threadId":"24333","inReplyTo":"alpine.561.2.00.1007081113210.3936@daniel2.local","subject":"Re: [PATCH] Add svnrdump","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-07-09T13:43:18Z","receivedAt":"2010-07-09T13:43:18Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Daniel,\n\nDaniel Shahaf writes:\n> > > +  /* Use a temporary file to measure the text-content-length */\n> > > +  apr_err = apr_temp_dir_get(&tempdir, hb->pool);\n> \n> svn_io_temp_dir()\n\nFixed.\n\n> > > +  if (apr_err != APR_SUCCESS)\n> > > +    SVN_ERR(svn_error_wrap_apr(apr_err, NULL));\n> > > +\n> > > +  hb->temp_filepath = apr_psprintf(eb->pool, \"%s/svn-fe-XXXXXX\",\n> > > tempdir);\n> > \n> \n> os.path.join()\n> \n> Err, I mean, svn_dirent_join().\n\nFixed. Thanks :)\n\n-- Ram\n"},{"id":"145219","messageId":"20100709134600.GD12315@debian","threadId":"24333","inReplyTo":"002d01cb1e7f$e0ff03c0$a2fd0b40$@nl","subject":"Re: [PATCH] Add svnrdump","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-07-09T13:46:00Z","receivedAt":"2010-07-09T13:46:00Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nBert Huijben writes:\n> > +  /* Cleanup */\n> > +  SVN_ERR(svn_io_file_close(hb->temp_file, hb->pool));\n> > +  SVN_ERR(svn_stream_close(hb->temp_filestream));\n> \n> The standard handler already closes the stream for you and if you don't\n> disown the file on mapping, this also closes the file.\n> \n> > +  svn_pool_destroy(hb->pool);\n> \n> And as you clear the pool that contains the file and stream here, closing\n> yourself is not necessary.\n\nI realize this, but I closed the stream anyway to make debugging\neasier. The pool is only destroyed much later. Do you think this is\nbad policy?\n\n-- Ram\n"},{"id":"145221","messageId":"20100709141746.GA20383@debian","threadId":"24333","inReplyTo":"20100709134228.GB12315@debian","subject":"Re: [PATCH] Add svnrdump","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-07-09T14:17:46Z","receivedAt":"2010-07-09T14:17:46Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nRamkumar Ramachandra writes:\n> Where is svn_dirent_basename defined? I can't seem to find it in the\n> codebase at all.\n\nnp, I found it. It's svn_relpath_basename.\n\n-- Ram\n"},{"id":"145230","messageId":"7vfwzsmwe7.fsf@alter.siamese.dyndns.org","threadId":"24333","inReplyTo":"4C36DAF3.7090208@drmicha.warpmail.net","subject":"Re: [PATCH] Add svnrdump","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-09T16:51:12Z","receivedAt":"2010-07-09T16:51:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Blair Zajac venit, vidit, dixit 09.07.2010 02:42:\n>> On 07/08/2010 01:17 AM, Daniel Shahaf wrote:\n>>> @Bert: could you please trim quoted patches to only the relevant parts?\n>>> Scrolling is tedious when I don't have have line folding available...\n>> \n>> +1 on this, in Thunderbird, it took a while to scan through the whole \n>> email to see the comments.\n>\n> <plug>\n> That is what the QuoteCollapse extension to Thunderbird was invented for. ;)\n> </plug>\n>\n> In fact, on the git list we tend to trim as little as possible.\n\nWhat???  Perhaps we are on different git lists?\n"}]}