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 *
161  getContext();
162 
170  void
171  setContext(Context * context = NULL);
172 
188  status(const char * path,
189  const bool descend = false,
190  const bool get_all = true,
191  const bool update = false,
192  const bool no_ignore = false,
193  const bool ignore_externals = false);
194 
213  svn_revnum_t
214  status(const char * path,
215  const StatusFilter & filter,
216  const bool descend,
217  const bool update,
218  StatusEntries & entries);
219 
220 
232  svn_revnum_t
233  checkout(const char * moduleName,
234  const Path & destPath,
235  const Revision & revision,
236  svn_depth_t depth,
237  bool ignore_externals = false,
238  const Revision & peg_revision = Revision::UNSPECIFIED);
239 
244  void
245  relocate(const Path & path, const char *from_url,
246  const char *to_url, bool recurse);
247 
252  void
253  remove(const Path & path, bool force);
254 
262  void
263  remove(const Targets & targets,
264  bool force);
265 
274  void
275  lock(const Targets & targets, bool force,
276  const char * comment);
277 
285  void
286  unlock(const Targets & targets, bool force);
287 
292  void
293  revert(const Targets & targets, bool recurse);
294 
299  void
300  add(const Path & path, bool recurse);
301 
316  std::vector<svn_revnum_t>
317  update(const Targets & targets,
318  const Revision & revision,
319  svn_depth_t depth,
320  bool depth_is_sticky,
321  bool ignore_externals);
322 
337  svn_revnum_t
338  update(const Path & path,
339  const Revision & revision,
340  svn_depth_t depth,
341  bool depth_is_sticky,
342  bool ignore_externals);
343 
355  std::string
356  cat(const Path & path,
357  const Revision & revision,
358  const Revision & peg_revision = Revision::UNSPECIFIED);
359 
360 
378  void
379  get(Path & dstPath,
380  const Path & path,
381  const Revision & revision,
382  const Revision & peg_revision = Revision::UNSPECIFIED);
383 
384 
395  AnnotatedFile *
396  annotate(const Path & path,
397  const Revision & revisionStart,
398  const Revision & revisionEnd);
399 
415  svn_revnum_t
416  commit(const Targets & targets,
417  const char * message,
418  bool recurse,
419  bool keep_locks = false);
420 
425  void
426  copy(const Path & srcPath,
427  const Revision & srcRevision,
428  const Path & destPath);
429 
434  void
435  move(const Path & srcPath,
436  const Revision & srcRevision,
437  const Path & destPath,
438  bool force);
439 
448  void
449  mkdir(const Path & path);
450 
460  void
461  mkdir(const Targets & targets);
462 
469  void
470  cleanup(const Path & path);
471 
483  void
484  cleanup(const Path & path,
485  bool breakLocks, bool fixTimestamps, bool vacuumPristines,
486  bool includeExternals);
487 
499  void
500  vacuum(const Path &path,
501  bool removeUnversioned, bool removeIgnored,
502  bool fixTimestamps, bool vacuumPristines,
503  bool includeExternals);
504 
513  void
514  upgrade(const Path &path);
515 
520  void
521  resolved(const Path & path, bool recurse);
522 
536  void
537  doExport(const Path & from_path,
538  const Path & to_path,
539  const Revision & revision,
540  bool overwrite = false,
541  const Revision & peg_revision = Revision::UNSPECIFIED,
542  bool ignore_externals = false,
543  svn_depth_t depth = svn_depth_infinity,
544  const char * native_eol = NULL);
545 
551  svn_revnum_t
552  doSwitch(const Path & path, const char * url,
553  const Revision & revision,
554  bool recurse);
555 
565  void
566  import(const Path & path,
567  const char * url,
568  const char * message,
569  bool recurse);
570  void
571  import(const Path & path,
572  const Path & url,
573  const char * message,
574  bool recurse);
575 
576 
581  void
582  merge(const Path & path1, const Revision & revision1,
583  const Path & path2, const Revision & revision2,
584  const Path & localPath, bool force,
585  bool recurse,
586  bool notice_ancestry = false,
587  bool dry_run = false);
588 
589 
603  InfoVector
604  info(const Path & pathOrUrl,
605  bool recurse=false,
606  const Revision & revision = Revision::UNSPECIFIED,
607  const Revision & pegRevision = Revision::UNSPECIFIED);
608 
609 
626  const LogEntries *
627  log(const char * path,
628  const Revision & revisionStart,
629  const Revision & revisionEnd,
630  bool discoverChangedPaths = false,
631  bool strictNodeHistory = true);
632 
651  const LogEntries *
652  log(const char * path,
653  const Revision & revisionStart,
654  const Revision & revisionEnd,
655  const int limit,
656  bool discoverChangedPaths = false,
657  bool strictNodeHistory = true);
658 
681  std::string
682  diff(const Path & tmpPath, const Path & path,
683  const Revision & revision1, const Revision & revision2,
684  const bool recurse, const bool ignoreAncestry,
685  const bool noDiffDeleted);
686 
710  std::string
711  diff(const Path & tmpPath, const Path & path1, const Path & path2,
712  const Revision & revision1, const Revision & revision2,
713  const bool recurse, const bool ignoreAncestry,
714  const bool noDiffDeleted);
715 
739  std::string
740  diff(const Path & tmpPath, const Path & path,
741  const Revision & pegRevision, const Revision & revision1,
742  const Revision & revision2, const bool recurse,
743  const bool ignoreAncestry, const bool noDiffDeleted);
744 
756  DirEntries
757  list(const char * pathOrUrl,
758  svn_opt_revision_t * revision,
759  bool recurse);
760 
772  proplist(const Path &path,
773  const Revision &revision,
774  bool recurse = false);
775 
788  propget(const char * propName,
789  const Path & path,
790  const Revision & revision,
791  bool recurse = false);
792 
810  void
811  propset(const char * propName,
812  const char * propValue,
813  const Path & path,
814  const Revision & revision,
815  bool recurse = false,
816  bool skip_checks = true);
817 
828  void
829  propdel(const char * propName,
830  const Path & path,
831  const Revision & revision,
832  bool recurse = false);
833 
834 
844  std::pair<svn_revnum_t,PropertiesMap>
845  revproplist(const Path & path,
846  const Revision & revision);
847 
858  std::pair<svn_revnum_t,std::string>
859  revpropget(const char * propName,
860  const Path & path,
861  const Revision & revision);
862 
875  svn_revnum_t
876  revpropset(const char * propName,
877  const char * propValue,
878  const Path & path,
879  const Revision & revision,
880  bool force = false);
881 
893  svn_revnum_t
894  revpropdel(const char * propName,
895  const Path & path,
896  const Revision & revision,
897  bool force = false);
898 
899 
907  void
908  ignore(const Path & path);
909 
917  void
918  ignore(const Targets & targets);
919  private:
920  Context * m_context;
921  CommitInfo m_commitInfo;
922 
926  Client & operator= (const Client &);
927 
931  Client(const Client &);
932  };
933 }
934 
935 #endif
936 /* -----------------------------------------------------------------
937  * local variables:
938  * eval: (load-file "../../rapidsvn-dev.el")
939  * end:
940  */
void upgrade(const Path &path)
static const Revision UNSPECIFIED
Definition: revision.hpp:55
bool showExternals
Definition: client.hpp:88
svn_revnum_t commit(const Targets &targets, const char *message, bool recurse, bool keep_locks=false)
InfoVector info(const Path &pathOrUrl, bool recurse=false, const Revision &revision=Revision::UNSPECIFIED, const Revision &pegRevision=Revision::UNSPECIFIED)
void propdel(const char *propName, const Path &path, const Revision &revision, bool recurse=false)
Definition: targets.hpp:43
std::vector< Status > StatusEntries
Definition: client.hpp:64
std::string cat(const Path &path, const Revision &revision, const Revision &peg_revision=Revision::UNSPECIFIED)
void relocate(const Path &path, const char *from_url, const char *to_url, bool recurse)
std::vector< Info > InfoVector
Definition: client.hpp:62
void cleanup(const Path &path)
PathPropertiesMapList proplist(const Path &path, const Revision &revision, bool recurse=false)
std::string author
Definition: client.hpp:107
void mkdir(const Path &path)
void add(const Path &path, bool recurse)
virtual ~Client()
std::vector< svn_revnum_t > update(const Targets &targets, const Revision &revision, svn_depth_t depth, bool depth_is_sticky, bool ignore_externals)
Definition: revision.hpp:42
void propset(const char *propName, const char *propValue, const Path &path, const Revision &revision, bool recurse=false, bool skip_checks=true)
DirEntries list(const char *pathOrUrl, svn_opt_revision_t *revision, bool recurse)
bool showUnversioned
Definition: client.hpp:83
std::string diff(const Path &tmpPath, const Path &path, const Revision &revision1, const Revision &revision2, const bool recurse, const bool ignoreAncestry, const bool noDiffDeleted)
Definition: context.hpp:48
Definition: path.hpp:37
bool showConflicted
Definition: client.hpp:86
void unlock(const Targets &targets, bool force)
std::vector< LogEntry > LogEntries
Definition: client.hpp:63
const Context * getContext() const
bool showIgnored
Definition: client.hpp:87
Definition: annotate_line.hpp:31
std::vector< AnnotateLine > AnnotatedFile
Definition: client.hpp:58
Definition: client.hpp:80
svn_revnum_t revpropset(const char *propName, const char *propValue, const Path &path, const Revision &revision, bool force=false)
const CommitInfo & commitInfo() const
Definition: client.hpp:146
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)
std::pair< svn_revnum_t, std::string > revpropget(const char *propName, const Path &path, const Revision &revision)
bool showUnmodified
Definition: client.hpp:84
const LogEntries * log(const char *path, const Revision &revisionStart, const Revision &revisionEnd, bool discoverChangedPaths=false, bool strictNodeHistory=true)
void lock(const Targets &targets, bool force, const char *comment)
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)
AnnotatedFile * annotate(const Path &path, const Revision &revisionStart, const Revision &revisionEnd)
std::vector< DirEntry > DirEntries
Definition: client.hpp:61
bool showModified
this includes showConflicted as well
Definition: client.hpp:85
svn_revnum_t revpropdel(const char *propName, const Path &path, const Revision &revision, bool force=false)
CommitInfo(const svn_commit_info_t *info)
Definition: client.hpp:117
std::string date
Definition: client.hpp:104
void vacuum(const Path &path, bool removeUnversioned, bool removeIgnored, bool fixTimestamps, bool vacuumPristines, bool includeExternals)
svn_revnum_t doSwitch(const Path &path, const char *url, const Revision &revision, bool recurse)
void ignore(const Path &path)
svn_revnum_t revision
Definition: client.hpp:101
PathPropertiesMapList propget(const char *propName, const Path &path, const Revision &revision, bool recurse=false)
std::string postCommitErr
Definition: client.hpp:110
std::vector< PathPropertiesMapEntry > PathPropertiesMapList
Definition: client.hpp:72
void revert(const Targets &targets, bool recurse)
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)
std::pair< svn_revnum_t, PropertiesMap > revproplist(const Path &path, const Revision &revision)
CommitInfo()
Definition: client.hpp:112
void move(const Path &srcPath, const Revision &srcRevision, const Path &destPath, bool force)
std::map< std::string, std::string > PropertiesMap
Definition: client.hpp:68
void setContext(Context *context=NULL)
Definition: client.hpp:99
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)
void resolved(const Path &path, bool recurse)
void copy(const Path &srcPath, const Revision &srcRevision, const Path &destPath)
Client(Context *context=0)
StatusFilter()
Definition: client.hpp:90
std::pair< std::string, PropertiesMap > PathPropertiesMapEntry
Definition: client.hpp:70
Definition: client.hpp:133