[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] fix for issue 765: move project from one repo to another

From: Florin Iucha <florin_at_iucha.net>
Date: 2003-03-21 17:28:31 CET

Hello,

Included is a patch for issue 765.

Log entry:

/include/svn_repos.h
   (svn_repos_load_fs) add the parent_dir parameter
   
/libsvn_repos/load.c
   (struct parse_baton) add the parent_dir parameter
   (make_node_baton) prepend parent_dir to the node path read from
      dump file
   (svn_repos_get_fs_build_parser) add the parent_dir parameter
      put the parameter in the parse_baton structure
   (svn_repos_load_fs) add the parent_dir parameter
      pass the parent_dir to svn_repos_get_fs_build_parser
   
/svnadmin/main.c
   (subcommand_load) pass the parent_dir parameter to svn_repos_load_fs
   (main) add the --parent-dir to the option list for "load"

Patch:

Index: subversion/svnadmin/main.c
===================================================================
--- subversion/svnadmin/main.c (revision 5418)
+++ subversion/svnadmin/main.c (working copy)
@@ -84,6 +84,7 @@
     svnadmin__in_repos_template,
     svnadmin__ignore_uuid,
     svnadmin__force_uuid,
+ svnadmin__parent_dir,
     svnadmin__bdb_txn_nosync
   };
 
@@ -126,6 +127,9 @@
     {"force-uuid", svnadmin__force_uuid, 0,
      "set repos UUID to that found in stream, if any."},
 
+ {"parent-dir", svnadmin__parent_dir, 1,
+ "Select the parent directory of the imported tree; the default is root."},
+
     {SVN_FS_CONFIG_BDB_TXN_NOSYNC, svnadmin__bdb_txn_nosync, 0,
      "disable fsync at database transaction commit [Berkeley DB]."},
 
@@ -170,7 +174,7 @@
      "new revisions into the repository's filesystem. If the repository\n"
      "was previously empty, its UUID will, by default, be changed to the\n"
      "one specified in the stream. Progress feedback is sent to stdout.\n",
- {svnadmin__ignore_uuid, svnadmin__force_uuid} },
+ {svnadmin__ignore_uuid, svnadmin__force_uuid, svnadmin__parent_dir} },
 
     {"lscr", subcommand_lscr, {0},
      "usage: svnadmin lscr REPOS_PATH PATH [--copies]\n\n"
@@ -226,6 +230,7 @@
                                                        --force-uuid */
   const char *on_disk;
   const char *in_repos;
+ const char *parent_dir;
 };
 
 /* This implements `svn_opt_subcommand_t'. */
@@ -364,7 +369,7 @@
   struct svnadmin_opt_state *opt_state = baton;
   svn_repos_t *repos;
   svn_stream_t *stdin_stream, *stdout_stream;
-
+
   SVN_ERR (svn_repos_open (&repos, opt_state->repository_path, pool));
   
   /* Read the stream from STDIN. Users can redirect a file. */
@@ -376,7 +381,8 @@
                                 apr_file_open_stdout, pool));
   
   SVN_ERR (svn_repos_load_fs (repos, stdin_stream, stdout_stream,
- opt_state->uuid_action, pool));
+ opt_state->uuid_action, opt_state->parent_dir,
+ pool));
 
   return SVN_NO_ERROR;
 }
@@ -690,6 +696,16 @@
       case svnadmin__force_uuid:
         opt_state.uuid_action = svn_repos_load_uuid_force;
         break;
+ case svnadmin__parent_dir:
+ err = svn_utf_cstring_to_utf8 (&opt_state.parent_dir, opt_arg,
+ NULL, pool);
+ if (err)
+ {
+ svn_handle_error (err, stderr, FALSE);
+ svn_pool_destroy (pool);
+ return EXIT_FAILURE;
+ }
+ break;
       case svnadmin__bdb_txn_nosync:
         opt_state.bdb_txn_nosync = TRUE;
         break;
Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h (revision 5418)
+++ subversion/include/svn_repos.h (working copy)
@@ -824,6 +824,7 @@
                                 svn_stream_t *dumpstream,
                                 svn_stream_t *feedback_stream,
                                 enum svn_repos_load_uuid uuid_action,
+ const char *parent_dir,
                                 apr_pool_t *pool);
 
 
@@ -954,6 +955,9 @@
  * 'copyfrom' history to exist in the repository when it encounters
  * nodes that are added-with-history.
  *
+ * If @a parent_dir is not null, then the parser will reparent all the
+ * loaded nodes, from root to parent_dir.
+ *
  * Print all parsing feedback to @a outstream (if non-@c NULL).
  *
  */
@@ -964,6 +968,7 @@
                                svn_boolean_t use_history,
                                enum svn_repos_load_uuid uuid_action,
                                svn_stream_t *outstream,
+ const char *parent_dir,
                                apr_pool_t *pool);
 /** @} */
 
Index: subversion/libsvn_repos/load.c
===================================================================
--- subversion/libsvn_repos/load.c (revision 5418)
+++ subversion/libsvn_repos/load.c (working copy)
@@ -40,6 +40,7 @@
   svn_boolean_t use_history;
   svn_stream_t *outstream;
   enum svn_repos_load_uuid uuid_action;
+ const char* parent_dir;
 };
 
 struct revision_baton
@@ -560,7 +561,18 @@
   /* Then add info from the headers. */
   if ((val = apr_hash_get (headers, SVN_REPOS_DUMPFILE_NODE_PATH,
                            APR_HASH_KEY_STRING)))
- nb->path = apr_pstrdup (pool, val);
+ {
+ /* Append the rb->pb->parent_dir if necessary. */
+ if (rb->pb->parent_dir)
+ {
+ /* Successive / are converted to a single / so it is safe
+ * here to always add a / between the parent and the child.
+ */
+ nb->path = apr_pstrcat (pool, rb->pb->parent_dir, "/", val, 0);
+ }
+ else
+ nb->path = apr_pstrdup (pool, val);
+ }
 
   if ((val = apr_hash_get (headers, SVN_REPOS_DUMPFILE_NODE_KIND,
                            APR_HASH_KEY_STRING)))
@@ -921,6 +933,7 @@
                                svn_boolean_t use_history,
                                enum svn_repos_load_uuid uuid_action,
                                svn_stream_t *outstream,
+ const char* parent_dir,
                                apr_pool_t *pool)
 {
   svn_repos_parser_fns_t *parser = apr_pcalloc (pool, sizeof(*parser));
@@ -940,6 +953,7 @@
   pb->use_history = use_history;
   pb->outstream = outstream;
   pb->uuid_action = uuid_action;
+ pb->parent_dir = parent_dir;
 
   *parser_callbacks = parser;
   *parse_baton = pb;
@@ -953,6 +967,7 @@
                    svn_stream_t *dumpstream,
                    svn_stream_t *feedback_stream,
                    enum svn_repos_load_uuid uuid_action,
+ const char *parent_dir,
                    apr_pool_t *pool)
 {
   const svn_repos_parser_fns_t *parser;
@@ -965,6 +980,7 @@
                                           TRUE, /* look for copyfrom revs */
                                           uuid_action,
                                           feedback_stream,
+ parent_dir,
                                           pool));
 
   SVN_ERR (svn_repos_parse_dumpstream (dumpstream, parser, parse_baton, pool));

-- 
"NT is to UNIX what a doughnut is to a particle accelerator."

  • application/pgp-signature attachment: stored
Received on Fri Mar 21 17:29:14 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.