TortoiseGitMerge: Updated libsvn stuff
[TortoiseGit.git] / src / TortoiseMerge / libsvn_diff / deprecated.c
blob2edfd8ace07c0c760e71c1af08623473d6a585d3
1 /*
2 * deprecated.c: holding file for all deprecated APIs.
3 * "we can't lose 'em, but we can shun 'em!"
5 * ====================================================================
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
21 * under the License.
22 * ====================================================================
25 /* ==================================================================== */
29 /*** Includes. ***/
31 /* We define this here to remove any further warnings about the usage of
32 deprecated functions in this file. */
33 #define SVN_DEPRECATED
35 #include "svn_diff.h"
36 #include "svn_utf.h"
38 #include "svn_private_config.h"
43 /*** Code. ***/
44 struct fns_wrapper_baton
46 /* We put the old baton in front of this one, so that we can still use
47 this baton in place of the old. This prevents us from having to
48 implement simple wrappers around each member of diff_fns_t. */
49 void *old_baton;
50 const svn_diff_fns_t *vtable;
53 static svn_error_t *
54 datasources_open(void *baton,
55 apr_off_t *prefix_lines,
56 apr_off_t *suffix_lines,
57 const svn_diff_datasource_e *datasources,
58 apr_size_t datasource_len)
60 struct fns_wrapper_baton *fwb = baton;
61 apr_size_t i;
63 /* Just iterate over the datasources, using the old singular version. */
64 for (i = 0; i < datasource_len; i++)
66 SVN_ERR(fwb->vtable->datasource_open(fwb->old_baton, datasources[i]));
69 /* Don't claim any prefix or suffix matches. */
70 *prefix_lines = 0;
71 *suffix_lines = 0;
73 return SVN_NO_ERROR;
76 static svn_error_t *
77 datasource_close(void *baton,
78 svn_diff_datasource_e datasource)
80 struct fns_wrapper_baton *fwb = baton;
81 return fwb->vtable->datasource_close(fwb->old_baton, datasource);
84 static svn_error_t *
85 datasource_get_next_token(apr_uint32_t *hash,
86 void **token,
87 void *baton,
88 svn_diff_datasource_e datasource)
90 struct fns_wrapper_baton *fwb = baton;
91 return fwb->vtable->datasource_get_next_token(hash, token, fwb->old_baton,
92 datasource);
95 static svn_error_t *
96 token_compare(void *baton,
97 void *ltoken,
98 void *rtoken,
99 int *compare)
101 struct fns_wrapper_baton *fwb = baton;
102 return fwb->vtable->token_compare(fwb->old_baton, ltoken, rtoken, compare);
105 static void
106 token_discard(void *baton,
107 void *token)
109 struct fns_wrapper_baton *fwb = baton;
110 fwb->vtable->token_discard(fwb->old_baton, token);
113 static void
114 token_discard_all(void *baton)
116 struct fns_wrapper_baton *fwb = baton;
117 fwb->vtable->token_discard_all(fwb->old_baton);
121 static void
122 wrap_diff_fns(svn_diff_fns2_t **diff_fns2,
123 struct fns_wrapper_baton **baton2,
124 const svn_diff_fns_t *diff_fns,
125 void *baton,
126 apr_pool_t *result_pool)
128 /* Initialize the return vtable. */
129 *diff_fns2 = apr_palloc(result_pool, sizeof(**diff_fns2));
131 (*diff_fns2)->datasources_open = datasources_open;
132 (*diff_fns2)->datasource_close = datasource_close;
133 (*diff_fns2)->datasource_get_next_token = datasource_get_next_token;
134 (*diff_fns2)->token_compare = token_compare;
135 (*diff_fns2)->token_discard = token_discard;
136 (*diff_fns2)->token_discard_all = token_discard_all;
138 /* Initialize the wrapper baton. */
139 *baton2 = apr_palloc(result_pool, sizeof (**baton2));
140 (*baton2)->old_baton = baton;
141 (*baton2)->vtable = diff_fns;
145 /*** From diff_file.c ***/
146 svn_error_t *
147 svn_diff_file_output_unified2(svn_stream_t *output_stream,
148 svn_diff_t *diff,
149 const char *original_path,
150 const char *modified_path,
151 const char *original_header,
152 const char *modified_header,
153 const char *header_encoding,
154 apr_pool_t *pool)
156 return svn_diff_file_output_unified3(output_stream, diff,
157 original_path, modified_path,
158 original_header, modified_header,
159 header_encoding, NULL, FALSE, pool);
162 svn_error_t *
163 svn_diff_file_output_unified(svn_stream_t *output_stream,
164 svn_diff_t *diff,
165 const char *original_path,
166 const char *modified_path,
167 const char *original_header,
168 const char *modified_header,
169 apr_pool_t *pool)
171 return svn_diff_file_output_unified2(output_stream, diff,
172 original_path, modified_path,
173 original_header, modified_header,
174 SVN_APR_LOCALE_CHARSET, pool);
177 svn_error_t *
178 svn_diff_file_diff(svn_diff_t **diff,
179 const char *original,
180 const char *modified,
181 apr_pool_t *pool)
183 return svn_diff_file_diff_2(diff, original, modified,
184 svn_diff_file_options_create(pool), pool);
187 svn_error_t *
188 svn_diff_file_diff3(svn_diff_t **diff,
189 const char *original,
190 const char *modified,
191 const char *latest,
192 apr_pool_t *pool)
194 return svn_diff_file_diff3_2(diff, original, modified, latest,
195 svn_diff_file_options_create(pool), pool);
198 svn_error_t *
199 svn_diff_file_diff4(svn_diff_t **diff,
200 const char *original,
201 const char *modified,
202 const char *latest,
203 const char *ancestor,
204 apr_pool_t *pool)
206 return svn_diff_file_diff4_2(diff, original, modified, latest, ancestor,
207 svn_diff_file_options_create(pool), pool);
210 svn_error_t *
211 svn_diff_file_output_merge(svn_stream_t *output_stream,
212 svn_diff_t *diff,
213 const char *original_path,
214 const char *modified_path,
215 const char *latest_path,
216 const char *conflict_original,
217 const char *conflict_modified,
218 const char *conflict_latest,
219 const char *conflict_separator,
220 svn_boolean_t display_original_in_conflict,
221 svn_boolean_t display_resolved_conflicts,
222 apr_pool_t *pool)
224 svn_diff_conflict_display_style_t style =
225 svn_diff_conflict_display_modified_latest;
227 if (display_resolved_conflicts)
228 style = svn_diff_conflict_display_resolved_modified_latest;
230 if (display_original_in_conflict)
231 style = svn_diff_conflict_display_modified_original_latest;
233 return svn_diff_file_output_merge2(output_stream,
234 diff,
235 original_path,
236 modified_path,
237 latest_path,
238 conflict_original,
239 conflict_modified,
240 conflict_latest,
241 conflict_separator,
242 style,
243 pool);
247 /*** From diff.c ***/
248 svn_error_t *
249 svn_diff_diff(svn_diff_t **diff,
250 void *diff_baton,
251 const svn_diff_fns_t *vtable,
252 apr_pool_t *pool)
254 svn_diff_fns2_t *diff_fns2;
255 struct fns_wrapper_baton *fwb;
257 wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
258 return svn_diff_diff_2(diff, fwb, diff_fns2, pool);
262 /*** From diff3.c ***/
263 svn_error_t *
264 svn_diff_diff3(svn_diff_t **diff,
265 void *diff_baton,
266 const svn_diff_fns_t *vtable,
267 apr_pool_t *pool)
269 svn_diff_fns2_t *diff_fns2;
270 struct fns_wrapper_baton *fwb;
272 wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
273 return svn_diff_diff3_2(diff, fwb, diff_fns2, pool);
277 /*** From diff4.c ***/
278 svn_error_t *
279 svn_diff_diff4(svn_diff_t **diff,
280 void *diff_baton,
281 const svn_diff_fns_t *vtable,
282 apr_pool_t *pool)
284 svn_diff_fns2_t *diff_fns2;
285 struct fns_wrapper_baton *fwb;
287 wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
288 return svn_diff_diff4_2(diff, fwb, diff_fns2, pool);