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_ra_private.h
24 * @brief The Subversion repository access library - Internal routines
27 #ifndef SVN_RA_PRIVATE_H
28 #define SVN_RA_PRIVATE_H
30 #include <apr_pools.h>
32 #include "svn_error.h"
34 #include "svn_delta.h"
35 #include "svn_editor.h"
40 #endif /* __cplusplus */
42 /* Equivalent to svn_ra__assert_capable_server()
43 for SVN_RA_CAPABILITY_MERGEINFO. */
45 svn_ra__assert_mergeinfo_capable_server(svn_ra_session_t *ra_session,
46 const char *path_or_url,
49 /* Return an error with code SVN_ERR_UNSUPPORTED_FEATURE, and an error
50 message referencing PATH_OR_URL, if the "server" pointed to by
51 RA_SESSION doesn't support CAPABILITY (an SVN_RA_CAPABILITY_* constant).
52 Perform temporary allocations in POOL. */
54 svn_ra__assert_capable_server(svn_ra_session_t *ra_session,
55 const char *capability,
56 const char *path_or_url,
60 /*** Operational Locks ***/
62 /** This is a function type which allows svn_ra__get_operational_lock()
63 * to report lock attempt failures. If non-NULL, @a locktoken is the
64 * preexisting lock which prevented lock acquisition.
68 typedef svn_error_t *(*svn_ra__lock_retry_func_t)(void *baton,
69 const svn_string_t *locktoken,
72 /** Acquire a lock (of sorts) on the repository associated with the
73 * given RA @a session, retrying as necessary up to @a num_retries
74 * times, and set @a *lock_string_p to the value of the acquired lock
75 * token. Allocate the returned token from @a pool. (See this
76 * function's counterpart svn_ra__release_operational_lock() for your
77 * lock removal needs.)
79 * @a lock_revprop_name is the name of the revision-0 property used to
82 * If @a steal_lock is set, then replace any pre-existing lock on the
83 * repository with our own. Iff such a theft occurs and
84 * @a stolen_lock_p is non-NULL, set @a *stolen_lock_p to the token of
87 * Call @a retry_func with @a retry_baton each time the retry loop
88 * fails to acquire a lock.
90 * Use @a cancel_func and @a cancel_baton to check for early
93 * @note If the server does not support #SVN_RA_CAPABILITY_ATOMIC_REVPROPS
94 * (i.e., is a pre-1.7 server), then this function makes a "best effort"
95 * attempt to obtain the lock, but is susceptible to a race condition; see
101 svn_ra__get_operational_lock(const svn_string_t **lock_string_p,
102 const svn_string_t **stolen_lock_p,
103 svn_ra_session_t *session,
104 const char *lock_revprop_name,
105 svn_boolean_t steal_lock,
107 svn_ra__lock_retry_func_t retry_func,
109 svn_cancel_func_t cancel_func,
113 /** Release an operational lock (whose value is @a mylocktoken) on the
114 * repository associated with RA @a session. (This is the counterpart
115 * to svn_ra__get_operational_lock().)
117 * @a lock_revprop_name is the name of the revision-0 property used to
120 * Use @a scratch_pool for temporary allocations.
125 svn_ra__release_operational_lock(svn_ra_session_t *session,
126 const char *lock_revprop_name,
127 const svn_string_t *mylocktoken,
128 apr_pool_t *scratch_pool);
130 /** Register CALLBACKS to be used with the Ev2 shims in RA_SESSION. */
132 svn_ra__register_editor_shim_callbacks(svn_ra_session_t *ra_session,
133 svn_delta_shim_callbacks_t *callbacks);
136 /* Using information from BATON, provide the (file's) pristine contents
137 for REPOS_RELPATH. They are returned in *CONTENTS, and correspond to
140 If a pristine is not available (ie. a locally-added node), then set
141 *CONTENTS to NULL; *REVISION will not be examined in this case.
143 These are allocated in RESULT_POOL. SCRATCH_POOL can be used
144 for temporary allocations. */
145 typedef svn_error_t *(*svn_ra__provide_base_cb_t)(
146 svn_stream_t **contents,
147 svn_revnum_t *revision,
149 const char *repos_relpath,
150 apr_pool_t *result_pool,
151 apr_pool_t *scratch_pool);
153 /* Using information from BATON, provide the pristine properties for
154 REPOS_RELPATH. They are returned in *PROPS, and correspond to *REVISION.
156 If properties are not available (ie. a locally-added node), then set
157 *PROPS to NULL; *REVISION will not be examined in this case.
159 The properties are allocated in RESULT_POOL. SCRATCH_POOL can be used
160 for temporary allocations. */
161 typedef svn_error_t *(*svn_ra__provide_props_cb_t)(
163 svn_revnum_t *revision,
165 const char *repos_relpath,
166 apr_pool_t *result_pool,
167 apr_pool_t *scratch_pool);
169 /* Using information from BATON, fetch the kind of REPOS_RELPATH at revision
170 SRC_REVISION, returning it in *KIND.
172 If the kind cannot be determined, then set *KIND to svn_node_unknown.
174 Temporary allocations can be made in SCRATCH_POOL. */
175 typedef svn_error_t *(*svn_ra__get_copysrc_kind_cb_t)(
176 svn_node_kind_t *kind,
178 const char *repos_relpath,
179 svn_revnum_t src_revision,
180 apr_pool_t *scratch_pool);
183 /* Return an Ev2-based editor for performing commits.
185 The editor is associated with the given SESSION, and its implied target
188 REVPROPS contains all the revision properties that should be stored onto
189 the newly-committed revision. SVN_PROP_REVISION_AUTHOR will be set to
190 the username as determined by the session; overwriting any prior value
191 that may be present in REVPROPS.
193 COMMIT_CB/BATON contain the callback to receive post-commit information.
195 LOCK_TOKENS should contain all lock tokens necessary to modify paths
196 within the commit. If KEEP_LOCKS is FALSE, then the paths associated
197 with these tokens will be unlocked.
198 ### today, LOCK_TOKENS is session_relpath:token_value. in the future,
199 ### it should be repos_relpath:token_value.
201 PROVIDE_BASE_CB is a callback to fetch pristine contents, used to send
202 an svndiff over the wire to the server. This may be NULL, indicating
203 pristine contents are not available (eg. URL-based operations or import).
205 PROVIDE_PROPS_CB is a callback to fetch pristine properties, used to
206 send property deltas over the wire to the server. This may be NULL,
207 indicating pristine properties are not available (eg. URL-based operations
210 GET_COPYSRC_KIND_CB is a callback to determine the kind of a copy-source.
211 This is necessary when an Ev2/Ev1 shim is required by the RA provider,
212 in order to determine whether to use delta->add_directory() or the
213 delta->add_file() vtable entry to perform the copy.
214 ### unclear on impact if this is NULL.
215 ### this callback will disappear when "everything" is running Ev2
217 CB_BATON is the baton used/shared by the above three callbacks.
219 Cancellation is handled through the callbacks provided when SESSION
222 *EDITOR will be allocated in RESULT_POOL, and all temporary allocations
223 will be performed in SCRATCH_POOL.
226 svn_ra__get_commit_ev2(svn_editor_t **editor,
227 svn_ra_session_t *session,
228 apr_hash_t *revprops,
229 svn_commit_callback2_t commit_cb,
231 apr_hash_t *lock_tokens,
232 svn_boolean_t keep_locks,
233 svn_ra__provide_base_cb_t provide_base_cb,
234 svn_ra__provide_props_cb_t provide_props_cb,
235 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
237 apr_pool_t *result_pool,
238 apr_pool_t *scratch_pool);
241 /* Similar to #svn_ra_replay_revstart_callback_t, but with an Ev2 editor. */
242 typedef svn_error_t *(*svn_ra__replay_revstart_ev2_callback_t)(
243 svn_revnum_t revision,
245 svn_editor_t **editor,
246 apr_hash_t *rev_props,
249 /* Similar to #svn_ra_replay_revfinish_callback_t, but with an Ev2 editor. */
250 typedef svn_error_t *(*svn_ra__replay_revfinish_ev2_callback_t)(
251 svn_revnum_t revision,
253 svn_editor_t *editor,
254 apr_hash_t *rev_props,
257 /* Similar to svn_ra_replay_range(), but uses Ev2 versions of the callback
260 svn_ra__replay_range_ev2(svn_ra_session_t *session,
261 svn_revnum_t start_revision,
262 svn_revnum_t end_revision,
263 svn_revnum_t low_water_mark,
264 svn_boolean_t send_deltas,
265 svn_ra__replay_revstart_ev2_callback_t revstart_func,
266 svn_ra__replay_revfinish_ev2_callback_t revfinish_func,
268 svn_ra__provide_base_cb_t provide_base_cb,
269 svn_ra__provide_props_cb_t provide_props_cb,
270 svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb,
272 apr_pool_t *scratch_pool);
274 /* Similar to svn_ra_replay(), but with an Ev2 editor. */
276 svn_ra__replay_ev2(svn_ra_session_t *session,
277 svn_revnum_t revision,
278 svn_revnum_t low_water_mark,
279 svn_boolean_t send_deltas,
280 svn_editor_t *editor,
281 apr_pool_t *scratch_pool);
286 #endif /* __cplusplus */
288 #endif /* SVN_RA_PRIVATE_H */