SvnCpp
client.hpp
Go to the documentation of this file.
1 /*
2  * ====================================================================
3  * Copyright (c) 2002-2018 The RapidSVN Group. All rights reserved.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as
7  * published by the Free Software Foundation, either version 3 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program (in the file LGPL.txt).
17  * If not, see <http://www.gnu.org/licenses/>.
18  *
19  * This software consists of voluntary contributions made by many
20  * individuals. For exact contribution history, see the revision
21  * history and logs, available at http://rapidsvn.tigris.org/.
22  * ====================================================================
23  */
24 
25 #ifndef _SVNCPP_CLIENT_H_
26 #define _SVNCPP_CLIENT_H_
27 
28 // Ignore MSVC 7,8,9 compiler warnings
29 #if defined (_MSC_VER) && _MSC_VER > 1200 && _MSC_VER <= 1500
30 // C++ exception specification
31 #pragma warning (disable: 4290)
32 #endif
33 
34 
35 // stl
36 #include <assert.h>
39 #include "svncpp/map_wrapper.hpp"
40 
41 // svncpp
42 #include "svncpp/context.hpp"
43 #include "svncpp/exception.hpp"
44 #include "svncpp/path.hpp"
45 #include "svncpp/entry.hpp"
46 #include "svncpp/revision.hpp"
47 #include "svncpp/log_entry.hpp"
48 #include "svncpp/annotate_line.hpp"
49 
50 
51 namespace svn
52 {
53  // forward declarations
54  class Context;
55  class DirEntry;
56  class Info;
57  class Status;
58  class Targets;
59 
60  typedef std::vector<AnnotateLine> AnnotatedFile;
61  typedef std::vector<DirEntry> DirEntries;
62  typedef std::vector<Info> InfoVector;
63  typedef std::vector<LogEntry> LogEntries;
64  typedef std::vector<Status> StatusEntries;
65 
66 
67  // map of property names to values
68  typedef std::map<std::string,std::string> PropertiesMap;
69  // pair of path, PropertiesMap
70  typedef std::pair<std::string, PropertiesMap> PathPropertiesMapEntry;
71  // vector of path, Properties pairs
72  typedef std::vector<PathPropertiesMapEntry> PathPropertiesMapList;
73 
80  struct StatusFilter
81  {
82  public:
85  bool showModified;
89 
91  : showUnversioned(false), showUnmodified(false),
92  showModified(false), showConflicted(false),
93  showExternals(false)
94  {
95  }
96  };
97 
98 
99  struct CommitInfo
100  {
101  svn_revnum_t revision;
102 
104  std::string date;
105 
107  std::string author;
108 
110  std::string postCommitErr;
111 
113  revision(SVN_INVALID_REVNUM)
114  {
115  }
116 
117  CommitInfo(const svn_commit_info_t *info)
118  {
119  assert(0 != info);
120 
121  revision = info->revision;
122  date = info->date;
123  author = info->author;
124  if (0 != info->post_commit_err)
125  postCommitErr = info->post_commit_err;
126  }
127  };
128 
129 
133  class Client
134  {
135  public:
139  Client(Context * context = 0);
140 
141  virtual ~Client();
142 
146  const CommitInfo& commitInfo() const
147  {
148  return m_commitInfo;
149  }
150 
154  const Context *
155  getContext() const;
156 
160  Context *
162 
170  void
171  setContext(Context * context = NULL);
172 
187  status(const char * path,
188  const bool descend = false,
189  const bool get_all = true,
190  const bool update = false,
191  const bool no_ignore = false,
192  const bool ignore_externals = false) throw(ClientException);
193 
211  svn_revnum_t
212  status(const char * path,
213  const StatusFilter & filter,
214  const bool descend,
215  const bool update,
216  StatusEntries & entries) throw(ClientException);
217 
218 
230  svn_revnum_t
231  checkout(const char * moduleName,
232  const Path & destPath,
233  const Revision & revision,
234  svn_depth_t depth,
235  bool ignore_externals = false,
236  const Revision & peg_revision = Revision::UNSPECIFIED) throw(ClientException);
237 
242  void
243  relocate(const Path & path, const char *from_url,
244  const char *to_url, bool recurse) throw(ClientException);
245 
250  void
251  remove(const Path & path, bool force) throw(ClientException);
252 
260  void
261  remove(const Targets & targets,
262  bool force) throw(ClientException);
263 
272  void
273  lock(const Targets & targets, bool force,
274  const char * comment) throw(ClientException);
275 
283  void
284  unlock(const Targets & targets, bool force) throw(ClientException);
285 
290  void
291  revert(const Targets & targets, bool recurse) throw(ClientException);
292 
297  void
298  add(const Path & path, bool recurse) throw(ClientException);
299 
314  std::vector<svn_revnum_t>
315  update(const Targets & targets,
316  const Revision & revision,
317  svn_depth_t depth,
318  bool depth_is_sticky,
319  bool ignore_externals) throw(ClientException);
320 
321  svn_revnum_t
322  update(const Path & path,
323  const Revision & revision,
324  svn_depth_t depth,
325  bool depth_is_sticky,
326  bool ignore_externals) throw(ClientException);
327 
338  std::string
339  cat(const Path & path,
340  const Revision & revision,
341  const Revision & peg_revision = Revision::UNSPECIFIED) throw(ClientException);
342 
343 
360  void
361  get(Path & dstPath,
362  const Path & path,
363  const Revision & revision,
364  const Revision & peg_revision = Revision::UNSPECIFIED) throw(ClientException);
365 
366 
376  AnnotatedFile *
377  annotate(const Path & path,
378  const Revision & revisionStart,
379  const Revision & revisionEnd) throw(ClientException);
380 
396  svn_revnum_t
397  commit(const Targets & targets,
398  const char * message,
399  bool recurse,
400  bool keep_locks = false) throw(ClientException);
401 
406  void
407  copy(const Path & srcPath,
408  const Revision & srcRevision,
409  const Path & destPath) throw(ClientException);
410 
415  void
416  move(const Path & srcPath,
417  const Revision & srcRevision,
418  const Path & destPath,
419  bool force) throw(ClientException);
420 
429  void
430  mkdir(const Path & path) throw(ClientException);
431 
432  void
433  mkdir(const Targets & targets) throw(ClientException);
434 
441  void
442  cleanup(const Path & path) throw(ClientException);
443 
455  void
456  cleanup(const Path & path,
457  bool breakLocks, bool fixTimestamps, bool vacuumPristines,
458  bool includeExternals) throw(ClientException);
459 
471  void
472  vacuum(const Path &path,
473  bool removeUnversioned, bool removeIgnored,
474  bool fixTimestamps, bool vacuumPristines,
475  bool includeExternals) throw(ClientException);
476 
484  void
485  upgrade(const Path &path) throw(ClientException);
486 
491  void
492  resolved(const Path & path, bool recurse) throw(ClientException);
493 
507  void
508  doExport(const Path & from_path,
509  const Path & to_path,
510  const Revision & revision,
511  bool overwrite = false,
512  const Revision & peg_revision = Revision::UNSPECIFIED,
513  bool ignore_externals = false,
514  svn_depth_t depth = svn_depth_infinity,
515  const char * native_eol = NULL) throw(ClientException);
516 
522  svn_revnum_t
523  doSwitch(const Path & path, const char * url,
524  const Revision & revision,
525  bool recurse) throw(ClientException);
526 
536  void
537  import(const Path & path,
538  const char * url,
539  const char * message,
540  bool recurse) throw(ClientException);
541  void
542  import(const Path & path,
543  const Path & url,
544  const char * message,
545  bool recurse) throw(ClientException);
546 
547 
552  void
553  merge(const Path & path1, const Revision & revision1,
554  const Path & path2, const Revision & revision2,
555  const Path & localPath, bool force,
556  bool recurse,
557  bool notice_ancestry = false,
558  bool dry_run = false) throw(ClientException);
559 
560 
573  InfoVector
574  info(const Path & pathOrUrl,
575  bool recurse=false,
576  const Revision & revision = Revision::UNSPECIFIED,
577  const Revision & pegRevision = Revision::UNSPECIFIED) throw(ClientException);
578 
579 
595  const LogEntries *
596  log(const char * path,
597  const Revision & revisionStart,
598  const Revision & revisionEnd,
599  bool discoverChangedPaths = false,
600  bool strictNodeHistory = true) throw(ClientException);
601 
619  const LogEntries *
620  log(const char * path,
621  const Revision & revisionStart,
622  const Revision & revisionEnd,
623  const int limit,
624  bool discoverChangedPaths = false,
625  bool strictNodeHistory = true) throw(ClientException);
626 
649  std::string
650  diff(const Path & tmpPath, const Path & path,
651  const Revision & revision1, const Revision & revision2,
652  const bool recurse, const bool ignoreAncestry,
653  const bool noDiffDeleted) throw(ClientException);
654 
678  std::string
679  diff(const Path & tmpPath, const Path & path1, const Path & path2,
680  const Revision & revision1, const Revision & revision2,
681  const bool recurse, const bool ignoreAncestry,
682  const bool noDiffDeleted) throw(ClientException);
683 
707  std::string
708  diff(const Path & tmpPath, const Path & path,
709  const Revision & pegRevision, const Revision & revision1,
710  const Revision & revision2, const bool recurse,
711  const bool ignoreAncestry, const bool noDiffDeleted)
712  throw(ClientException);
713 
724  DirEntries
725  list(const char * pathOrUrl,
726  svn_opt_revision_t * revision,
727  bool recurse) throw(ClientException);
728 
739  proplist(const Path &path,
740  const Revision &revision,
741  bool recurse = false);
742 
754  propget(const char * propName,
755  const Path & path,
756  const Revision & revision,
757  bool recurse = false);
758 
775  void
776  propset(const char * propName,
777  const char * propValue,
778  const Path & path,
779  const Revision & revision,
780  bool recurse = false,
781  bool skip_checks = true);
782 
792  void
793  propdel(const char * propName,
794  const Path & path,
795  const Revision & revision,
796  bool recurse = false);
797 
798 
807  std::pair<svn_revnum_t,PropertiesMap>
808  revproplist(const Path & path,
809  const Revision & revision);
810 
820  std::pair<svn_revnum_t,std::string>
821  revpropget(const char * propName,
822  const Path & path,
823  const Revision & revision);
824 
836  svn_revnum_t
837  revpropset(const char * propName,
838  const char * propValue,
839  const Path & path,
840  const Revision & revision,
841  bool force = false);
842 
853  svn_revnum_t
854  revpropdel(const char * propName,
855  const Path & path,
856  const Revision & revision,
857  bool force = false);
858 
859 
867  void
868  ignore(const Path & path) throw(ClientException);
869 
877  void
878  ignore(const Targets & targets) throw(ClientException);
879  private:
880  Context * m_context;
881  CommitInfo m_commitInfo;
882 
886  Client & operator= (const Client &);
887 
891  Client(const Client &);
892  };
893 }
894 
895 #endif
896 /* -----------------------------------------------------------------
897  * local variables:
898  * eval: (load-file "../../rapidsvn-dev.el")
899  * end:
900  */
svn::Client::import
void import(const Path &path, const char *url, const char *message, bool recurse)
svn::InfoVector
std::vector< Info > InfoVector
Definition: client.hpp:62
svn::CommitInfo::date
std::string date
Definition: client.hpp:104
svn::StatusFilter::showModified
bool showModified
this includes showConflicted as well
Definition: client.hpp:85
svn::Client::propget
PathPropertiesMapList propget(const char *propName, const Path &path, const Revision &revision, bool recurse=false)
svn::Client::doSwitch
svn_revnum_t doSwitch(const Path &path, const char *url, const Revision &revision, bool recurse)
svn::Client::getContext
Context * getContext()
svn::ClientException
Definition: exception.hpp:75
svn::Client::~Client
virtual ~Client()
svn::Client::diff
std::string diff(const Path &tmpPath, const Path &path, const Revision &revision1, const Revision &revision2, const bool recurse, const bool ignoreAncestry, const bool noDiffDeleted)
svn::Client::Client
Client(Context *context=0)
svn::Client::info
InfoVector info(const Path &pathOrUrl, bool recurse=false, const Revision &revision=Revision::UNSPECIFIED, const Revision &pegRevision=Revision::UNSPECIFIED)
svn::Client::merge
void merge(const Path &path1, const Revision &revision1, const Path &path2, const Revision &revision2, const Path &localPath, bool force, bool recurse, bool notice_ancestry=false, bool dry_run=false)
svn::Client::annotate
AnnotatedFile * annotate(const Path &path, const Revision &revisionStart, const Revision &revisionEnd)
log_entry.hpp
context.hpp
svn::StatusFilter::showIgnored
bool showIgnored
Definition: client.hpp:87
svn::DirEntries
std::vector< DirEntry > DirEntries
Definition: client.hpp:61
svn::Client::ignore
void ignore(const Path &path)
svn::Client::add
void add(const Path &path, bool recurse)
svn::Revision
Definition: revision.hpp:43
svn::StatusFilter
Definition: client.hpp:81
svn::Client::commitInfo
const CommitInfo & commitInfo() const
Definition: client.hpp:146
svn::Client::copy
void copy(const Path &srcPath, const Revision &srcRevision, const Path &destPath)
svn::StatusEntries
std::vector< Status > StatusEntries
Definition: client.hpp:64
svn::Client::update
std::vector< svn_revnum_t > update(const Targets &targets, const Revision &revision, svn_depth_t depth, bool depth_is_sticky, bool ignore_externals)
svn::CommitInfo::postCommitErr
std::string postCommitErr
Definition: client.hpp:110
svn::Client::doExport
void doExport(const Path &from_path, const Path &to_path, const Revision &revision, bool overwrite=false, const Revision &peg_revision=Revision::UNSPECIFIED, bool ignore_externals=false, svn_depth_t depth=svn_depth_infinity, const char *native_eol=NULL)
svn::PropertiesMap
std::map< std::string, std::string > PropertiesMap
Definition: client.hpp:68
utility_wrapper.hpp
svn::Client::mkdir
void mkdir(const Path &path)
svn::Client::setContext
void setContext(Context *context=NULL)
map_wrapper.hpp
annotate_line.hpp
svn::Client::vacuum
void vacuum(const Path &path, bool removeUnversioned, bool removeIgnored, bool fixTimestamps, bool vacuumPristines, bool includeExternals)
svn::Client::revert
void revert(const Targets &targets, bool recurse)
svn::CommitInfo
Definition: client.hpp:100
svn::StatusFilter::showUnmodified
bool showUnmodified
Definition: client.hpp:84
svn::Targets
Definition: targets.hpp:44
svn::Client::log
const LogEntries * log(const char *path, const Revision &revisionStart, const Revision &revisionEnd, bool discoverChangedPaths=false, bool strictNodeHistory=true)
svn::CommitInfo::CommitInfo
CommitInfo(const svn_commit_info_t *info)
Definition: client.hpp:117
svn::Client::revpropget
std::pair< svn_revnum_t, std::string > revpropget(const char *propName, const Path &path, const Revision &revision)
svn::Client::propdel
void propdel(const char *propName, const Path &path, const Revision &revision, bool recurse=false)
svn::CommitInfo::author
std::string author
Definition: client.hpp:107
svn::Client
Definition: client.hpp:134
svn::Client::unlock
void unlock(const Targets &targets, bool force)
svn::CommitInfo::revision
svn_revnum_t revision
Definition: client.hpp:101
entry.hpp
svn::Client::upgrade
void upgrade(const Path &path)
svn::Client::status
StatusEntries status(const char *path, const bool descend=false, const bool get_all=true, const bool update=false, const bool no_ignore=false, const bool ignore_externals=false)
svn
Definition: annotate_line.hpp:32
svn::Client::checkout
svn_revnum_t checkout(const char *moduleName, const Path &destPath, const Revision &revision, svn_depth_t depth, bool ignore_externals=false, const Revision &peg_revision=Revision::UNSPECIFIED)
revision.hpp
exception.hpp
svn::StatusFilter::showConflicted
bool showConflicted
Definition: client.hpp:86
svn::Client::commit
svn_revnum_t commit(const Targets &targets, const char *message, bool recurse, bool keep_locks=false)
svn::PathPropertiesMapList
std::vector< PathPropertiesMapEntry > PathPropertiesMapList
Definition: client.hpp:72
svn::CommitInfo::CommitInfo
CommitInfo()
Definition: client.hpp:112
svn::Client::revproplist
std::pair< svn_revnum_t, PropertiesMap > revproplist(const Path &path, const Revision &revision)
svn::Path
Definition: path.hpp:38
svn::Client::cat
std::string cat(const Path &path, const Revision &revision, const Revision &peg_revision=Revision::UNSPECIFIED)
svn::Client::relocate
void relocate(const Path &path, const char *from_url, const char *to_url, bool recurse)
svn::Client::lock
void lock(const Targets &targets, bool force, const char *comment)
svn::Context
Definition: context.hpp:49
svn::StatusFilter::StatusFilter
StatusFilter()
Definition: client.hpp:90
svn::Client::cleanup
void cleanup(const Path &path)
svn::Client::proplist
PathPropertiesMapList proplist(const Path &path, const Revision &revision, bool recurse=false)
svn::Client::getContext
const Context * getContext() const
svn::AnnotatedFile
std::vector< AnnotateLine > AnnotatedFile
Definition: client.hpp:58
svn::Client::move
void move(const Path &srcPath, const Revision &srcRevision, const Path &destPath, bool force)
svn::Client::remove
void remove(const Path &path, bool force)
svn::StatusFilter::showUnversioned
bool showUnversioned
Definition: client.hpp:83
svn::Client::revpropdel
svn_revnum_t revpropdel(const char *propName, const Path &path, const Revision &revision, bool force=false)
path.hpp
svn::StatusFilter::showExternals
bool showExternals
Definition: client.hpp:88
svn::Client::resolved
void resolved(const Path &path, bool recurse)
svn::PathPropertiesMapEntry
std::pair< std::string, PropertiesMap > PathPropertiesMapEntry
Definition: client.hpp:70
svn::LogEntries
std::vector< LogEntry > LogEntries
Definition: client.hpp:63
svn::Client::get
void get(Path &dstPath, const Path &path, const Revision &revision, const Revision &peg_revision=Revision::UNSPECIFIED)
svn::Client::propset
void propset(const char *propName, const char *propValue, const Path &path, const Revision &revision, bool recurse=false, bool skip_checks=true)
vector_wrapper.hpp
svn::Client::revpropset
svn_revnum_t revpropset(const char *propName, const char *propValue, const Path &path, const Revision &revision, bool force=false)
svn::Client::list
DirEntries list(const char *pathOrUrl, svn_opt_revision_t *revision, bool recurse)