1 |
douglas |
697 |
// Subversion Client |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include <cxx/standard.hh> |
8 |
|
|
|
9 |
|
|
#include "Client.hpp" |
10 |
|
|
|
11 |
|
|
namespace Subversion |
12 |
|
|
{ |
13 |
|
|
|
14 |
|
|
Client::Client() |
15 |
|
|
{ |
16 |
douglas |
698 |
CheckError(::svn_client_create_context(&context, pool)); |
17 |
douglas |
697 |
} |
18 |
|
|
|
19 |
douglas |
701 |
cse::String Client::GetProperty(const cse::String &property, const cse::String &target) const |
20 |
douglas |
697 |
{ |
21 |
douglas |
700 |
::apr_hash_t *hash; |
22 |
|
|
::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified }; |
23 |
|
|
|
24 |
|
|
CheckError(::svn_client_propget2(&hash, property.NullTerminate(), target.NullTerminate(), &revision, &revision, false, context, pool)); |
25 |
|
|
|
26 |
|
|
if (::apr_hash_index_t *index = ::apr_hash_first(pool, hash)) |
27 |
|
|
{ |
28 |
|
|
::svn_string_t *string; |
29 |
|
|
|
30 |
|
|
::apr_hash_this(index, NULL, NULL, reinterpret_cast<void **>(&string)); |
31 |
|
|
|
32 |
|
|
return cse::String(string->data, string->len); |
33 |
|
|
} |
34 |
|
|
else |
35 |
|
|
return cse::EmptyString; |
36 |
douglas |
697 |
} |
37 |
|
|
|
38 |
douglas |
701 |
_L<Entry> Client::GetEntries(const cse::String &target) const |
39 |
douglas |
697 |
{ |
40 |
douglas |
701 |
::apr_hash_t *hash; |
41 |
|
|
::svn_opt_revision_t revision = { ::svn_opt_revision_unspecified }; |
42 |
douglas |
697 |
|
43 |
douglas |
703 |
#if (SVN_VER_MAJOR == 1) && (SVN_VER_MINOR == 2) |
44 |
douglas |
701 |
CheckError(::svn_client_ls2(&hash, target.NullTerminate(), &revision, &revision, false, context, pool)); |
45 |
douglas |
703 |
#else |
46 |
douglas |
701 |
CheckError(::svn_client_ls3(&hash, NULL, target.NullTerminate(), &revision, &revision, false, context, pool)); |
47 |
douglas |
703 |
#endif |
48 |
douglas |
697 |
|
49 |
douglas |
701 |
_L<Entry> entries; |
50 |
|
|
|
51 |
|
|
for (::apr_hash_index_t *index(::apr_hash_first(pool, hash)); index; index = apr_hash_next(index)) |
52 |
|
|
{ |
53 |
|
|
const char *string; |
54 |
|
|
::apr_ssize_t size; |
55 |
|
|
::svn_dirent_t *entry; |
56 |
|
|
|
57 |
|
|
::apr_hash_this(index, reinterpret_cast<const void **>(&string), &size, reinterpret_cast<void **>(&entry)); |
58 |
|
|
|
59 |
|
|
entries.InsertLast(Entry(cse::String(string, size), entry)); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
return entries; |
63 |
douglas |
697 |
} |
64 |
|
|
|
65 |
|
|
} |