summaryrefslogtreecommitdiffstats
path: root/src/svnqt/client_merge.cpp
blob: feb846c05888382bd7d67347050e4ed9bdc0ed95 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include "svnqt/client_impl.h"

// subversion api
#include "svn_client.h"

#include "svnqt/exception.h"
#include "svnqt/pool.h"
#include "svnqt/targets.h"
#include "svnqt/svnqt_defines.h"
#include "svnqt/stringarray.h"

#include "svnqt/helper.h"

namespace svn
{
void Client_impl::merge (const Path & path1, const Revision & revision1,
                 const Path & path2, const Revision & revision2,
                 const Path & localPath,
                 bool force,
                 Depth depth,
                 bool notice_ancestry,
                 bool dry_run,
                 bool record_only,
                 const StringArray&merge_options
                     )
{
    Pool pool;
    svn_error_t * error = 0;
#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 5)) || (SVN_VER_MAJOR > 1)
    error = svn_client_merge3(path1.cstr (),
                    revision1.revision (),
                    path2.cstr (),
                    revision2.revision (),
                    localPath.cstr (),
                    internal::DepthToSvn(depth),
                    !notice_ancestry,
                    force,
                    record_only,
                    dry_run,
                    merge_options.array(pool),
                    *m_context,
                    pool);
#else
    bool recurse = depth==DepthInfinity;
    Q_UNUSED(record_only);
#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 4))
    error = svn_client_merge2(path1.cstr (),
                    revision1.revision (),
                    path2.cstr (),
                    revision2.revision (),
                    localPath.cstr (),
                    recurse,
                    !notice_ancestry,
                    force,
                    dry_run,
                    merge_options.array(pool),
                    *m_context,
                    pool);
#else
    Q_UNUSED(merge_options);
    error = svn_client_merge(path1.cstr (),
                        revision1.revision (),
                        path2.cstr (),
                        revision2.revision (),
                        localPath.cstr (),
                        recurse,
                        !notice_ancestry,
                        force,
                        dry_run,
                        *m_context,
                        pool);
#endif
#endif

    if(error != 0) {
        throw ClientException (error);
    }
  }

  void Client_impl::merge_peg(const Path&src,
                              const RevisionRanges&ranges,
                    const Revision&peg,
                    const Path&targetWc,
                    Depth depth,
                    bool notice_ancestry,
                    bool dry_run,
                    bool force,
                    bool record_only,
                    const StringArray&merge_options
                   )
  {
#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 5)) || (SVN_VER_MAJOR > 1)
      Pool pool;
      internal::RevisionRangesToHash _rhash(ranges);

      svn_error_t*error;

      error = svn_client_merge_peg3(
                                    src.cstr(),
                                    _rhash.array(pool),
                                    peg,
                                    targetWc.cstr(),
                                    internal::DepthToSvn(depth),
                                    !notice_ancestry,
                                    force,
                                    record_only,
                                    dry_run,
                                    merge_options.array(pool),
                                    *m_context,
                                    pool
                                   );
      if(error != 0) {
          throw ClientException (error);
      }
#else
      Q_UNUSED(record_only);
      for (unsigned long i=0;i<ranges.count();++i) {
          merge_peg(src,ranges[i],peg,targetWc,depth,notice_ancestry,dry_run,force,merge_options);
      }
#endif
  }

    void Client_impl::merge_peg(const Path&src,
                              const RevisionRange&range,
                              const Revision&peg,
                              const Path&targetWc,
                              Depth depth,
                              bool notice_ancestry,
                              bool dry_run,
                              bool force,
                              const StringArray&merge_options
                             )
    {
#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 5)) || (SVN_VER_MAJOR > 1)
        RevisionRanges ranges;
        ranges.append(range);
        merge_peg(src,ranges,peg,targetWc,depth,notice_ancestry,dry_run,force,false,merge_options);
#else
        Pool pool;
        bool recurse=depth==DepthInfinity;
        svn_error_t*error;

#if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 4)) || (SVN_VER_MAJOR > 1)
        error = svn_client_merge_peg2(
                                      src.cstr(),
                                      range.first,
                                      range.second,
                                      peg.revision(),
                                      targetWc.cstr(),
                                      recurse,
                                      !notice_ancestry,
                                      force,
                                      dry_run,
                                      merge_options.array(pool),
                                      *m_context,
                                      pool
                                     );
#else
        Q_UNUSED(merge_options);
        error = svn_client_merge_peg(
                                      src.cstr(),
                                      range.first,
                                      range.second,
                                      peg.revision(),
                                      targetWc.cstr(),
                                      recurse,
                                      !notice_ancestry,
                                      force,
                                      dry_run,
                                      *m_context,
                                      pool
                                     );
#endif
        if(error != 0) {
            throw ClientException (error);
        }
#endif
    }

}