]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/include/private/svn_branch_compat.h
Update svn-1.9.7 to 1.10.0.
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / include / private / svn_branch_compat.h
1 /**
2  * @copyright
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_branch_compat.h
24  * @brief Compatibility with svn_delta_editor_t etc.
25  *
26  * @since New in ???.
27  */
28
29 #ifndef SVN_BRANCH_COMPAT_H
30 #define SVN_BRANCH_COMPAT_H
31
32 #include <apr_pools.h>
33
34 #include "svn_types.h"
35 #include "svn_error.h"
36 #include "svn_delta.h"
37 #include "svn_ra.h"
38 #include "private/svn_branch.h"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43
44
45 /** Callback to retrieve a node's kind and content.  This is
46  * needed by the various editor shims in order to effect backwards
47  * compatibility.
48  *
49  * Implementations should set @a *kind to the node kind of @a repos_relpath
50  * in @a revision.
51  *
52  * Implementations should set @a *props to the hash of properties
53  * associated with @a repos_relpath in @a revision, allocating that hash
54  * and its contents in @a result_pool. Only the 'regular' props should be
55  * included, not special props such as 'entry props'.
56  *
57  * Implementations should set @a *filename to the name of a file
58  * suitable for use as a delta base for @a repos_relpath in @a revision
59  * (allocating @a *filename from @a result_pool), or to @c NULL if the
60  * base stream is empty.
61  *
62  * Any output argument may be NULL if the output is not wanted.
63  *
64  * @a baton is an implementation-specific closure.
65  * @a repos_relpath is relative to the repository root.
66  * The implementation should ensure that @a new_content, including any
67  * file therein, lives at least for the life time of @a result_pool.
68  * @a scratch_pool is provided for temporary allocations.
69  */
70 typedef svn_error_t *(*svn_branch__compat_fetch_func_t)(
71   svn_node_kind_t *kind,
72   apr_hash_t **props,
73   svn_stringbuf_t **file_text,
74   apr_hash_t **children_names,
75   void *baton,
76   const char *repos_relpath,
77   svn_revnum_t revision,
78   apr_pool_t *result_pool,
79   apr_pool_t *scratch_pool
80   );
81
82 /*
83  */
84 svn_error_t *
85 svn_branch__compat_fetch(svn_element__payload_t **payload_p,
86                          svn_branch__txn_t *txn,
87                          svn_element__branch_ref_t branch_ref,
88                          svn_branch__compat_fetch_func_t fetch_func,
89                          void *fetch_baton,
90                          apr_pool_t *result_pool,
91                          apr_pool_t *scratch_pool);
92
93 /* An object for communicating out-of-band details between an Ev1-to-Ev3
94  * shim and an Ev3-to-Ev1 shim. */
95 typedef struct svn_branch__compat_shim_connector_t svn_branch__compat_shim_connector_t;
96
97 /* Return an Ev3 editor in *EDITOR_P which will drive the Ev1 delta
98  * editor DEDITOR/DEDIT_BATON.
99  *
100  * This editor buffers all the changes and then drives the Ev1 when the
101  * returned editor's "close" method is called.
102  *
103  * This editor converts moves into copy-and-delete. It presently makes a
104  * one-way (lossy) conversion.
105  *
106  *   TODO: Option to pass the 'move' information through as some sort of
107  *   metadata so that it can be preserved in an Ev3-Ev1-Ev3 round-trip
108  *   conversion.
109  *     - Use 'entry-props'?
110  *     - Send copy-and-delete with copy-from-rev = -1?
111  *
112  * This editor implements the "independent per-element changes" variant
113  * of the Ev3 commit editor interface.
114  *
115  * Use *BRANCHING_TXN as the branching state info ...
116  *
117  * SHIM_CONNECTOR can be used to enable a more exact round-trip conversion
118  * from an Ev1 drive to Ev3 and back to Ev1. The caller should pass the
119  * returned *SHIM_CONNECTOR value to svn_delta__delta_from_ev3_for_commit().
120  * SHIM_CONNECTOR may be null if not wanted.
121  *
122  * REPOS_ROOT_URL is the repository root URL.
123  *
124  * FETCH_FUNC/FETCH_BATON is a callback by which the shim may retrieve the
125  * original or copy-from kind/properties/text for a path being committed.
126  *
127  * CANCEL_FUNC / CANCEL_BATON: The usual cancellation callback; folded
128  * into the produced editor. May be NULL/NULL if not wanted.
129  *
130  * Allocate the new editor in RESULT_POOL, which may become large and must
131  * live for the lifetime of the edit. Use SCRATCH_POOL for temporary
132  * allocations.
133  */
134 svn_error_t *
135 svn_branch__compat_txn_from_delta_for_commit(
136                         svn_branch__txn_t **txn_p,
137                         svn_branch__compat_shim_connector_t **shim_connector,
138                         const svn_delta_editor_t *deditor,
139                         void *dedit_baton,
140                         svn_branch__txn_t *branching_txn,
141                         const char *repos_root_url,
142                         svn_branch__compat_fetch_func_t fetch_func,
143                         void *fetch_baton,
144                         svn_cancel_func_t cancel_func,
145                         void *cancel_baton,
146                         apr_pool_t *result_pool,
147                         apr_pool_t *scratch_pool);
148
149 /* Return a delta editor in DEDITOR/DEDITOR_BATON which will drive EDITOR.
150  *
151  * REPOS_ROOT_URL is the repository root URL, and BASE_RELPATH is the
152  * relative path within the repository of the root directory of the edit.
153  * (An Ev1 edit must be rooted at a directory, not at a file.)
154  *
155  * FETCH_FUNC/FETCH_BATON is a callback by which the shim may retrieve the
156  * original or copy-from kind/properties/text for a path being committed.
157  *
158  * SHIM_CONNECTOR can be used to enable a more exact round-trip conversion
159  * from an Ev1 drive to Ev3 and back to Ev1. It must live for the lifetime
160  * of the edit. It may be null if not wanted.
161  *
162  * Allocate the new editor in RESULT_POOL, which may become large and must
163  * live for the lifetime of the edit. Use SCRATCH_POOL for temporary
164  * allocations.
165  */
166 svn_error_t *
167 svn_branch__compat_delta_from_txn_for_commit(
168                         const svn_delta_editor_t **deditor,
169                         void **dedit_baton,
170                         svn_branch__txn_t *edit_txn,
171                         const char *repos_root_url,
172                         const char *base_relpath,
173                         svn_branch__compat_fetch_func_t fetch_func,
174                         void *fetch_baton,
175                         const svn_branch__compat_shim_connector_t *shim_connector,
176                         apr_pool_t *result_pool,
177                         apr_pool_t *scratch_pool);
178
179 /* Return in NEW_DEDITOR/NEW_DETIT_BATON a delta editor that wraps
180  * OLD_DEDITOR/OLD_DEDIT_BATON, inserting a pair of shims that convert
181  * Ev1 to Ev3 and back to Ev1.
182  *
183  * REPOS_ROOT_URL is the repository root URL, and BASE_RELPATH is the
184  * relative path within the repository of the root directory of the edit.
185  *
186  * FETCH_FUNC/FETCH_BATON is a callback by which the shim may retrieve the
187  * original or copy-from kind/properties/text for a path being committed.
188  */
189 svn_error_t *
190 svn_branch__compat_insert_shims(
191                         const svn_delta_editor_t **new_deditor,
192                         void **new_dedit_baton,
193                         const svn_delta_editor_t *old_deditor,
194                         void *old_dedit_baton,
195                         const char *repos_root,
196                         const char *base_relpath,
197                         svn_branch__compat_fetch_func_t fetch_func,
198                         void *fetch_baton,
199                         apr_pool_t *result_pool,
200                         apr_pool_t *scratch_pool);
201
202 /* A callback for declaring the target revision of an update or switch.
203  */
204 typedef svn_error_t *(*svn_branch__compat_set_target_revision_func_t)(
205   void *baton,
206   svn_revnum_t target_revision,
207   apr_pool_t *scratch_pool);
208
209 /* An update (or switch) editor.
210  *
211  * This consists of a plain Ev3 editor and the additional methods or
212  * resources needed for use as an update or switch editor.
213  */
214 typedef struct svn_branch__compat_update_editor3_t {
215   /* The txn we're driving. */
216   svn_branch__txn_t *edit_txn;
217
218   /* A method to communicate the target revision of the update (or switch),
219    * to be called before driving the editor. It has its own baton, rather
220    * than using the editor's baton, so that the editor can be replaced (by
221    * a wrapper editor, typically) without having to wrap this callback. */
222   svn_branch__compat_set_target_revision_func_t set_target_revision_func;
223   void *set_target_revision_baton;
224 } svn_branch__compat_update_editor3_t;
225
226 /* Like svn_delta__ev3_from_delta_for_commit() but for an update editor.
227  */
228 svn_error_t *
229 svn_branch__compat_txn_from_delta_for_update(
230                         svn_branch__compat_update_editor3_t **editor_p,
231                         const svn_delta_editor_t *deditor,
232                         void *dedit_baton,
233                         svn_branch__txn_t *branching_txn,
234                         const char *repos_root_url,
235                         const char *base_repos_relpath,
236                         svn_branch__compat_fetch_func_t fetch_func,
237                         void *fetch_baton,
238                         svn_cancel_func_t cancel_func,
239                         void *cancel_baton,
240                         apr_pool_t *result_pool,
241                         apr_pool_t *scratch_pool);
242
243 /* Like svn_delta__delta_from_ev3_for_commit() but for an update editor.
244  */
245 svn_error_t *
246 svn_branch__compat_delta_from_txn_for_update(
247                         const svn_delta_editor_t **deditor,
248                         void **dedit_baton,
249                         svn_branch__compat_update_editor3_t *update_editor,
250                         const char *repos_root_url,
251                         const char *base_repos_relpath,
252                         svn_branch__compat_fetch_func_t fetch_func,
253                         void *fetch_baton,
254                         apr_pool_t *result_pool,
255                         apr_pool_t *scratch_pool);
256
257 /* An Ev1 editor that drives (heuristically) a move-tracking editor.
258  */
259 svn_error_t *
260 svn_branch__compat_get_migration_editor(
261                         const svn_delta_editor_t **old_editor,
262                         void **old_edit_baton,
263                         svn_branch__txn_t *edit_txn,
264                         svn_ra_session_t *from_session,
265                         svn_revnum_t revision,
266                         apr_pool_t *result_pool);
267
268
269 #ifdef __cplusplus
270 }
271 #endif /* __cplusplus */
272
273 #endif /* SVN_BRANCH_COMPAT_H */