ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/Subversion/Client.cpp
Revision: 1016
Committed: 2008-05-25T07:22:49-07:00 (17 years ago) by douglas
File size: 2933 byte(s)
Log Message:
Grr gcc 4!

File Contents

# User Rev Content
1 douglas 697 // Subversion Client
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include <cxx/standard.hh>
8    
9 douglas 712 #include <api/apr/array.hpp>
10 douglas 704
11 douglas 697 #include "Client.hpp"
12    
13 douglas 1016 /*namespace api
14 douglas 712 {
15    
16     namespace Apr
17     {
18    
19     template <>
20 douglas 1016 inline Array<const char *>::Array(_L<cse::String>::ConstIterator begin, _L<cse::String>::ConstIterator end)
21 douglas 712 {
22     _forall (_L<cse::String>::ConstIterator, string, begin, end)
23     Push() = string->NullTerminate();
24     }
25    
26     }
27    
28 douglas 1016 }*/
29 douglas 712
30 douglas 697 namespace Subversion
31     {
32    
33     Client::Client()
34     {
35 douglas 698 CheckError(::svn_client_create_context(&context, pool));
36 douglas 704
37 douglas 712 api::Apr::Array< ::svn_auth_provider_object_t *> providers;
38 douglas 704
39     #ifdef _WIN32
40 douglas 712 ::svn_client_get_windows_simple_provider(&providers.Push(), pool);
41 douglas 704 #endif
42 douglas 712 ::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 douglas 704 ::svn_auth_open(&context->auth_baton, providers, pool);
48 douglas 697 }
49    
50 douglas 701 cse::String Client::GetProperty(const cse::String &property, const cse::String &target) const
51 douglas 697 {
52 douglas 704 api::Apr::Pool pool;
53 douglas 700 ::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 douglas 697 }
69    
70 douglas 701 _L<Entry> Client::GetEntries(const cse::String &target) const
71 douglas 697 {
72 douglas 704 api::Apr::Pool pool;
73 douglas 701 ::apr_hash_t *hash;
74     ::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified };
75 douglas 697
76 douglas 703 #if (SVN_VER_MAJOR == 1) && (SVN_VER_MINOR == 2)
77 douglas 701 CheckError(::svn_client_ls2(&hash, target.NullTerminate(), &revision, &revision, false, context, pool));
78 douglas 703 #else
79 douglas 701 CheckError(::svn_client_ls3(&hash, NULL, target.NullTerminate(), &revision, &revision, false, context, pool));
80 douglas 703 #endif
81 douglas 697
82 douglas 701 _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 douglas 697 }
97    
98 douglas 712 void Client::Update(const _L<cse::String> &paths)
99     {
100     ::svn_opt_revision_t revision = { ::svn_opt_revision_head };
101 douglas 1016 api::Apr::Array<const char *> array;
102    
103     _foreach(const _L<cse::String>, path, paths)
104     array.Push() = path->NullTerminate();
105    
106 douglas 712 api::Apr::Pool pool;
107    
108 douglas 1016 CheckError(::svn_client_update2(NULL, /*api::Apr::Array<const char *>(paths.Begin(), paths.End())*/ array, &revision, false, true, context, pool));
109 douglas 697 }
110 douglas 712
111     }

Properties

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