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