]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/subversion/subversion/include/private/svn_ra_private.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / subversion / subversion / include / private / svn_ra_private.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_ra_private.h
24  * @brief The Subversion repository access library - Internal routines
25  */
26
27 #ifndef SVN_RA_PRIVATE_H
28 #define SVN_RA_PRIVATE_H
29
30 #include <apr_pools.h>
31
32 #include "svn_error.h"
33 #include "svn_ra.h"
34 #include "svn_delta.h"
35 #include "svn_editor.h"
36 #include "svn_io.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41
42 /* Equivalent to svn_ra__assert_capable_server()
43    for SVN_RA_CAPABILITY_MERGEINFO. */
44 svn_error_t *
45 svn_ra__assert_mergeinfo_capable_server(svn_ra_session_t *ra_session,
46                                         const char *path_or_url,
47                                         apr_pool_t *pool);
48
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. */
53 svn_error_t *
54 svn_ra__assert_capable_server(svn_ra_session_t *ra_session,
55                               const char *capability,
56                               const char *path_or_url,
57                               apr_pool_t *pool);
58
59 \f
60 /*** Operational Locks ***/
61
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.
65  *
66  * @since New in 1.7.
67  */
68 typedef svn_error_t *(*svn_ra__lock_retry_func_t)(void *baton,
69                                                   const svn_string_t *locktoken,
70                                                   apr_pool_t *pool);
71
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.)
78  *
79  * @a lock_revprop_name is the name of the revision-0 property used to
80  * store the lock.
81  *
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
85  * the lock we stole.
86  *
87  * Call @a retry_func with @a retry_baton each time the retry loop
88  * fails to acquire a lock.
89  *
90  * Use @a cancel_func and @a cancel_baton to check for early
91  * cancellation.
92  *
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
96  * issue #3546.
97  *
98  * @since New in 1.7.
99  */
100 svn_error_t *
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,
106                              int num_retries,
107                              svn_ra__lock_retry_func_t retry_func,
108                              void *retry_baton,
109                              svn_cancel_func_t cancel_func,
110                              void *cancel_baton,
111                              apr_pool_t *pool);
112
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().)
116  *
117  * @a lock_revprop_name is the name of the revision-0 property used to
118  * store the lock.
119  *
120  * Use @a scratch_pool for temporary allocations.
121  *
122  * @since New in 1.7.
123  */
124 svn_error_t *
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);
129
130 /** Register CALLBACKS to be used with the Ev2 shims in RA_SESSION. */
131 svn_error_t *
132 svn_ra__register_editor_shim_callbacks(svn_ra_session_t *ra_session,
133                                        svn_delta_shim_callbacks_t *callbacks);
134
135
136 /* Using information from BATON, provide the (file's) pristine contents
137    for REPOS_RELPATH. They are returned in *CONTENTS, and correspond to
138    *REVISION.
139
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.
142
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,
148   void *baton,
149   const char *repos_relpath,
150   apr_pool_t *result_pool,
151   apr_pool_t *scratch_pool);
152
153 /* Using information from BATON, provide the pristine properties for
154    REPOS_RELPATH. They are returned in *PROPS, and correspond to *REVISION.
155
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.
158
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)(
162   apr_hash_t **props,
163   svn_revnum_t *revision,
164   void *baton,
165   const char *repos_relpath,
166   apr_pool_t *result_pool,
167   apr_pool_t *scratch_pool);
168
169 /* Using information from BATON, fetch the kind of REPOS_RELPATH at revision
170    SRC_REVISION, returning it in *KIND.
171
172    If the kind cannot be determined, then set *KIND to svn_node_unknown.
173
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,
177   void *baton,
178   const char *repos_relpath,
179   svn_revnum_t src_revision,
180   apr_pool_t *scratch_pool);
181
182
183 /* Return an Ev2-based editor for performing commits.
184
185    The editor is associated with the given SESSION, and its implied target
186    repository.
187
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.
192
193    COMMIT_CB/BATON contain the callback to receive post-commit information.
194
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.
200
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).
204
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
208    or an import).
209
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
216
217    CB_BATON is the baton used/shared by the above three callbacks.
218
219    Cancellation is handled through the callbacks provided when SESSION
220    is initially opened.
221
222    *EDITOR will be allocated in RESULT_POOL, and all temporary allocations
223    will be performed in SCRATCH_POOL.
224 */
225 svn_error_t *
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,
230                        void *commit_baton,
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,
236                        void *cb_baton,
237                        apr_pool_t *result_pool,
238                        apr_pool_t *scratch_pool);
239
240
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,
244   void *replay_baton,
245   svn_editor_t **editor,
246   apr_hash_t *rev_props,
247   apr_pool_t *pool);
248
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,
252   void *replay_baton,
253   svn_editor_t *editor,
254   apr_hash_t *rev_props,
255   apr_pool_t *pool);
256
257 /* Similar to svn_ra_replay_range(), but uses Ev2 versions of the callback
258    functions. */
259 svn_error_t *
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,
267                          void *replay_baton,
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,
271                          void *cb_baton,
272                          apr_pool_t *scratch_pool);
273
274 /* Similar to svn_ra_replay(), but with an Ev2 editor. */
275 svn_error_t *
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);
282
283
284 #ifdef __cplusplus
285 }
286 #endif /* __cplusplus */
287
288 #endif /* SVN_RA_PRIVATE_H */