1 /* 2 * Port for usage with qt-framework and development for kdesvn 3 * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de) 4 * http://kdesvn.alwins-world.de 5 */ 6 /* 7 * ==================================================================== 8 * Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved. 9 * dev@rapidsvn.tigris.org 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library (in the file LGPL.txt); if not, 23 * write to the Free Software Foundation, Inc., 51 Franklin St, 24 * Fifth Floor, Boston, MA 02110-1301 USA 25 * 26 * This software consists of voluntary contributions made by many 27 * individuals. For exact contribution history, see the revision 28 * history and logs, available at http://rapidsvn.tigris.org/. 29 * ==================================================================== 30 */ 31 32 #ifndef SVNQT_CLIENT_IMPL_H 33 #define SVNQT_CLIENT_IMPL_H 34 35 #include <svnqt/client.h> 36 #include <svnqt/svnqt_defines.h> 37 38 class QStringList; 39 40 namespace svn 41 { 42 namespace stream 43 { 44 class SvnStream; 45 } 46 47 /** 48 * Subversion client API. 49 */ 50 class SVNQT_NOEXPORT Client_impl: public Client 51 { 52 public: 53 /** 54 * Initializes the primary memory pool. 55 */ 56 explicit Client_impl(const ContextP &context); 57 58 virtual ~Client_impl(); 59 60 /** 61 * @return returns the Client context 62 */ 63 const ContextP getContext() const override; 64 65 /** 66 * sets the client context 67 * you have to make sure the old context 68 * is de-allocated 69 * 70 * @param context new context to use 71 */ 72 void setContext(const ContextP &context) override; 73 74 75 /** 76 * Enumerates all files/dirs at a given path. 77 * 78 * Throws an exception if an error occurs 79 * 80 * @param params the parameter for this method 81 * @return vector with Status entries. 82 */ 83 StatusEntries status(const StatusParameter ¶ms) override; 84 85 /** 86 * Returns the status of a single file in the path. 87 * 88 * Throws an exception if an error occurs 89 * 90 * @param path File to gather status. 91 * @param update if check against repository if new updates are there (for WC only) 92 * @param revision list specific revision when browsing remote, on working copies parameter will ignored 93 * @return a Status with Statis.isVersioned = FALSE 94 */ 95 StatusPtr singleStatus(const Path &path, bool update = false, const Revision &revision = svn::Revision::HEAD) override; 96 97 /** 98 * Executes a revision checkout. 99 * @param params the parameters to use 100 * @return revision number checked out 101 * @exception ClientException 102 */ 103 Revision checkout(const CheckoutParameter ¶ms) override; 104 105 /** 106 * relocate wc @a from to @a to 107 * @exception ClientException 108 */ 109 void relocate(const Path &path, const Url &from_url, 110 const Url &to_url, bool recurse, bool ignore_externals) override; 111 112 /** 113 * Sets files for deletion. 114 * 115 * @param targets targets to delete 116 * @param force force if files are locally modified 117 * @exception ClientException 118 */ 119 svn::Revision 120 remove(const Targets &targets, 121 bool force, 122 bool keep_local = true, 123 const PropertiesMap &revProps = PropertiesMap()) override; 124 125 /** 126 * Reverts a couple of files to a pristiner state. 127 * @exception ClientException 128 */ 129 void 130 revert(const Targets &targets, 131 Depth depth, 132 const StringArray &changelist = StringArray() 133 ) override; 134 135 136 /** 137 * Adds a file to the repository. 138 * @param path the path to add 139 * @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. 140 * @param force if true, do not error on already-versioned items. 141 * @param no_ignore if false don't add files or directories that match ignore patterns. 142 * @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 143 * @exception ClientException 144 * @sa svn::Depth 145 */ 146 void add(const Path &path, svn::Depth depth, bool force = false, bool no_ignore = false, bool add_parents = true) override; 147 148 /** 149 * Updates the file or directory. 150 * @param params the parameter for subversion 151 * @exception ClientException 152 */ 153 Revisions update(const UpdateParameter ¶ms) override; 154 155 /** 156 * Retrieves the contents for a specific @a revision of 157 * a @a path at @a peg_revision 158 * 159 * @param path path of file or directory 160 * @param peg_revision revision to base the URL 161 * @param revision revision to retrieve 162 * @param peg_revision Revision to look at 163 * @return contents of the file 164 */ 165 QByteArray 166 cat(const Path &path, 167 const Revision &revision, 168 const Revision &peg_revision = Revision::UNDEFINED) override; 169 /** 170 * Retrieves the contents for a specific @a revision of 171 * a @a path at @a peg_revision 172 * 173 * @param buffer Stream to store content direct 174 * @param path path of file or directory 175 * @param peg_revision revision to base the URL 176 * @param revision revision to retrieve 177 * @exception ClientException 178 */ 179 void 180 cat(svn::stream::SvnStream &buffer, 181 const Path &path, 182 const Revision &revision, 183 const Revision &peg_revision) override; 184 185 /** 186 * Retrieves the contents for a specific @a revision of 187 * a @a path at @a peg_revision 188 * 189 * @param path path of file or directory 190 * @param target new (local) name 191 * @param peg_revision revision to base the URL 192 * @param revision revision to retrieve 193 * @param peg_revision Revision to look at 194 */ 195 void get(const Path &path, 196 const QString &target, 197 const Revision &revision, 198 const Revision &peg_revision = Revision::UNDEFINED) override; 199 200 /** 201 * Retrieves the contents for a specific @a revision of 202 * a @a path and stores the result in @a target 203 * 204 * @param target the container where to store the result 205 * @param path path of file or directory 206 * @param revisionStart revision to retrieve 207 * @param revisionEnd revision to retrieve 208 * @param peg indicates in which revision path is valid 209 */ 210 void annotate(AnnotatedFile &target, const AnnotateParameter ¶ms) override; 211 212 /** 213 * Commits changes to the repository. This usually requires 214 * authentication, see Auth. 215 * @param parameters CommitParameter to use 216 * @return Returns revision transferred or svn::Revision::UNDEFINED if the revision number is invalid. 217 * @exception ClientException 218 */ 219 svn::Revision commit(const CommitParameter ¶meters) override; 220 221 /** 222 * Copies a versioned file with the history preserved. 223 * @exception ClientException 224 */ 225 svn::Revision 226 copy(const Path &srcPath, 227 const Revision &srcRevision, 228 const Path &destPath) override; 229 /** 230 * Copies a versioned file with the history preserved. 231 * @since subversion 1.5 api 232 * @param parameter Class holding old required parameter 233 * @see svn_client_copy4,svn_client_copy5 234 * @exception ClientException 235 */ 236 svn::Revision copy(const CopyParameter ¶meter) override; 237 238 /** 239 * Moves or renames a file. 240 * @param parameter Class holding old required parameter 241 * @exception ClientException 242 */ 243 svn::Revision move(const CopyParameter ¶meter) override; 244 245 /** 246 * Creates a directory directly in a repository or creates a 247 * directory on disk and schedules it for addition. If <i>path</i> 248 * is a URL then authentication is usually required, see Auth and 249 * the callback asks for a logmessage. 250 * 251 * @param targets encoded pathes to create 252 * @param message log message. if it is QString::null asks when working on repository 253 * @exception ClientException 254 */ 255 svn::Revision 256 mkdir(const Targets &targets, 257 const QString &message, 258 bool makeParent = true, 259 const PropertiesMap &revProps = PropertiesMap() 260 ) override; 261 262 /** 263 * Recursively cleans up a local directory, finishing any 264 * incomplete operations, removing lockfiles, etc. 265 * @param path a local directory. 266 * @exception ClientException 267 */ 268 void cleanup(const Path &path) override; 269 270 /** 271 * Removes the 'conflicted' state on a file. 272 * @exception ClientException 273 */ 274 void resolve(const Path &path, Depth depth, const ConflictResult &resolution = ConflictResult()) override; 275 276 /** 277 * Exports the contents of either a subversion repository into a 278 * 'clean' directory (meaning a directory with no administrative 279 * directories). 280 * @exception ClientException 281 * @param params Parameter to use 282 * @return revision exported 283 */ 284 Revision doExport(const CheckoutParameter ¶ms) override; 285 286 /** 287 * Update local copy to mirror a new url. This excapsulates the 288 * svn_client_switch() client method. 289 * @exception ClientException 290 */ 291 Revision 292 doSwitch(const Path &path, const Url &url, 293 const Revision &revision, 294 Depth depth, 295 const Revision &peg = Revision::UNDEFINED, 296 bool sticky_depth = true, 297 bool ignore_externals = false, 298 bool allow_unversioned = false, 299 bool ignore_ancestry = false 300 ) override; 301 302 /** 303 * Import file or directory PATH into repository directory URL at 304 * head. This usually requires authentication, see Auth. 305 * @param path path to import 306 * @param importRepository 307 * @param message log message. 308 * @param depth kind of recurse operation 309 * @param no_ignore if false, don't add items matching global ignore pattern 310 * @param no_unknown_nodetype if true ignore files type not known like pipes or device files 311 * @exception ClientException 312 */ 313 svn::Revision 314 import(const Path &path, const Url &importRepository, 315 const QString &message, 316 svn::Depth depth, 317 bool no_ignore, bool no_unknown_nodetype, 318 const PropertiesMap &revProps = PropertiesMap()) override; 319 320 /** 321 * Merge changes from two paths into a new local path. For reintegrate merge see svn::MergeParameter! 322 * @exception ClientException 323 * @sa svn::MergeParameter 324 */ 325 void merge(const MergeParameter ¶meters) override; 326 327 void merge_peg(const MergeParameter ¶meters) override; 328 329 /** 330 * Retrieve information for the given path 331 * remote or local. Only gives with subversion 1.2 332 * useful results 333 * 334 * @param path path for info 335 * @param rec recursive (if dir) 336 * @param rev for which revision 337 * @param peg_revision peg revision 338 * @return InfoEntries 339 * @since subversion 1.2 340 */ 341 InfoEntries 342 info(const Path &path, 343 Depth depth, 344 const Revision &rev, 345 const Revision &peg_revision = Revision::UNDEFINED, 346 const StringArray &changelists = StringArray() 347 ) override; 348 349 /** 350 * Retrieve log information for the given path 351 * Loads the log messages result set. Result will stored 352 * in a map where the key is the revision number 353 * 354 * You can use the constants Revision::START and 355 * Revision::HEAD 356 * 357 * @param params Parameter to use for log 358 * @param target where to store the resulting logs 359 * @return true if success 360 * @sa LogParameter 361 */ 362 bool log(const LogParameter ¶ms, LogEntriesMap &target) override; 363 /** 364 * Produce diff output which describes the delta between 365 * @a path/@a revision1 and @a path/@a revision2. @a path 366 * can be either a working-copy path or a URL. 367 * 368 * A ClientException will be thrown if either @a revision1 or 369 * @a revision2 has an `unspecified' or unrecognized `kind'. 370 * 371 * @param options set of options required for diff 372 * @return delta between the files 373 * @exception ClientException 374 */ 375 QByteArray diff_peg(const DiffParameter &options) override; 376 377 /** 378 * Produce diff output which describes the delta between 379 * @a path1/@a revision1 and @a path2/@a revision2. @a path2 380 * can be either a working-copy path or a URL. 381 * 382 * A ClientException will be thrown if either @a revision1 or 383 * @a revision2 has an `unspecified' or unrecognized `kind'. 384 * 385 * @param options set of options required for diff 386 * @return delta between the files 387 * @exception ClientException 388 */ 389 QByteArray diff(const DiffParameter &options) override; 390 391 /** 392 * lists entries in @a pathOrUrl no matter whether local or 393 * repository 394 * 395 * @param pathOrUrl 396 * @param revision 397 * @param peg at which revision path exists 398 * @param depth @sa svn::Depth 399 * @param retrieve_locks check for REPOSITORY locks while listing 400 * @return a vector of directory entries, each with 401 * a relative path (only filename) 402 */ 403 virtual DirEntries 404 list(const Path &pathOrUrl, 405 const Revision &revision, 406 const Revision &peg, 407 svn::Depth depth, bool retrieve_locks) override; 408 409 /** 410 * lists properties in @a path no matter whether local or 411 * repository 412 * 413 * @param path 414 * @param revision 415 * @param peg most case should set to @a revision 416 * @param recurse 417 * @return PropertiesList 418 */ 419 virtual PathPropertiesMapListPtr 420 proplist(const Path &path, 421 const Revision &revision, 422 const Revision &peg, 423 Depth depth = DepthEmpty, 424 const StringArray &changelists = StringArray()) override; 425 426 /** 427 * lists one property in @a path no matter whether local or 428 * repository 429 * 430 * @param propName 431 * @param path 432 * @param revision 433 * @param peg most case should set to @a revision 434 * @param recurse 435 * @return PathPropertiesMapList 436 */ 437 virtual QPair<qlonglong, PathPropertiesMapList> 438 propget(const QString &propName, 439 const Path &path, 440 const Revision &revision, 441 const Revision &peg, 442 Depth depth = svn::DepthEmpty, 443 const StringArray &changelists = StringArray()) override; 444 445 /** 446 * set property in @a path no matter whether local or 447 * repository 448 * 449 * @param params svn::PropertiesParameter holding required values. 450 * Following is used:<br/> 451 * <ul> 452 * <li> svn::PropertiesParameter::propertyName() 453 * <li> svn::PropertiesParameter::propertyValue() 454 * <li> svn::PropertiesParameter::depth() 455 * <li> svn::PropertiesParameter::skipCheck() 456 * <li> svn::PropertiesParameter::revision() 457 * <li> svn::PropertiesParameter::changeList() 458 * <li> svn::PropertiesParameter::revisionProperties() 459 * </ul> 460 */ 461 virtual void 462 propset(const PropertiesParameter ¶ms) override; 463 464 /** 465 * lists revision properties in @a path no matter whether local or 466 * repository 467 * 468 * @param path 469 * @param revision 470 * @return PropertiesList 471 */ 472 virtual QPair<qlonglong, PropertiesMap> 473 revproplist(const Path &path, 474 const Revision &revision) override; 475 476 /** 477 * lists one revision property in @a path no matter whether local or 478 * repository 479 * 480 * @param propName 481 * @param path 482 * @param revision 483 * @return PropertiesList 484 */ 485 QPair<qlonglong, QString> 486 revpropget(const QString &propName, 487 const Path &path, 488 const Revision &revision) override; 489 490 /** 491 * set revision property in @a path no matter whether local or 492 * repository 493 * 494 * @param params parameter to use 495 * @return Revision 496 * @sa PropertiesParameter 497 */ 498 virtual qlonglong 499 revpropset(const PropertiesParameter ¶ms) override; 500 501 /** 502 * delete revision property in @a path no matter whether local or 503 * repository 504 * 505 * @param propName 506 * @param path 507 * @param revision 508 * @param force 509 * @return Revision 510 */ 511 virtual qlonglong 512 revpropdel(const QString &propName, 513 const Path &path, 514 const Revision &revision) override; 515 516 /** 517 * lock files in repository or working copy 518 * @param targets items to be locked 519 * @param message if non null stored with each lock in repository 520 * @param steal_lock if true locks in wc will stolen. 521 * @since subversion 1.2 522 */ 523 void lock(const Targets &targets, const QString &message, 524 bool steal_lock) override; 525 /** 526 * unlock files in repository or working copy 527 * @param targets items to unlock 528 * @param break_lock ignore any errors 529 */ 530 void unlock(const Targets &targets, 531 bool break_lock) override; 532 533 void url2Revision(const QString &revstring, 534 Revision &start, Revision &end) override; 535 void url2Revision(const QString &revstring, 536 Revision &start) override; 537 538 bool RepoHasCapability(const Path &repository, Capability capability) override; 539 checkErrorThrow(svn_error_t * error)540 static void checkErrorThrow(svn_error_t *error) 541 { 542 if (!error || error->apr_err == APR_SUCCESS) { 543 return; 544 } 545 throw ClientException(error); 546 } 547 548 private: 549 ContextP m_context; 550 551 /** 552 * disallow assignment operator 553 */ 554 Client_impl &operator= (const Client &); 555 556 /** 557 * disallow copy constructor 558 */ 559 Client_impl(const Client_impl &); 560 561 svn_error_t *internal_cat(const Path &path, 562 const Revision &revision, 563 const Revision &peg_revision, 564 svn::stream::SvnStream &); 565 566 static apr_hash_t *map2hash(const PropertiesMap &, const Pool &); 567 568 /** helper method 569 * @sa svn_client_merge_reintegrate 570 */ 571 virtual void merge_reintegrate(const MergeParameter ¶meters); 572 }; 573 574 575 } 576 577 #endif 578 /* ----------------------------------------------------------------- 579 * local variables: 580 * eval: (load-file "../../rapidsvn-dev.el") 581 * end: 582 */ 583