You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/09/17 22:15:04 UTC
svn commit: r998300 - in /subversion/branches/object-model: BRANCH-README
subversion/bindings/c++/Client.cpp subversion/bindings/c++/include/Client.h
subversion/tests/libsvn++/client-test.cpp
Author: hwright
Date: Fri Sep 17 20:15:04 2010
New Revision: 998300
URL: http://svn.apache.org/viewvc?rev=998300&view=rev
Log:
On the object-model branch:
Implement a wrapper for svn_client_cat2() in C++.
* BRANCH-README:
Mark a task complete.
* subversion/bindings/c++/Client.cpp
(Client::Client): Initialize the member pool, and fetch the client context.
(Client::cat): Two new methods.
* subversion/bindings/c++/include/Client.h
(Client::cat): Prototype the cat wrappers.
* subversion/tests/libsvn++/client-test.cpp
(create_greek_repo): New.
(test_cat): New test.
(test_funcs): Run the new test.
Modified:
subversion/branches/object-model/BRANCH-README
subversion/branches/object-model/subversion/bindings/c++/Client.cpp
subversion/branches/object-model/subversion/bindings/c++/include/Client.h
subversion/branches/object-model/subversion/tests/libsvn++/client-test.cpp
Modified: subversion/branches/object-model/BRANCH-README
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/BRANCH-README?rev=998300&r1=998299&r2=998300&view=diff
==============================================================================
--- subversion/branches/object-model/BRANCH-README (original)
+++ subversion/branches/object-model/BRANCH-README Fri Sep 17 20:15:04 2010
@@ -47,7 +47,7 @@ on a branch, without any knowledge of ho
* svn_client_proplist3()
* svn_client_export5()
* svn_client_list2()
- * svn_client_cat2()
+ * svn_client_cat2() [DONE]
* svn_client_add_to_changelist()
* svn_client_remove_from_changelists()
* svn_client_get_changelists()
Modified: subversion/branches/object-model/subversion/bindings/c++/Client.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/Client.cpp?rev=998300&r1=998299&r2=998300&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/Client.cpp (original)
+++ subversion/branches/object-model/subversion/bindings/c++/Client.cpp Fri Sep 17 20:15:04 2010
@@ -23,10 +23,20 @@
*/
#include "Client.h"
+#include "Pool.h"
+#include "Utility.h"
+
+#include "Common.h"
namespace SVN {
Client::Client()
+ : m_pool()
+{
+ svn_error_clear(svn_client_create_context(&m_ctx, m_pool.pool()));
+}
+
+Client::~Client()
{
}
@@ -36,8 +46,22 @@ Client::getVersion()
return Version(svn_client_version());
}
-Client::~Client()
+void
+Client::cat(std::ostream &stream, const std::string &path_or_url)
{
+ cat(stream, path_or_url, Revision::HEAD, Revision::HEAD);
+}
+
+void
+Client::cat(std::ostream &stream, const std::string &path_or_url,
+ const Revision &peg_revision, const Revision &revision)
+{
+ Pool pool;
+ svn_stream_t *out = Private::Utility::ostream_wrapper(stream, pool);
+
+ SVN_CPP_ERR(svn_client_cat2(out, path_or_url.c_str(),
+ peg_revision.revision(),
+ revision.revision(), m_ctx, pool.pool()));
}
}
Modified: subversion/branches/object-model/subversion/bindings/c++/include/Client.h
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/include/Client.h?rev=998300&r1=998299&r2=998300&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/include/Client.h (original)
+++ subversion/branches/object-model/subversion/bindings/c++/include/Client.h Fri Sep 17 20:15:04 2010
@@ -28,24 +28,34 @@
#define CLIENT_H
#include "Version.h"
+#include "Revision.h"
+#include "Pool.h"
#include "svn_client.h"
+#include <ostream>
+
namespace SVN
{
class Client
{
private:
+ Pool m_pool;
+ svn_client_ctx_t *m_ctx;
public:
/** The constructor. */
Client();
- Version getVersion();
-
/** The destructor needs to be public. */
virtual ~Client();
+
+ Version getVersion();
+
+ void cat(std::ostream &stream, const std::string &path_or_url);
+ void cat(std::ostream &stream, const std::string &path_or_url,
+ const Revision &peg_revision, const Revision &revision);
};
}
Modified: subversion/branches/object-model/subversion/tests/libsvn++/client-test.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/tests/libsvn%2B%2B/client-test.cpp?rev=998300&r1=998299&r2=998300&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/tests/libsvn++/client-test.cpp (original)
+++ subversion/branches/object-model/subversion/tests/libsvn++/client-test.cpp Fri Sep 17 20:15:04 2010
@@ -22,12 +22,40 @@
*/
#include "../svn_test.h"
+#include "../svn_test_fs.h"
#include "Client.h"
+#include "Pool.h"
+
+#include <sstream>
+#include <iostream>
using namespace SVN;
static svn_error_t *
+create_greek_repo(svn_repos_t **repos,
+ const char *repos_name,
+ const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+ svn_revnum_t committed_rev;
+
+ SVN_ERR(svn_test__create_repos(repos, repos_name, opts, pool));
+ fs = svn_repos_fs(*repos);
+
+ /* Prepare a txn to receive the greek tree. */
+ SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, 0, pool));
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+ SVN_ERR(svn_test__create_greek_tree(txn_root, pool));
+ SVN_ERR(svn_repos_fs_commit_txn(NULL, *repos, &committed_rev, txn, pool));
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
test_get_version(apr_pool_t *p)
{
Client client;
@@ -38,6 +66,30 @@ test_get_version(apr_pool_t *p)
return SVN_NO_ERROR;
}
+static svn_error_t *
+test_cat(const svn_test_opts_t *opts,
+ apr_pool_t *p)
+{
+ Pool pool;
+ svn_repos_t *repos;
+ const char *repos_url;
+ std::string iota_url;
+
+ SVN_ERR(create_greek_repo(&repos, "test-cpp-client-repos", opts,
+ pool.pool()));
+ SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, "test-cpp-client-repos",
+ pool.pool()));
+ iota_url = svn_path_url_add_component2(repos_url, "iota", pool.pool());
+
+ std::ostringstream stream;
+ Client client;
+
+ client.cat(stream, iota_url);
+ SVN_TEST_ASSERT(stream.str() == "This is the file 'iota'.\n");
+
+ return SVN_NO_ERROR;
+}
+
/* The test table. */
struct svn_test_descriptor_t test_funcs[] =
@@ -45,5 +97,7 @@ struct svn_test_descriptor_t test_funcs[
SVN_TEST_NULL,
SVN_TEST_PASS2(test_get_version,
"test get client version"),
+ SVN_TEST_OPTS_PASS(test_cat,
+ "test client cat"),
SVN_TEST_NULL
};