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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * ====================================================================
23 * @file svn_branch_compat.h
24 * @brief Compatibility with svn_delta_editor_t etc.
29 #ifndef SVN_BRANCH_COMPAT_H
30 #define SVN_BRANCH_COMPAT_H
32 #include <apr_pools.h>
34 #include "svn_types.h"
35 #include "svn_error.h"
36 #include "svn_delta.h"
38 #include "private/svn_branch.h"
42 #endif /* __cplusplus */
45 /** Callback to retrieve a node's kind and content. This is
46 * needed by the various editor shims in order to effect backwards
49 * Implementations should set @a *kind to the node kind of @a repos_relpath
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'.
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.
62 * Any output argument may be NULL if the output is not wanted.
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.
70 typedef svn_error_t *(*svn_branch__compat_fetch_func_t)(
71 svn_node_kind_t *kind,
73 svn_stringbuf_t **file_text,
74 apr_hash_t **children_names,
76 const char *repos_relpath,
77 svn_revnum_t revision,
78 apr_pool_t *result_pool,
79 apr_pool_t *scratch_pool
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,
90 apr_pool_t *result_pool,
91 apr_pool_t *scratch_pool);
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;
97 /* Return an Ev3 editor in *EDITOR_P which will drive the Ev1 delta
98 * editor DEDITOR/DEDIT_BATON.
100 * This editor buffers all the changes and then drives the Ev1 when the
101 * returned editor's "close" method is called.
103 * This editor converts moves into copy-and-delete. It presently makes a
104 * one-way (lossy) conversion.
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
109 * - Use 'entry-props'?
110 * - Send copy-and-delete with copy-from-rev = -1?
112 * This editor implements the "independent per-element changes" variant
113 * of the Ev3 commit editor interface.
115 * Use *BRANCHING_TXN as the branching state info ...
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.
122 * REPOS_ROOT_URL is the repository root URL.
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.
127 * CANCEL_FUNC / CANCEL_BATON: The usual cancellation callback; folded
128 * into the produced editor. May be NULL/NULL if not wanted.
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
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,
140 svn_branch__txn_t *branching_txn,
141 const char *repos_root_url,
142 svn_branch__compat_fetch_func_t fetch_func,
144 svn_cancel_func_t cancel_func,
146 apr_pool_t *result_pool,
147 apr_pool_t *scratch_pool);
149 /* Return a delta editor in DEDITOR/DEDITOR_BATON which will drive EDITOR.
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.)
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.
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.
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
167 svn_branch__compat_delta_from_txn_for_commit(
168 const svn_delta_editor_t **deditor,
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,
175 const svn_branch__compat_shim_connector_t *shim_connector,
176 apr_pool_t *result_pool,
177 apr_pool_t *scratch_pool);
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.
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.
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.
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,
199 apr_pool_t *result_pool,
200 apr_pool_t *scratch_pool);
202 /* A callback for declaring the target revision of an update or switch.
204 typedef svn_error_t *(*svn_branch__compat_set_target_revision_func_t)(
206 svn_revnum_t target_revision,
207 apr_pool_t *scratch_pool);
209 /* An update (or switch) editor.
211 * This consists of a plain Ev3 editor and the additional methods or
212 * resources needed for use as an update or switch editor.
214 typedef struct svn_branch__compat_update_editor3_t {
215 /* The txn we're driving. */
216 svn_branch__txn_t *edit_txn;
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;
226 /* Like svn_delta__ev3_from_delta_for_commit() but for an update editor.
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,
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,
238 svn_cancel_func_t cancel_func,
240 apr_pool_t *result_pool,
241 apr_pool_t *scratch_pool);
243 /* Like svn_delta__delta_from_ev3_for_commit() but for an update editor.
246 svn_branch__compat_delta_from_txn_for_update(
247 const svn_delta_editor_t **deditor,
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,
254 apr_pool_t *result_pool,
255 apr_pool_t *scratch_pool);
257 /* An Ev1 editor that drives (heuristically) a move-tracking editor.
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);
271 #endif /* __cplusplus */
273 #endif /* SVN_BRANCH_COMPAT_H */