]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/include/private/svn_client_private.h
Update Subversion to 1.14.0 LTS. See contrib/subversion/CHANGES for a
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / include / private / svn_client_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_client_private.h
24  * @brief Subversion-internal client APIs.
25  */
26
27 #ifndef SVN_CLIENT_PRIVATE_H
28 #define SVN_CLIENT_PRIVATE_H
29
30 #include <apr_pools.h>
31
32 #include "svn_ra.h"
33 #include "svn_client.h"
34 #include "svn_types.h"
35
36 #include "private/svn_diff_tree.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41
42
43 /* Set *REVNUM to the revision number identified by REVISION.
44
45    If REVISION->kind is svn_opt_revision_number, just use
46    REVISION->value.number, ignoring LOCAL_ABSPATH and RA_SESSION.
47
48    Else if REVISION->kind is svn_opt_revision_committed,
49    svn_opt_revision_previous, or svn_opt_revision_base, or
50    svn_opt_revision_working, then the revision can be identified
51    purely based on the working copy's administrative information for
52    LOCAL_ABSPATH, so RA_SESSION is ignored.  If LOCAL_ABSPATH is not
53    under revision control, return SVN_ERR_UNVERSIONED_RESOURCE, or if
54    LOCAL_ABSPATH is null, return SVN_ERR_CLIENT_VERSIONED_PATH_REQUIRED.
55
56    Else if REVISION->kind is svn_opt_revision_date or
57    svn_opt_revision_head, then RA_SESSION is used to retrieve the
58    revision from the repository (using REVISION->value.date in the
59    former case), and LOCAL_ABSPATH is ignored.  If RA_SESSION is null,
60    return SVN_ERR_CLIENT_RA_ACCESS_REQUIRED.
61
62    Else if REVISION->kind is svn_opt_revision_unspecified, set
63    *REVNUM to SVN_INVALID_REVNUM.
64
65    If YOUNGEST_REV is non-NULL, it is an in/out parameter.  If
66    *YOUNGEST_REV is valid, use it as the youngest revision in the
67    repository (regardless of reality) -- don't bother to lookup the
68    true value for HEAD, and don't return any value in *REVNUM greater
69    than *YOUNGEST_REV.  If *YOUNGEST_REV is not valid, and a HEAD
70    lookup is required to populate *REVNUM, then also populate
71    *YOUNGEST_REV with the result.  This is useful for making multiple
72    serialized calls to this function with a basically static view of
73    the repository, avoiding race conditions which could occur between
74    multiple invocations with HEAD lookup requests.
75
76    Else return SVN_ERR_CLIENT_BAD_REVISION.
77
78    Use SCRATCH_POOL for any temporary allocation.  */
79 svn_error_t *
80 svn_client__get_revision_number(svn_revnum_t *revnum,
81                                 svn_revnum_t *youngest_rev,
82                                 svn_wc_context_t *wc_ctx,
83                                 const char *local_abspath,
84                                 svn_ra_session_t *ra_session,
85                                 const svn_opt_revision_t *revision,
86                                 apr_pool_t *scratch_pool);
87
88 /* Return true if KIND is a revision kind that is dependent on the working
89  * copy. Otherwise, return false. */
90 #define SVN_CLIENT__REVKIND_NEEDS_WC(kind)                                 \
91   ((kind) == svn_opt_revision_base ||                                      \
92    (kind) == svn_opt_revision_previous ||                                  \
93    (kind) == svn_opt_revision_working ||                                   \
94    (kind) == svn_opt_revision_committed)                                   \
95
96 /* Return true if KIND is a revision kind that the WC can supply without
97  * contacting the repository. Otherwise, return false. */
98 #define SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(kind)                           \
99   ((kind) == svn_opt_revision_base ||                                      \
100    (kind) == svn_opt_revision_working ||                                   \
101    (kind) == svn_opt_revision_committed)
102
103 /* A location in a repository. */
104 typedef struct svn_client__pathrev_t
105 {
106   const char *repos_root_url;
107   const char *repos_uuid;
108   svn_revnum_t rev;
109   const char *url;
110 } svn_client__pathrev_t;
111
112 /* Return a new path-rev structure, allocated in RESULT_POOL,
113  * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, REV and URL. */
114 svn_client__pathrev_t *
115 svn_client__pathrev_create(const char *repos_root_url,
116                            const char *repos_uuid,
117                            svn_revnum_t rev,
118                            const char *url,
119                            apr_pool_t *result_pool);
120
121 /* Return a new path-rev structure, allocated in RESULT_POOL,
122  * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, and REV,
123  * and using the repository-relative RELPATH to construct the URL. */
124 svn_client__pathrev_t *
125 svn_client__pathrev_create_with_relpath(const char *repos_root_url,
126                                         const char *repos_uuid,
127                                         svn_revnum_t rev,
128                                         const char *relpath,
129                                         apr_pool_t *result_pool);
130
131 /* Set *PATHREV_P to a new path-rev structure, allocated in RESULT_POOL,
132  * initialized with deep copies of the repository root URL and UUID from
133  * RA_SESSION, and of REV and URL. */
134 svn_error_t *
135 svn_client__pathrev_create_with_session(svn_client__pathrev_t **pathrev_p,
136                                         svn_ra_session_t *ra_session,
137                                         svn_revnum_t rev,
138                                         const char *url,
139                                         apr_pool_t *result_pool);
140
141 /* Return a deep copy of PATHREV, allocated in RESULT_POOL. */
142 svn_client__pathrev_t *
143 svn_client__pathrev_dup(const svn_client__pathrev_t *pathrev,
144                         apr_pool_t *result_pool);
145
146 /* Return a deep copy of PATHREV, with a URI-encoded representation of
147  * RELPATH joined on to the URL.  Allocate the result in RESULT_POOL. */
148 svn_client__pathrev_t *
149 svn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev,
150                                  const char *relpath,
151                                  apr_pool_t *result_pool);
152
153 /* Return the repository-relative relpath of PATHREV. */
154 const char *
155 svn_client__pathrev_relpath(const svn_client__pathrev_t *pathrev,
156                             apr_pool_t *result_pool);
157
158 /* Return the repository-relative fspath of PATHREV. */
159 const char *
160 svn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev,
161                            apr_pool_t *result_pool);
162
163 /* Given PATH_OR_URL, which contains either a working copy path or an
164    absolute URL, a peg revision PEG_REVISION, and a desired revision
165    REVISION, create an RA connection to that object as it exists in
166    that revision, following copy history if necessary.  If REVISION is
167    younger than PEG_REVISION, then PATH_OR_URL will be checked to see
168    that it is the same node in both PEG_REVISION and REVISION.  If it
169    is not, then @c SVN_ERR_CLIENT_UNRELATED_RESOURCES is returned.
170
171    BASE_DIR_ABSPATH is the working copy path the ra_session corresponds
172    to. If provided it will be used to read and dav props. So if provided
173    this directory MUST match the session anchor.
174
175    If PEG_REVISION->kind is 'unspecified', the peg revision is 'head'
176    for a URL or 'working' for a WC path.  If REVISION->kind is
177    'unspecified', the operative revision is the peg revision.
178
179    Store the resulting ra_session in *RA_SESSION_P.  Store the final
180    resolved location of the object in *RESOLVED_LOC_P.  RESOLVED_LOC_P
181    may be NULL if not wanted.
182
183    Use authentication baton cached in CTX to authenticate against the
184    repository.
185
186    Use POOL for all allocations. */
187 svn_error_t *
188 svn_client__ra_session_from_path2(svn_ra_session_t **ra_session_p,
189                                  svn_client__pathrev_t **resolved_loc_p,
190                                  const char *path_or_url,
191                                  const char *base_dir_abspath,
192                                  const svn_opt_revision_t *peg_revision,
193                                  const svn_opt_revision_t *revision,
194                                  svn_client_ctx_t *ctx,
195                                  apr_pool_t *pool);
196
197 /* Given PATH_OR_URL, which contains either a working copy path or an
198    absolute URL, a peg revision PEG_REVISION, and a desired revision
199    REVISION, find the path at which that object exists in REVISION,
200    following copy history if necessary.  If REVISION is younger than
201    PEG_REVISION, then check that PATH_OR_URL is the same node in both
202    PEG_REVISION and REVISION, and return @c
203    SVN_ERR_CLIENT_UNRELATED_RESOURCES if it is not the same node.
204
205    If PEG_REVISION->kind is 'unspecified', the peg revision is 'head'
206    for a URL or 'working' for a WC path.  If REVISION->kind is
207    'unspecified', the operative revision is the peg revision.
208
209    Store the actual location of the object in *RESOLVED_LOC_P.
210
211    RA_SESSION should be an open RA session pointing at the URL of
212    PATH_OR_URL, or NULL, in which case this function will open its own
213    temporary session.
214
215    Use authentication baton cached in CTX to authenticate against the
216    repository.
217
218    Use POOL for all allocations. */
219 svn_error_t *
220 svn_client__resolve_rev_and_url(svn_client__pathrev_t **resolved_loc_p,
221                                 svn_ra_session_t *ra_session,
222                                 const char *path_or_url,
223                                 const svn_opt_revision_t *peg_revision,
224                                 const svn_opt_revision_t *revision,
225                                 svn_client_ctx_t *ctx,
226                                 apr_pool_t *pool);
227
228 /** Return @c SVN_ERR_ILLEGAL_TARGET if TARGETS contains a mixture of
229  * URLs and paths; otherwise return SVN_NO_ERROR.
230  *
231  * @since New in 1.7.
232  */
233 svn_error_t *
234 svn_client__assert_homogeneous_target_type(const apr_array_header_t *targets);
235
236
237 /* Create a svn_client_status_t structure *CST for LOCAL_ABSPATH, shallow
238  * copying data from *STATUS wherever possible and retrieving the other values
239  * where needed. Perform temporary allocations in SCRATCH_POOL and allocate the
240  * result in RESULT_POOL
241  */
242 svn_error_t *
243 svn_client__create_status(svn_client_status_t **cst,
244                           svn_wc_context_t *wc_ctx,
245                           const char *local_abspath,
246                           const svn_wc_status3_t *status,
247                           apr_pool_t *result_pool,
248                           apr_pool_t *scratch_pool);
249
250 /* Get the repository location of the base node at LOCAL_ABSPATH.
251  *
252  * A pathrev_t wrapper around svn_wc__node_get_base().
253  *
254  * Set *BASE_P to the location that this node was checked out at or last
255  * updated/switched to, regardless of any uncommitted changes (delete,
256  * replace and/or copy-here/move-here).
257  *
258  * If there is no base node at LOCAL_ABSPATH (such as when there is a
259  * locally added/copied/moved-here node that is not part of a replace),
260  * set *BASE_P to NULL.
261  */
262 svn_error_t *
263 svn_client__wc_node_get_base(svn_client__pathrev_t **base_p,
264                              const char *wc_abspath,
265                              svn_wc_context_t *wc_ctx,
266                              apr_pool_t *result_pool,
267                              apr_pool_t *scratch_pool);
268
269 /* Get the original location of the WC node at LOCAL_ABSPATH.
270  *
271  * A pathrev_t wrapper around svn_wc__node_get_origin().
272  *
273  * Set *ORIGIN_P to the origin of the WC node at WC_ABSPATH.  If the node
274  * is a local copy, give the copy-from location.  If the node is locally
275  * added or deleted, set *ORIGIN_P to NULL.
276  */
277 svn_error_t *
278 svn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p,
279                                const char *wc_abspath,
280                                svn_client_ctx_t *ctx,
281                                apr_pool_t *result_pool,
282                                apr_pool_t *scratch_pool);
283
284 /* Same as the public svn_client_mergeinfo_log2 API, except for the addition
285  * of the TARGET_MERGEINFO_CATALOG and RESULT_POOL parameters.
286  *
287  * If TARGET_MERGEINFO_CATALOG is NULL then this acts exactly as the public
288  * API.  If *TARGET_MERGEINFO_CATALOG is NULL, then *TARGET_MERGEINFO_CATALOG
289  * is set to the a mergeinfo catalog representing the mergeinfo on
290  * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH, (like the public API only
291  * depths of svn_depth_empty or svn_depth_infinity are supported) allocated in
292  * RESULT_POOL.  Finally, if *TARGET_MERGEINFO_CATALOG is non-NULL, then it is
293  * assumed to be a mergeinfo catalog representing the mergeinfo on
294  * TARGET_PATH_OR_URL@TARGET_PEG_REVISION at DEPTH.
295  *
296  * The keys for the subtree mergeinfo are the repository root-relative
297  * paths of TARGET_PATH_OR_URL and/or its subtrees, regardless of whether
298  * TARGET_PATH_OR_URL is a URL or WC path.
299  *
300  * If RA_SESSION is not NULL, use it to obtain merge information instead of
301  * opening a new session. The session might be reparented after usage, so
302  * callers should reparent the session back to their original location if
303  * needed.
304  */
305 svn_error_t *
306 svn_client__mergeinfo_log(svn_boolean_t finding_merged,
307                           const char *target_path_or_url,
308                           const svn_opt_revision_t *target_peg_revision,
309                           svn_mergeinfo_catalog_t *target_mergeinfo_catalog,
310                           const char *source_path_or_url,
311                           const svn_opt_revision_t *source_peg_revision,
312                           const svn_opt_revision_t *source_start_revision,
313                           const svn_opt_revision_t *source_end_revision,
314                           svn_log_entry_receiver_t log_receiver,
315                           void *log_receiver_baton,
316                           svn_boolean_t discover_changed_paths,
317                           svn_depth_t depth,
318                           const apr_array_header_t *revprops,
319                           svn_client_ctx_t *ctx,
320                           svn_ra_session_t *ra_session,
321                           apr_pool_t *result_pool,
322                           apr_pool_t *scratch_pool);
323
324 /** Return a diff processor that will print a Subversion-style
325  * (not git-style) diff.
326  *
327  * @a anchor is optional (may be null), and is the 'anchor' path to prefix
328  * to the diff-processor paths before displaying.
329  *
330  * @a orig_path_1 and @a orig_path_2 are the two main root paths to be
331  * diffed; each may be a URL, a local WC path or a local unversioned path.
332  *
333  * Other arguments are as for svn_client_diff7() etc.
334  */
335 svn_error_t *
336 svn_client__get_diff_writer_svn(
337                 svn_diff_tree_processor_t **diff_processor,
338                 const char *anchor,
339                 const char *orig_path_1,
340                 const char *orig_path_2,
341                 const apr_array_header_t *options,
342                 const char *relative_to_dir,
343                 svn_boolean_t no_diff_added,
344                 svn_boolean_t no_diff_deleted,
345                 svn_boolean_t show_copies_as_adds,
346                 svn_boolean_t ignore_content_type,
347                 svn_boolean_t ignore_properties,
348                 svn_boolean_t properties_only,
349                 svn_boolean_t pretty_print_mergeinfo,
350                 const char *header_encoding,
351                 svn_stream_t *outstream,
352                 svn_stream_t *errstream,
353                 svn_client_ctx_t *ctx,
354                 apr_pool_t *pool);
355
356 /*** Editor for diff summary ***/
357
358 /* Set *DIFF_PROCESSOR to a diff processor that will report a diff summary
359    to SUMMARIZE_FUNC.
360
361    SUMMARIZE_FUNC is called with SUMMARIZE_BATON as parameter by the
362    created callbacks for each changed item.
363 */
364 svn_error_t *
365 svn_client__get_diff_summarize_callbacks(
366                         svn_diff_tree_processor_t **diff_processor,
367                         svn_client_diff_summarize_func_t summarize_func,
368                         void *summarize_baton,
369                         apr_pool_t *result_pool,
370                         apr_pool_t *scratch_pool);
371
372 /** Copy a directory tree or a file (according to @a kind) from @a src_url at
373  * @a src_rev, to @a dst_abspath in a WC.
374  *
375  * The caller should be holding a WC write lock that allows @a dst_abspath to
376  * be created, such as on the parent of @a dst_abspath.
377  *
378  * If not same repositories, then remove any svn:mergeinfo property.
379  *
380  * Use @a ra_session to fetch the data. The session may point to any URL
381  * within the source repository.
382  *
383  * This API does not process any externals definitions that may be present
384  * on copied directories.
385  */
386 svn_error_t *
387 svn_client__repos_to_wc_copy_internal(svn_boolean_t *timestamp_sleep,
388                              svn_node_kind_t kind,
389                              const char *src_url,
390                              svn_revnum_t src_rev,
391                              const char *dst_abspath,
392                              svn_ra_session_t *ra_session,
393                              svn_client_ctx_t *ctx,
394                              apr_pool_t *scratch_pool);
395
396 /** Copy a directory tree or a file (according to @a kind) from @a src_url at
397  * @a src_rev, to @a dst_abspath in a WC.
398  *
399  * The caller should be holding a WC write lock that allows @a dst_abspath to
400  * be created, such as on the parent of @a dst_abspath.
401  *
402  * If not same repositories, then remove any svn:mergeinfo property.
403  *
404  * Use @a ra_session to fetch the data. The session may point to a different
405  * URL after returning.
406  *
407  * This API does not process any externals definitions that may be present
408  * on copied directories.
409  */
410 svn_error_t *
411 svn_client__repos_to_wc_copy_by_editor(svn_boolean_t *timestamp_sleep,
412                 svn_node_kind_t kind,
413                 const char *src_url,
414                 svn_revnum_t src_rev,
415                 const char *dst_abspath,
416                 svn_ra_session_t *ra_session,
417                 svn_client_ctx_t *ctx,
418                 apr_pool_t *scratch_pool);
419
420 /** Return an editor for applying local modifications to a WC.
421  *
422  * Return an editor in @a *editor_p, @a *edit_baton_p that will apply
423  * local modifications to the WC subdirectory at @a dst_abspath.
424  *
425  * The @a path arguments to the editor methods shall be local WC paths,
426  * relative to @a dst_abspath. The @a copyfrom_path arguments to the
427  * editor methods shall be URLs.
428  *
429  * Send notifications via @a notify_func / @a notify_baton.
430  * ### INCOMPLETE
431  *
432  * @a ra_session is used to fetch the original content for copies.
433  *
434  * Ignore changes to non-regular property (entry-props, DAV/WC-props).
435  *
436  * Acquire the WC write lock in 'open_root' and release it in
437  * 'close_edit', in 'abort_edit', or when @a result_pool is cleared.
438  */
439 svn_error_t *
440 svn_client__wc_editor(const svn_delta_editor_t **editor_p,
441                       void **edit_baton_p,
442                       const char *dst_abspath,
443                       svn_wc_notify_func2_t notify_func,
444                       void *notify_baton,
445                       svn_ra_session_t *ra_session,
446                       svn_client_ctx_t *ctx,
447                       apr_pool_t *result_pool);
448
449 /* Return an editor for applying local modifications to a WC.
450  *
451  * Like svn_client__wc_editor() but with additional options.
452  *
453  * If @a root_dir_add is true, then create and schedule for addition
454  * the root directory of this edit, else assume it is already a versioned,
455  * existing directory.
456  *
457  * If @a ignore_mergeinfo_changes is true, ignore any incoming changes
458  * to the 'svn:mergeinfo' property.
459  *
460  * If @a manage_wc_write_lock is true, acquire the WC write lock in
461  * 'open_root' and release it in 'close_edit', in 'abort_edit', or
462  * when @a result_pool is cleared.
463  */
464 svn_error_t *
465 svn_client__wc_editor_internal(const svn_delta_editor_t **editor_p,
466                                void **edit_baton_p,
467                                const char *dst_abspath,
468                                svn_boolean_t root_dir_add,
469                                svn_boolean_t ignore_mergeinfo_changes,
470                                svn_boolean_t manage_wc_write_lock,
471                                svn_wc_notify_func2_t notify_func,
472                                void *notify_baton,
473                                svn_ra_session_t *ra_session,
474                                svn_client_ctx_t *ctx,
475                                apr_pool_t *result_pool);
476
477 /** Send committable changes found in the WC to a delta-editor.
478  *
479  * Committable changes are found in TARGETS:DEPTH:CHANGELISTS.
480  *
481  * Send the changes to @a editor:@a edit_baton. The @a path arguments
482  * to the editor methods are URL-paths relative to the URL of
483  * @a src_wc_abspath.
484  *
485  *    ### We will presumably need to change this so that the @a path
486  *        arguments to the editor will be local WC relpaths, in order
487  *        to handle switched paths.
488  *
489  * The @a copyfrom_path arguments to the editor methods are URLs. As the
490  * WC does not store copied-from-foreign-repository metadata, the URL will
491  * be in the same repository as the URL of its parent path.
492  *
493  * Compared with svn_client__do_commit(), this (like svn_client_commit6)
494  * handles:
495  *  - condense targets and find committable paths
496  *  - checking only one repository is involved
497  *
498  * Compared with svn_client_commit6(), this does not handle:
499  *  - externals
500  *  - log message
501  *  - revprops
502  *  - checking the commit includes both halves of each local move
503  *  - changing the copy revision of each local move to ~HEAD
504  *  - WC write locks
505  *  - bumping revisions in WC
506  *  - removing locks and changelists in WC
507  */
508 svn_error_t *
509 svn_client__wc_replay(const char *src_wc_abspath,
510                       const apr_array_header_t *targets,
511                       svn_depth_t depth,
512                       const apr_array_header_t *changelists,
513                       const svn_delta_editor_t *editor,
514                       void *edit_baton,
515                       svn_wc_notify_func2_t notify_func,
516                       void *notify_baton,
517                       svn_client_ctx_t *ctx,
518                       apr_pool_t *scratch_pool);
519
520 /** Copy local modifications from one WC subtree to another.
521  *
522  * Find local modifications under @a src_wc_abspath, in the same way as
523  * for a commit.
524  *
525  * Edit the WC at @a dst_wc_abspath, applying those modifications to the
526  * current working state to produce a new working state.
527  *
528  * The source and destination may be in the same WC or in different WCs.
529  */
530 svn_error_t *
531 svn_client__wc_copy_mods(const char *src_wc_abspath,
532                          const char *dst_wc_abspath,
533                          svn_wc_notify_func2_t notify_func,
534                          void *notify_baton,
535                          svn_client_ctx_t *ctx,
536                          apr_pool_t *scratch_pool);
537
538 #ifdef __cplusplus
539 }
540 #endif /* __cplusplus */
541
542 #endif /* SVN_CLIENT_PRIVATE_H */