File indexing completed on 2024-05-12 17:16:22

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2009 by Rajko Albrecht                             *
0003  *   ral@alwins-world.de                                                   *
0004  *                                                                         *
0005  * This program is free software; you can redistribute it and/or           *
0006  * modify it under the terms of the GNU Lesser General Public              *
0007  * License as published by the Free Software Foundation; either            *
0008  * version 2.1 of the License, or (at your option) any later version.      *
0009  *                                                                         *
0010  * This program is distributed in the hope that it will be useful,         *
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0013  * Lesser General Public License for more details.                         *
0014  *                                                                         *
0015  * You should have received a copy of the GNU Lesser General Public        *
0016  * License along with this program (in the file LGPL.txt); if not,         *
0017  * write to the Free Software Foundation, Inc., 51 Franklin St,            *
0018  * Fifth Floor, Boston, MA  02110-1301  USA                                *
0019  *                                                                         *
0020  * This software consists of voluntary contributions made by many          *
0021  * individuals.  For exact contribution history, see the revision          *
0022  * history and logs, available at http://kdesvn.alwins-world.de.           *
0023  ***************************************************************************/
0024 /*!
0025  * \file client_parameter.h
0026  * \brief defining classes working as named parameters for different subversion methods
0027  *
0028  * Subversion has various functions which has growing / changing parameter lists from version to version.
0029  * since subversion 1.4 this changes are more and more unhandy for a c++ wrapper due every time changes to
0030  * virtual class. This special data containers may reduce changes of signatures to the client interface.
0031  */
0032 
0033 #ifndef CLIENT_PARAMETER_H
0034 #define CLIENT_PARAMETER_H
0035 
0036 #include <svnqt/svnqt_defines.h>
0037 #include <svnqt/svnqttypes.h>
0038 #include <svnqt/revision.h>
0039 #include <svnqt/targets.h>
0040 #include <svnqt/path.h>
0041 #include <QScopedPointer>
0042 
0043 namespace svn
0044 {
0045 
0046 struct CopyParameterData;
0047 
0048 //! parameter for svn_copy wrapper
0049 /*!
0050  * This class should never contains virtual methods. New Methods are always appended at end of class definition
0051  * \sa svn::Client::copy
0052  */
0053 class SVNQT_EXPORT CopyParameter
0054 {
0055 private:
0056     QScopedPointer<CopyParameterData> _data;
0057 public:
0058     CopyParameter(const Targets &_srcPath, const Path &_destPath);
0059     ~CopyParameter();
0060 
0061     //! Targets for copy operation
0062     const Targets &srcPath()const;
0063     //! Targets for copy operation
0064     CopyParameter &srcPath(const Targets &_srcPath);
0065     //! Destination path for copy operation
0066     const Path &destination()const;
0067     //! Destination path for copy operation
0068     CopyParameter &destination(const Path &destination);
0069 
0070     //! set copy operation parameter asChild to true
0071     CopyParameter &asChild(bool);
0072     //! return value for asChild
0073     bool asChild()const;
0074 
0075     //! copy should ignore externals
0076     /*!
0077      * \since subversion 1.6
0078      */
0079     CopyParameter &ignoreExternal(bool);
0080     //! return externals has to ignored
0081     /*!
0082      * \since subversion 1.6
0083      */
0084     bool ignoreExternal()const;
0085 
0086     //! set copy/move operation parameter makeParent
0087     CopyParameter &makeParent(bool);
0088     //! return value for asChild
0089     bool makeParent()const;
0090 
0091     //! set the source revision for the copy operation
0092     CopyParameter &srcRevision(const Revision &);
0093     //! get the source revision for the copy operation
0094     const Revision &srcRevision()const;
0095     //! set the peg revision for the copy operation
0096     CopyParameter &pegRevision(const Revision &);
0097     //! get the peg revision for the copy operation
0098     const Revision &pegRevision()const;
0099 
0100     //! set the properties map for the copy operation
0101     CopyParameter &properties(const PropertiesMap &);
0102     //! get the properties map for the copy operation
0103     const PropertiesMap &properties()const;
0104 
0105 };
0106 
0107 struct DiffParameterData;
0108 
0109 //! parameter for svn_diff and svn_diff_peg wrapper
0110 /*!
0111  * This class should never contains virtual methods. New Methods are always appended at end of class definition
0112  * \sa svn::Client::diff svn::Client::diff_peg
0113  */
0114 class SVNQT_EXPORT DiffParameter
0115 {
0116 private:
0117     QScopedPointer<DiffParameterData> _data;
0118 public:
0119     DiffParameter();
0120     ~DiffParameter();
0121 
0122     //! Changelist filter
0123     /*!
0124      * if empty. no filtering is done
0125      * \since subversion 1.5
0126      * \sa svn_client_diff4
0127      */
0128     const svn::StringArray &changeList()const;
0129     //! type of recurse operation
0130     /*!
0131      * \sa svn::Depth
0132      */
0133     Depth depth()const;
0134     //! extra options for diff ("-b", "-w","--ignore-eol-style")
0135     const svn::StringArray &extra()const;
0136     //! whether the files will be checked for relatedness.
0137     bool ignoreAncestry()const;
0138     //! if true generate diff even the items are marked as binaries
0139     bool ignoreContentType()const;
0140     //! if true, no diff output will be generated on deleted files.
0141     bool noDiffDeleted()const;
0142     //! first file or folder to diff.
0143     const Path &path1()const;
0144     //! second file or folder to diff.
0145     /*!
0146      * this is ignored for diff_peg calls
0147      */
0148     const Path &path2()const;
0149     //! peg revision (only used for diff_peg)
0150     const svn::Revision &peg()const;
0151     //! if set, all pathes are related to this folder
0152     /*!
0153      * Must not be an url! May be empty
0154      */
0155     const Path &relativeTo()const;
0156     //! one of the revisions to check (path1).
0157     const svn::Revision &rev1()const;
0158     //! the other revision (path2 for non peg diff).
0159     const svn::Revision &rev2()const;
0160     //! prefix for a temporary directory needed by diff.
0161     /*!
0162      * Filenames will have ".tmp" and similar added to this prefix in
0163      * order to ensure uniqueness.
0164      */
0165     const Path &tmpPath()const;
0166 
0167     DiffParameter &path1(const Path &path);
0168     DiffParameter &path2(const Path &path);
0169     DiffParameter &tmpPath(const Path &path);
0170     DiffParameter &relativeTo(const Path &path);
0171     DiffParameter &depth(Depth _depth);
0172     DiffParameter &changeList(const svn::StringArray &changeList);
0173     DiffParameter &extra(const svn::StringArray &_extra);
0174     DiffParameter &ignoreAncestry(bool value);
0175     DiffParameter &ignoreContentType(bool value);
0176     DiffParameter &peg(const svn::Revision &_rev);
0177     DiffParameter &rev1(const svn::Revision &_rev);
0178     DiffParameter &rev2(const svn::Revision &_rev);
0179     DiffParameter &noDiffDeleted(bool value);
0180 
0181     //! use gits diff format
0182     /*!
0183      * \since subversion  1.7
0184      * \sa svn_client_diff_peg5,svn_client_diff5
0185      */
0186     DiffParameter &git_diff_format(bool value);
0187     //! use gits diff format
0188     /*!
0189      * \since subversion  1.7
0190      * \sa svn_client_diff_peg5,svn_client_diff5
0191      */
0192     bool git_diff_format()const;
0193 
0194     //! show copies as new add
0195     /*!
0196      * \since subversion  1.7
0197      * \sa svn_client_diff_peg5,svn_client_diff5
0198      */
0199     DiffParameter &copies_as_adds(bool value);
0200     //! show copies as new add
0201     /*!
0202      * \since subversion  1.7
0203      * \sa svn_client_diff_peg5,svn_client_diff5
0204      */
0205     bool copies_as_adds()const;
0206 
0207 
0208 };
0209 
0210 struct StatusParameterData;
0211 
0212 class SVNQT_EXPORT StatusParameter
0213 {
0214 private:
0215     QScopedPointer<StatusParameterData> _data;
0216 public:
0217     explicit StatusParameter(const Path &_path = Path());
0218     ~StatusParameter();
0219 
0220     //! path to explore
0221     const Path &path()const;
0222     StatusParameter &path(const Path &_path);
0223     //! list specific revision when browsing remote, on working copies parameter will ignored
0224     const Revision &revision()const;
0225     StatusParameter &revision(const Revision &rev);
0226     //! recursion level
0227     Depth depth()const;
0228     StatusParameter &depth(Depth d);
0229     //! Return all entries, not just the interesting ones.
0230     bool all()const;
0231     StatusParameter &all(bool getall);
0232     //! Query the repository for updates.
0233     bool update()const;
0234     StatusParameter &update(bool updates);
0235     //! Disregard default and svn:ignore property ignores.
0236     bool noIgnore()const;
0237     StatusParameter &noIgnore(bool noignore);
0238     //! don't recurse into external definitions
0239     bool ignoreExternals()const;
0240     StatusParameter &ignoreExternals(bool noexternals);
0241     const StringArray &changeList()const;
0242     StatusParameter &changeList(const StringArray &list);
0243     //!if on remote listing detailed item info should get if possible
0244     /*! that may slow so should configureable in frontends!
0245      */
0246     bool detailedRemote()const;
0247     StatusParameter &detailedRemote(bool value);
0248 };
0249 
0250 struct LogParameterData;
0251 
0252 class SVNQT_EXPORT LogParameter
0253 {
0254 private:
0255     QScopedPointer<LogParameterData> _data;
0256 
0257 public:
0258     LogParameter();
0259     ~LogParameter();
0260 
0261     //! items to get the logs for
0262     const Targets &targets()const;
0263     //! set items to get the logs for
0264     LogParameter &targets(const Targets &targets);
0265     //! range of revisions getting logs for
0266     /*!
0267      * when build against subversion prior 1.6 only the first pair is used!
0268      */
0269     const RevisionRanges &revisions()const;
0270     //! set range of revisions getting logs for
0271     LogParameter &revisions(const RevisionRanges &revisions);
0272     //! simple start-end range.
0273     /*!
0274      * in fact it is the first item in internal revision range. May used when only one pair is required.
0275      */
0276     const RevisionRange &revisionRange()const;
0277     //! set a simple start-end range
0278     /*!
0279      * this is useful if only one range is required. This will converted into internal ranges when set.
0280      */
0281     LogParameter &revisionRange(const Revision &start, const Revision &end);
0282 
0283     //! the peg revision to use
0284     const Revision &peg()const;
0285     //! set the peg revision to use
0286     LogParameter &peg(const Revision &peg);
0287     //! if not zero limit logs to this count
0288     int limit()const;
0289     LogParameter &limit(int limit);
0290     bool discoverChangedPathes()const;
0291     LogParameter &discoverChangedPathes(bool value);
0292     bool strictNodeHistory()const;
0293     LogParameter &strictNodeHistory(bool value);
0294     bool includeMergedRevisions()const;
0295     LogParameter &includeMergedRevisions(bool value);
0296     const StringArray &revisionProperties()const;
0297     LogParameter &revisionProperties(const StringArray &props);
0298     const StringArray &excludeList()const;
0299     LogParameter &excludeList(const StringArray &props);
0300 };
0301 
0302 struct PropertiesParameterData;
0303 
0304 class SVNQT_EXPORT PropertiesParameter
0305 {
0306 private:
0307     QScopedPointer<PropertiesParameterData> _data;
0308 public:
0309     PropertiesParameter();
0310     ~PropertiesParameter();
0311 
0312     PropertiesParameter &propertyName(const QString &);
0313     const QString &propertyName()const;
0314 
0315     PropertiesParameter &propertyValue(const QString &);
0316     const QString &propertyValue()const;
0317 
0318     //! Old value to check against
0319     /*!
0320      * used for revpropset only
0321      */
0322     PropertiesParameter &propertyOriginalValue(const QString &);
0323     const QString &propertyOriginalValue()const;
0324 
0325     //! path or url
0326     PropertiesParameter &path(const Path &);
0327     const Path &path()const;
0328 
0329     //! set on revision
0330     /*! for revpropset it should be a valid Revision, for propset it should be INVALID
0331      * if url is a local path otherwise it must be a valid revision.
0332      */
0333     PropertiesParameter &revision(const Revision &);
0334     //! set/get on revision
0335     /*! for revpropset it should be a valid Revision, for propset it should be INVALID
0336      * if url is a local path otherwise it must be a valid revision.
0337      */
0338     const Revision &revision()const;
0339 
0340     //! allow newlines in author property
0341     /*!
0342      * used for revprop_set only
0343      */
0344     PropertiesParameter &force(bool);
0345     //! allow newlines in author property
0346     /*!
0347      * used for revprop_set only
0348      */
0349     bool force()const;
0350 
0351     //! set depth of operation
0352     /*!
0353      * used for local propset only
0354      */
0355     PropertiesParameter &depth(Depth depth);
0356     //! depth of operation
0357     /*!
0358      * used for local propset only
0359      */
0360     Depth depth()const;
0361 
0362     //! set skip check
0363     /*!
0364      * used for local propset only
0365      */
0366     PropertiesParameter &skipCheck(bool value);
0367     //! skip check
0368     /*!
0369      * used for local propset only
0370      */
0371     bool skipCheck()const;
0372 
0373     //! set filter list. if empty no filtering is done
0374     /*!
0375      * used for local propset only
0376      */
0377     PropertiesParameter &changeList(const StringArray &_list);
0378     //! filter list. if empty no filtering is done
0379     /*!
0380      * used for local propset only
0381      */
0382     const StringArray &changeList()const;
0383 
0384     PropertiesParameter &revisionProperties(const PropertiesMap &props);
0385     const PropertiesMap &revisionProperties()const;
0386 };
0387 
0388 struct MergeParameterData;
0389 
0390 /**
0391  * Wrapper for all mergeparameters.
0392  */
0393 class SVNQT_EXPORT MergeParameter
0394 {
0395 private:
0396     QScopedPointer<MergeParameterData> _data;
0397 public:
0398     MergeParameter();
0399     ~MergeParameter();
0400 
0401     MergeParameter &path1(const Path &path);
0402     const Path &path1()const;
0403     MergeParameter &path2(const Path &path);
0404     const Path &path2()const;
0405     MergeParameter &localPath(const Path &path);
0406     const Path &localPath()const;
0407 
0408     /*!
0409      * used for Client::merge_peg only, when build against subversion prior 1.6 only the first pair is used!
0410      */
0411     MergeParameter &peg(const Revision &rev);
0412     /*!
0413      * used for Client::merge_peg only or reintegrate merge
0414      */
0415     const Revision &peg()const;
0416     /*!
0417      * used for Client::merge_peg only, when build against subversion prior 1.6 only the first pair is used!
0418      */
0419     MergeParameter &revisions(const RevisionRanges &revs);
0420     /*!
0421      * used for Client::merge_peg only, when build against subversion prior 1.6 only the first pair is used!
0422      */
0423     const RevisionRanges &revisions()const;
0424     //! simple start-end range.
0425     /*!
0426      * in fact it is the first item in internal revision range. May used when only one pair is required.
0427      * used for Client::merge, pair is [start,end], with subversion prior 1.6 for Client::merge_peg, too.
0428      */
0429     const RevisionRange &revisionRange()const;
0430     //! set a simple start-end range
0431     /*!
0432      * this is useful if only one range is required. This will converted into internal ranges when set.
0433      * used for Client::merge, pair is [rev1,rev2], with subversion prior 1.6 for Client::merge_peg, too.
0434      */
0435     MergeParameter &revisionRange(const Revision &start, const Revision &end);
0436 
0437     //! get start revision
0438     /*!
0439      * used for Client::merge. Revision1 is the first item in first pair of Revision ranges
0440      */
0441     const Revision &revision1()const;
0442     //! get end revision
0443     /*!
0444      * used for Client::merge. Revision2 is the second item in first pair of Revision ranges
0445      */
0446     const Revision &revision2()const;
0447 
0448     MergeParameter &force(bool how);
0449     bool force()const;
0450     MergeParameter &notice_ancestry(bool how);
0451     bool notice_ancestry()const;
0452     MergeParameter &dry_run(bool how);
0453     bool dry_run()const;
0454     MergeParameter &record_only(bool how);
0455     bool record_only()const;
0456 
0457     MergeParameter &depth(Depth depth);
0458     Depth depth()const;
0459 
0460     MergeParameter &merge_options(const StringArray &options);
0461     const StringArray &merge_options()const;
0462 
0463     /**
0464      * @param reintegrate must be true if this parameter are for a reintegrate merge.
0465      */
0466     MergeParameter &reintegrate(bool reintegrate);
0467     /**
0468      * Check whether the parameters are for a reintegrate merge or not. If yes, than parameters are used as follows:
0469      *   - peg() - setup the required peg revision
0470      *   - path1() gives the source path
0471      *   - localPath() the local working copy to merge into
0472      *   - dry_run() run without real modifications
0473      *   - merge_options() all other svn options for merge
0474      *
0475      * All other parameters are ignored in that case.
0476      */
0477     bool reintegrate()const;
0478 
0479     /**
0480      * @param allow_mixed_rev true if merging into mixed rev working copy is allowed. If false, merge fails if mixed rev WC
0481      * @since subversion 1.7
0482      */
0483     MergeParameter &allow_mixed_rev(bool allow_mixed_rev);
0484     bool allow_mixed_rev()const;
0485 };
0486 
0487 struct CheckoutParameterData;
0488 //! parameter for Checkout and Export
0489 class SVNQT_EXPORT CheckoutParameter
0490 {
0491 private:
0492     QScopedPointer<CheckoutParameterData> _data;
0493 
0494 public:
0495     CheckoutParameter();
0496     ~CheckoutParameter();
0497 
0498     //!name of the module to checkout.
0499     CheckoutParameter &moduleName(const Path &path);
0500     //!name of the module to checkout.
0501     const Path &moduleName()const;
0502     //!destination directory for checkout.
0503     CheckoutParameter &destination(const Path &path);
0504     //!destination directory for checkout.
0505     const Path &destination()const;
0506     //!the revision number to checkout.
0507     /*! If the number is -1
0508      *  then it will checkout the latest revision.
0509      */
0510     CheckoutParameter &revision(const Revision &rev);
0511     //!the revision number to checkout.
0512     /*! If the number is -1
0513      *  then it will checkout the latest revision.
0514      */
0515     const Revision &revision()const;
0516     //! Revision to look up
0517     CheckoutParameter &peg(const Revision &rev);
0518     //! Revision to look up
0519     const Revision &peg()const;
0520     //! depth of operation
0521     /*!
0522      * \sa svn::Depth
0523      */
0524     CheckoutParameter &depth(Depth depth);
0525     //! depth of operation
0526     /*!
0527      * \sa svn::Depth
0528      */
0529     Depth depth()const;
0530     //!if true don't process externals definitions.
0531     CheckoutParameter &ignoreExternals(bool ignore);
0532     //!if true don't process externals definitions.
0533     bool ignoreExternals()const;
0534     //!if true overwrite existing not versioned items.
0535     CheckoutParameter &overWrite(bool overwrite);
0536     //!if true overwrite existing not versioned items.
0537     bool overWrite()const;
0538     //! do not replace svn:keywords on export
0539     bool ignoreKeywords()const;
0540     CheckoutParameter &ignoreKeywords(bool ignorekeywords);
0541 
0542     //!Either "LF", "CR" or "CRLF" or QString().
0543     /*!
0544      * Used only from Client::doExport, QString() is default (will used as NULL for subversion)
0545      */
0546     CheckoutParameter &nativeEol(const QString &native);
0547     //!Either "LF", "CR" or "CRLF" or QString().
0548     /*!
0549      * Used only from Client::doExport, QString() is default (will used as NULL for subversion)
0550      */
0551     const QString &nativeEol()const;
0552 };
0553 }
0554 
0555 
0556 #endif