ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/Subversion/Client.cpp
Revision: 712
Committed: 2006-03-25T23:27:01-08:00 (19 years, 2 months ago) by douglas
File size: 2786 byte(s)
Log Message:
This seemed like a useful addition, at least for use with Subversion APIs.

File Contents

# Content
1 // Subversion Client
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include <cxx/standard.hh>
8
9 #include <api/apr/array.hpp>
10
11 #include "Client.hpp"
12
13 namespace api
14 {
15
16 namespace Apr
17 {
18
19 template <>
20 Array<const char *>::Array(_L<cse::String>::ConstIterator begin, _L<cse::String>::ConstIterator end)
21 {
22 _forall (_L<cse::String>::ConstIterator, string, begin, end)
23 Push() = string->NullTerminate();
24 }
25
26 }
27
28 }
29
30 namespace Subversion
31 {
32
33 Client::Client()
34 {
35 CheckError(::svn_client_create_context(&context, pool));
36
37 api::Apr::Array< ::svn_auth_provider_object_t *> providers;
38
39 #ifdef _WIN32
40 ::svn_client_get_windows_simple_provider(&providers.Push(), pool);
41 #endif
42 ::svn_client_get_simple_provider(&providers.Push(), pool);
43 ::svn_client_get_username_provider(&providers.Push(), pool);
44 ::svn_client_get_ssl_server_trust_file_provider(&providers.Push(), pool);
45 ::svn_client_get_ssl_client_cert_file_provider(&providers.Push(), pool);
46 ::svn_client_get_ssl_client_cert_pw_file_provider(&providers.Push(), pool);
47 ::svn_auth_open(&context->auth_baton, providers, pool);
48 }
49
50 cse::String Client::GetProperty(const cse::String &property, const cse::String &target) const
51 {
52 api::Apr::Pool pool;
53 ::apr_hash_t *hash;
54 ::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified };
55
56 CheckError(::svn_client_propget2(&hash, property.NullTerminate(), target.NullTerminate(), &revision, &revision, false, context, pool));
57
58 if (::apr_hash_index_t *index = ::apr_hash_first(pool, hash))
59 {
60 ::svn_string_t *string;
61
62 ::apr_hash_this(index, NULL, NULL, reinterpret_cast<void **>(&string));
63
64 return cse::String(string->data, string->len);
65 }
66 else
67 return cse::EmptyString;
68 }
69
70 _L<Entry> Client::GetEntries(const cse::String &target) const
71 {
72 api::Apr::Pool pool;
73 ::apr_hash_t *hash;
74 ::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified };
75
76 #if (SVN_VER_MAJOR == 1) && (SVN_VER_MINOR == 2)
77 CheckError(::svn_client_ls2(&hash, target.NullTerminate(), &revision, &revision, false, context, pool));
78 #else
79 CheckError(::svn_client_ls3(&hash, NULL, target.NullTerminate(), &revision, &revision, false, context, pool));
80 #endif
81
82 _L<Entry> entries;
83
84 for (::apr_hash_index_t *index(::apr_hash_first(pool, hash)); index; index = apr_hash_next(index))
85 {
86 const char *string;
87 ::apr_ssize_t size;
88 ::svn_dirent_t *entry;
89
90 ::apr_hash_this(index, reinterpret_cast<const void **>(&string), &size, reinterpret_cast<void **>(&entry));
91
92 entries.InsertLast(Entry(cse::String(string, size), entry));
93 }
94
95 return entries;
96 }
97
98 void Client::Update(const _L<cse::String> &paths)
99 {
100 ::svn_opt_revision_t revision = { ::svn_opt_revision_head };
101 api::Apr::Pool pool;
102
103 CheckError(::svn_client_update2(NULL, api::Apr::Array<const char *>(paths.Begin(), paths.End()), &revision, false, true, context, pool));
104 }
105
106 }

Properties

Name Value
svn:eol-style native
svn:keywords Id