]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/libsvn_ra/deprecated.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / libsvn_ra / deprecated.c
1 /*
2  * deprecated.c:  holding file for all deprecated APIs.
3  *                "we can't lose 'em, but we can shun 'em!"
4  *
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
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
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  * ====================================================================
23  */
24
25 /* We define this here to remove any further warnings about the usage of
26    deprecated functions in this file. */
27 #define SVN_DEPRECATED
28
29 #include "svn_hash.h"
30 #include "svn_ra.h"
31 #include "svn_path.h"
32 #include "svn_compat.h"
33 #include "svn_props.h"
34 #include "svn_pools.h"
35
36 #include "ra_loader.h"
37 #include "deprecated.h"
38
39 #include "svn_private_config.h"
40
41
42
43 \f
44 /*** From ra_loader.c ***/
45 /*** Compatibility Wrappers ***/
46
47 /* Wrap @c svn_ra_reporter3_t in an interface that looks like
48    @c svn_ra_reporter2_t, for compatibility with functions that take
49    the latter.  This shields the ra-specific implementations from
50    worrying about what kind of reporter they're dealing with.
51
52    This code does not live in wrapper_template.h because that file is
53    about the big changeover from a vtable-style to function-style
54    interface, and does not contain the post-changeover interfaces
55    that we are compatiblizing here.
56
57    This code looks like it duplicates code in libsvn_wc/adm_crawler.c,
58    but in fact it does not.  That code makes old things look like new
59    things; this code makes a new thing look like an old thing. */
60
61 /* Baton for abovementioned wrapping. */
62 struct reporter_3in2_baton {
63   const svn_ra_reporter3_t *reporter3;
64   void *reporter3_baton;
65 };
66
67 /* Wrap the corresponding svn_ra_reporter3_t field in an
68    svn_ra_reporter2_t interface.  @a report_baton is a
69    @c reporter_3in2_baton_t *. */
70 static svn_error_t *
71 set_path(void *report_baton,
72          const char *path,
73          svn_revnum_t revision,
74          svn_boolean_t start_empty,
75          const char *lock_token,
76          apr_pool_t *pool)
77 {
78   struct reporter_3in2_baton *b = report_baton;
79   return b->reporter3->set_path(b->reporter3_baton,
80                                 path, revision, svn_depth_infinity,
81                                 start_empty, lock_token, pool);
82 }
83
84 /* Wrap the corresponding svn_ra_reporter3_t field in an
85    svn_ra_reporter2_t interface.  @a report_baton is a
86    @c reporter_3in2_baton_t *. */
87 static svn_error_t *
88 delete_path(void *report_baton,
89             const char *path,
90             apr_pool_t *pool)
91 {
92   struct reporter_3in2_baton *b = report_baton;
93   return b->reporter3->delete_path(b->reporter3_baton, path, pool);
94 }
95
96 /* Wrap the corresponding svn_ra_reporter3_t field in an
97    svn_ra_reporter2_t interface.  @a report_baton is a
98    @c reporter_3in2_baton_t *. */
99 static svn_error_t *
100 link_path(void *report_baton,
101           const char *path,
102           const char *url,
103           svn_revnum_t revision,
104           svn_boolean_t start_empty,
105           const char *lock_token,
106           apr_pool_t *pool)
107 {
108   struct reporter_3in2_baton *b = report_baton;
109   return b->reporter3->link_path(b->reporter3_baton,
110                                  path, url, revision, svn_depth_infinity,
111                                  start_empty, lock_token, pool);
112
113 }
114
115 /* Wrap the corresponding svn_ra_reporter3_t field in an
116    svn_ra_reporter2_t interface.  @a report_baton is a
117    @c reporter_3in2_baton_t *. */
118 static svn_error_t *
119 finish_report(void *report_baton,
120               apr_pool_t *pool)
121 {
122   struct reporter_3in2_baton *b = report_baton;
123   return b->reporter3->finish_report(b->reporter3_baton, pool);
124 }
125
126 /* Wrap the corresponding svn_ra_reporter3_t field in an
127    svn_ra_reporter2_t interface.  @a report_baton is a
128    @c reporter_3in2_baton_t *. */
129 static svn_error_t *
130 abort_report(void *report_baton,
131              apr_pool_t *pool)
132 {
133   struct reporter_3in2_baton *b = report_baton;
134   return b->reporter3->abort_report(b->reporter3_baton, pool);
135 }
136
137 /* Wrap svn_ra_reporter3_t calls in an svn_ra_reporter2_t interface.
138
139    Note: For calls where the prototypes are exactly the same, we could
140    avoid the pass-through overhead by using the function in the
141    reporter returned from session->vtable->do_foo.  But the code would
142    get a lot less readable, and the only benefit would be to shave a
143    few instructions in a network-bound operation anyway.  So in
144    delete_path(), finish_report(), and abort_report(), we cheerfully
145    pass through to identical functions. */
146 static svn_ra_reporter2_t reporter_3in2_wrapper = {
147   set_path,
148   delete_path,
149   link_path,
150   finish_report,
151   abort_report
152 };
153
154 svn_error_t *svn_ra_open3(svn_ra_session_t **session_p,
155                           const char *repos_URL,
156                           const char *uuid,
157                           const svn_ra_callbacks2_t *callbacks,
158                           void *callback_baton,
159                           apr_hash_t *config,
160                           apr_pool_t *pool)
161 {
162   return svn_ra_open4(session_p, NULL, repos_URL, uuid,
163                       callbacks, callback_baton, config, pool);
164 }
165
166 svn_error_t *svn_ra_open2(svn_ra_session_t **session_p,
167                           const char *repos_URL,
168                           const svn_ra_callbacks2_t *callbacks,
169                           void *callback_baton,
170                           apr_hash_t *config,
171                           apr_pool_t *pool)
172 {
173   return svn_ra_open3(session_p, repos_URL, NULL,
174                       callbacks, callback_baton, config, pool);
175 }
176
177 svn_error_t *svn_ra_open(svn_ra_session_t **session_p,
178                          const char *repos_URL,
179                          const svn_ra_callbacks_t *callbacks,
180                          void *callback_baton,
181                          apr_hash_t *config,
182                          apr_pool_t *pool)
183 {
184   /* Deprecated function. Copy the contents of the svn_ra_callbacks_t
185      to a new svn_ra_callbacks2_t and call svn_ra_open2(). */
186   svn_ra_callbacks2_t *callbacks2;
187   SVN_ERR(svn_ra_create_callbacks(&callbacks2, pool));
188   callbacks2->open_tmp_file = callbacks->open_tmp_file;
189   callbacks2->auth_baton = callbacks->auth_baton;
190   callbacks2->get_wc_prop = callbacks->get_wc_prop;
191   callbacks2->set_wc_prop = callbacks->set_wc_prop;
192   callbacks2->push_wc_prop = callbacks->push_wc_prop;
193   callbacks2->invalidate_wc_props = callbacks->invalidate_wc_props;
194   callbacks2->progress_func = NULL;
195   callbacks2->progress_baton = NULL;
196   return svn_ra_open2(session_p, repos_URL,
197                       callbacks2, callback_baton,
198                       config, pool);
199 }
200
201 svn_error_t *svn_ra_change_rev_prop(svn_ra_session_t *session,
202                                     svn_revnum_t rev,
203                                     const char *name,
204                                     const svn_string_t *value,
205                                     apr_pool_t *pool)
206 {
207   return svn_ra_change_rev_prop2(session, rev, name, NULL, value, pool);
208 }
209
210 svn_error_t *svn_ra_get_commit_editor2(svn_ra_session_t *session,
211                                        const svn_delta_editor_t **editor,
212                                        void **edit_baton,
213                                        const char *log_msg,
214                                        svn_commit_callback2_t commit_callback,
215                                        void *commit_baton,
216                                        apr_hash_t *lock_tokens,
217                                        svn_boolean_t keep_locks,
218                                        apr_pool_t *pool)
219 {
220   apr_hash_t *revprop_table = apr_hash_make(pool);
221   if (log_msg)
222     svn_hash_sets(revprop_table, SVN_PROP_REVISION_LOG,
223                   svn_string_create(log_msg, pool));
224   return svn_ra_get_commit_editor3(session, editor, edit_baton, revprop_table,
225                                    commit_callback, commit_baton,
226                                    lock_tokens, keep_locks, pool);
227 }
228
229 svn_error_t *svn_ra_get_commit_editor(svn_ra_session_t *session,
230                                       const svn_delta_editor_t **editor,
231                                       void **edit_baton,
232                                       const char *log_msg,
233                                       svn_commit_callback_t callback,
234                                       void *callback_baton,
235                                       apr_hash_t *lock_tokens,
236                                       svn_boolean_t keep_locks,
237                                       apr_pool_t *pool)
238 {
239   svn_commit_callback2_t callback2;
240   void *callback2_baton;
241
242   svn_compat_wrap_commit_callback(&callback2, &callback2_baton,
243                                   callback, callback_baton,
244                                   pool);
245
246   return svn_ra_get_commit_editor2(session, editor, edit_baton,
247                                    log_msg, callback2,
248                                    callback2_baton, lock_tokens,
249                                    keep_locks, pool);
250 }
251
252 svn_error_t *svn_ra_do_diff2(svn_ra_session_t *session,
253                              const svn_ra_reporter2_t **reporter,
254                              void **report_baton,
255                              svn_revnum_t revision,
256                              const char *diff_target,
257                              svn_boolean_t recurse,
258                              svn_boolean_t ignore_ancestry,
259                              svn_boolean_t text_deltas,
260                              const char *versus_url,
261                              const svn_delta_editor_t *diff_editor,
262                              void *diff_baton,
263                              apr_pool_t *pool)
264 {
265   struct reporter_3in2_baton *b = apr_palloc(pool, sizeof(*b));
266   SVN_ERR_ASSERT(svn_path_is_empty(diff_target)
267                  || svn_path_is_single_path_component(diff_target));
268   *reporter = &reporter_3in2_wrapper;
269   *report_baton = b;
270   return session->vtable->do_diff(session,
271                                   &(b->reporter3), &(b->reporter3_baton),
272                                   revision, diff_target,
273                                   SVN_DEPTH_INFINITY_OR_FILES(recurse),
274                                   ignore_ancestry, text_deltas, versus_url,
275                                   diff_editor, diff_baton, pool);
276 }
277
278 svn_error_t *svn_ra_do_diff(svn_ra_session_t *session,
279                             const svn_ra_reporter2_t **reporter,
280                             void **report_baton,
281                             svn_revnum_t revision,
282                             const char *diff_target,
283                             svn_boolean_t recurse,
284                             svn_boolean_t ignore_ancestry,
285                             const char *versus_url,
286                             const svn_delta_editor_t *diff_editor,
287                             void *diff_baton,
288                             apr_pool_t *pool)
289 {
290   SVN_ERR_ASSERT(svn_path_is_empty(diff_target)
291                  || svn_path_is_single_path_component(diff_target));
292   return svn_ra_do_diff2(session, reporter, report_baton, revision,
293                          diff_target, recurse, ignore_ancestry, TRUE,
294                          versus_url, diff_editor, diff_baton, pool);
295 }
296
297 svn_error_t *svn_ra_get_log(svn_ra_session_t *session,
298                             const apr_array_header_t *paths,
299                             svn_revnum_t start,
300                             svn_revnum_t end,
301                             int limit,
302                             svn_boolean_t discover_changed_paths,
303                             svn_boolean_t strict_node_history,
304                             svn_log_message_receiver_t receiver,
305                             void *receiver_baton,
306                             apr_pool_t *pool)
307 {
308   svn_log_entry_receiver_t receiver2;
309   void *receiver2_baton;
310
311   if (paths)
312     {
313       int i;
314       for (i = 0; i < paths->nelts; i++)
315         {
316           const char *path = APR_ARRAY_IDX(paths, i, const char *);
317           SVN_ERR_ASSERT(*path != '/');
318         }
319     }
320
321   svn_compat_wrap_log_receiver(&receiver2, &receiver2_baton,
322                                receiver, receiver_baton,
323                                pool);
324
325   return svn_ra_get_log2(session, paths, start, end, limit,
326                          discover_changed_paths, strict_node_history,
327                          FALSE, svn_compat_log_revprops_in(pool),
328                          receiver2, receiver2_baton, pool);
329 }
330
331 svn_error_t *svn_ra_get_file_revs(svn_ra_session_t *session,
332                                   const char *path,
333                                   svn_revnum_t start,
334                                   svn_revnum_t end,
335                                   svn_ra_file_rev_handler_t handler,
336                                   void *handler_baton,
337                                   apr_pool_t *pool)
338 {
339   svn_file_rev_handler_t handler2;
340   void *handler2_baton;
341
342   SVN_ERR_ASSERT(*path != '/');
343
344   svn_compat_wrap_file_rev_handler(&handler2, &handler2_baton,
345                                    handler, handler_baton,
346                                    pool);
347
348   return svn_ra_get_file_revs2(session, path, start, end, FALSE, handler2,
349                                handler2_baton, pool);
350 }
351
352 svn_error_t *
353 svn_ra_do_update2(svn_ra_session_t *session,
354                   const svn_ra_reporter3_t **reporter,
355                   void **report_baton,
356                   svn_revnum_t revision_to_update_to,
357                   const char *update_target,
358                   svn_depth_t depth,
359                   svn_boolean_t send_copyfrom_args,
360                   const svn_delta_editor_t *update_editor,
361                   void *update_baton,
362                   apr_pool_t *pool)
363 {
364   return svn_error_trace(
365             svn_ra_do_update3(session,
366                               reporter, report_baton,
367                               revision_to_update_to, update_target,
368                               depth,
369                               send_copyfrom_args,
370                               FALSE /* ignore_ancestry */,
371                               update_editor, update_baton,
372                               pool, pool));
373 }
374
375 svn_error_t *svn_ra_do_update(svn_ra_session_t *session,
376                               const svn_ra_reporter2_t **reporter,
377                               void **report_baton,
378                               svn_revnum_t revision_to_update_to,
379                               const char *update_target,
380                               svn_boolean_t recurse,
381                               const svn_delta_editor_t *update_editor,
382                               void *update_baton,
383                               apr_pool_t *pool)
384 {
385   struct reporter_3in2_baton *b = apr_palloc(pool, sizeof(*b));
386   SVN_ERR_ASSERT(svn_path_is_empty(update_target)
387                  || svn_path_is_single_path_component(update_target));
388   *reporter = &reporter_3in2_wrapper;
389   *report_baton = b;
390   return session->vtable->do_update(session,
391                                     &(b->reporter3), &(b->reporter3_baton),
392                                     revision_to_update_to, update_target,
393                                     SVN_DEPTH_INFINITY_OR_FILES(recurse),
394                                     FALSE, /* no copyfrom args */
395                                     FALSE /* ignore_ancestry */,
396                                     update_editor, update_baton,
397                                     pool, pool);
398 }
399
400
401 svn_error_t *
402 svn_ra_do_switch2(svn_ra_session_t *session,
403                   const svn_ra_reporter3_t **reporter,
404                   void **report_baton,
405                   svn_revnum_t revision_to_switch_to,
406                   const char *switch_target,
407                   svn_depth_t depth,
408                   const char *switch_url,
409                   const svn_delta_editor_t *switch_editor,
410                   void *switch_baton,
411                   apr_pool_t *pool)
412 {
413   return svn_error_trace(
414             svn_ra_do_switch3(session,
415                               reporter, report_baton,
416                               revision_to_switch_to, switch_target,
417                               depth,
418                               switch_url,
419                               FALSE /* send_copyfrom_args */,
420                               TRUE /* ignore_ancestry */,
421                               switch_editor, switch_baton,
422                               pool, pool));
423 }
424
425 svn_error_t *svn_ra_do_switch(svn_ra_session_t *session,
426                               const svn_ra_reporter2_t **reporter,
427                               void **report_baton,
428                               svn_revnum_t revision_to_switch_to,
429                               const char *switch_target,
430                               svn_boolean_t recurse,
431                               const char *switch_url,
432                               const svn_delta_editor_t *switch_editor,
433                               void *switch_baton,
434                               apr_pool_t *pool)
435 {
436   struct reporter_3in2_baton *b = apr_palloc(pool, sizeof(*b));
437   SVN_ERR_ASSERT(svn_path_is_empty(switch_target)
438                  || svn_path_is_single_path_component(switch_target));
439   *reporter = &reporter_3in2_wrapper;
440   *report_baton = b;
441   return session->vtable->do_switch(session,
442                                     &(b->reporter3), &(b->reporter3_baton),
443                                     revision_to_switch_to, switch_target,
444                                     SVN_DEPTH_INFINITY_OR_FILES(recurse),
445                                     switch_url,
446                                     FALSE /* send_copyfrom_args */,
447                                     TRUE /* ignore_ancestry */,
448                                     switch_editor, switch_baton,
449                                     pool, pool);
450 }
451
452 svn_error_t *svn_ra_do_status(svn_ra_session_t *session,
453                               const svn_ra_reporter2_t **reporter,
454                               void **report_baton,
455                               const char *status_target,
456                               svn_revnum_t revision,
457                               svn_boolean_t recurse,
458                               const svn_delta_editor_t *status_editor,
459                               void *status_baton,
460                               apr_pool_t *pool)
461 {
462   struct reporter_3in2_baton *b = apr_palloc(pool, sizeof(*b));
463   SVN_ERR_ASSERT(svn_path_is_empty(status_target)
464                  || svn_path_is_single_path_component(status_target));
465   *reporter = &reporter_3in2_wrapper;
466   *report_baton = b;
467   return session->vtable->do_status(session,
468                                     &(b->reporter3), &(b->reporter3_baton),
469                                     status_target, revision,
470                                     SVN_DEPTH_INFINITY_OR_IMMEDIATES(recurse),
471                                     status_editor, status_baton, pool);
472 }
473
474 svn_error_t *svn_ra_get_dir(svn_ra_session_t *session,
475                             const char *path,
476                             svn_revnum_t revision,
477                             apr_hash_t **dirents,
478                             svn_revnum_t *fetched_rev,
479                             apr_hash_t **props,
480                             apr_pool_t *pool)
481 {
482   SVN_ERR_ASSERT(*path != '/');
483   return session->vtable->get_dir(session, dirents, fetched_rev, props,
484                                   path, revision, SVN_DIRENT_ALL, pool);
485 }
486
487 svn_error_t *
488 svn_ra_local__deprecated_init(int abi_version,
489                               apr_pool_t *pool,
490                               apr_hash_t *hash)
491 {
492   return svn_error_trace(svn_ra_local_init(abi_version, pool, hash));
493 }
494
495 svn_error_t *
496 svn_ra_svn__deprecated_init(int abi_version,
497                             apr_pool_t *pool,
498                             apr_hash_t *hash)
499 {
500   return svn_error_trace(svn_ra_svn_init(abi_version, pool, hash));
501 }
502
503 svn_error_t *
504 svn_ra_serf__deprecated_init(int abi_version,
505                              apr_pool_t *pool,
506                              apr_hash_t *hash)
507 {
508   return svn_error_trace(svn_ra_serf_init(abi_version, pool, hash));
509 }