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

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2009 by Rajko Albrecht  ral@alwins-world.de        *
0003  *   http://kdesvn.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 #include "client_impl.h"
0025 
0026 // subversion api
0027 #include <svn_client.h>
0028 
0029 #include "exception.h"
0030 #include "pool.h"
0031 #include "targets.h"
0032 #include "svnqt_defines.h"
0033 #include "helper.h"
0034 #include "client_parameter.h"
0035 
0036 #include <QDebug>
0037 
0038 namespace svn
0039 {
0040 
0041 void Client_impl::merge_reintegrate(const MergeParameter &parameters)
0042 {
0043     Pool pool;
0044     svn_error_t *error = nullptr;
0045     error = svn_client_merge_reintegrate(parameters.path1().cstr(),
0046                                          parameters.peg().revision(),
0047                                          parameters.localPath().cstr(),
0048                                          parameters.dry_run(),
0049                                          parameters.merge_options().array(pool),
0050                                          *m_context,
0051                                          pool
0052                                         );
0053     if (error != nullptr) {
0054         throw ClientException(error);
0055     }
0056 }
0057 
0058 void Client_impl::merge(const MergeParameter &parameters)
0059 {
0060     Pool pool;
0061     svn_error_t *error = nullptr;
0062     if (parameters.reintegrate()) {
0063         merge_reintegrate(parameters);
0064     } else {
0065       // todo svn 1.8: svn_client_merge5
0066         error =
0067             svn_client_merge4
0068             (parameters.path1().cstr(),
0069              parameters.revision1().revision(),
0070              parameters.path2().cstr(),
0071              parameters.revision2().revision(),
0072              parameters.localPath().cstr(),
0073              internal::DepthToSvn(parameters.depth()),
0074              !parameters.notice_ancestry(),
0075              parameters.force(),
0076              parameters.record_only(),
0077              parameters.dry_run(),
0078              parameters.allow_mixed_rev(),
0079              parameters.merge_options().array(pool),
0080              *m_context,
0081              pool);
0082     }
0083 
0084     if (error != nullptr) {
0085         throw ClientException(error);
0086     }
0087 }
0088 
0089 void Client_impl::merge_peg(const MergeParameter &parameters)
0090 {
0091     Pool pool;
0092     internal::RevisionRangesToHash _rhash(parameters.revisions());
0093 
0094     // todo svn 1.8: svn_client_merge_peg5
0095     svn_error_t *error =
0096         svn_client_merge_peg4
0097         (
0098             parameters.path1().cstr(),
0099             _rhash.array(pool),
0100             parameters.peg(),
0101             parameters.localPath().cstr(),
0102             internal::DepthToSvn(parameters.depth()),
0103             !parameters.notice_ancestry(),
0104             parameters.force(),
0105             parameters.record_only(),
0106             parameters.dry_run(),
0107             parameters.allow_mixed_rev(),
0108             parameters.merge_options().array(pool),
0109             *m_context,
0110             pool
0111         );
0112     if (error != nullptr) {
0113         throw ClientException(error);
0114     }
0115 }
0116 }