1251881Speter/*
2251881Speter * svn_fs_private.h: Private declarations for the filesystem layer to
3251881Speter * be consumed by libsvn_fs* and non-libsvn_fs* modules.
4251881Speter *
5251881Speter * ====================================================================
6251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
7251881Speter *    or more contributor license agreements.  See the NOTICE file
8251881Speter *    distributed with this work for additional information
9251881Speter *    regarding copyright ownership.  The ASF licenses this file
10251881Speter *    to you under the Apache License, Version 2.0 (the
11251881Speter *    "License"); you may not use this file except in compliance
12251881Speter *    with the License.  You may obtain a copy of the License at
13251881Speter *
14251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
15251881Speter *
16251881Speter *    Unless required by applicable law or agreed to in writing,
17251881Speter *    software distributed under the License is distributed on an
18251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19251881Speter *    KIND, either express or implied.  See the License for the
20251881Speter *    specific language governing permissions and limitations
21251881Speter *    under the License.
22251881Speter * ====================================================================
23251881Speter */
24251881Speter
25251881Speter#ifndef SVN_FS_PRIVATE_H
26251881Speter#define SVN_FS_PRIVATE_H
27251881Speter
28251881Speter#include "svn_fs.h"
29251881Speter#include "private/svn_editor.h"
30251881Speter
31251881Speter#ifdef __cplusplus
32251881Speterextern "C" {
33251881Speter#endif /* __cplusplus */
34251881Speter
35251881Speter/* The maximum length of a transaction name.  The Berkeley DB backend
36251881Speter   generates transaction names from a sequence expressed as a base 36
37251881Speter   number with a maximum of MAX_KEY_SIZE (currently 200) bytes.  The
38251881Speter   FSFS backend generates transaction names of the form
39251881Speter   <rev>-<base 36-number> where the base 36 number is a sequence value
40251881Speter   with a maximum length of MAX_KEY_SIZE bytes.  The maximum length is
41251881Speter   212, but use 220 just to have some extra space:
42251881Speter     10   -> 32 bit revision number
43251881Speter     1    -> '-'
44251881Speter     200  -> 200 digit base 36 number
45251881Speter     1    -> '\0'
46251881Speter */
47251881Speter#define SVN_FS__TXN_MAX_LEN 220
48251881Speter
49251881Speter/** Retrieve the lock-tokens associated in the context @a access_ctx.
50251881Speter * The tokens are in a hash keyed with <tt>const char *</tt> tokens,
51251881Speter * and with <tt>const char *</tt> values for the paths associated.
52251881Speter *
53251881Speter * You should always use svn_fs_access_add_lock_token2() if you intend
54251881Speter * to use this function.  The result of the function is not guaranteed
55251881Speter * if you use it with the deprecated svn_fs_access_add_lock_token()
56251881Speter * API.
57251881Speter *
58251881Speter * @since New in 1.6. */
59251881Speterapr_hash_t *
60251881Spetersvn_fs__access_get_lock_tokens(svn_fs_access_t *access_ctx);
61251881Speter
62251881Speter
63251881Speter/* Check whether PATH is valid for a filesystem, following (most of) the
64251881Speter * requirements in svn_fs.h:"Directory entry names and directory paths".
65251881Speter *
66251881Speter * Return SVN_ERR_FS_PATH_SYNTAX if PATH is not valid.
67251881Speter */
68251881Spetersvn_error_t *
69251881Spetersvn_fs__path_valid(const char *path, apr_pool_t *pool);
70251881Speter
71251881Speter
72251881Speter
73251881Speter/** Editors
74251881Speter *
75251881Speter * ### docco
76251881Speter *
77251881Speter * @defgroup svn_fs_editor Transaction editors
78251881Speter * @{
79251881Speter */
80251881Speter
81251881Speter/**
82251881Speter * Create a new filesystem transaction, based on based on the youngest
83251881Speter * revision of @a fs, and return its name @a *txn_name and an @a *editor
84251881Speter * that can be used to make changes into it.
85251881Speter *
86251881Speter * @a flags determines transaction enforcement behaviors, and is composed
87251881Speter * from the constants SVN_FS_TXN_* (#SVN_FS_TXN_CHECK_OOD etc.). It is a
88251881Speter * property of the underlying transaction, and will not change if multiple
89251881Speter * editors are used to refer to that transaction (see @a autocommit, below).
90251881Speter *
91251881Speter * @note If you're building a txn for committing, you probably don't want
92251881Speter * to call this directly.  Instead, call svn_repos__get_commit_ev2(), which
93251881Speter * honors the repository's hook configurations.
94251881Speter *
95251881Speter * When svn_editor_complete() is called for @a editor, internal resources
96251881Speter * will be cleaned and nothing more will happen. If you wish to commit the
97251881Speter * transaction, call svn_fs_editor_commit() instead. It is illegal to call
98251881Speter * both; the second call will return #SVN_ERR_FS_INCORRECT_EDITOR_COMPLETION.
99251881Speter *
100251881Speter * @see svn_fs_commit_txn()
101251881Speter *
102251881Speter * @since New in 1.8.
103251881Speter */
104251881Spetersvn_error_t *
105251881Spetersvn_fs__editor_create(svn_editor_t **editor,
106251881Speter                      const char **txn_name,
107251881Speter                      svn_fs_t *fs,
108251881Speter                      apr_uint32_t flags,
109251881Speter                      svn_cancel_func_t cancel_func,
110251881Speter                      void *cancel_baton,
111251881Speter                      apr_pool_t *result_pool,
112251881Speter                      apr_pool_t *scratch_pool);
113251881Speter
114251881Speter
115251881Speter/**
116251881Speter * Like svn_fs__editor_create(), but open an existing transaction
117251881Speter * @a txn_name and continue editing it.
118251881Speter *
119251881Speter * @since New in 1.8.
120251881Speter */
121251881Spetersvn_error_t *
122251881Spetersvn_fs__editor_create_for(svn_editor_t **editor,
123251881Speter                          svn_fs_t *fs,
124251881Speter                          const char *txn_name,
125251881Speter                          svn_cancel_func_t cancel_func,
126251881Speter                          void *cancel_baton,
127251881Speter                          apr_pool_t *result_pool,
128251881Speter                          apr_pool_t *scratch_pool);
129251881Speter
130251881Speter
131251881Speter/**
132251881Speter * Commit the transaction represented by @a editor.
133251881Speter *
134251881Speter * If the commit to the filesystem succeeds, then @a *revision will be set
135251881Speter * to the resulting revision number. Note that further errors may occur,
136251881Speter * as described below. If the commit process does not succeed, for whatever
137251881Speter * reason, then @a *revision will be set to #SVN_INVALID_REVNUM.
138251881Speter *
139251881Speter * If a conflict occurs during the commit, then @a *conflict_path will
140251881Speter * be set to a path that caused the conflict. #SVN_NO_ERROR will be returned.
141251881Speter * Callers may want to construct an #SVN_ERR_FS_CONFLICT error with a
142251881Speter * message that incorporates @a *conflict_path.
143251881Speter *
144251881Speter * If a non-conflict error occurs during the commit, then that error will
145251881Speter * be returned.
146251881Speter * As is standard with any Subversion API, @a revision, @a post_commit_err,
147251881Speter * and @a conflict_path (the OUT parameters) have an indeterminate value if
148251881Speter * an error is returned.
149251881Speter *
150251881Speter * If the commit completes (and a revision is returned in @a *revision), then
151251881Speter * it is still possible for an error to occur during the cleanup process.
152251881Speter * Any such error will be returned in @a *post_commit_err. The caller must
153251881Speter * properly use or clear that error.
154251881Speter *
155251881Speter * If svn_editor_complete() has already been called on @a editor, then
156251881Speter * #SVN_ERR_FS_INCORRECT_EDITOR_COMPLETION will be returned.
157251881Speter *
158251881Speter * @note After calling this function, @a editor will be marked as completed
159251881Speter * and no further operations may be performed on it. The underlying
160251881Speter * transaction will either be committed or aborted once this function is
161251881Speter * called. It cannot be recovered for additional work.
162251881Speter *
163251881Speter * @a result_pool will be used to allocate space for @a conflict_path.
164251881Speter * @a scratch_pool will be used for all temporary allocations.
165251881Speter *
166251881Speter * @note To summarize, there are three possible outcomes of this function:
167251881Speter * successful commit (with or without an associated @a *post_commit_err);
168251881Speter * failed commit due to a conflict (reported via @a *conflict_path); and
169251881Speter * failed commit for some other reason (reported via the returned error.)
170251881Speter *
171251881Speter * @since New in 1.8.
172251881Speter */
173251881Spetersvn_error_t *
174251881Spetersvn_fs__editor_commit(svn_revnum_t *revision,
175251881Speter                      svn_error_t **post_commit_err,
176251881Speter                      const char **conflict_path,
177251881Speter                      svn_editor_t *editor,
178251881Speter                      apr_pool_t *result_pool,
179251881Speter                      apr_pool_t *scratch_pool);
180251881Speter
181251881Speter
182251881Speter/** @} */
183251881Speter
184251881Speter
185251881Speter#ifdef __cplusplus
186251881Speter}
187251881Speter#endif /* __cplusplus */
188251881Speter
189251881Speter#endif /* SVN_FS_PRIVATE_H */
190