File indexing completed on 2024-04-28 05:42:07
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 * https://kde.org/applications/development/org.kde.kdesvn 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 #ifndef SVNQT_CLIENT_IMPL_H 0033 #define SVNQT_CLIENT_IMPL_H 0034 0035 #include <svnqt/client.h> 0036 #include <svnqt/svnqt_defines.h> 0037 0038 #include <QtContainerFwd> 0039 0040 namespace svn 0041 { 0042 namespace stream 0043 { 0044 class SvnStream; 0045 } 0046 0047 /** 0048 * Subversion client API. 0049 */ 0050 class SVNQT_NOEXPORT Client_impl : public Client 0051 { 0052 public: 0053 /** 0054 * Initializes the primary memory pool. 0055 */ 0056 explicit Client_impl(const ContextP &context); 0057 0058 virtual ~Client_impl(); 0059 0060 /** 0061 * @return returns the Client context 0062 */ 0063 const ContextP getContext() const override; 0064 0065 /** 0066 * sets the client context 0067 * you have to make sure the old context 0068 * is de-allocated 0069 * 0070 * @param context new context to use 0071 */ 0072 void setContext(const ContextP &context) override; 0073 0074 /** 0075 * Enumerates all files/dirs at a given path. 0076 * 0077 * Throws an exception if an error occurs 0078 * 0079 * @param params the parameter for this method 0080 * @return vector with Status entries. 0081 */ 0082 StatusEntries status(const StatusParameter ¶ms) override; 0083 0084 /** 0085 * Returns the status of a single file in the path. 0086 * 0087 * Throws an exception if an error occurs 0088 * 0089 * @param path File to gather status. 0090 * @param update if check against repository if new updates are there (for WC only) 0091 * @param revision list specific revision when browsing remote, on working copies parameter will ignored 0092 * @return a Status with Statis.isVersioned = FALSE 0093 */ 0094 StatusPtr singleStatus(const Path &path, bool update = false, const Revision &revision = svn::Revision::HEAD) override; 0095 0096 /** 0097 * Executes a revision checkout. 0098 * @param params the parameters to use 0099 * @return revision number checked out 0100 * @exception ClientException 0101 */ 0102 Revision checkout(const CheckoutParameter ¶ms) override; 0103 0104 /** 0105 * relocate wc @a from to @a to 0106 * @exception ClientException 0107 */ 0108 void relocate(const Path &path, const Url &from_url, const Url &to_url, bool recurse, bool ignore_externals) override; 0109 0110 /** 0111 * Sets files for deletion. 0112 * 0113 * @param targets targets to delete 0114 * @param force force if files are locally modified 0115 * @exception ClientException 0116 */ 0117 svn::Revision remove(const Targets &targets, bool force, bool keep_local = true, const PropertiesMap &revProps = PropertiesMap()) override; 0118 0119 /** 0120 * Reverts a couple of files to a pristiner state. 0121 * @exception ClientException 0122 */ 0123 void revert(const Targets &targets, Depth depth, const StringArray &changelist = StringArray()) override; 0124 0125 /** 0126 * Adds a file to the repository. 0127 * @param path the path to add 0128 * @param depth if @a path is a folder add items recursive depending on value if it. Pre-subversion 1.5 DepthInfinity is mapped to recursive, all other to 0129 * not-recursive. 0130 * @param force if true, do not error on already-versioned items. 0131 * @param no_ignore if false don't add files or directories that match ignore patterns. 0132 * @param add_parents if true, go up to the next versioned folder and add all between path and this folder. Used only with subversion 1.5 or newer 0133 * @exception ClientException 0134 * @sa svn::Depth 0135 */ 0136 void add(const Path &path, svn::Depth depth, bool force = false, bool no_ignore = false, bool add_parents = true) override; 0137 0138 /** 0139 * Updates the file or directory. 0140 * @param params the parameter for subversion 0141 * @exception ClientException 0142 */ 0143 Revisions update(const UpdateParameter ¶ms) override; 0144 0145 /** 0146 * Retrieves the contents for a specific @a revision of 0147 * a @a path at @a peg_revision 0148 * 0149 * @param path path of file or directory 0150 * @param peg_revision revision to base the URL 0151 * @param revision revision to retrieve 0152 * @param peg_revision Revision to look at 0153 * @return contents of the file 0154 */ 0155 QByteArray cat(const Path &path, const Revision &revision, const Revision &peg_revision = Revision::UNDEFINED) override; 0156 /** 0157 * Retrieves the contents for a specific @a revision of 0158 * a @a path at @a peg_revision 0159 * 0160 * @param buffer Stream to store content direct 0161 * @param path path of file or directory 0162 * @param peg_revision revision to base the URL 0163 * @param revision revision to retrieve 0164 * @exception ClientException 0165 */ 0166 void cat(svn::stream::SvnStream &buffer, const Path &path, const Revision &revision, const Revision &peg_revision) override; 0167 0168 /** 0169 * Retrieves the contents for a specific @a revision of 0170 * a @a path at @a peg_revision 0171 * 0172 * @param path path of file or directory 0173 * @param target new (local) name 0174 * @param peg_revision revision to base the URL 0175 * @param revision revision to retrieve 0176 * @param peg_revision Revision to look at 0177 */ 0178 void get(const Path &path, const QString &target, const Revision &revision, const Revision &peg_revision = Revision::UNDEFINED) override; 0179 0180 /** 0181 * Retrieves the contents for a specific @a revision of 0182 * a @a path and stores the result in @a target 0183 * 0184 * @param target the container where to store the result 0185 * @param path path of file or directory 0186 * @param revisionStart revision to retrieve 0187 * @param revisionEnd revision to retrieve 0188 * @param peg indicates in which revision path is valid 0189 */ 0190 void annotate(AnnotatedFile &target, const AnnotateParameter ¶ms) override; 0191 0192 /** 0193 * Commits changes to the repository. This usually requires 0194 * authentication, see Auth. 0195 * @param parameters CommitParameter to use 0196 * @return Returns revision transferred or svn::Revision::UNDEFINED if the revision number is invalid. 0197 * @exception ClientException 0198 */ 0199 svn::Revision commit(const CommitParameter ¶meters) override; 0200 0201 /** 0202 * Copies a versioned file with the history preserved. 0203 * @exception ClientException 0204 */ 0205 svn::Revision copy(const Path &srcPath, const Revision &srcRevision, const Path &destPath) override; 0206 /** 0207 * Copies a versioned file with the history preserved. 0208 * @since subversion 1.5 api 0209 * @param parameter Class holding old required parameter 0210 * @see svn_client_copy4,svn_client_copy5 0211 * @exception ClientException 0212 */ 0213 svn::Revision copy(const CopyParameter ¶meter) override; 0214 0215 /** 0216 * Moves or renames a file. 0217 * @param parameter Class holding old required parameter 0218 * @exception ClientException 0219 */ 0220 svn::Revision move(const CopyParameter ¶meter) override; 0221 0222 /** 0223 * Creates a directory directly in a repository or creates a 0224 * directory on disk and schedules it for addition. If <i>path</i> 0225 * is a URL then authentication is usually required, see Auth and 0226 * the callback asks for a logmessage. 0227 * 0228 * @param targets encoded pathes to create 0229 * @param message log message. if it is QString::null asks when working on repository 0230 * @exception ClientException 0231 */ 0232 svn::Revision mkdir(const Targets &targets, const QString &message, bool makeParent = true, const PropertiesMap &revProps = PropertiesMap()) override; 0233 0234 /** 0235 * Recursively cleans up a local directory, finishing any 0236 * incomplete operations, removing lockfiles, etc. 0237 * @param path a local directory. 0238 * @exception ClientException 0239 */ 0240 void cleanup(const Path &path) override; 0241 0242 /** 0243 * Removes the 'conflicted' state on a file. 0244 * @exception ClientException 0245 */ 0246 void resolve(const Path &path, Depth depth, const ConflictResult &resolution = ConflictResult()) override; 0247 0248 /** 0249 * Exports the contents of either a subversion repository into a 0250 * 'clean' directory (meaning a directory with no administrative 0251 * directories). 0252 * @exception ClientException 0253 * @param params Parameter to use 0254 * @return revision exported 0255 */ 0256 Revision doExport(const CheckoutParameter ¶ms) override; 0257 0258 /** 0259 * Update local copy to mirror a new url. This excapsulates the 0260 * svn_client_switch() client method. 0261 * @exception ClientException 0262 */ 0263 Revision doSwitch(const Path &path, 0264 const Url &url, 0265 const Revision &revision, 0266 Depth depth, 0267 const Revision &peg = Revision::UNDEFINED, 0268 bool sticky_depth = true, 0269 bool ignore_externals = false, 0270 bool allow_unversioned = false, 0271 bool ignore_ancestry = false) override; 0272 0273 /** 0274 * Import file or directory PATH into repository directory URL at 0275 * head. This usually requires authentication, see Auth. 0276 * @param path path to import 0277 * @param importRepository 0278 * @param message log message. 0279 * @param depth kind of recurse operation 0280 * @param no_ignore if false, don't add items matching global ignore pattern 0281 * @param no_unknown_nodetype if true ignore files type not known like pipes or device files 0282 * @exception ClientException 0283 */ 0284 svn::Revision import(const Path &path, 0285 const Url &importRepository, 0286 const QString &message, 0287 svn::Depth depth, 0288 bool no_ignore, 0289 bool no_unknown_nodetype, 0290 const PropertiesMap &revProps = PropertiesMap()) override; 0291 0292 /** 0293 * Merge changes from two paths into a new local path. For reintegrate merge see svn::MergeParameter! 0294 * @exception ClientException 0295 * @sa svn::MergeParameter 0296 */ 0297 void merge(const MergeParameter ¶meters) override; 0298 0299 void merge_peg(const MergeParameter ¶meters) override; 0300 0301 /** 0302 * Retrieve information for the given path 0303 * remote or local. Only gives with subversion 1.2 0304 * useful results 0305 * 0306 * @param path path for info 0307 * @param rec recursive (if dir) 0308 * @param rev for which revision 0309 * @param peg_revision peg revision 0310 * @return InfoEntries 0311 * @since subversion 1.2 0312 */ 0313 InfoEntries info(const Path &path, 0314 Depth depth, 0315 const Revision &rev, 0316 const Revision &peg_revision = Revision::UNDEFINED, 0317 const StringArray &changelists = StringArray()) override; 0318 0319 /** 0320 * Retrieve log information for the given path 0321 * Loads the log messages result set. Result will stored 0322 * in a map where the key is the revision number 0323 * 0324 * You can use the constants Revision::START and 0325 * Revision::HEAD 0326 * 0327 * @param params Parameter to use for log 0328 * @param target where to store the resulting logs 0329 * @return true if success 0330 * @sa LogParameter 0331 */ 0332 bool log(const LogParameter ¶ms, LogEntriesMap &target) override; 0333 /** 0334 * Produce diff output which describes the delta between 0335 * @a path/@a revision1 and @a path/@a revision2. @a path 0336 * can be either a working-copy path or a URL. 0337 * 0338 * A ClientException will be thrown if either @a revision1 or 0339 * @a revision2 has an `unspecified' or unrecognized `kind'. 0340 * 0341 * @param options set of options required for diff 0342 * @return delta between the files 0343 * @exception ClientException 0344 */ 0345 QByteArray diff_peg(const DiffParameter &options) override; 0346 0347 /** 0348 * Produce diff output which describes the delta between 0349 * @a path1/@a revision1 and @a path2/@a revision2. @a path2 0350 * can be either a working-copy path or a URL. 0351 * 0352 * A ClientException will be thrown if either @a revision1 or 0353 * @a revision2 has an `unspecified' or unrecognized `kind'. 0354 * 0355 * @param options set of options required for diff 0356 * @return delta between the files 0357 * @exception ClientException 0358 */ 0359 QByteArray diff(const DiffParameter &options) override; 0360 0361 /** 0362 * lists entries in @a pathOrUrl no matter whether local or 0363 * repository 0364 * 0365 * @param pathOrUrl 0366 * @param revision 0367 * @param peg at which revision path exists 0368 * @param depth @sa svn::Depth 0369 * @param retrieve_locks check for REPOSITORY locks while listing 0370 * @return a vector of directory entries, each with 0371 * a relative path (only filename) 0372 */ 0373 virtual DirEntries list(const Path &pathOrUrl, const Revision &revision, const Revision &peg, svn::Depth depth, bool retrieve_locks) override; 0374 0375 /** 0376 * lists properties in @a path no matter whether local or 0377 * repository 0378 * 0379 * @param path 0380 * @param revision 0381 * @param peg most case should set to @a revision 0382 * @param recurse 0383 * @return PropertiesList 0384 */ 0385 virtual PathPropertiesMapListPtr proplist(const Path &path, 0386 const Revision &revision, 0387 const Revision &peg, 0388 Depth depth = DepthEmpty, 0389 const StringArray &changelists = StringArray()) override; 0390 0391 /** 0392 * lists one property in @a path no matter whether local or 0393 * repository 0394 * 0395 * @param propName 0396 * @param path 0397 * @param revision 0398 * @param peg most case should set to @a revision 0399 * @param recurse 0400 * @return PathPropertiesMapList 0401 */ 0402 virtual QPair<qlonglong, PathPropertiesMapList> propget(const QString &propName, 0403 const Path &path, 0404 const Revision &revision, 0405 const Revision &peg, 0406 Depth depth = svn::DepthEmpty, 0407 const StringArray &changelists = StringArray()) override; 0408 0409 /** 0410 * set property in @a path no matter whether local or 0411 * repository 0412 * 0413 * @param params svn::PropertiesParameter holding required values. 0414 * Following is used:<br/> 0415 * <ul> 0416 * <li> svn::PropertiesParameter::propertyName() 0417 * <li> svn::PropertiesParameter::propertyValue() 0418 * <li> svn::PropertiesParameter::depth() 0419 * <li> svn::PropertiesParameter::skipCheck() 0420 * <li> svn::PropertiesParameter::revision() 0421 * <li> svn::PropertiesParameter::changeList() 0422 * <li> svn::PropertiesParameter::revisionProperties() 0423 * </ul> 0424 */ 0425 virtual void propset(const PropertiesParameter ¶ms) override; 0426 0427 /** 0428 * lists revision properties in @a path no matter whether local or 0429 * repository 0430 * 0431 * @param path 0432 * @param revision 0433 * @return PropertiesList 0434 */ 0435 virtual QPair<qlonglong, PropertiesMap> revproplist(const Path &path, const Revision &revision) override; 0436 0437 /** 0438 * lists one revision property in @a path no matter whether local or 0439 * repository 0440 * 0441 * @param propName 0442 * @param path 0443 * @param revision 0444 * @return PropertiesList 0445 */ 0446 QPair<qlonglong, QString> revpropget(const QString &propName, const Path &path, const Revision &revision) override; 0447 0448 /** 0449 * set revision property in @a path no matter whether local or 0450 * repository 0451 * 0452 * @param params parameter to use 0453 * @return Revision 0454 * @sa PropertiesParameter 0455 */ 0456 virtual qlonglong revpropset(const PropertiesParameter ¶ms) override; 0457 0458 /** 0459 * delete revision property in @a path no matter whether local or 0460 * repository 0461 * 0462 * @param propName 0463 * @param path 0464 * @param revision 0465 * @param force 0466 * @return Revision 0467 */ 0468 virtual qlonglong revpropdel(const QString &propName, const Path &path, const Revision &revision) override; 0469 0470 /** 0471 * lock files in repository or working copy 0472 * @param targets items to be locked 0473 * @param message if non null stored with each lock in repository 0474 * @param steal_lock if true locks in wc will stolen. 0475 * @since subversion 1.2 0476 */ 0477 void lock(const Targets &targets, const QString &message, bool steal_lock) override; 0478 /** 0479 * unlock files in repository or working copy 0480 * @param targets items to unlock 0481 * @param break_lock ignore any errors 0482 */ 0483 void unlock(const Targets &targets, bool break_lock) override; 0484 0485 void url2Revision(const QString &revstring, Revision &start, Revision &end) override; 0486 void url2Revision(const QString &revstring, Revision &start) override; 0487 0488 bool RepoHasCapability(const Path &repository, Capability capability) override; 0489 0490 static void checkErrorThrow(svn_error_t *error) 0491 { 0492 if (!error || error->apr_err == APR_SUCCESS) { 0493 return; 0494 } 0495 throw ClientException(error); 0496 } 0497 0498 private: 0499 ContextP m_context; 0500 0501 /** 0502 * disallow assignment operator 0503 */ 0504 Client_impl &operator=(const Client &); 0505 0506 /** 0507 * disallow copy constructor 0508 */ 0509 Client_impl(const Client_impl &); 0510 0511 svn_error_t *internal_cat(const Path &path, const Revision &revision, const Revision &peg_revision, svn::stream::SvnStream &); 0512 0513 static apr_hash_t *map2hash(const PropertiesMap &, const Pool &); 0514 0515 /** helper method 0516 * @sa svn_client_merge_reintegrate 0517 */ 0518 virtual void merge_reintegrate(const MergeParameter ¶meters); 0519 }; 0520 } 0521 0522 #endif 0523 /* ----------------------------------------------------------------- 0524 * local variables: 0525 * eval: (load-file "../../rapidsvn-dev.el") 0526 * end: 0527 */