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