deprecated.c revision 362181
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_repos.h"
30#include "svn_compat.h"
31#include "svn_hash.h"
32#include "svn_path.h"
33#include "svn_props.h"
34#include "svn_pools.h"
35
36#include "svn_private_config.h"
37
38#include "repos.h"
39
40#include "private/svn_repos_private.h"
41#include "private/svn_subr_private.h"
42
43
44
45
46/*** From commit.c ***/
47
48svn_error_t *
49svn_repos_get_commit_editor4(const svn_delta_editor_t **editor,
50                             void **edit_baton,
51                             svn_repos_t *repos,
52                             svn_fs_txn_t *txn,
53                             const char *repos_url,
54                             const char *base_path,
55                             const char *user,
56                             const char *log_msg,
57                             svn_commit_callback2_t commit_callback,
58                             void *commit_baton,
59                             svn_repos_authz_callback_t authz_callback,
60                             void *authz_baton,
61                             apr_pool_t *pool)
62{
63  apr_hash_t *revprop_table = apr_hash_make(pool);
64  if (user)
65    svn_hash_sets(revprop_table, SVN_PROP_REVISION_AUTHOR,
66                  svn_string_create(user, pool));
67  if (log_msg)
68    svn_hash_sets(revprop_table, SVN_PROP_REVISION_LOG,
69                  svn_string_create(log_msg, pool));
70  return svn_repos_get_commit_editor5(editor, edit_baton, repos, txn,
71                                      repos_url, base_path, revprop_table,
72                                      commit_callback, commit_baton,
73                                      authz_callback, authz_baton, pool);
74}
75
76
77svn_error_t *
78svn_repos_get_commit_editor3(const svn_delta_editor_t **editor,
79                             void **edit_baton,
80                             svn_repos_t *repos,
81                             svn_fs_txn_t *txn,
82                             const char *repos_url,
83                             const char *base_path,
84                             const char *user,
85                             const char *log_msg,
86                             svn_commit_callback_t callback,
87                             void *callback_baton,
88                             svn_repos_authz_callback_t authz_callback,
89                             void *authz_baton,
90                             apr_pool_t *pool)
91{
92  svn_commit_callback2_t callback2;
93  void *callback2_baton;
94
95  svn_compat_wrap_commit_callback(&callback2, &callback2_baton,
96                                  callback, callback_baton,
97                                  pool);
98
99  return svn_repos_get_commit_editor4(editor, edit_baton, repos, txn,
100                                      repos_url, base_path, user,
101                                      log_msg, callback2,
102                                      callback2_baton, authz_callback,
103                                      authz_baton, pool);
104}
105
106
107svn_error_t *
108svn_repos_get_commit_editor2(const svn_delta_editor_t **editor,
109                             void **edit_baton,
110                             svn_repos_t *repos,
111                             svn_fs_txn_t *txn,
112                             const char *repos_url,
113                             const char *base_path,
114                             const char *user,
115                             const char *log_msg,
116                             svn_commit_callback_t callback,
117                             void *callback_baton,
118                             apr_pool_t *pool)
119{
120  return svn_repos_get_commit_editor3(editor, edit_baton, repos, txn,
121                                      repos_url, base_path, user,
122                                      log_msg, callback, callback_baton,
123                                      NULL, NULL, pool);
124}
125
126
127svn_error_t *
128svn_repos_get_commit_editor(const svn_delta_editor_t **editor,
129                            void **edit_baton,
130                            svn_repos_t *repos,
131                            const char *repos_url,
132                            const char *base_path,
133                            const char *user,
134                            const char *log_msg,
135                            svn_commit_callback_t callback,
136                            void *callback_baton,
137                            apr_pool_t *pool)
138{
139  return svn_repos_get_commit_editor2(editor, edit_baton, repos, NULL,
140                                      repos_url, base_path, user,
141                                      log_msg, callback,
142                                      callback_baton, pool);
143}
144
145svn_error_t *
146svn_repos_open2(svn_repos_t **repos_p,
147                const char *path,
148                apr_hash_t *fs_config,
149                apr_pool_t *pool)
150{
151  return svn_repos_open3(repos_p, path, fs_config, pool, pool);
152}
153
154svn_error_t *
155svn_repos_open(svn_repos_t **repos_p,
156               const char *path,
157               apr_pool_t *pool)
158{
159  return svn_repos_open2(repos_p, path, NULL, pool);
160}
161
162
163/*** From repos.c ***/
164struct recover_baton
165{
166  svn_error_t *(*start_callback)(void *baton);
167  void *start_callback_baton;
168};
169
170static void
171recovery_started(void *baton,
172                 const svn_repos_notify_t *notify,
173                 apr_pool_t *scratch_pool)
174{
175  struct recover_baton *rb = baton;
176
177  if (notify->action == svn_repos_notify_mutex_acquired
178      && rb->start_callback != NULL)
179    svn_error_clear(rb->start_callback(rb->start_callback_baton));
180}
181
182svn_error_t *
183svn_repos_recover3(const char *path,
184                   svn_boolean_t nonblocking,
185                   svn_error_t *(*start_callback)(void *baton),
186                   void *start_callback_baton,
187                   svn_cancel_func_t cancel_func, void *cancel_baton,
188                   apr_pool_t *pool)
189{
190  struct recover_baton rb;
191
192  rb.start_callback = start_callback;
193  rb.start_callback_baton = start_callback_baton;
194
195  return svn_repos_recover4(path, nonblocking, recovery_started, &rb,
196                            cancel_func, cancel_baton, pool);
197}
198
199svn_error_t *
200svn_repos_recover2(const char *path,
201                   svn_boolean_t nonblocking,
202                   svn_error_t *(*start_callback)(void *baton),
203                   void *start_callback_baton,
204                   apr_pool_t *pool)
205{
206  return svn_repos_recover3(path, nonblocking,
207                            start_callback, start_callback_baton,
208                            NULL, NULL,
209                            pool);
210}
211
212svn_error_t *
213svn_repos_recover(const char *path,
214                  apr_pool_t *pool)
215{
216  return svn_repos_recover2(path, FALSE, NULL, NULL, pool);
217}
218
219svn_error_t *
220svn_repos_upgrade(const char *path,
221                  svn_boolean_t nonblocking,
222                  svn_error_t *(*start_callback)(void *baton),
223                  void *start_callback_baton,
224                  apr_pool_t *pool)
225{
226  struct recover_baton rb;
227
228  rb.start_callback = start_callback;
229  rb.start_callback_baton = start_callback_baton;
230
231  return svn_repos_upgrade2(path, nonblocking, recovery_started, &rb, pool);
232}
233
234svn_error_t *
235svn_repos_hotcopy2(const char *src_path,
236                   const char *dst_path,
237                   svn_boolean_t clean_logs,
238                   svn_boolean_t incremental,
239                   svn_cancel_func_t cancel_func,
240                   void *cancel_baton,
241                   apr_pool_t *pool)
242{
243  return svn_error_trace(svn_repos_hotcopy3(src_path, dst_path, clean_logs,
244                                            incremental, NULL, NULL,
245                                            cancel_func, cancel_baton, pool));
246}
247
248svn_error_t *
249svn_repos_hotcopy(const char *src_path,
250                  const char *dst_path,
251                  svn_boolean_t clean_logs,
252                  apr_pool_t *pool)
253{
254  return svn_error_trace(svn_repos_hotcopy2(src_path, dst_path, clean_logs,
255                                            FALSE, NULL, NULL, pool));
256}
257
258/*** From reporter.c ***/
259svn_error_t *
260svn_repos_begin_report(void **report_baton,
261                       svn_revnum_t revnum,
262                       const char *username,
263                       svn_repos_t *repos,
264                       const char *fs_base,
265                       const char *s_operand,
266                       const char *switch_path,
267                       svn_boolean_t text_deltas,
268                       svn_boolean_t recurse,
269                       svn_boolean_t ignore_ancestry,
270                       const svn_delta_editor_t *editor,
271                       void *edit_baton,
272                       svn_repos_authz_func_t authz_read_func,
273                       void *authz_read_baton,
274                       apr_pool_t *pool)
275{
276  return svn_repos_begin_report2(report_baton,
277                                 revnum,
278                                 repos,
279                                 fs_base,
280                                 s_operand,
281                                 switch_path,
282                                 text_deltas,
283                                 SVN_DEPTH_INFINITY_OR_FILES(recurse),
284                                 ignore_ancestry,
285                                 FALSE, /* don't send copyfrom args */
286                                 editor,
287                                 edit_baton,
288                                 authz_read_func,
289                                 authz_read_baton,
290                                 pool);
291}
292
293svn_error_t *
294svn_repos_begin_report2(void **report_baton,
295                        svn_revnum_t revnum,
296                        svn_repos_t *repos,
297                        const char *fs_base,
298                        const char *target,
299                        const char *tgt_path,
300                        svn_boolean_t text_deltas,
301                        svn_depth_t depth,
302                        svn_boolean_t ignore_ancestry,
303                        svn_boolean_t send_copyfrom_args,
304                        const svn_delta_editor_t *editor,
305                        void *edit_baton,
306                        svn_repos_authz_func_t authz_read_func,
307                        void *authz_read_baton,
308                        apr_pool_t *pool)
309{
310  return svn_repos_begin_report3(report_baton,
311                                 revnum,
312                                 repos,
313                                 fs_base,
314                                 target,
315                                 tgt_path,
316                                 text_deltas,
317                                 depth,
318                                 ignore_ancestry,
319                                 send_copyfrom_args,
320                                 editor,
321                                 edit_baton,
322                                 authz_read_func,
323                                 authz_read_baton,
324                                 0,     /* disable zero-copy code path */
325                                 pool);
326}
327
328svn_error_t *
329svn_repos_set_path2(void *baton, const char *path, svn_revnum_t rev,
330                    svn_boolean_t start_empty, const char *lock_token,
331                    apr_pool_t *pool)
332{
333  return svn_repos_set_path3(baton, path, rev, svn_depth_infinity,
334                             start_empty, lock_token, pool);
335}
336
337svn_error_t *
338svn_repos_set_path(void *baton, const char *path, svn_revnum_t rev,
339                   svn_boolean_t start_empty, apr_pool_t *pool)
340{
341  return svn_repos_set_path2(baton, path, rev, start_empty, NULL, pool);
342}
343
344svn_error_t *
345svn_repos_link_path2(void *baton, const char *path, const char *link_path,
346                     svn_revnum_t rev, svn_boolean_t start_empty,
347                     const char *lock_token, apr_pool_t *pool)
348{
349  return svn_repos_link_path3(baton, path, link_path, rev, svn_depth_infinity,
350                              start_empty, lock_token, pool);
351}
352
353svn_error_t *
354svn_repos_link_path(void *baton, const char *path, const char *link_path,
355                    svn_revnum_t rev, svn_boolean_t start_empty,
356                    apr_pool_t *pool)
357{
358  return svn_repos_link_path2(baton, path, link_path, rev, start_empty,
359                              NULL, pool);
360}
361
362/*** From dir-delta.c ***/
363svn_error_t *
364svn_repos_dir_delta(svn_fs_root_t *src_root,
365                    const char *src_parent_dir,
366                    const char *src_entry,
367                    svn_fs_root_t *tgt_root,
368                    const char *tgt_fullpath,
369                    const svn_delta_editor_t *editor,
370                    void *edit_baton,
371                    svn_repos_authz_func_t authz_read_func,
372                    void *authz_read_baton,
373                    svn_boolean_t text_deltas,
374                    svn_boolean_t recurse,
375                    svn_boolean_t entry_props,
376                    svn_boolean_t ignore_ancestry,
377                    apr_pool_t *pool)
378{
379  return svn_repos_dir_delta2(src_root,
380                              src_parent_dir,
381                              src_entry,
382                              tgt_root,
383                              tgt_fullpath,
384                              editor,
385                              edit_baton,
386                              authz_read_func,
387                              authz_read_baton,
388                              text_deltas,
389                              SVN_DEPTH_INFINITY_OR_FILES(recurse),
390                              entry_props,
391                              ignore_ancestry,
392                              pool);
393}
394
395/*** From replay.c ***/
396svn_error_t *
397svn_repos_replay(svn_fs_root_t *root,
398                 const svn_delta_editor_t *editor,
399                 void *edit_baton,
400                 apr_pool_t *pool)
401{
402  return svn_repos_replay2(root,
403                           "" /* the whole tree */,
404                           SVN_INVALID_REVNUM, /* no low water mark */
405                           FALSE /* no text deltas */,
406                           editor, edit_baton,
407                           NULL /* no authz func */,
408                           NULL /* no authz baton */,
409                           pool);
410}
411
412/*** From fs-wrap.c ***/
413svn_error_t *
414svn_repos_fs_change_rev_prop3(svn_repos_t *repos,
415                              svn_revnum_t rev,
416                              const char *author,
417                              const char *name,
418                              const svn_string_t *new_value,
419                              svn_boolean_t use_pre_revprop_change_hook,
420                              svn_boolean_t use_post_revprop_change_hook,
421                              svn_repos_authz_func_t authz_read_func,
422                              void *authz_read_baton,
423                              apr_pool_t *pool)
424{
425  return svn_repos_fs_change_rev_prop4(repos, rev, author, name, NULL,
426                                       new_value,
427                                       use_pre_revprop_change_hook,
428                                       use_post_revprop_change_hook,
429                                       authz_read_func,
430                                       authz_read_baton, pool);
431}
432
433svn_error_t *
434svn_repos_fs_change_rev_prop2(svn_repos_t *repos,
435                              svn_revnum_t rev,
436                              const char *author,
437                              const char *name,
438                              const svn_string_t *new_value,
439                              svn_repos_authz_func_t authz_read_func,
440                              void *authz_read_baton,
441                              apr_pool_t *pool)
442{
443  return svn_repos_fs_change_rev_prop3(repos, rev, author, name, new_value,
444                                       TRUE, TRUE, authz_read_func,
445                                       authz_read_baton, pool);
446}
447
448
449
450svn_error_t *
451svn_repos_fs_change_rev_prop(svn_repos_t *repos,
452                             svn_revnum_t rev,
453                             const char *author,
454                             const char *name,
455                             const svn_string_t *new_value,
456                             apr_pool_t *pool)
457{
458  return svn_repos_fs_change_rev_prop2(repos, rev, author, name, new_value,
459                                       NULL, NULL, pool);
460}
461
462struct pack_notify_wrapper_baton
463{
464  svn_fs_pack_notify_t notify_func;
465  void *notify_baton;
466};
467
468static void
469pack_notify_wrapper_func(void *baton,
470                         const svn_repos_notify_t *notify,
471                         apr_pool_t *scratch_pool)
472{
473  struct pack_notify_wrapper_baton *pnwb = baton;
474
475  svn_error_clear(pnwb->notify_func(pnwb->notify_baton, notify->shard,
476                                    notify->action - 3, scratch_pool));
477}
478
479svn_error_t *
480svn_repos_fs_pack(svn_repos_t *repos,
481                  svn_fs_pack_notify_t notify_func,
482                  void *notify_baton,
483                  svn_cancel_func_t cancel_func,
484                  void *cancel_baton,
485                  apr_pool_t *pool)
486{
487  struct pack_notify_wrapper_baton pnwb;
488
489  pnwb.notify_func = notify_func;
490  pnwb.notify_baton = notify_baton;
491
492  return svn_repos_fs_pack2(repos, pack_notify_wrapper_func, &pnwb,
493                            cancel_func, cancel_baton, pool);
494}
495
496
497svn_error_t *
498svn_repos_fs_get_locks(apr_hash_t **locks,
499                       svn_repos_t *repos,
500                       const char *path,
501                       svn_repos_authz_func_t authz_read_func,
502                       void *authz_read_baton,
503                       apr_pool_t *pool)
504{
505  return svn_error_trace(svn_repos_fs_get_locks2(locks, repos, path,
506                                                 svn_depth_infinity,
507                                                 authz_read_func,
508                                                 authz_read_baton, pool));
509}
510
511static svn_error_t *
512mergeinfo_receiver(const char *path,
513                   svn_mergeinfo_t mergeinfo,
514                   void *baton,
515                   apr_pool_t *scratch_pool)
516{
517  svn_mergeinfo_catalog_t catalog = baton;
518  apr_pool_t *result_pool = apr_hash_pool_get(catalog);
519  apr_size_t len = strlen(path);
520
521  apr_hash_set(catalog,
522               apr_pstrmemdup(result_pool, path, len),
523               len,
524               svn_mergeinfo_dup(mergeinfo, result_pool));
525
526  return SVN_NO_ERROR;
527}
528
529svn_error_t *
530svn_repos_fs_get_mergeinfo(svn_mergeinfo_catalog_t *mergeinfo,
531                           svn_repos_t *repos,
532                           const apr_array_header_t *paths,
533                           svn_revnum_t rev,
534                           svn_mergeinfo_inheritance_t inherit,
535                           svn_boolean_t include_descendants,
536                           svn_repos_authz_func_t authz_read_func,
537                           void *authz_read_baton,
538                           apr_pool_t *pool)
539{
540  svn_mergeinfo_catalog_t result_catalog = svn_hash__make(pool);
541  SVN_ERR(svn_repos_fs_get_mergeinfo2(repos, paths, rev, inherit,
542                                      include_descendants,
543                                      authz_read_func, authz_read_baton,
544                                      mergeinfo_receiver, result_catalog,
545                                      pool));
546  *mergeinfo = result_catalog;
547
548  return SVN_NO_ERROR;
549}
550
551/*** From logs.c ***/
552svn_error_t *
553svn_repos_get_logs4(svn_repos_t *repos,
554                    const apr_array_header_t *paths,
555                    svn_revnum_t start,
556                    svn_revnum_t end,
557                    int limit,
558                    svn_boolean_t discover_changed_paths,
559                    svn_boolean_t strict_node_history,
560                    svn_boolean_t include_merged_revisions,
561                    const apr_array_header_t *revprops,
562                    svn_repos_authz_func_t authz_read_func,
563                    void *authz_read_baton,
564                    svn_log_entry_receiver_t receiver,
565                    void *receiver_baton,
566                    apr_pool_t *pool)
567{
568  return svn_repos__get_logs_compat(repos, paths, start, end, limit,
569                                    discover_changed_paths,
570                                    strict_node_history,
571                                    include_merged_revisions, revprops,
572                                    authz_read_func, authz_read_baton,
573                                    receiver, receiver_baton, pool);
574}
575
576svn_error_t *
577svn_repos_get_logs3(svn_repos_t *repos,
578                    const apr_array_header_t *paths,
579                    svn_revnum_t start,
580                    svn_revnum_t end,
581                    int limit,
582                    svn_boolean_t discover_changed_paths,
583                    svn_boolean_t strict_node_history,
584                    svn_repos_authz_func_t authz_read_func,
585                    void *authz_read_baton,
586                    svn_log_message_receiver_t receiver,
587                    void *receiver_baton,
588                    apr_pool_t *pool)
589{
590  svn_log_entry_receiver_t receiver2;
591  void *receiver2_baton;
592
593  svn_compat_wrap_log_receiver(&receiver2, &receiver2_baton,
594                               receiver, receiver_baton,
595                               pool);
596
597  return svn_repos_get_logs4(repos, paths, start, end, limit,
598                             discover_changed_paths, strict_node_history,
599                             FALSE, svn_compat_log_revprops_in(pool),
600                             authz_read_func, authz_read_baton,
601                             receiver2, receiver2_baton,
602                             pool);
603}
604
605svn_error_t *
606svn_repos_get_logs2(svn_repos_t *repos,
607                    const apr_array_header_t *paths,
608                    svn_revnum_t start,
609                    svn_revnum_t end,
610                    svn_boolean_t discover_changed_paths,
611                    svn_boolean_t strict_node_history,
612                    svn_repos_authz_func_t authz_read_func,
613                    void *authz_read_baton,
614                    svn_log_message_receiver_t receiver,
615                    void *receiver_baton,
616                    apr_pool_t *pool)
617{
618  return svn_repos_get_logs3(repos, paths, start, end, 0,
619                             discover_changed_paths, strict_node_history,
620                             authz_read_func, authz_read_baton, receiver,
621                             receiver_baton, pool);
622}
623
624
625svn_error_t *
626svn_repos_get_logs(svn_repos_t *repos,
627                   const apr_array_header_t *paths,
628                   svn_revnum_t start,
629                   svn_revnum_t end,
630                   svn_boolean_t discover_changed_paths,
631                   svn_boolean_t strict_node_history,
632                   svn_log_message_receiver_t receiver,
633                   void *receiver_baton,
634                   apr_pool_t *pool)
635{
636  return svn_repos_get_logs3(repos, paths, start, end, 0,
637                             discover_changed_paths, strict_node_history,
638                             NULL, NULL, /* no authz stuff */
639                             receiver, receiver_baton, pool);
640}
641
642/*** From rev_hunt.c ***/
643svn_error_t *
644svn_repos_history(svn_fs_t *fs,
645                  const char *path,
646                  svn_repos_history_func_t history_func,
647                  void *history_baton,
648                  svn_revnum_t start,
649                  svn_revnum_t end,
650                  svn_boolean_t cross_copies,
651                  apr_pool_t *pool)
652{
653  return svn_repos_history2(fs, path, history_func, history_baton,
654                            NULL, NULL,
655                            start, end, cross_copies, pool);
656}
657
658svn_error_t *
659svn_repos_get_file_revs(svn_repos_t *repos,
660                        const char *path,
661                        svn_revnum_t start,
662                        svn_revnum_t end,
663                        svn_repos_authz_func_t authz_read_func,
664                        void *authz_read_baton,
665                        svn_repos_file_rev_handler_t handler,
666                        void *handler_baton,
667                        apr_pool_t *pool)
668{
669  svn_file_rev_handler_t handler2;
670  void *handler2_baton;
671
672  svn_compat_wrap_file_rev_handler(&handler2, &handler2_baton, handler,
673                                   handler_baton, pool);
674
675  return svn_repos_get_file_revs2(repos, path, start, end, FALSE,
676                                  authz_read_func, authz_read_baton,
677                                  handler2, handler2_baton, pool);
678}
679
680/*** From dump.c ***/
681svn_error_t *
682svn_repos_dump_fs(svn_repos_t *repos,
683                  svn_stream_t *stream,
684                  svn_stream_t *feedback_stream,
685                  svn_revnum_t start_rev,
686                  svn_revnum_t end_rev,
687                  svn_boolean_t incremental,
688                  svn_cancel_func_t cancel_func,
689                  void *cancel_baton,
690                  apr_pool_t *pool)
691{
692  return svn_repos_dump_fs2(repos, stream, feedback_stream, start_rev,
693                            end_rev, incremental, FALSE, cancel_func,
694                            cancel_baton, pool);
695}
696
697/* Implementation of svn_repos_notify_func_t to wrap the output to a
698   response stream for svn_repos_dump_fs2() and svn_repos_verify_fs() */
699static void
700repos_notify_handler(void *baton,
701                     const svn_repos_notify_t *notify,
702                     apr_pool_t *scratch_pool)
703{
704  svn_stream_t *feedback_stream = baton;
705  apr_size_t len;
706
707  switch (notify->action)
708  {
709    case svn_repos_notify_warning:
710      svn_error_clear(svn_stream_puts(feedback_stream, notify->warning_str));
711      return;
712
713    case svn_repos_notify_dump_rev_end:
714      svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
715                                        _("* Dumped revision %ld.\n"),
716                                        notify->revision));
717      return;
718
719    case svn_repos_notify_verify_rev_end:
720      svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
721                                        _("* Verified revision %ld.\n"),
722                                        notify->revision));
723      return;
724
725    case svn_repos_notify_load_txn_committed:
726      if (notify->old_revision == SVN_INVALID_REVNUM)
727        {
728          svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
729                            _("\n------- Committed revision %ld >>>\n\n"),
730                            notify->new_revision));
731        }
732      else
733        {
734          svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
735                            _("\n------- Committed new rev %ld"
736                              " (loaded from original rev %ld"
737                              ") >>>\n\n"), notify->new_revision,
738                              notify->old_revision));
739        }
740      return;
741
742    case svn_repos_notify_load_node_start:
743      {
744        switch (notify->node_action)
745        {
746          case svn_node_action_change:
747            svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
748                                  _("     * editing path : %s ..."),
749                                  notify->path));
750            break;
751
752          case svn_node_action_delete:
753            svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
754                                  _("     * deleting path : %s ..."),
755                                  notify->path));
756            break;
757
758          case svn_node_action_add:
759            svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
760                                  _("     * adding path : %s ..."),
761                                  notify->path));
762            break;
763
764          case svn_node_action_replace:
765            svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
766                                  _("     * replacing path : %s ..."),
767                                  notify->path));
768            break;
769
770        }
771      }
772      return;
773
774    case svn_repos_notify_load_node_done:
775      len = 7;
776      svn_error_clear(svn_stream_write(feedback_stream, _(" done.\n"), &len));
777      return;
778
779    case svn_repos_notify_load_copied_node:
780      len = 9;
781      svn_error_clear(svn_stream_write(feedback_stream, "COPIED...", &len));
782      return;
783
784    case svn_repos_notify_load_txn_start:
785      svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
786                                _("<<< Started new transaction, based on "
787                                  "original revision %ld\n"),
788                                notify->old_revision));
789      return;
790
791    case svn_repos_notify_load_normalized_mergeinfo:
792      svn_error_clear(svn_stream_printf(feedback_stream, scratch_pool,
793                                _(" removing '\\r' from %s ..."),
794                                SVN_PROP_MERGEINFO));
795      return;
796
797    default:
798      return;
799  }
800}
801
802svn_error_t *
803svn_repos_dump_fs3(svn_repos_t *repos,
804                   svn_stream_t *stream,
805                   svn_revnum_t start_rev,
806                   svn_revnum_t end_rev,
807                   svn_boolean_t incremental,
808                   svn_boolean_t use_deltas,
809                   svn_repos_notify_func_t notify_func,
810                   void *notify_baton,
811                   svn_cancel_func_t cancel_func,
812                   void *cancel_baton,
813                   apr_pool_t *pool)
814{
815  return svn_error_trace(svn_repos_dump_fs4(repos,
816                                            stream,
817                                            start_rev,
818                                            end_rev,
819                                            incremental,
820                                            use_deltas,
821                                            TRUE,
822                                            TRUE,
823                                            notify_func,
824                                            notify_baton,
825                                            NULL, NULL,
826                                            cancel_func,
827                                            cancel_baton,
828                                            pool));
829}
830
831svn_error_t *
832svn_repos_dump_fs2(svn_repos_t *repos,
833                   svn_stream_t *stream,
834                   svn_stream_t *feedback_stream,
835                   svn_revnum_t start_rev,
836                   svn_revnum_t end_rev,
837                   svn_boolean_t incremental,
838                   svn_boolean_t use_deltas,
839                   svn_cancel_func_t cancel_func,
840                   void *cancel_baton,
841                   apr_pool_t *pool)
842{
843  return svn_error_trace(svn_repos_dump_fs3(repos,
844                                            stream,
845                                            start_rev,
846                                            end_rev,
847                                            incremental,
848                                            use_deltas,
849                                            feedback_stream
850                                              ? repos_notify_handler
851                                              : NULL,
852                                            feedback_stream,
853                                            cancel_func,
854                                            cancel_baton,
855                                            pool));
856}
857
858svn_error_t *
859svn_repos_verify_fs2(svn_repos_t *repos,
860                     svn_revnum_t start_rev,
861                     svn_revnum_t end_rev,
862                     svn_repos_notify_func_t notify_func,
863                     void *notify_baton,
864                     svn_cancel_func_t cancel_func,
865                     void *cancel_baton,
866                     apr_pool_t *pool)
867{
868  return svn_error_trace(svn_repos_verify_fs3(repos,
869                                              start_rev,
870                                              end_rev,
871                                              FALSE,
872                                              FALSE,
873                                              notify_func,
874                                              notify_baton,
875                                              NULL, NULL,
876                                              cancel_func,
877                                              cancel_baton,
878                                              pool));
879}
880
881svn_error_t *
882svn_repos_verify_fs(svn_repos_t *repos,
883                    svn_stream_t *feedback_stream,
884                    svn_revnum_t start_rev,
885                    svn_revnum_t end_rev,
886                    svn_cancel_func_t cancel_func,
887                    void *cancel_baton,
888                    apr_pool_t *pool)
889{
890  return svn_error_trace(svn_repos_verify_fs2(repos,
891                                              start_rev,
892                                              end_rev,
893                                              feedback_stream
894                                                ? repos_notify_handler
895                                                : NULL,
896                                              feedback_stream,
897                                              cancel_func,
898                                              cancel_baton,
899                                              pool));
900}
901
902/*** From load.c ***/
903
904svn_error_t *
905svn_repos_load_fs5(svn_repos_t *repos,
906                   svn_stream_t *dumpstream,
907                   svn_revnum_t start_rev,
908                   svn_revnum_t end_rev,
909                   enum svn_repos_load_uuid uuid_action,
910                   const char *parent_dir,
911                   svn_boolean_t use_pre_commit_hook,
912                   svn_boolean_t use_post_commit_hook,
913                   svn_boolean_t validate_props,
914                   svn_boolean_t ignore_dates,
915                   svn_repos_notify_func_t notify_func,
916                   void *notify_baton,
917                   svn_cancel_func_t cancel_func,
918                   void *cancel_baton,
919                   apr_pool_t *pool)
920{
921  return svn_repos_load_fs6(repos, dumpstream, start_rev, end_rev,
922                            uuid_action, parent_dir,
923                            use_post_commit_hook, use_post_commit_hook,
924                            validate_props, ignore_dates, FALSE,
925                            notify_func, notify_baton,
926                            cancel_func, cancel_baton, pool);
927}
928
929svn_error_t *
930svn_repos_load_fs4(svn_repos_t *repos,
931                   svn_stream_t *dumpstream,
932                   svn_revnum_t start_rev,
933                   svn_revnum_t end_rev,
934                   enum svn_repos_load_uuid uuid_action,
935                   const char *parent_dir,
936                   svn_boolean_t use_pre_commit_hook,
937                   svn_boolean_t use_post_commit_hook,
938                   svn_boolean_t validate_props,
939                   svn_repos_notify_func_t notify_func,
940                   void *notify_baton,
941                   svn_cancel_func_t cancel_func,
942                   void *cancel_baton,
943                   apr_pool_t *pool)
944{
945  return svn_repos_load_fs5(repos, dumpstream, start_rev, end_rev,
946                            uuid_action, parent_dir,
947                            use_post_commit_hook, use_post_commit_hook,
948                            validate_props, FALSE,
949                            notify_func, notify_baton,
950                            cancel_func, cancel_baton, pool);
951}
952
953svn_error_t *
954svn_repos_load_fs3(svn_repos_t *repos,
955                   svn_stream_t *dumpstream,
956                   enum svn_repos_load_uuid uuid_action,
957                   const char *parent_dir,
958                   svn_boolean_t use_pre_commit_hook,
959                   svn_boolean_t use_post_commit_hook,
960                   svn_boolean_t validate_props,
961                   svn_repos_notify_func_t notify_func,
962                   void *notify_baton,
963                   svn_cancel_func_t cancel_func,
964                   void *cancel_baton,
965                   apr_pool_t *pool)
966{
967  return svn_repos_load_fs4(repos, dumpstream,
968                            SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
969                            uuid_action, parent_dir,
970                            use_pre_commit_hook, use_post_commit_hook,
971                            validate_props, notify_func, notify_baton,
972                            cancel_func, cancel_baton, pool);
973}
974
975svn_error_t *
976svn_repos_load_fs2(svn_repos_t *repos,
977                   svn_stream_t *dumpstream,
978                   svn_stream_t *feedback_stream,
979                   enum svn_repos_load_uuid uuid_action,
980                   const char *parent_dir,
981                   svn_boolean_t use_pre_commit_hook,
982                   svn_boolean_t use_post_commit_hook,
983                   svn_cancel_func_t cancel_func,
984                   void *cancel_baton,
985                   apr_pool_t *pool)
986{
987  return svn_repos_load_fs3(repos, dumpstream, uuid_action, parent_dir,
988                            use_pre_commit_hook, use_post_commit_hook, FALSE,
989                            feedback_stream ? repos_notify_handler : NULL,
990                            feedback_stream, cancel_func, cancel_baton, pool);
991}
992
993
994static svn_repos_parser_fns_t *
995fns_from_fns2(const svn_repos_parse_fns2_t *fns2,
996              apr_pool_t *pool)
997{
998  svn_repos_parser_fns_t *fns;
999
1000  fns = apr_palloc(pool, sizeof(*fns));
1001  fns->new_revision_record = fns2->new_revision_record;
1002  fns->uuid_record = fns2->uuid_record;
1003  fns->new_node_record = fns2->new_node_record;
1004  fns->set_revision_property = fns2->set_revision_property;
1005  fns->set_node_property = fns2->set_node_property;
1006  fns->remove_node_props = fns2->remove_node_props;
1007  fns->set_fulltext = fns2->set_fulltext;
1008  fns->close_node = fns2->close_node;
1009  fns->close_revision = fns2->close_revision;
1010  return fns;
1011}
1012
1013static svn_repos_parser_fns2_t *
1014fns2_from_fns3(const svn_repos_parse_fns3_t *fns3,
1015              apr_pool_t *pool)
1016{
1017  svn_repos_parser_fns2_t *fns2;
1018
1019  fns2 = apr_palloc(pool, sizeof(*fns2));
1020  fns2->new_revision_record = fns3->new_revision_record;
1021  fns2->uuid_record = fns3->uuid_record;
1022  fns2->new_node_record = fns3->new_node_record;
1023  fns2->set_revision_property = fns3->set_revision_property;
1024  fns2->set_node_property = fns3->set_node_property;
1025  fns2->remove_node_props = fns3->remove_node_props;
1026  fns2->set_fulltext = fns3->set_fulltext;
1027  fns2->close_node = fns3->close_node;
1028  fns2->close_revision = fns3->close_revision;
1029  fns2->delete_node_property = fns3->delete_node_property;
1030  fns2->apply_textdelta = fns3->apply_textdelta;
1031  return fns2;
1032}
1033
1034static svn_repos_parse_fns2_t *
1035fns2_from_fns(const svn_repos_parser_fns_t *fns,
1036              apr_pool_t *pool)
1037{
1038  svn_repos_parse_fns2_t *fns2;
1039
1040  fns2 = apr_palloc(pool, sizeof(*fns2));
1041  fns2->new_revision_record = fns->new_revision_record;
1042  fns2->uuid_record = fns->uuid_record;
1043  fns2->new_node_record = fns->new_node_record;
1044  fns2->set_revision_property = fns->set_revision_property;
1045  fns2->set_node_property = fns->set_node_property;
1046  fns2->remove_node_props = fns->remove_node_props;
1047  fns2->set_fulltext = fns->set_fulltext;
1048  fns2->close_node = fns->close_node;
1049  fns2->close_revision = fns->close_revision;
1050  fns2->delete_node_property = NULL;
1051  fns2->apply_textdelta = NULL;
1052  return fns2;
1053}
1054
1055static svn_repos_parse_fns3_t *
1056fns3_from_fns2(const svn_repos_parser_fns2_t *fns2,
1057               apr_pool_t *pool)
1058{
1059  svn_repos_parse_fns3_t *fns3;
1060
1061  fns3 = apr_palloc(pool, sizeof(*fns3));
1062  fns3->magic_header_record = NULL;
1063  fns3->uuid_record = fns2->uuid_record;
1064  fns3->new_revision_record = fns2->new_revision_record;
1065  fns3->new_node_record = fns2->new_node_record;
1066  fns3->set_revision_property = fns2->set_revision_property;
1067  fns3->set_node_property = fns2->set_node_property;
1068  fns3->remove_node_props = fns2->remove_node_props;
1069  fns3->set_fulltext = fns2->set_fulltext;
1070  fns3->close_node = fns2->close_node;
1071  fns3->close_revision = fns2->close_revision;
1072  fns3->delete_node_property = fns2->delete_node_property;
1073  fns3->apply_textdelta = fns2->apply_textdelta;
1074  return fns3;
1075}
1076
1077svn_error_t *
1078svn_repos_parse_dumpstream2(svn_stream_t *stream,
1079                            const svn_repos_parser_fns2_t *parse_fns,
1080                            void *parse_baton,
1081                            svn_cancel_func_t cancel_func,
1082                            void *cancel_baton,
1083                            apr_pool_t *pool)
1084{
1085  svn_repos_parse_fns3_t *fns3 = fns3_from_fns2(parse_fns, pool);
1086
1087  return svn_repos_parse_dumpstream3(stream, fns3, parse_baton, FALSE,
1088                                     cancel_func, cancel_baton, pool);
1089}
1090
1091svn_error_t *
1092svn_repos_parse_dumpstream(svn_stream_t *stream,
1093                           const svn_repos_parser_fns_t *parse_fns,
1094                           void *parse_baton,
1095                           svn_cancel_func_t cancel_func,
1096                           void *cancel_baton,
1097                           apr_pool_t *pool)
1098{
1099  svn_repos_parse_fns2_t *fns2 = fns2_from_fns(parse_fns, pool);
1100
1101  return svn_repos_parse_dumpstream2(stream, fns2, parse_baton,
1102                                     cancel_func, cancel_baton, pool);
1103}
1104
1105svn_error_t *
1106svn_repos_load_fs(svn_repos_t *repos,
1107                  svn_stream_t *dumpstream,
1108                  svn_stream_t *feedback_stream,
1109                  enum svn_repos_load_uuid uuid_action,
1110                  const char *parent_dir,
1111                  svn_cancel_func_t cancel_func,
1112                  void *cancel_baton,
1113                  apr_pool_t *pool)
1114{
1115  return svn_repos_load_fs2(repos, dumpstream, feedback_stream,
1116                            uuid_action, parent_dir, FALSE, FALSE,
1117                            cancel_func, cancel_baton, pool);
1118}
1119
1120svn_error_t *
1121svn_repos_get_fs_build_parser5(const svn_repos_parse_fns3_t **parser,
1122                               void **parse_baton,
1123                               svn_repos_t *repos,
1124                               svn_revnum_t start_rev,
1125                               svn_revnum_t end_rev,
1126                               svn_boolean_t use_history,
1127                               svn_boolean_t validate_props,
1128                               enum svn_repos_load_uuid uuid_action,
1129                               const char *parent_dir,
1130                               svn_boolean_t use_pre_commit_hook,
1131                               svn_boolean_t use_post_commit_hook,
1132                               svn_boolean_t ignore_dates,
1133                               svn_repos_notify_func_t notify_func,
1134                               void *notify_baton,
1135                               apr_pool_t *pool)
1136{
1137  SVN_ERR(svn_repos_get_fs_build_parser6(parser, parse_baton,
1138                                         repos,
1139                                         start_rev, end_rev,
1140                                         use_history,
1141                                         validate_props,
1142                                         uuid_action,
1143                                         parent_dir,
1144                                         use_pre_commit_hook,
1145                                         use_post_commit_hook,
1146                                         ignore_dates,
1147                                         FALSE /* normalize_props */,
1148                                         notify_func,
1149                                         notify_baton,
1150                                         pool));
1151  return SVN_NO_ERROR;
1152}
1153
1154svn_error_t *
1155svn_repos_get_fs_build_parser4(const svn_repos_parse_fns3_t **callbacks,
1156                               void **parse_baton,
1157                               svn_repos_t *repos,
1158                               svn_revnum_t start_rev,
1159                               svn_revnum_t end_rev,
1160                               svn_boolean_t use_history,
1161                               svn_boolean_t validate_props,
1162                               enum svn_repos_load_uuid uuid_action,
1163                               const char *parent_dir,
1164                               svn_repos_notify_func_t notify_func,
1165                               void *notify_baton,
1166                               apr_pool_t *pool)
1167{
1168  SVN_ERR(svn_repos_get_fs_build_parser5(callbacks, parse_baton,
1169                                         repos,
1170                                         start_rev, end_rev,
1171                                         use_history,
1172                                         validate_props,
1173                                         uuid_action,
1174                                         parent_dir,
1175                                         FALSE, FALSE, /*hooks */
1176                                         FALSE /*ignore_dates*/,
1177                                         notify_func,
1178                                         notify_baton,
1179                                         pool));
1180  return SVN_NO_ERROR;
1181}
1182
1183svn_error_t *
1184svn_repos_get_fs_build_parser3(const svn_repos_parse_fns2_t **callbacks,
1185                               void **parse_baton,
1186                               svn_repos_t *repos,
1187                               svn_boolean_t use_history,
1188                               svn_boolean_t validate_props,
1189                               enum svn_repos_load_uuid uuid_action,
1190                               const char *parent_dir,
1191                               svn_repos_notify_func_t notify_func,
1192                               void *notify_baton,
1193                               apr_pool_t *pool)
1194{
1195  const svn_repos_parse_fns3_t *fns3;
1196
1197  SVN_ERR(svn_repos_get_fs_build_parser4(&fns3, parse_baton, repos,
1198                                         SVN_INVALID_REVNUM,
1199                                         SVN_INVALID_REVNUM,
1200                                         use_history, validate_props,
1201                                         uuid_action, parent_dir,
1202                                         notify_func, notify_baton, pool));
1203
1204  *callbacks = fns2_from_fns3(fns3, pool);
1205  return SVN_NO_ERROR;
1206}
1207
1208svn_error_t *
1209svn_repos_get_fs_build_parser2(const svn_repos_parse_fns2_t **parser,
1210                               void **parse_baton,
1211                               svn_repos_t *repos,
1212                               svn_boolean_t use_history,
1213                               enum svn_repos_load_uuid uuid_action,
1214                               svn_stream_t *outstream,
1215                               const char *parent_dir,
1216                               apr_pool_t *pool)
1217{
1218  return svn_repos_get_fs_build_parser3(parser, parse_baton, repos, use_history,
1219                                        FALSE, uuid_action, parent_dir,
1220                                        outstream ? repos_notify_handler : NULL,
1221                                        outstream, pool);
1222}
1223
1224svn_error_t *
1225svn_repos_get_fs_build_parser(const svn_repos_parser_fns_t **parser_callbacks,
1226                              void **parse_baton,
1227                              svn_repos_t *repos,
1228                              svn_boolean_t use_history,
1229                              enum svn_repos_load_uuid uuid_action,
1230                              svn_stream_t *outstream,
1231                              const char *parent_dir,
1232                              apr_pool_t *pool)
1233{
1234  const svn_repos_parse_fns2_t *fns2;
1235
1236  SVN_ERR(svn_repos_get_fs_build_parser2(&fns2, parse_baton, repos,
1237                                         use_history, uuid_action, outstream,
1238                                         parent_dir, pool));
1239
1240  *parser_callbacks = fns_from_fns2(fns2, pool);
1241  return SVN_NO_ERROR;
1242}
1243
1244
1245svn_error_t *
1246svn_repos_fs_begin_txn_for_update(svn_fs_txn_t **txn_p,
1247                                  svn_repos_t *repos,
1248                                  svn_revnum_t rev,
1249                                  const char *author,
1250                                  apr_pool_t *pool)
1251{
1252  /* ### someday, we might run a read-hook here. */
1253
1254  /* Begin the transaction. */
1255  SVN_ERR(svn_fs_begin_txn2(txn_p, repos->fs, rev, 0, pool));
1256
1257  /* We pass the author to the filesystem by adding it as a property
1258     on the txn. */
1259
1260  /* User (author). */
1261  if (author)
1262    {
1263      svn_string_t val;
1264      val.data = author;
1265      val.len = strlen(author);
1266      SVN_ERR(svn_fs_change_txn_prop(*txn_p, SVN_PROP_REVISION_AUTHOR,
1267                                     &val, pool));
1268    }
1269
1270  return SVN_NO_ERROR;
1271}
1272
1273/*** From authz.c ***/
1274
1275svn_error_t *
1276svn_repos_authz_read3(svn_authz_t **authz_p,
1277                      const char *path,
1278                      const char *groups_path,
1279                      svn_boolean_t must_exist,
1280                      svn_repos_t *repos_hint,
1281                      apr_pool_t *result_pool,
1282                      apr_pool_t *scratch_pool)
1283{
1284  return svn_error_trace(svn_repos_authz_read4(authz_p, path, groups_path,
1285                                               must_exist, repos_hint,
1286                                               NULL, NULL, result_pool,
1287                                               scratch_pool));
1288}
1289
1290svn_error_t *
1291svn_repos_authz_read2(svn_authz_t **authz_p,
1292                      const char *path,
1293                      const char *groups_path,
1294                      svn_boolean_t must_exist,
1295                      apr_pool_t *pool)
1296{
1297  apr_pool_t *scratch_pool = svn_pool_create(pool);
1298  svn_error_t *err = svn_repos_authz_read3(authz_p, path, groups_path,
1299                                           must_exist, NULL,
1300                                           pool, scratch_pool);
1301  svn_pool_destroy(scratch_pool);
1302
1303  return svn_error_trace(err);
1304}
1305
1306svn_error_t *
1307svn_repos_authz_read(svn_authz_t **authz_p, const char *file,
1308                     svn_boolean_t must_exist, apr_pool_t *pool)
1309{
1310  /* Prevent accidental new features in existing API. */
1311  if (svn_path_is_url(file))
1312    return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL,
1313                             "'%s' is not a file name", file);
1314
1315  return svn_error_trace(svn_repos_authz_read2(authz_p, file, NULL,
1316                                               must_exist, pool));
1317}
1318
1319svn_error_t *
1320svn_repos_authz_parse(svn_authz_t **authz_p,
1321                      svn_stream_t *stream,
1322                      svn_stream_t *groups_stream,
1323                      apr_pool_t *pool)
1324{
1325  apr_pool_t *scratch_pool = svn_pool_create(pool);
1326  svn_error_t *err = svn_repos_authz_parse2(authz_p, stream, groups_stream,
1327                                            NULL, NULL, pool, scratch_pool);
1328  svn_pool_destroy(scratch_pool);
1329
1330  return svn_error_trace(err);
1331}
1332