File indexing completed on 2024-05-12 17:16:21
0001 /* 0002 * Port for usage with qt-framework and development for kdesvn 0003 * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de) 0004 * http://kdesvn.alwins-world.de 0005 */ 0006 /* 0007 * ==================================================================== 0008 * Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved. 0009 * dev@rapidsvn.tigris.org 0010 * 0011 * This library is free software; you can redistribute it and/or 0012 * modify it under the terms of the GNU Lesser General Public 0013 * License as published by the Free Software Foundation; either 0014 * version 2.1 of the License, or (at your option) any later version. 0015 * 0016 * This library is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 * Lesser General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Lesser General Public 0022 * License along with this library (in the file LGPL.txt); if not, 0023 * write to the Free Software Foundation, Inc., 51 Franklin St, 0024 * Fifth Floor, Boston, MA 02110-1301 USA 0025 * 0026 * This software consists of voluntary contributions made by many 0027 * individuals. For exact contribution history, see the revision 0028 * history and logs, available at http://rapidsvn.tigris.org/. 0029 * ==================================================================== 0030 */ 0031 0032 // svncpp 0033 #include "client_impl.h" 0034 #include "svnqt_defines.h" 0035 #include "exception.h" 0036 #include "helper.h" 0037 0038 #include <svn_opt.h> 0039 #include <svn_ra.h> 0040 0041 namespace svn 0042 { 0043 0044 Client_impl::Client_impl(const ContextP &context) 0045 : Client() 0046 { 0047 setContext(context); 0048 } 0049 0050 Client_impl::~Client_impl() 0051 { 0052 } 0053 0054 const ContextP 0055 Client_impl::getContext() const 0056 { 0057 return m_context; 0058 } 0059 0060 void 0061 Client_impl::setContext(const ContextP &context) 0062 { 0063 m_context = context; 0064 } 0065 0066 0067 void 0068 Client_impl::url2Revision(const QString &revstring, 0069 Revision &start, Revision &end) 0070 { 0071 Pool pool; 0072 int n = svn_opt_parse_revision(start, end, revstring.toUtf8(), pool); 0073 0074 if (n < 0) { 0075 start = Revision::UNDEFINED; 0076 end = Revision::UNDEFINED; 0077 } 0078 } 0079 0080 void Client_impl::url2Revision(const QString &revstring, Revision &start) 0081 { 0082 if (revstring == QLatin1String("WORKING")) { 0083 start = Revision::WORKING; 0084 } else if (revstring == QLatin1String("BASE")) { 0085 start = Revision::BASE; 0086 } else if (revstring == QLatin1String("START")) { 0087 start = Revision::START; 0088 } else { 0089 Revision end; 0090 url2Revision(revstring, start, end); 0091 } 0092 } 0093 0094 apr_hash_t *Client_impl::map2hash(const PropertiesMap &aMap, const Pool &pool) 0095 { 0096 return svn::internal::Map2Hash(aMap).hash(pool); 0097 } 0098 0099 bool Client_impl::RepoHasCapability(const Path &repository, Capability capability) 0100 { 0101 svn_error_t *error = nullptr; 0102 Pool pool; 0103 0104 svn_ra_session_t *session = nullptr; 0105 // todo svn 1.8: svn_client_open_ra_session2 0106 error = svn_client_open_ra_session(&session, 0107 repository.cstr(), 0108 *m_context, 0109 pool); 0110 if (error != nullptr) { 0111 throw ClientException(error); 0112 } 0113 if (!session) { 0114 return false; 0115 } 0116 const char *capa = nullptr; 0117 switch (capability) { 0118 case CapabilityMergeinfo: 0119 capa = SVN_RA_CAPABILITY_MERGEINFO; 0120 break; 0121 case CapabilityDepth: 0122 capa = SVN_RA_CAPABILITY_DEPTH; 0123 break; 0124 case CapabilityCommitRevProps: 0125 capa = SVN_RA_CAPABILITY_COMMIT_REVPROPS; 0126 break; 0127 case CapabilityLogRevProps: 0128 capa = SVN_RA_CAPABILITY_LOG_REVPROPS; 0129 break; 0130 default: 0131 return false; 0132 } 0133 svn_boolean_t has = 0; 0134 error = svn_ra_has_capability(session, &has, capa, pool); 0135 if (error != nullptr) { 0136 throw ClientException(error); 0137 } 0138 return has; 0139 } 0140 } 0141 0142 /* ----------------------------------------------------------------- 0143 * local variables: 0144 * eval: (load-file "../../rapidsvn-dev.el") 0145 * end: 0146 */