[PATCH 02/13] Add skeleton SVN client and Makefile
From: Ramkumar Ramachandra <artagnon_at_gmail.com>
Date: Wed, 7 Jul 2010 02:14:42 +0200
Add a basic SVN command-line client along with a Makefile that does
Signed-off-by: Ramkumar Ramachandra <artagnon_at_gmail.com>
---
Makefile | 8 +++++++
svndumpr.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 0 deletions(-)
create mode 100644 Makefile
create mode 100644 svndumpr.c
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a6022f7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+svndumpr: *.c *.h
+ $(CC) -Wall -Werror -DAPR_POOL_DEBUG -ggdb3 -O0 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+
+svndumpr_bench: *.c *.h
+ $(CC) -O2 -o $@ svndumpr.c -lsvn_client-1 -I. -I/usr/include/subversion-1 -I/usr/include/apr-1.0
+
+clean:
+ $(RM) svndumpr svndumpr_bench
diff --git a/svndumpr.c b/svndumpr.c
new file mode 100644
index 0000000..737c4aa
--- /dev/null
+++ b/svndumpr.c
@@ -0,0 +1,68 @@
+/* Licensed under a two-clause BSD-style license.
+ * See LICENSE for details.
+ */
+
+#include "svn_pools.h"
+#include "svn_cmdline.h"
+#include "svn_client.h"
+#include "svn_ra.h"
+#include "svn_repos.h"
+
+static apr_pool_t *pool = NULL;
+static svn_client_ctx_t *ctx = NULL;
+static svn_ra_session_t *session = NULL;
+
+svn_error_t *populate_context()
+{
+ const char *http_library;
+
+ SVN_ERR(svn_config_get_config(&(ctx->config), NULL, pool));
+
+ http_library = getenv("SVN_HTTP_LIBRARY");
+ if (http_library)
+ svn_config_set(apr_hash_get(ctx->config, "servers", APR_HASH_KEY_STRING),
+ "global", "http-library", http_library);
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *open_connection(const char *url)
+{
+ SVN_ERR(svn_config_ensure (NULL, pool));
+ SVN_ERR(svn_client_create_context (&ctx, pool));
+ SVN_ERR(svn_ra_initialize(pool));
+
+#if defined(WIN32) || defined(__CYGWIN__)
+ if (getenv("SVN_ASP_DOT_NET_HACK"))
+ SVN_ERR(svn_wc_set_adm_dir("_svn", pool));
+#endif
+
+ SVN_ERR(populate_context());
+ SVN_ERR(svn_cmdline_create_auth_baton(&(ctx->auth_baton), TRUE,
+ NULL, NULL, NULL, FALSE,
+ FALSE, NULL, NULL, NULL,
+ pool));
+ SVN_ERR(svn_client_open_ra_session(&session, url, ctx, pool));
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *replay_range(svn_revnum_t start_revision, svn_revnum_t end_revision)
+{
+ return SVN_NO_ERROR;
+}
+
+int main()
+{
+ const char url[] = "http://svn.apache.org/repos/asf";
+ svn_revnum_t start_revision = 1, end_revision = 500;
+ if (svn_cmdline_init ("svndumpr", stderr) != EXIT_SUCCESS)
+ return 1;
+
+ pool = svn_pool_create(NULL);
+
+ SVN_INT_ERR(open_connection(url));
+ SVN_INT_ERR(replay_range(start_revision, end_revision));
+
+ svn_pool_destroy(pool);
+
+ return 0;
+}
--
1.7.1
Received on 2010-07-07 02:14:53 CEST
|
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.