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

0001 /***************************************************************************
0002  *   Copyright (C) 2008-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 "conflictdescription.h"
0025 #include "svnqt_defines.h"
0026 
0027 #include <svn_wc.h>
0028 #include "helper.h"
0029 
0030 namespace svn
0031 {
0032 
0033 ConflictDescription::~ConflictDescription()
0034 {
0035 }
0036 
0037 ConflictDescription::ConflictDescription(const svn_wc_conflict_description2_t *conflict)
0038 {
0039     init();
0040     if (!conflict) {
0041         return;
0042     }
0043     m_baseFile = QString::fromUtf8(conflict->base_abspath);
0044     m_mergedFile = QString::fromUtf8(conflict->merged_file);
0045     m_mimeType = QString::fromUtf8(conflict->mime_type);
0046     m_myFile = QString::fromUtf8(conflict->my_abspath);
0047     m_Path = QString::fromUtf8(conflict->local_abspath);
0048     m_propertyName = QString::fromUtf8(conflict->property_name);
0049     m_theirFile = QString::fromUtf8(conflict->their_abspath);
0050     switch (conflict->action) {
0051     case svn_wc_conflict_action_edit:
0052         m_action = ConflictAction::Edit;
0053         break;
0054     case svn_wc_conflict_action_add:
0055         m_action = ConflictAction::Add;
0056         break;
0057     case svn_wc_conflict_action_delete:
0058         m_action = ConflictAction::Delete;
0059         break;
0060     case svn_wc_conflict_action_replace:
0061         m_action = ConflictAction::Replace;
0062         break;
0063     }
0064     switch (conflict->kind) {
0065     case svn_wc_conflict_kind_text:
0066         m_Type = ConflictType::Text;
0067         break;
0068     case svn_wc_conflict_kind_property:
0069         m_Type = ConflictType::Property;
0070         break;
0071     case svn_wc_conflict_kind_tree:
0072         m_Type = ConflictType::Tree;
0073         break;
0074     }
0075     m_nodeKind = conflict->node_kind;
0076     m_binary = conflict->is_binary;
0077     switch (conflict->reason) {
0078     case svn_wc_conflict_reason_edited:
0079         m_reason = ConflictReason::Edited;
0080         break;
0081     case svn_wc_conflict_reason_obstructed:
0082         m_reason = ConflictReason::Obstructed;
0083         break;
0084     case svn_wc_conflict_reason_deleted:
0085         m_reason = ConflictReason::Deleted;
0086         break;
0087     case svn_wc_conflict_reason_missing:
0088         m_reason = ConflictReason::Missing;
0089         break;
0090     case svn_wc_conflict_reason_unversioned:
0091         m_reason = ConflictReason::Unversioned;
0092         break;
0093     case svn_wc_conflict_reason_added:
0094         m_reason = ConflictReason::Added;
0095         break;
0096     case svn_wc_conflict_reason_replaced:
0097         m_reason = ConflictReason::Replaced;
0098         break;
0099 #if SVN_API_VERSION >= SVN_VERSION_CHECK(1,8,0)
0100     case svn_wc_conflict_reason_moved_away:
0101         m_reason = ConflictReason::MovedAway;
0102         break;
0103     case svn_wc_conflict_reason_moved_here:
0104         m_reason = ConflictReason::MovedHere;
0105         break;
0106 #endif
0107     }
0108 }
0109 
0110 ConflictDescription::ConflictDescription(const svn_wc_conflict_description_t *conflict)
0111     : m_pool()
0112 {
0113     init();
0114     if (!conflict) {
0115         return;
0116     }
0117     m_baseFile = QString::fromUtf8(conflict->base_file);
0118     m_mergedFile = QString::fromUtf8(conflict->merged_file);
0119     m_mimeType = QString::fromUtf8(conflict->mime_type);
0120     m_myFile = QString::fromUtf8(conflict->my_file);
0121     m_Path = QString::fromUtf8(conflict->path);
0122     m_propertyName = QString::fromUtf8(conflict->property_name);
0123     m_theirFile = QString::fromUtf8(conflict->their_file);
0124     switch (conflict->action) {
0125     case svn_wc_conflict_action_edit:
0126         m_action = ConflictAction::Edit;
0127         break;
0128     case svn_wc_conflict_action_add:
0129         m_action = ConflictAction::Add;
0130         break;
0131     case svn_wc_conflict_action_delete:
0132         m_action = ConflictAction::Delete;
0133         break;
0134     case svn_wc_conflict_action_replace:
0135         m_action = ConflictAction::Replace;
0136         break;
0137     }
0138     switch (conflict->kind) {
0139     case svn_wc_conflict_kind_text:
0140         m_Type = ConflictType::Text;
0141         break;
0142     case svn_wc_conflict_kind_property:
0143         m_Type = ConflictType::Property;
0144         break;
0145     case svn_wc_conflict_kind_tree:
0146         m_Type = ConflictType::Tree;
0147         break;
0148     }
0149     m_nodeKind = conflict->node_kind;
0150     m_binary = conflict->is_binary;
0151     switch (conflict->reason) {
0152     case svn_wc_conflict_reason_edited:
0153         m_reason = ConflictReason::Edited;
0154         break;
0155     case svn_wc_conflict_reason_obstructed:
0156         m_reason = ConflictReason::Obstructed;
0157         break;
0158     case svn_wc_conflict_reason_deleted:
0159         m_reason = ConflictReason::Deleted;
0160         break;
0161     case svn_wc_conflict_reason_missing:
0162         m_reason = ConflictReason::Missing;
0163         break;
0164     case svn_wc_conflict_reason_unversioned:
0165         m_reason = ConflictReason::Unversioned;
0166         break;
0167     case svn_wc_conflict_reason_added:
0168         m_reason = ConflictReason::Added;
0169         break;
0170     case svn_wc_conflict_reason_replaced:
0171         m_reason = ConflictReason::Replaced;
0172         break;
0173 #if SVN_API_VERSION >= SVN_VERSION_CHECK(1,8,0)
0174     case svn_wc_conflict_reason_moved_away:
0175         m_reason = ConflictReason::MovedAway;
0176         break;
0177     case svn_wc_conflict_reason_moved_here:
0178         m_reason = ConflictReason::MovedHere;
0179         break;
0180 #endif
0181     }
0182 }
0183 
0184 }
0185 
0186 svn::ConflictDescription::ConflictAction svn::ConflictDescription::action() const
0187 {
0188     return m_action;
0189 }
0190 
0191 const QString &svn::ConflictDescription::baseFile() const
0192 {
0193     return m_baseFile;
0194 }
0195 
0196 
0197 /*!
0198     \fn svn::ConflictDescription::init()
0199  */
0200 void svn::ConflictDescription::init()
0201 {
0202     m_action = ConflictAction::Edit;
0203     m_Type = ConflictType::Text;
0204     m_reason = ConflictReason::Edited;
0205     m_binary = false;
0206     m_nodeKind = svn_node_unknown;
0207 }
0208 
0209 
0210 bool svn::ConflictDescription::binary() const
0211 {
0212     return m_binary;
0213 }
0214 
0215 
0216 const QString &svn::ConflictDescription::mergedFile() const
0217 {
0218     return m_mergedFile;
0219 }
0220 
0221 
0222 const QString &svn::ConflictDescription::mimeType() const
0223 {
0224     return m_mimeType;
0225 }
0226 
0227 
0228 const QString &svn::ConflictDescription::myFile() const
0229 {
0230     return m_myFile;
0231 }
0232 
0233 
0234 svn_node_kind_t svn::ConflictDescription::nodeKind() const
0235 {
0236     return m_nodeKind;
0237 }
0238 
0239 
0240 const QString &svn::ConflictDescription::Path() const
0241 {
0242     return m_Path;
0243 }
0244 
0245 
0246 const QString &svn::ConflictDescription::propertyName() const
0247 {
0248     return m_propertyName;
0249 }
0250 
0251 
0252 svn::ConflictDescription::ConflictReason svn::ConflictDescription::reason() const
0253 {
0254     return m_reason;
0255 }
0256 
0257 
0258 const QString &svn::ConflictDescription::theirFile() const
0259 {
0260     return m_theirFile;
0261 }
0262 
0263 
0264 svn::ConflictDescription::ConflictType svn::ConflictDescription::Type() const
0265 {
0266     return m_Type;
0267 }