summaryrefslogtreecommitdiffstats
path: root/src/svnqt/conflictresult.cpp
blob: 0465e334a89178bd165095d45d5481bec8a96ec3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/***************************************************************************
 *   Copyright (C) 2007 by Rajko Albrecht  ral@alwins-world.de             *
 *   http://kdesvn.alwins-world.de/                                        *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include "conflictresult.hpp"

#include "svnqt_defines.hpp"

#include <svn_wc.h>

namespace svn
{
    ConflictResult::ConflictResult()
    :m_choice(ChooseMerged),m_MergedFile(QString::null)
    {
    }

    ConflictResult::ConflictResult(const svn_wc_conflict_result_t*aResult)
    {
        if (!aResult){
            return;
        }
#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 5)) || (SVN_VER_MAJOR > 1)
        switch (aResult->choice){
            case svn_wc_conflict_choose_base:
                m_choice=ChooseBase;
                break;
            case svn_wc_conflict_choose_theirs_full:
                m_choice=ChooseTheirsFull;
                break;
            case svn_wc_conflict_choose_mine_full:
                m_choice=ChooseMineFull;
                break;
            case svn_wc_conflict_choose_theirs_conflict:
                m_choice=ChooseTheirsConflict;
                break;
            case svn_wc_conflict_choose_mine_conflict:
                m_choice=ChooseMineConflict;
                break;
            case svn_wc_conflict_choose_merged:
                m_choice=ChooseMerged;
                break;
            case svn_wc_conflict_choose_postpone:
            default:
                m_choice=ChoosePostpone;
                break;
        }
        if (aResult->merged_file) {
            m_MergedFile=QString::FROMUTF8(aResult->merged_file);
        } else {
            m_MergedFile=QString::null;
        }
#else
        Q_UNUSED(aResult);
#endif
    }

    void ConflictResult::setMergedFile(const QString&aMergedfile) {
        m_MergedFile=aMergedfile;
    }

    void ConflictResult::setChoice(ConflictChoice aValue)
    {
        m_choice=aValue;
    }

    void ConflictResult::assignResult(svn_wc_conflict_result_t**aResult,const Pool&pool)const
    {
#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 5)) || (SVN_VER_MAJOR > 1)
        svn_wc_conflict_choice_t _choice;
        switch (choice()) {
            case ConflictResult::ChooseBase:
                _choice=svn_wc_conflict_choose_base;
                break;
            case ConflictResult::ChooseTheirsFull:
                _choice=svn_wc_conflict_choose_theirs_full;
                break;
            case ConflictResult::ChooseMineFull:
                _choice=svn_wc_conflict_choose_mine_full;
                break;
            case ConflictResult::ChooseTheirsConflict:
                _choice=svn_wc_conflict_choose_theirs_conflict;
                break;
            case ConflictResult::ChooseMineConflict:
                _choice=svn_wc_conflict_choose_mine_conflict;
                break;
            case ConflictResult::ChooseMerged:
                _choice=svn_wc_conflict_choose_merged;
                break;
            case ConflictResult::ChoosePostpone:
            default:
                _choice=svn_wc_conflict_choose_postpone;
                break;

        }
        const char* _merged_file = mergedFile().isNull()?0:apr_pstrdup (pool,mergedFile().TOUTF8());
        if ((*aResult)==0) {
            (*aResult) = svn_wc_create_conflict_result(_choice,_merged_file,pool);
        } else {
            (*aResult)->choice=_choice;
            (*aResult)->merged_file=_merged_file;
        }
#else
        Q_UNUSED(aResult);
        Q_UNUSED(pool);
#endif
    }

    const svn_wc_conflict_result_t*ConflictResult::result(const Pool&pool)const
    {
        svn_wc_conflict_result_t*result=0;
        assignResult(&result,pool);
        return result;
    }
}