Revision: 40678
http://brlcad.svn.sourceforge.net/brlcad/?rev=40678&view=rev
Author: starseeker
Date: 2010-09-24 18:19:36 +0000 (Fri, 24 Sep 2010)
Log Message:
-----------
Add in an svntest executable - will try to pin down the C calls needed to
create, commit to, checkout from, and update a repository.
Modified Paths:
--------------
rt^3/branches/subversion-cmake/CMakeLists.txt
Added Paths:
-----------
rt^3/branches/subversion-cmake/svntest/
rt^3/branches/subversion-cmake/svntest/CMakeLists.txt
rt^3/branches/subversion-cmake/svntest/main.c
Modified: rt^3/branches/subversion-cmake/CMakeLists.txt
===================================================================
--- rt^3/branches/subversion-cmake/CMakeLists.txt 2010-09-24 15:24:58 UTC
(rev 40677)
+++ rt^3/branches/subversion-cmake/CMakeLists.txt 2010-09-24 18:19:36 UTC
(rev 40678)
@@ -166,3 +166,4 @@
ADD_SUBDIRECTORY(svnserve)
ADD_SUBDIRECTORY(svnadmin)
ADD_SUBDIRECTORY(svn)
+ADD_SUBDIRECTORY(svntest)
Added: rt^3/branches/subversion-cmake/svntest/CMakeLists.txt
===================================================================
--- rt^3/branches/subversion-cmake/svntest/CMakeLists.txt
(rev 0)
+++ rt^3/branches/subversion-cmake/svntest/CMakeLists.txt 2010-09-24
18:19:36 UTC (rev 40678)
@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+SET(SVNTEST_SRCS
+ main.c
+)
+
+add_executable(svntest ${SVNTEST_SRCS})
+target_link_libraries(svntest svn_repos)
+install(TARGETS svntest RUNTIME DESTINATION bin)
Property changes on: rt^3/branches/subversion-cmake/svntest/CMakeLists.txt
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: rt^3/branches/subversion-cmake/svntest/main.c
===================================================================
--- rt^3/branches/subversion-cmake/svntest/main.c
(rev 0)
+++ rt^3/branches/subversion-cmake/svntest/main.c 2010-09-24 18:19:36 UTC
(rev 40678)
@@ -0,0 +1,466 @@
+#include <apr_file_io.h>
+#include <apr_signal.h>
+
+#include "svn_pools.h"
+#include "svn_cmdline.h"
+#include "svn_error.h"
+#include "svn_opt.h"
+#include "svn_utf.h"
+#include "svn_subst.h"
+#include "svn_path.h"
+#include "svn_config.h"
+#include "svn_repos.h"
+#include "svn_fs.h"
+#include "svn_version.h"
+#include "svn_props.h"
+#include "svn_time.h"
+#include "svn_user.h"
+
+#include "private/svn_opt_private.h"
+
+#include "svn_private_config.h"
+
+/*** Code. ***/
+
+/* A flag to see if we've been cancelled. */
+static volatile sig_atomic_t cancelled = FALSE;
+
+/* A signal handler to support cancellation. */
+static void
+signal_handler(int signum)
+{
+ apr_signal(signum, SIG_IGN);
+ cancelled = TRUE;
+}
+
+
+/* A helper to set up the cancellation signal handlers. */
+static void
+setup_cancellation_signals(void (*handler)(int signum))
+{
+ apr_signal(SIGINT, handler);
+#ifdef SIGBREAK
+ /* SIGBREAK is a Win32 specific signal generated by ctrl-break. */
+ apr_signal(SIGBREAK, handler);
+#endif
+#ifdef SIGHUP
+ apr_signal(SIGHUP, handler);
+#endif
+#ifdef SIGTERM
+ apr_signal(SIGTERM, handler);
+#endif
+}
+
+
+/* Our cancellation callback. */
+static svn_error_t *
+check_cancel(void *baton)
+{
+ if (cancelled)
+ return svn_error_create(SVN_ERR_CANCELLED, NULL, _("Caught signal"));
+ else
+ return SVN_NO_ERROR;
+}
+
+
+/* Helper to open stdio streams */
+static svn_error_t *
+create_stdio_stream(svn_stream_t **stream,
+ APR_DECLARE(apr_status_t) open_fn(apr_file_t **,
+ apr_pool_t *),
+ apr_pool_t *pool)
+{
+ apr_file_t *stdio_file;
+ apr_status_t apr_err = open_fn(&stdio_file, pool);
+
+ if (apr_err)
+ return svn_error_wrap_apr(apr_err, _("Can't open stdio file"));
+
+ *stream = svn_stream_from_aprfile2(stdio_file, TRUE, pool);
+ return SVN_NO_ERROR;
+}
+
+
+/* Helper to parse local repository path. Try parsing next parameter
+ * of OS as a local path to repository. If successfull *REPOS_PATH
+ * will contain internal style path to the repository.
+ */
+static svn_error_t *
+parse_local_repos_path(apr_getopt_t *os,
+ const char ** repos_path,
+ apr_pool_t *pool)
+{
+ *repos_path = NULL;
+
+ /* Check to see if there is one more parameter. */
+ if (os->ind < os->argc)
+ {
+ const char * path = os->argv[os->ind++];
+ SVN_ERR(svn_utf_cstring_to_utf8(repos_path, path, pool));
+ *repos_path = svn_path_internal_style(*repos_path, pool);
+ }
+
+ if (*repos_path == NULL)
+ {
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("Repository argument required"));
+ }
+ else if (svn_path_is_url(*repos_path))
+ {
+ return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
+ _("'%s' is an URL when it should be a path"),
+ *repos_path);
+ }
+
+ return SVN_NO_ERROR;
+}
+
+
+/* Custom filesystem warning function. */
+static void
+warning_func(void *baton,
+ svn_error_t *err)
+{
+ if (! err)
+ return;
+ svn_handle_error2(err, stderr, FALSE, "svnadmin: ");
+}
+
+
+/* Helper to open a repository and set a warning func (so we don't
+ * SEGFAULT when libsvn_fs's default handler gets run). */
+static svn_error_t *
+open_repos(svn_repos_t **repos,
+ const char *path,
+ apr_pool_t *pool)
+{
+ SVN_ERR(svn_repos_open(repos, path, pool));
+ svn_fs_set_warning_func(svn_repos_fs(*repos), warning_func, NULL);
+ return SVN_NO_ERROR;
+}
+
+
+/* Version compatibility check */
+static svn_error_t *
+check_lib_versions(void)
+{
+ static const svn_version_checklist_t checklist[] =
+ {
+ { "svn_subr", svn_subr_version },
+ { "svn_repos", svn_repos_version },
+ { "svn_fs", svn_fs_version },
+ { "svn_delta", svn_delta_version },
+ { NULL, NULL }
+ };
+
+ SVN_VERSION_DEFINE(my_version);
+ return svn_ver_check_list(&my_version, checklist);
+}
+
+
+
+/** Subcommands. **/
+
+static svn_opt_subcommand_t
+ subcommand_create;
+
+enum
+ {
+ svnadmin__version = SVN_OPT_FIRST_LONGOPT_ID,
+ svnadmin__incremental,
+ svnadmin__deltas,
+ svnadmin__ignore_uuid,
+ svnadmin__force_uuid,
+ svnadmin__fs_type,
+ svnadmin__parent_dir,
+ svnadmin__bdb_txn_nosync,
+ svnadmin__bdb_log_keep,
+ svnadmin__config_dir,
+ svnadmin__bypass_hooks,
+ svnadmin__use_pre_commit_hook,
+ svnadmin__use_post_commit_hook,
+ svnadmin__use_pre_revprop_change_hook,
+ svnadmin__use_post_revprop_change_hook,
+ svnadmin__clean_logs,
+ svnadmin__wait,
+ svnadmin__pre_1_4_compatible,
+ svnadmin__pre_1_5_compatible,
+ svnadmin__pre_1_6_compatible
+ };
+
+/* Option codes and descriptions.
+ *
+ * The entire list must be terminated with an entry of nulls.
+ */
+static const apr_getopt_option_t options_table[] =
+ {
+ {"help", 'h', 0,
+ N_("show help on a subcommand")},
+
+ {NULL, '?', 0,
+ N_("show help on a subcommand")},
+
+ {"version", svnadmin__version, 0,
+ N_("show program version information")},
+
+ {"revision", 'r', 1,
+ N_("specify revision number ARG (or X:Y range)")},
+
+ {"incremental", svnadmin__incremental, 0,
+ N_("dump incrementally")},
+
+ {"deltas", svnadmin__deltas, 0,
+ N_("use deltas in dump output")},
+
+ {"bypass-hooks", svnadmin__bypass_hooks, 0,
+ N_("bypass the repository hook system")},
+
+ {"quiet", 'q', 0,
+ N_("no progress (only errors) to stderr")},
+
+ {"ignore-uuid", svnadmin__ignore_uuid, 0,
+ N_("ignore any repos UUID found in the stream")},
+
+ {"force-uuid", svnadmin__force_uuid, 0,
+ N_("set repos UUID to that found in stream, if any")},
+
+ {"fs-type", svnadmin__fs_type, 1,
+ N_("type of repository: 'fsfs' (default) or 'bdb'")},
+
+ {"parent-dir", svnadmin__parent_dir, 1,
+ N_("load at specified directory in repository")},
+
+ {"bdb-txn-nosync", svnadmin__bdb_txn_nosync, 0,
+ N_("disable fsync at transaction commit [Berkeley DB]")},
+
+ {"bdb-log-keep", svnadmin__bdb_log_keep, 0,
+ N_("disable automatic log file removal [Berkeley DB]")},
+
+ {"config-dir", svnadmin__config_dir, 1,
+ N_("read user configuration files from directory ARG")},
+
+ {"clean-logs", svnadmin__clean_logs, 0,
+ N_("remove redundant Berkeley DB log files\n"
+ " from source repository [Berkeley DB]")},
+
+ {"use-pre-commit-hook", svnadmin__use_pre_commit_hook, 0,
+ N_("call pre-commit hook before committing revisions")},
+
+ {"use-post-commit-hook", svnadmin__use_post_commit_hook, 0,
+ N_("call post-commit hook after committing revisions")},
+
+ {"use-pre-revprop-change-hook", svnadmin__use_pre_revprop_change_hook, 0,
+ N_("call hook before changing revision property")},
+
+ {"use-post-revprop-change-hook", svnadmin__use_post_revprop_change_hook, 0,
+ N_("call hook after changing revision property")},
+
+ {"wait", svnadmin__wait, 0,
+ N_("wait instead of exit if the repository is in\n"
+ " use by another process")},
+
+ {"pre-1.4-compatible", svnadmin__pre_1_4_compatible, 0,
+ N_("use format compatible with Subversion versions\n"
+ " earlier than 1.4")},
+
+ {"pre-1.5-compatible", svnadmin__pre_1_5_compatible, 0,
+ N_("use format compatible with Subversion versions\n"
+ " earlier than 1.5")},
+
+ {"pre-1.6-compatible", svnadmin__pre_1_6_compatible, 0,
+ N_("use format compatible with Subversion versions\n"
+ " earlier than 1.6")},
+
+ {NULL}
+ };
+
+
+/* Array of available subcommands.
+ * The entire list must be terminated with an entry of nulls.
+ */
+static const svn_opt_subcommand_desc2_t cmd_table[] =
+{
+ {"create", subcommand_create, {0}, N_
+ ("usage: svnadmin create REPOS_PATH\n\n"
+ "Create a new, empty repository at REPOS_PATH.\n"),
+ {svnadmin__bdb_txn_nosync, svnadmin__bdb_log_keep,
+ svnadmin__config_dir, svnadmin__fs_type, svnadmin__pre_1_4_compatible,
+ svnadmin__pre_1_5_compatible, svnadmin__pre_1_6_compatible } },
+
+ { NULL, NULL, {0}, NULL, {0} }
+};
+
+
+/* Baton for passing option/argument state to a subcommand function. */
+struct svnadmin_opt_state
+{
+ const char *repository_path;
+ const char *new_repository_path; /* hotcopy dest. path */
+ const char *fs_type; /* --fs-type */
+ svn_boolean_t pre_1_4_compatible; /* --pre-1.4-compatible */
+ svn_boolean_t pre_1_5_compatible; /* --pre-1.5-compatible */
+ svn_boolean_t pre_1_6_compatible; /* --pre-1.6-compatible */
+ svn_opt_revision_t start_revision, end_revision; /* -r X[:Y] */
+ svn_boolean_t help; /* --help or -? */
+ svn_boolean_t version; /* --version */
+ svn_boolean_t incremental; /* --incremental */
+ svn_boolean_t use_deltas; /* --deltas */
+ svn_boolean_t use_pre_commit_hook; /* --use-pre-commit-hook */
+ svn_boolean_t use_post_commit_hook; /* --use-post-commit-hook
*/
+ svn_boolean_t use_pre_revprop_change_hook; /*
--use-pre-revprop-change-hook */
+ svn_boolean_t use_post_revprop_change_hook; /*
--use-post-revprop-change-hook */
+ svn_boolean_t quiet; /* --quiet */
+ svn_boolean_t bdb_txn_nosync; /* --bdb-txn-nosync */
+ svn_boolean_t bdb_log_keep; /* --bdb-log-keep */
+ svn_boolean_t clean_logs; /* --clean-logs */
+ svn_boolean_t bypass_hooks; /* --bypass-hooks */
+ svn_boolean_t wait; /* --wait */
+ enum svn_repos_load_uuid uuid_action; /* --ignore-uuid,
+ --force-uuid */
+ const char *parent_dir;
+
+ const char *config_dir; /* Overriding Configuration Directory */
+};
+
+
+/* This implements `svn_opt_subcommand_t'. */
+static svn_error_t *
+subcommand_create(apr_getopt_t *os, void *baton, apr_pool_t *pool)
+{
+ struct svnadmin_opt_state *opt_state = baton;
+ svn_repos_t *repos;
+ apr_hash_t *config;
+ apr_hash_t *fs_config = apr_hash_make(pool);
+
+ apr_hash_set(fs_config, SVN_FS_CONFIG_BDB_TXN_NOSYNC,
+ APR_HASH_KEY_STRING,
+ (opt_state->bdb_txn_nosync ? "1" : "0"));
+
+ apr_hash_set(fs_config, SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE,
+ APR_HASH_KEY_STRING,
+ (opt_state->bdb_log_keep ? "0" : "1"));
+
+ if (opt_state->fs_type)
+ apr_hash_set(fs_config, SVN_FS_CONFIG_FS_TYPE,
+ APR_HASH_KEY_STRING,
+ opt_state->fs_type);
+
+ if (opt_state->pre_1_4_compatible)
+ apr_hash_set(fs_config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE,
+ APR_HASH_KEY_STRING,
+ "1");
+
+ if (opt_state->pre_1_5_compatible)
+ apr_hash_set(fs_config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE,
+ APR_HASH_KEY_STRING,
+ "1");
+
+ if (opt_state->pre_1_6_compatible)
+ apr_hash_set(fs_config, SVN_FS_CONFIG_PRE_1_6_COMPATIBLE,
+ APR_HASH_KEY_STRING,
+ "1");
+
+ SVN_ERR(svn_config_get_config(&config, opt_state->config_dir, pool));
+ SVN_ERR(svn_repos_create(&repos, opt_state->repository_path,
+ NULL, NULL,
+ config, fs_config, pool));
+ svn_fs_set_warning_func(svn_repos_fs(repos), warning_func, NULL);
+ return SVN_NO_ERROR;
+}
+
+
+
+/** Main. **/
+
+int
+main(int argc, const char *argv[])
+{
+ svn_error_t *err;
+ apr_status_t apr_err;
+ apr_allocator_t *allocator;
+ apr_pool_t *pool;
+
+ const svn_opt_subcommand_desc2_t *subcommand = NULL;
+ struct svnadmin_opt_state opt_state;
+ apr_getopt_t *os;
+ int opt_id;
+ apr_array_header_t *received_opts;
+ int i;
+
+ /* Initialize the app. */
+ if (svn_cmdline_init("svntest", stderr) != EXIT_SUCCESS)
+ return EXIT_FAILURE;
+
+ /* Create our top-level pool. Use a separate mutexless allocator,
+ * given this application is single threaded.
+ */
+ if (apr_allocator_create(&allocator))
+ return EXIT_FAILURE;
+
+ apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
+
+ pool = svn_pool_create_ex(NULL, allocator);
+ apr_allocator_owner_set(allocator, pool);
+
+ received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
+
+ /* Check library versions */
+ err = check_lib_versions();
+ if (err)
+ return svn_cmdline_handle_exit_error(err, pool, "svnadmin: ");
+
+ /* Initialize the FS library. */
+ err = svn_fs_initialize(pool);
+ if (err)
+ return svn_cmdline_handle_exit_error(err, pool, "svnadmin: ");
+
+ /* Initialize opt_state. */
+ memset(&opt_state, 0, sizeof(opt_state));
+ opt_state.start_revision.kind = svn_opt_revision_unspecified;
+ opt_state.end_revision.kind = svn_opt_revision_unspecified;
+
+ /* Set up our cancellation support. */
+ setup_cancellation_signals(signal_handler);
+
+#ifdef SIGPIPE
+ /* Disable SIGPIPE generation for the platforms that have it. */
+ apr_signal(SIGPIPE, SIG_IGN);
+#endif
+
+#ifdef SIGXFSZ
+ /* Disable SIGXFSZ generation for the platforms that have it, otherwise
+ * working with large files when compiled against an APR that doesn't have
+ * large file support will crash the program, which is uncool. */
+ apr_signal(SIGXFSZ, SIG_IGN);
+#endif
+
+ /* Run the subcommand. */
+ err = (*subcommand->cmd_func)(os, &opt_state, pool);
+ if (err)
+ {
+ /* For argument-related problems, suggest using the 'help'
+ subcommand. */
+ if (err->apr_err == SVN_ERR_CL_INSUFFICIENT_ARGS
+ || err->apr_err == SVN_ERR_CL_ARG_PARSING_ERROR)
+ {
+ err = svn_error_quick_wrap(err,
+ _("Try 'svnadmin help' for more info"));
+ }
+ return svn_cmdline_handle_exit_error(err, pool, "svnadmin: ");
+ }
+ else
+ {
+ svn_pool_destroy(pool);
+ /* Ensure that everything is written to stdout, so the user will
+ see any print errors. */
+ err = svn_cmdline_fflush(stdout);
+ if (err)
+ {
+ svn_handle_error2(err, stderr, FALSE, "svnadmin: ");
+ svn_error_clear(err);
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
+ }
+}
+
Property changes on: rt^3/branches/subversion-cmake/svntest/main.c
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits