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