diff options
author | peter <peter@FreeBSD.org> | 2013-06-18 02:07:41 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2013-06-18 02:07:41 +0000 |
commit | d25dac7fcc6acc838b71bbda8916fd9665c709ab (patch) | |
tree | 135691142dc0e75a5e5d97b5074d03436435b8e0 /subversion/include | |
download | FreeBSD-src-d25dac7fcc6acc838b71bbda8916fd9665c709ab.zip FreeBSD-src-d25dac7fcc6acc838b71bbda8916fd9665c709ab.tar.gz |
Import trimmed svn-1.8.0-rc3
Diffstat (limited to 'subversion/include')
83 files changed, 53364 insertions, 0 deletions
diff --git a/subversion/include/mod_authz_svn.h b/subversion/include/mod_authz_svn.h new file mode 100644 index 0000000..2cf1464 --- /dev/null +++ b/subversion/include/mod_authz_svn.h @@ -0,0 +1,61 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file mod_authz_svn.h + * @brief Subversion authorization extensions for mod_dav_svn + */ + +#ifndef MOD_AUTHZ_SVN_H +#define MOD_AUTHZ_SVN_H + +#include <httpd.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * mod_dav_svn to mod_authz_svn bypass mechanism + */ +/** Provider group for subrequest bypass */ +#define AUTHZ_SVN__SUBREQ_BYPASS_PROV_GRP "dav2authz_subreq_bypass" +/** Provider name for subrequest bypass */ +#define AUTHZ_SVN__SUBREQ_BYPASS_PROV_NAME "mod_authz_svn_subreq_bypass" +/** Provider version for subrequest bypass */ +#define AUTHZ_SVN__SUBREQ_BYPASS_PROV_VER "00.00a" +/** Provider to allow mod_dav_svn to bypass the generation of an apache + * request when checking GET access from "mod_dav_svn/auth.c". + * + * Uses @a r @a repos_path and @a repos_name to determine if the user + * making the request is authorized. + * + * If the access is allowed returns @c OK or @c HTTP_FORBIDDEN if it is not. + */ +typedef int (*authz_svn__subreq_bypass_func_t)(request_rec *r, + const char *repos_path, + const char *repos_name); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/subversion/include/mod_dav_svn.h b/subversion/include/mod_dav_svn.h new file mode 100644 index 0000000..c498c5e --- /dev/null +++ b/subversion/include/mod_dav_svn.h @@ -0,0 +1,99 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file mod_dav_svn.h + * @brief Subversion's backend for Apache's mod_dav module + */ + + +#ifndef MOD_DAV_SVN_H +#define MOD_DAV_SVN_H + +#include <httpd.h> +#include <mod_dav.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + Given an apache request @a r, a @a uri, and a @a root_path to the svn + location block, process @a uri and return many things, allocated in + @a r->pool: + + - @a cleaned_uri: The uri with duplicate and trailing slashes removed. + + - @a trailing_slash: Whether the uri had a trailing slash on it. + + Three special substrings of the uri are returned for convenience: + + - @a repos_basename: The single path component that is the directory + which contains the repository. (Don't confuse + this with the "repository name" as optionally + defined via the SVNReposName directive!) + + - @a relative_path: The remaining imaginary path components. + + - @a repos_path: The actual path within the repository filesystem, or + NULL if no part of the uri refers to a path in + the repository (e.g. "!svn/vcc/default" or + "!svn/bln/25"). + + + For example, consider the uri + + /svn/repos/proj1/!svn/blah/13//A/B/alpha + + In the SVNPath case, this function would receive a @a root_path of + '/svn/repos/proj1', and in the SVNParentPath case would receive a + @a root_path of '/svn/repos'. But either way, we would get back: + + - @a cleaned_uri: /svn/repos/proj1/!svn/blah/13/A/B/alpha + - @a repos_basename: proj1 + - @a relative_path: /!svn/blah/13/A/B/alpha + - @a repos_path: A/B/alpha + - @a trailing_slash: FALSE +*/ +AP_MODULE_DECLARE(dav_error *) dav_svn_split_uri(request_rec *r, + const char *uri, + const char *root_path, + const char **cleaned_uri, + int *trailing_slash, + const char **repos_basename, + const char **relative_path, + const char **repos_path); + + +/** + * Given an apache request @a r and a @a root_path to the svn location + * block, set @a *repos_path to the path of the repository on disk. */ +AP_MODULE_DECLARE(dav_error *) dav_svn_get_repos_path(request_rec *r, + const char *root_path, + const char **repos_path); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* MOD_DAV_SVN_H */ diff --git a/subversion/include/private/README b/subversion/include/private/README new file mode 100644 index 0000000..05527e2 --- /dev/null +++ b/subversion/include/private/README @@ -0,0 +1,4 @@ +Header files in this private/ directory are for internal APIs shared +across Subversion's implementation. They are not part of the public +API, nor are they ever copied into or under the include/ directory +(e.g. by the installation process). diff --git a/subversion/include/private/ra_svn_sasl.h b/subversion/include/private/ra_svn_sasl.h new file mode 100644 index 0000000..428e20e --- /dev/null +++ b/subversion/include/private/ra_svn_sasl.h @@ -0,0 +1,86 @@ +/* + * ra_svn_sasl.h : SASL-related declarations shared between the + * ra_svn and svnserve module + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + + + +#ifndef RA_SVN_SASL_H +#define RA_SVN_SASL_H + +#ifdef WIN32 +/* This prevents sasl.h from redefining iovec, which is always defined by APR + on win32. */ +#define STRUCT_IOVEC_DEFINED +#include <sasl.h> +#else +#include <sasl/sasl.h> +#endif + +#include <apr_errno.h> +#include <apr_pools.h> + +#include "svn_error.h" +#include "svn_ra_svn.h" + +#include "private/svn_atomic.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** The application and service name used for sasl_client_new, + * sasl_server_init, and sasl_server_new. */ +#define SVN_RA_SVN_SASL_NAME "svn" + +extern volatile svn_atomic_t svn_ra_svn__sasl_status; + +/* Initialize secprops with default values. */ +void +svn_ra_svn__default_secprops(sasl_security_properties_t *secprops); + +/* This function is called by the client and the server before + calling sasl_{client, server}_init, pool is used for allocations. */ +svn_error_t * +svn_ra_svn__sasl_common_init(apr_pool_t *pool); + +/* Sets local_addrport and remote_addrport to a string containing the + remote and local IP address and port, formatted like this: a.b.c.d;port. */ +svn_error_t * +svn_ra_svn__get_addresses(const char **local_addrport, + const char **remote_addrport, + svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/* If a security layer was negotiated during the authentication exchange, + create an encrypted stream for conn. */ +svn_error_t * +svn_ra_svn__enable_sasl_encryption(svn_ra_svn_conn_t *conn, + sasl_conn_t *sasl_ctx, + apr_pool_t *pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RA_SVN_SASL_H */ diff --git a/subversion/include/private/svn_adler32.h b/subversion/include/private/svn_adler32.h new file mode 100644 index 0000000..8c9bbd2 --- /dev/null +++ b/subversion/include/private/svn_adler32.h @@ -0,0 +1,52 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_adler32.h + * @brief Subversion's take on Adler-32 calculation + */ + +#ifndef SVN_ADLER32_H +#define SVN_ADLER32_H + +#include <apr.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * Return an adler32 checksum based on CHECKSUM, updated with + * DATA of size LEN. + * + * @since New in 1.7. + */ +apr_uint32_t +svn__adler32(apr_uint32_t checksum, const char *data, apr_off_t len); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* SVN_ADLER32_H */ diff --git a/subversion/include/private/svn_atomic.h b/subversion/include/private/svn_atomic.h new file mode 100644 index 0000000..187703b --- /dev/null +++ b/subversion/include/private/svn_atomic.h @@ -0,0 +1,123 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_atomic.h + * @brief Macros and functions for atomic operations + */ + +#ifndef SVN_ATOMIC_H +#define SVN_ATOMIC_H + +#include <apr_version.h> +#include <apr_atomic.h> + +#include "svn_error.h" +#include "private/svn_dep_compat.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @name Macro definitions for atomic types and operations + * + * @note These are necessary because the apr_atomic API changed somewhat + * between apr-0.x and apr-1.x. + * @{ + */ + +/** The type used by all the other atomic operations. */ +#if APR_VERSION_AT_LEAST(1, 0, 0) +#define svn_atomic_t apr_uint32_t +#else +#define svn_atomic_t apr_atomic_t +#endif + +/** Atomically read an #svn_atomic_t from memory. */ +#if APR_VERSION_AT_LEAST(1, 0, 0) +#define svn_atomic_read(mem) apr_atomic_read32((mem)) +#else +#define svn_atomic_read(mem) apr_atomic_read((mem)) +#endif + +/** Atomically set an #svn_atomic_t in memory. */ +#if APR_VERSION_AT_LEAST(1, 0, 0) +#define svn_atomic_set(mem, val) apr_atomic_set32((mem), (val)) +#else +#define svn_atomic_set(mem, val) apr_atomic_set((mem), (val)) +#endif + +/** Atomically increment an #svn_atomic_t. */ +#if APR_VERSION_AT_LEAST(1, 0, 0) +#define svn_atomic_inc(mem) apr_atomic_inc32(mem) +#else +#define svn_atomic_inc(mem) apr_atomic_inc(mem) +#endif + +/** Atomically decrement an #svn_atomic_t. */ +#if APR_VERSION_AT_LEAST(1, 0, 0) +#define svn_atomic_dec(mem) apr_atomic_dec32(mem) +#else +#define svn_atomic_dec(mem) apr_atomic_dec(mem) +#endif + +/** + * Atomic compare-and-swap. + * + * Compare the value that @a mem points to with @a cmp. If they are + * the same swap the value with @a with. + * + * @note svn_atomic_cas should not be combined with the other + * svn_atomic operations. A comment in apr_atomic.h explains + * that on some platforms, the CAS function is implemented in a + * way that is incompatible with the other atomic operations. + */ +#if APR_VERSION_AT_LEAST(1, 0, 0) +#define svn_atomic_cas(mem, with, cmp) \ + apr_atomic_cas32((mem), (with), (cmp)) +#else +#define svn_atomic_cas(mem, with, cmp) \ + apr_atomic_cas((mem), (with), (cmp)) +#endif +/** @} */ + +/** + * Call an initialization function in a thread-safe manner. + * + * @a global_status must be a pointer to a global, zero-initialized + * #svn_atomic_t. @a init_func is a pointer to the function that performs + * the actual initialization. @a baton and and @a pool are passed on to the + * init_func for its use. + * + * @since New in 1.5. + */ +svn_error_t * +svn_atomic__init_once(volatile svn_atomic_t *global_status, + svn_error_t *(*init_func)(void*,apr_pool_t*), + void *baton, + apr_pool_t* pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_ATOMIC_H */ diff --git a/subversion/include/private/svn_auth_private.h b/subversion/include/private/svn_auth_private.h new file mode 100644 index 0000000..7a1c716 --- /dev/null +++ b/subversion/include/private/svn_auth_private.h @@ -0,0 +1,220 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_auth_private.h + * @brief Subversion's authentication system - Internal routines + */ + +#ifndef SVN_AUTH_PRIVATE_H +#define SVN_AUTH_PRIVATE_H + +#include <apr_pools.h> +#include <apr_hash.h> + +#include "svn_types.h" +#include "svn_error.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* If you add a password type for a provider which stores + * passwords on disk in encrypted form, remember to update + * svn_auth__simple_save_creds_helper. Otherwise it will be + * assumed that your provider stores passwords in plaintext. */ +#define SVN_AUTH__SIMPLE_PASSWORD_TYPE "simple" +#define SVN_AUTH__WINCRYPT_PASSWORD_TYPE "wincrypt" +#define SVN_AUTH__KEYCHAIN_PASSWORD_TYPE "keychain" +#define SVN_AUTH__KWALLET_PASSWORD_TYPE "kwallet" +#define SVN_AUTH__GNOME_KEYRING_PASSWORD_TYPE "gnome-keyring" +#define SVN_AUTH__GPG_AGENT_PASSWORD_TYPE "gpg-agent" + +/* A function that stores in *PASSWORD (potentially after decrypting it) + the user's password. It might be obtained directly from CREDS, or + from an external store, using REALMSTRING and USERNAME as keys. + (The behavior is undefined if REALMSTRING or USERNAME are NULL.) + If NON_INTERACTIVE is set, the user must not be involved in the + retrieval process. Set *DONE to TRUE if a password was stored + in *PASSWORD, to FALSE otherwise. POOL is used for any necessary + allocation. */ +typedef svn_error_t * (*svn_auth__password_get_t) + (svn_boolean_t *done, + const char **password, + apr_hash_t *creds, + const char *realmstring, + const char *username, + apr_hash_t *parameters, + svn_boolean_t non_interactive, + apr_pool_t *pool); + +/* A function that stores PASSWORD (or some encrypted version thereof) + either directly in CREDS, or externally using REALMSTRING and USERNAME + as keys into the external store. If NON_INTERACTIVE is set, the user + must not be involved in the storage process. Set *DONE to TRUE if the + password was store, to FALSE otherwise. POOL is used for any necessary + allocation. */ +typedef svn_error_t * (*svn_auth__password_set_t) + (svn_boolean_t *done, + apr_hash_t *creds, + const char *realmstring, + const char *username, + const char *password, + apr_hash_t *parameters, + svn_boolean_t non_interactive, + apr_pool_t *pool); + +/* Use PARAMETERS and REALMSTRING to set *CREDENTIALS to a set of + pre-cached authentication credentials pulled from the simple + credential cache store identified by PASSTYPE. PASSWORD_GET is + used to obtain the password value. Allocate *CREDENTIALS from + POOL. + + NOTE: This function is a common implementation of code used by + several of the simple credential providers (the default disk cache + mechanism, Windows CryptoAPI, GNOME Keyring, etc.), typically in + their "first_creds" implementation. */ +svn_error_t * +svn_auth__simple_creds_cache_get(void **credentials, + void **iter_baton, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + svn_auth__password_get_t password_get, + const char *passtype, + apr_pool_t *pool); + +/* Use PARAMETERS and REALMSTRING to save CREDENTIALS in the simple + credential cache store identified by PASSTYPE. PASSWORD_SET is + used to do the actual storage. Use POOL for necessary allocations. + Set *SAVED according to whether or not the credentials were + successfully stored. + + NOTE: This function is a common implementation of code used by + several of the simple credential providers (the default disk cache + mechanism, Windows CryptoAPI, GNOME Keyring, etc.) typically in + their "save_creds" implementation. */ +svn_error_t * +svn_auth__simple_creds_cache_set(svn_boolean_t *saved, + void *credentials, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + svn_auth__password_set_t password_set, + const char *passtype, + apr_pool_t *pool); + +/* Implementation of svn_auth__password_get_t that retrieves + the plaintext password from CREDS when USERNAME matches the stored + credentials. */ +svn_error_t * +svn_auth__simple_password_get(svn_boolean_t *done, + const char **password, + apr_hash_t *creds, + const char *realmstring, + const char *username, + apr_hash_t *parameters, + svn_boolean_t non_interactive, + apr_pool_t *pool); + +/* Implementation of svn_auth__password_set_t that stores + the plaintext password in CREDS. */ +svn_error_t * +svn_auth__simple_password_set(svn_boolean_t *done, + apr_hash_t *creds, + const char *realmstring, + const char *username, + const char *password, + apr_hash_t *parameters, + svn_boolean_t non_interactive, + apr_pool_t *pool); + + +/* Use PARAMETERS and REALMSTRING to set *CREDENTIALS to a set of + pre-cached authentication credentials pulled from the SSL client + certificate passphrase credential cache store identified by + PASSTYPE. PASSPHRASE_GET is used to obtain the passphrase value. + Allocate *CREDENTIALS from POOL. + + NOTE: This function is a common implementation of code used by + several of the ssl client passphrase credential providers (the + default disk cache mechanism, Windows CryptoAPI, GNOME Keyring, + etc.), typically in their "first_creds" implementation. */ +svn_error_t * +svn_auth__ssl_client_cert_pw_cache_get(void **credentials, + void **iter_baton, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + svn_auth__password_get_t passphrase_get, + const char *passtype, + apr_pool_t *pool); + +/* Use PARAMETERS and REALMSTRING to save CREDENTIALS in the SSL + client certificate passphrase credential cache store identified by + PASSTYPE. PASSPHRASE_SET is used to do the actual storage. Use + POOL for necessary allocations. Set *SAVED according to whether or + not the credentials were successfully stored. + + NOTE: This function is a common implementation of code used by + several of the simple credential providers (the default disk cache + mechanism, Windows CryptoAPI, GNOME Keyring, etc.) typically in + their "save_creds" implementation. */ +svn_error_t * +svn_auth__ssl_client_cert_pw_cache_set(svn_boolean_t *saved, + void *credentials, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + svn_auth__password_set_t passphrase_set, + const char *passtype, + apr_pool_t *pool); + +/* This implements the svn_auth__password_get_t interface. + Set **PASSPHRASE to the plaintext passphrase retrieved from CREDS; + ignore other parameters. */ +svn_error_t * +svn_auth__ssl_client_cert_pw_get(svn_boolean_t *done, + const char **passphrase, + apr_hash_t *creds, + const char *realmstring, + const char *username, + apr_hash_t *parameters, + svn_boolean_t non_interactive, + apr_pool_t *pool); + +/* This implements the svn_auth__password_set_t interface. + Store PASSPHRASE in CREDS; ignore other parameters. */ +svn_error_t * +svn_auth__ssl_client_cert_pw_set(svn_boolean_t *done, + apr_hash_t *creds, + const char *realmstring, + const char *username, + const char *passphrase, + apr_hash_t *parameters, + svn_boolean_t non_interactive, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_AUTH_PRIVATE_H */ diff --git a/subversion/include/private/svn_cache.h b/subversion/include/private/svn_cache.h new file mode 100644 index 0000000..df40f7e --- /dev/null +++ b/subversion/include/private/svn_cache.h @@ -0,0 +1,486 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_cache.h + * @brief In-memory cache implementation. + */ + + +#ifndef SVN_CACHE_H +#define SVN_CACHE_H + +#include <apr_pools.h> +#include <apr_hash.h> + +#include "svn_types.h" +#include "svn_error.h" +#include "svn_iter.h" +#include "svn_config.h" +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** + * @defgroup svn_cache__support In-memory caching + * @{ + */ + +/** + * A function type for deserializing an object @a *out from the string + * @a data of length @a data_len into @a result_pool. It is legal and + * generally suggested that the deserialization will be done in-place, + * i.e. modify @a data directly and return it in @a *out. + */ +typedef svn_error_t *(*svn_cache__deserialize_func_t)(void **out, + void *data, + apr_size_t data_len, + apr_pool_t *result_pool); + +/** + * A function type for deserializing an object @a *out from the string + * @a data of length @a data_len into @a result_pool. The extra information + * @a baton passed into can be used to deserialize only a specific part or + * sub-structure or to perform any other non-modifying operation that may + * not require the whole structure to be processed. + */ +typedef svn_error_t *(*svn_cache__partial_getter_func_t)(void **out, + const void *data, + apr_size_t data_len, + void *baton, + apr_pool_t *result_pool); + +/** + * A function type for modifying an already deserialized in the @a *data + * buffer of length @a *data_len. Additional information of the modification + * to do will be provided in @a baton. The function may change the size of + * data buffer and may re-allocate it if necessary. In that case, the new + * values must be passed back in @a *data_len and @a *data, respectively. + * Allocations will be done from @a result_pool. + */ +typedef svn_error_t *(*svn_cache__partial_setter_func_t)(void **data, + apr_size_t *data_len, + void *baton, + apr_pool_t *result_pool); + +/** + * A function type for serializing an object @a in into bytes. The + * function should allocate the serialized value in @a result_pool, set + * @a *data to the serialized value, and set @a *data_len to its length. + */ +typedef svn_error_t *(*svn_cache__serialize_func_t)(void **data, + apr_size_t *data_len, + void *in, + apr_pool_t *result_pool); + +/** + * A function type for transforming or ignoring errors. @a scratch_pool may + * be used for temporary allocations. + */ +typedef svn_error_t *(*svn_cache__error_handler_t)(svn_error_t *err, + void *baton, + apr_pool_t *scratch_pool); + +/** + * A wrapper around apr_memcache_t, provided essentially so that the + * Subversion public API doesn't depend on whether or not you have + * access to the APR memcache libraries. + */ +typedef struct svn_memcache_t svn_memcache_t; + +/** + * An opaque structure representing a membuffer cache object. + */ +typedef struct svn_membuffer_t svn_membuffer_t; + +/** + * Opaque type for an in-memory cache. + */ +typedef struct svn_cache__t svn_cache__t; + +/** + * A structure containing typical statistics about a given cache instance. + * Use svn_cache__get_info() to get this data. Note that not all types + * of caches will be able to report complete and correct information. + */ +typedef struct svn_cache__info_t +{ + /** A string identifying the cache instance. Usually a copy of the @a id + * or @a prefix parameter passed to the cache constructor. + */ + const char* id; + + /** Number of getter calls (svn_cache__get() or svn_cache__get()). + */ + apr_uint64_t gets; + + /** Number of getter calls that return data. + */ + apr_uint64_t hits; + + /** Number of setter calls (svn_cache__set()). + */ + apr_uint64_t sets; + + /** Number of function calls that returned an error. + */ + apr_uint64_t failures; + + /** Size of the data currently stored in the cache. + * May be 0 if that information is not available. + */ + apr_uint64_t used_size; + + /** Amount of memory currently reserved for cached data. + * Will be equal to @a used_size if no precise information is available. + */ + apr_uint64_t data_size; + + /** Lower threshold of the total size of memory allocated to the cache and + * its index as well as management structures. The actual memory allocated + * by the cache may be larger. + */ + apr_uint64_t total_size; + + /** Number of cache entries. + * May be 0 if that information is not available. + */ + apr_uint64_t used_entries; + + /** Maximum numbers of cache entries. + * May be 0 if that information is not available. + */ + apr_uint64_t total_entries; +} svn_cache__info_t; + +/** + * Creates a new cache in @a *cache_p. This cache will use @a pool + * for all of its storage needs. The elements in the cache will be + * indexed by keys of length @a klen, which may be APR_HASH_KEY_STRING + * if they are strings. Cached values will be copied in and out of + * the cache using @a serialize_func and @a deserialize_func, respectively. + * + * The cache stores up to @a pages * @a items_per_page items at a + * time. The exact cache invalidation strategy is not defined here, + * but in general, a lower value for @a items_per_page means more + * memory overhead for the same number of items, but a higher value + * for @a items_per_page means more items are cleared at once. Both + * @a pages and @a items_per_page must be positive (though they both + * may certainly be 1). + * + * If @a thread_safe is true, and APR is compiled with threads, all + * accesses to the cache will be protected with a mutex. The @a id + * is a purely user-visible information that will allow coders to + * identify this cache instance in a #svn_cache__info_t struct. + * It does not influence the behavior of the cache itself. + * + * Note that NULL is a legitimate value for cache entries (and + * @a serialize_func will not be called on it). + * + * It is not safe for @a serialize_func nor @a deserialize_func to + * interact with the cache itself. + */ +svn_error_t * +svn_cache__create_inprocess(svn_cache__t **cache_p, + svn_cache__serialize_func_t serialize_func, + svn_cache__deserialize_func_t deserialize_func, + apr_ssize_t klen, + apr_int64_t pages, + apr_int64_t items_per_page, + svn_boolean_t thread_safe, + const char *id, + apr_pool_t *pool); + +/** + * Creates a new cache in @a *cache_p, communicating to a memcached + * process via @a memcache. The elements in the cache will be indexed + * by keys of length @a klen, which may be APR_HASH_KEY_STRING if they + * are strings. Values will be serialized for memcached using @a + * serialize_func and deserialized using @a deserialize_func. Because + * the same memcached server may cache many different kinds of values, + * @a prefix should be specified to differentiate this cache from + * other caches. @a *cache_p will be allocated in @a result_pool. + * + * If @a deserialize_func is NULL, then the data is returned as an + * svn_string_t; if @a serialize_func is NULL, then the data is + * assumed to be an svn_stringbuf_t. + * + * These caches are always thread safe. + * + * These caches do not support svn_cache__iter. + * + * If Subversion was not built with apr_memcache support, always + * raises SVN_ERR_NO_APR_MEMCACHE. + */ +svn_error_t * +svn_cache__create_memcache(svn_cache__t **cache_p, + svn_memcache_t *memcache, + svn_cache__serialize_func_t serialize_func, + svn_cache__deserialize_func_t deserialize_func, + apr_ssize_t klen, + const char *prefix, + apr_pool_t *result_pool); + +/** + * Given @a config, returns an APR memcached interface in @a + * *memcache_p allocated in @a result_pool if @a config contains entries in + * the SVN_CACHE_CONFIG_CATEGORY_MEMCACHED_SERVERS section describing + * memcached servers; otherwise, sets @a *memcache_p to NULL. + * + * If Subversion was not built with apr_memcache_support, then raises + * SVN_ERR_NO_APR_MEMCACHE if and only if @a config is configured to + * use memcache. + */ +svn_error_t * +svn_cache__make_memcache_from_config(svn_memcache_t **memcache_p, + svn_config_t *config, + apr_pool_t *result_pool); + +/** + * Creates a new membuffer cache object in @a *cache. It will contain + * up to @a total_size bytes of data, using @a directory_size bytes + * for index information and the remainder for serialized objects. + * + * Since each index entry is about 50 bytes long, 1 to 10 percent of + * the @a total_size should be allocated to the @a directory_size, + * depending on the average serialized object size. Higher percentages + * will generally result in higher hit rates and reduced conflict + * resolution overhead. + * + * The cache will be split into @a segment_count segments of equal size. + * A higher number reduces lock contention but also limits the maximum + * cachable item size. If it is not a power of two, it will be rounded + * down to next lower power of two. Also, there is an implementation + * specific upper limit and the setting will be capped there automatically. + * If the number is 0, a default will be derived from @a total_size. + * + * If access to the resulting cache object is guaranteed to be serialized, + * @a thread_safe may be set to @c FALSE for maximum performance. + * + * There is no limit on the number of threads reading a given cache segment + * concurrently. Writes, however, need an exclusive lock on the respective + * segment. @a allow_blocking_writes controls contention is handled here. + * If set to TRUE, writes will wait until the lock becomes available, i.e. + * reads should be short. If set to FALSE, write attempts will be ignored + * (no data being written to the cache) if some reader or another writer + * currently holds the segment lock. + * + * Allocations will be made in @a result_pool, in particular the data buffers. + */ +svn_error_t * +svn_cache__membuffer_cache_create(svn_membuffer_t **cache, + apr_size_t total_size, + apr_size_t directory_size, + apr_size_t segment_count, + svn_boolean_t thread_safe, + svn_boolean_t allow_blocking_writes, + apr_pool_t *result_pool); + +/** + * Creates a new cache in @a *cache_p, storing the data in a potentially + * shared @a membuffer object. The elements in the cache will be indexed + * by keys of length @a klen, which may be APR_HASH_KEY_STRING if they + * are strings. Values will be serialized for the memcache using @a + * serialize_func and deserialized using @a deserialize_func. Because + * the same memcache object may cache many different kinds of values + * form multiple caches, @a prefix should be specified to differentiate + * this cache from other caches. @a *cache_p will be allocated in @a result_pool. + * + * If @a deserialize_func is NULL, then the data is returned as an + * svn_string_t; if @a serialize_func is NULL, then the data is + * assumed to be an svn_stringbuf_t. + * + * If @a thread_safe is true, and APR is compiled with threads, all + * accesses to the cache will be protected with a mutex, if the shared + * @a memcache has also been created with thread_safe flag set. + * + * These caches do not support svn_cache__iter. + */ +svn_error_t * +svn_cache__create_membuffer_cache(svn_cache__t **cache_p, + svn_membuffer_t *membuffer, + svn_cache__serialize_func_t serialize, + svn_cache__deserialize_func_t deserialize, + apr_ssize_t klen, + const char *prefix, + svn_boolean_t thread_safe, + apr_pool_t *result_pool); + +/** + * Sets @a handler to be @a cache's error handling routine. If any + * error is returned from a call to svn_cache__get or svn_cache__set, @a + * handler will be called with @a baton and the error, and the + * original function will return whatever error @a handler returns + * instead (possibly SVN_NO_ERROR); @a handler will receive the pool + * passed to the svn_cache_* function. @a scratch_pool is used for temporary + * allocations. + */ +svn_error_t * +svn_cache__set_error_handler(svn_cache__t *cache, + svn_cache__error_handler_t handler, + void *baton, + apr_pool_t *scratch_pool); + +/** + * Returns @c TRUE if the @a cache supports objects of the given @a size. + * There is no guarantee, that svn_cache__set() will actually store the + * respective object in that case. However, a @c FALSE return value indicates + * that an attempt to cache the item will either fail or impair the overall + * cache performance. @c FALSE will also be returned if @a cache is @c NULL. + */ +svn_boolean_t +svn_cache__is_cachable(svn_cache__t *cache, + apr_size_t size); + +#define SVN_CACHE_CONFIG_CATEGORY_MEMCACHED_SERVERS "memcached-servers" + +/** + * Fetches a value indexed by @a key from @a cache into @a *value, + * setting @a *found to TRUE iff it is in the cache and FALSE if it is + * not found. @a key may be NULL in which case @a *found will be + * FALSE. The value is copied into @a result_pool using the deserialize + * function provided to the cache's constructor. + */ +svn_error_t * +svn_cache__get(void **value, + svn_boolean_t *found, + svn_cache__t *cache, + const void *key, + apr_pool_t *result_pool); + +/** + * Stores the value @a value under the key @a key in @a cache. Uses @a + * scratch_pool for temporary allocations. The cache makes copies of + * @a key and @a value if necessary (that is, @a key and @a value may + * have shorter lifetimes than the cache). @a key may be NULL in which + * case the cache will remain unchanged. + * + * If there is already a value for @a key, this will replace it. Bear + * in mind that in some circumstances this may leak memory (that is, + * the cache's copy of the previous value may not be immediately + * cleared); it is only guaranteed to not leak for caches created with + * @a items_per_page equal to 1. + */ +svn_error_t * +svn_cache__set(svn_cache__t *cache, + const void *key, + void *value, + apr_pool_t *scratch_pool); + +/** + * Iterates over the elements currently in @a cache, calling @a func + * for each one until there are no more elements or @a func returns an + * error. Uses @a scratch_pool for temporary allocations. + * + * If @a completed is not NULL, then on return - if @a func returns no + * errors - @a *completed will be set to @c TRUE. + * + * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that + * error is returned. When @a func returns @c SVN_ERR_ITER_BREAK, + * iteration is interrupted, but no error is returned and @a + * *completed is set to @c FALSE. (The error handler set by + * svn_cache__set_error_handler is not used for svn_cache__iter.) + * + * It is not legal to perform any other cache operations on @a cache + * inside @a func. + * + * svn_cache__iter is not supported by all cache implementations; see + * the svn_cache__create_* function for details. + */ +svn_error_t * +svn_cache__iter(svn_boolean_t *completed, + svn_cache__t *cache, + svn_iter_apr_hash_cb_t func, + void *baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_cache__get() but will call a specific de-serialization + * function @a func. @a found will be set depending on whether the @a key + * has been found. Even if that reports @c TRUE, @a value may still return + * a @c NULL pointer depending on the logic inside @a func. For a @a NULL + * @a key, no data will be found. @a value will be allocated in + * @a result_pool. + */ +svn_error_t * +svn_cache__get_partial(void **value, + svn_boolean_t *found, + svn_cache__t *cache, + const void *key, + svn_cache__partial_getter_func_t func, + void *baton, + apr_pool_t *result_pool); + +/** + * Find the item identified by @a key in the @a cache. If it has been found, + * call @a func for it and @a baton to potentially modify the data. Changed + * data will be written back to the cache. If the item cannot be found, + * or if @a key is NULL, @a func does not get called. @a scratch_pool is + * used for temporary allocations. + */ +svn_error_t * +svn_cache__set_partial(svn_cache__t *cache, + const void *key, + svn_cache__partial_setter_func_t func, + void *baton, + apr_pool_t *scratch_pool); + +/** + * Collect all available usage statistics on the cache instance @a cache + * and write the data into @a info. If @a reset has been set, access + * counters will be reset right after copying the statistics info. + * @a result_pool will be used for allocations. + */ +svn_error_t * +svn_cache__get_info(svn_cache__t *cache, + svn_cache__info_t *info, + svn_boolean_t reset, + apr_pool_t *result_pool); + +/** + * Return the information given in @a info formatted as a multi-line string. + * Allocations take place in @a result_pool. + */ +svn_string_t * +svn_cache__format_info(const svn_cache__info_t *info, + apr_pool_t *result_pool); + +/* Access the process-global (singleton) membuffer cache. The first call + * will automatically allocate the cache using the current cache config. + * NULL will be returned if the desired cache size is 0. + * + * @since New in 1.7. + */ +struct svn_membuffer_t * +svn_cache__get_global_membuffer_cache(void); + +/** @} */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CACHE_H */ diff --git a/subversion/include/private/svn_client_private.h b/subversion/include/private/svn_client_private.h new file mode 100644 index 0000000..9eebc18 --- /dev/null +++ b/subversion/include/private/svn_client_private.h @@ -0,0 +1,299 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_client_private.h + * @brief Subversion-internal client APIs. + */ + +#ifndef SVN_CLIENT_PRIVATE_H +#define SVN_CLIENT_PRIVATE_H + +#include <apr_pools.h> + +#include "svn_ra.h" +#include "svn_client.h" +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Return true if KIND is a revision kind that is dependent on the working + * copy. Otherwise, return false. */ +#define SVN_CLIENT__REVKIND_NEEDS_WC(kind) \ + ((kind) == svn_opt_revision_base || \ + (kind) == svn_opt_revision_previous || \ + (kind) == svn_opt_revision_working || \ + (kind) == svn_opt_revision_committed) \ + +/* Return true if KIND is a revision kind that the WC can supply without + * contacting the repository. Otherwise, return false. */ +#define SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(kind) \ + ((kind) == svn_opt_revision_base || \ + (kind) == svn_opt_revision_working || \ + (kind) == svn_opt_revision_committed) + +/* A location in a repository. */ +typedef struct svn_client__pathrev_t +{ + const char *repos_root_url; + const char *repos_uuid; + svn_revnum_t rev; + const char *url; +} svn_client__pathrev_t; + +/* Return a new path-rev structure, allocated in RESULT_POOL, + * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, REV and URL. */ +svn_client__pathrev_t * +svn_client__pathrev_create(const char *repos_root_url, + const char *repos_uuid, + svn_revnum_t rev, + const char *url, + apr_pool_t *result_pool); + +/* Return a new path-rev structure, allocated in RESULT_POOL, + * initialized with deep copies of REPOS_ROOT_URL, REPOS_UUID, and REV, + * and using the repository-relative RELPATH to construct the URL. */ +svn_client__pathrev_t * +svn_client__pathrev_create_with_relpath(const char *repos_root_url, + const char *repos_uuid, + svn_revnum_t rev, + const char *relpath, + apr_pool_t *result_pool); + +/* Set *PATHREV_P to a new path-rev structure, allocated in RESULT_POOL, + * initialized with deep copies of the repository root URL and UUID from + * RA_SESSION, and of REV and URL. */ +svn_error_t * +svn_client__pathrev_create_with_session(svn_client__pathrev_t **pathrev_p, + svn_ra_session_t *ra_session, + svn_revnum_t rev, + const char *url, + apr_pool_t *result_pool); + +/* Return a deep copy of PATHREV, allocated in RESULT_POOL. */ +svn_client__pathrev_t * +svn_client__pathrev_dup(const svn_client__pathrev_t *pathrev, + apr_pool_t *result_pool); + +/* Return a deep copy of PATHREV, with a URI-encoded representation of + * RELPATH joined on to the URL. Allocate the result in RESULT_POOL. */ +svn_client__pathrev_t * +svn_client__pathrev_join_relpath(const svn_client__pathrev_t *pathrev, + const char *relpath, + apr_pool_t *result_pool); + +/* Return the repository-relative relpath of PATHREV. */ +const char * +svn_client__pathrev_relpath(const svn_client__pathrev_t *pathrev, + apr_pool_t *result_pool); + +/* Return the repository-relative fspath of PATHREV. */ +const char * +svn_client__pathrev_fspath(const svn_client__pathrev_t *pathrev, + apr_pool_t *result_pool); + +/* Given PATH_OR_URL, which contains either a working copy path or an + absolute URL, a peg revision PEG_REVISION, and a desired revision + REVISION, create an RA connection to that object as it exists in + that revision, following copy history if necessary. If REVISION is + younger than PEG_REVISION, then PATH_OR_URL will be checked to see + that it is the same node in both PEG_REVISION and REVISION. If it + is not, then @c SVN_ERR_CLIENT_UNRELATED_RESOURCES is returned. + + BASE_DIR_ABSPATH is the working copy path the ra_session corresponds + to. If provided it will be used to read and dav props. So if provided + this directory MUST match the session anchor. + + If PEG_REVISION->kind is 'unspecified', the peg revision is 'head' + for a URL or 'working' for a WC path. If REVISION->kind is + 'unspecified', the operative revision is the peg revision. + + Store the resulting ra_session in *RA_SESSION_P. Store the final + resolved location of the object in *RESOLVED_LOC_P. RESOLVED_LOC_P + may be NULL if not wanted. + + Use authentication baton cached in CTX to authenticate against the + repository. + + Use POOL for all allocations. */ +svn_error_t * +svn_client__ra_session_from_path2(svn_ra_session_t **ra_session_p, + svn_client__pathrev_t **resolved_loc_p, + const char *path_or_url, + const char *base_dir_abspath, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/* Given PATH_OR_URL, which contains either a working copy path or an + absolute URL, a peg revision PEG_REVISION, and a desired revision + REVISION, find the path at which that object exists in REVISION, + following copy history if necessary. If REVISION is younger than + PEG_REVISION, then check that PATH_OR_URL is the same node in both + PEG_REVISION and REVISION, and return @c + SVN_ERR_CLIENT_UNRELATED_RESOURCES if it is not the same node. + + If PEG_REVISION->kind is 'unspecified', the peg revision is 'head' + for a URL or 'working' for a WC path. If REVISION->kind is + 'unspecified', the operative revision is the peg revision. + + Store the actual location of the object in *RESOLVED_LOC_P. + + RA_SESSION should be an open RA session pointing at the URL of + PATH_OR_URL, or NULL, in which case this function will open its own + temporary session. + + Use authentication baton cached in CTX to authenticate against the + repository. + + Use POOL for all allocations. */ +svn_error_t * +svn_client__resolve_rev_and_url(svn_client__pathrev_t **resolved_loc_p, + svn_ra_session_t *ra_session, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Return @c SVN_ERR_ILLEGAL_TARGET if TARGETS contains a mixture of + * URLs and paths; otherwise return SVN_NO_ERROR. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client__assert_homogeneous_target_type(const apr_array_header_t *targets); + + +/* Create a svn_client_status_t structure *CST for LOCAL_ABSPATH, shallow + * copying data from *STATUS wherever possible and retrieving the other values + * where needed. Perform temporary allocations in SCRATCH_POOL and allocate the + * result in RESULT_POOL + */ +svn_error_t * +svn_client__create_status(svn_client_status_t **cst, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const svn_wc_status3_t *status, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Set *ANCESTOR_URL and *ANCESTOR_REVISION to the URL and revision, + * respectively, of the youngest common ancestor of the two locations + * PATH_OR_URL1@REV1 and PATH_OR_URL2@REV2. Set *ANCESTOR_RELPATH to + * NULL and *ANCESTOR_REVISION to SVN_INVALID_REVNUM if they have no + * common ancestor. This function assumes that PATH_OR_URL1@REV1 and + * PATH_OR_URL2@REV2 both refer to the same repository. + * + * Use the authentication baton cached in CTX to authenticate against + * the repository. + * + * See also svn_client__get_youngest_common_ancestor(). + */ +svn_error_t * +svn_client__youngest_common_ancestor(const char **ancestor_url, + svn_revnum_t *ancestor_rev, + const char *path_or_url1, + const svn_opt_revision_t *revision1, + const char *path_or_url2, + const svn_opt_revision_t *revision2, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Get the repository location of the base node at LOCAL_ABSPATH. + * + * A pathrev_t wrapper around svn_wc__node_get_base(). + * + * Set *BASE_P to the location that this node was checked out at or last + * updated/switched to, regardless of any uncommitted changes (delete, + * replace and/or copy-here/move-here). + * + * If there is no base node at LOCAL_ABSPATH (such as when there is a + * locally added/copied/moved-here node that is not part of a replace), + * set *BASE_P to NULL. + */ +svn_error_t * +svn_client__wc_node_get_base(svn_client__pathrev_t **base_p, + const char *wc_abspath, + svn_wc_context_t *wc_ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Get the original location of the WC node at LOCAL_ABSPATH. + * + * A pathrev_t wrapper around svn_wc__node_get_origin(). + * + * Set *ORIGIN_P to the origin of the WC node at WC_ABSPATH. If the node + * is a local copy, give the copy-from location. If the node is locally + * added or deleted, set *ORIGIN_P to NULL. + */ +svn_error_t * +svn_client__wc_node_get_origin(svn_client__pathrev_t **origin_p, + const char *wc_abspath, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Produce a diff with depth DEPTH between two files or two directories at + * LOCAL_ABSPATH1 and LOCAL_ABSPATH2, using the provided diff callbacks to + * show changes in files. The files and directories involved may be part of + * a working copy or they may be unversioned. For versioned files, show + * property changes, too. */ +svn_error_t * +svn_client__arbitrary_nodes_diff(const char *local_abspath1, + const char *local_abspath2, + svn_depth_t depth, + const svn_wc_diff_callbacks4_t *callbacks, + void *callback_baton, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/* Copy the file or directory on URL in some repository to DST_ABSPATH, + * copying node information and properties. Resolve URL using PEG_REV and + * REVISION. + * + * If URL specifies a directory, create the copy using depth DEPTH. + * + * If MAKE_PARENTS is TRUE and DST_ABSPATH doesn't have an added parent + * create missing parent directories + */ +svn_error_t * +svn_client__copy_foreign(const char *url, + const char *dst_abspath, + svn_opt_revision_t *peg_revision, + svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t make_parents, + svn_boolean_t already_locked, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CLIENT_PRIVATE_H */ diff --git a/subversion/include/private/svn_cmdline_private.h b/subversion/include/private/svn_cmdline_private.h new file mode 100644 index 0000000..ad16b66 --- /dev/null +++ b/subversion/include/private/svn_cmdline_private.h @@ -0,0 +1,228 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_cmdline_private.h + * @brief Private functions for Subversion cmdline. + */ + +#ifndef SVN_CMDLINE_PRIVATE_H +#define SVN_CMDLINE_PRIVATE_H + +#include <apr_pools.h> +#include <apr_hash.h> + +#include "svn_string.h" +#include "svn_error.h" +#include "svn_io.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Write a property as an XML element into @a *outstr. + * + * If @a outstr is NULL, allocate @a *outstr in @a pool; else append to + * @a *outstr, allocating in @a outstr's pool + * + * @a propname is the property name. @a propval is the property value, which + * will be encoded if it contains unsafe bytes. + * + * If @a inherited_prop is TRUE then @a propname is an inherited property, + * otherwise @a propname is an explicit property. + */ +void +svn_cmdline__print_xml_prop(svn_stringbuf_t **outstr, + const char *propname, + svn_string_t *propval, + svn_boolean_t inherited_prop, + apr_pool_t *pool); + + +/** An implementation of @c svn_auth_gnome_keyring_unlock_prompt_func_t that + * prompts the user for default GNOME Keyring password. + * + * Expects a @c svn_cmdline_prompt_baton2_t to be passed as @a baton. + * + * @since New in 1.6. + */ +svn_error_t * +svn_cmdline__auth_gnome_keyring_unlock_prompt(char **keyring_password, + const char *keyring_name, + void *baton, + apr_pool_t *pool); + +/** Container for config options parsed with svn_cmdline__parse_config_option + * + * @since New in 1.7. + */ +typedef struct svn_cmdline__config_argument_t +{ + const char *file; + const char *section; + const char *option; + const char *value; +} svn_cmdline__config_argument_t; + +/** Parser for 'FILE:SECTION:OPTION=[VALUE]'-style option arguments. + * + * Parses @a opt_arg and places its value in @a config_options, an apr array + * containing svn_cmdline__config_argument_t* elements, allocating the option + * data in @a pool + * + * @since New in 1.7. + */ +svn_error_t * +svn_cmdline__parse_config_option(apr_array_header_t *config_options, + const char *opt_arg, + apr_pool_t *pool); + +/** Sets the config options in @a config_options, an apr array containing + * @c svn_cmdline__config_argument_t* elements, to the configuration in @a cfg, + * a hash mapping of <tt>const char *</tt> configuration file names to + * @c svn_config_t *'s. Write warnings to stderr. + * + * Use @a prefix as prefix and @a argument_name in warning messages. + * + * @since New in 1.7. + */ +svn_error_t * +svn_cmdline__apply_config_options(apr_hash_t *config, + const apr_array_header_t *config_options, + const char *prefix, + const char *argument_name); + +/* Return a string allocated in POOL that is a copy of STR but with each + * line prefixed with INDENT. A line is all characters up to the first + * CR-LF, LF-CR, CR or LF, or the end of STR if sooner. */ +const char * +svn_cmdline__indent_string(const char *str, + const char *indent, + apr_pool_t *pool); + +/* Print to stdout a hash PROP_HASH that maps property names (char *) to + property values (svn_string_t *). The names are assumed to be in UTF-8 + format; the values are either in UTF-8 (the special Subversion props) or + plain binary values. + + If OUT is not NULL, then write to it rather than stdout. + + If NAMES_ONLY is true, print just names, else print names and + values. */ +svn_error_t * +svn_cmdline__print_prop_hash(svn_stream_t *out, + apr_hash_t *prop_hash, + svn_boolean_t names_only, + apr_pool_t *pool); + +/* Similar to svn_cmdline__print_prop_hash(), only output xml to *OUTSTR. + If INHERITED_PROPS is true, then PROP_HASH contains inherited properties, + otherwise PROP_HASH contains explicit properties. If *OUTSTR is NULL, + allocate it first from POOL, otherwise append to it. */ +svn_error_t * +svn_cmdline__print_xml_prop_hash(svn_stringbuf_t **outstr, + apr_hash_t *prop_hash, + svn_boolean_t names_only, + svn_boolean_t inherited_props, + apr_pool_t *pool); + + +/* Search for a text editor command in standard environment variables, + and invoke it to edit PATH. Use POOL for all allocations. + + If EDITOR_CMD is not NULL, it is the name of the external editor + command to use, overriding anything else that might determine the + editor. + + CONFIG is a hash of svn_config_t * items keyed on a configuration + category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL. */ +svn_error_t * +svn_cmdline__edit_file_externally(const char *path, + const char *editor_cmd, + apr_hash_t *config, + apr_pool_t *pool); + +/* Search for a text editor command in standard environment variables, + and invoke it to edit CONTENTS (using a temporary file created in + directory BASE_DIR). Return the new contents in *EDITED_CONTENTS, + or set *EDITED_CONTENTS to NULL if no edit was performed. + + If EDITOR_CMD is not NULL, it is the name of the external editor + command to use, overriding anything else that might determine the + editor. + + If TMPFILE_LEFT is NULL, the temporary file will be destroyed. + Else, the file will be left on disk, and its path returned in + *TMPFILE_LEFT. + + CONFIG is a hash of svn_config_t * items keyed on a configuration + category (SVN_CONFIG_CATEGORY_CONFIG et al), and may be NULL. + + If AS_TEXT is TRUE, recode CONTENTS and convert to native eol-style before + editing and back again afterwards. In this case, ENCODING determines the + encoding used during editing. If non-NULL, use the named encoding, else + use the system encoding. If AS_TEXT is FALSE, don't do any translation. + In that case, ENCODING is ignored. + + Use POOL for all allocations. Use PREFIX as the prefix for the + temporary file used by the editor. + + If return error, *EDITED_CONTENTS is not touched. */ +svn_error_t * +svn_cmdline__edit_string_externally(svn_string_t **edited_contents, + const char **tmpfile_left, + const char *editor_cmd, + const char *base_dir, + const svn_string_t *contents, + const char *prefix, + apr_hash_t *config, + svn_boolean_t as_text, + const char *encoding, + apr_pool_t *pool); + + +/** Wrapper for apr_getopt_init(), which see. + * + * @since New in 1.4. + */ +svn_error_t * +svn_cmdline__getopt_init(apr_getopt_t **os, + int argc, + const char *argv[], + apr_pool_t *pool); + +/* Determine whether interactive mode should be enabled, based on whether + * the user passed the --non-interactive or --force-interactive options. + * If neither option was passed, interactivity is enabled if standard + * input is connected to a terminal device. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_cmdline__be_interactive(svn_boolean_t non_interactive, + svn_boolean_t force_interactive); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CMDLINE_PRIVATE_H */ diff --git a/subversion/include/private/svn_dav_protocol.h b/subversion/include/private/svn_dav_protocol.h new file mode 100644 index 0000000..94cf069 --- /dev/null +++ b/subversion/include/private/svn_dav_protocol.h @@ -0,0 +1,68 @@ +/* + * svn_dav_protocol.h: Declarations of the protocol shared by the + * mod_dav_svn backend for httpd's mod_dav and its ra_serf RA DAV clients. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_DAV_PROTOCOL_H +#define SVN_DAV_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Names for the custom HTTP REPORTs understood by mod_dav_svn, sans + namespace. */ +#define SVN_DAV__MERGEINFO_REPORT "mergeinfo-report" +#define SVN_DAV__INHERITED_PROPS_REPORT "inherited-props-report" + +/** Names for XML child elements of the custom HTTP REPORTs understood + by mod_dav_svn, sans namespace. */ +#define SVN_DAV__CREATIONDATE "creationdate" +#define SVN_DAV__MERGEINFO_ITEM "mergeinfo-item" +#define SVN_DAV__MERGEINFO_PATH "mergeinfo-path" +#define SVN_DAV__MERGEINFO_INFO "mergeinfo-info" +#define SVN_DAV__PATH "path" +#define SVN_DAV__INHERIT "inherit" +#define SVN_DAV__REVISION "revision" +#define SVN_DAV__INCLUDE_DESCENDANTS "include-descendants" +#define SVN_DAV__VERSION_NAME "version-name" +#define SVN_DAV__IPROP_ITEM "iprop-item" +#define SVN_DAV__IPROP_PATH "iprop-path" +#define SVN_DAV__IPROP_PROPNAME "iprop-propname" +#define SVN_DAV__IPROP_PROPVAL "iprop-propval" + +/** Names of XML elements attributes and tags for svn_ra_change_rev_prop2()'s + extension of PROPPATCH. */ +#define SVN_DAV__OLD_VALUE "old-value" +#define SVN_DAV__OLD_VALUE__ABSENT "absent" + +/** Helper typedef for svn_ra_change_rev_prop2() implementation. */ +typedef struct svn_dav__two_props_t { + const svn_string_t *const *old_value_p; + const svn_string_t *new_value; +} svn_dav__two_props_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DAV_PROTOCOL_H */ diff --git a/subversion/include/private/svn_debug.h b/subversion/include/private/svn_debug.h new file mode 100644 index 0000000..a596ba1 --- /dev/null +++ b/subversion/include/private/svn_debug.h @@ -0,0 +1,107 @@ +/* svn_debug.h : handy little debug tools for the SVN developers + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_DEBUG_H +#define SVN_DEBUG_H + +#ifdef SVN_DEBUG +#define SVN_DBG__PROTOTYPES +#endif + +#ifdef SVN_DBG__PROTOTYPES +#define APR_WANT_STDIO +#include <apr_want.h> +#include <apr_hash.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef SVN_DBG__PROTOTYPES +/* A few helper functions for the macros below. */ +void +svn_dbg__preamble(const char *file, long line, FILE *output); +void +svn_dbg__printf(const char *fmt, ...) + __attribute__((format(printf, 1, 2))); +void +svn_dbg__print_props(apr_hash_t *props, + const char *header_fmt, + ...) + __attribute__((format(printf, 2, 3))); +#endif + +/* Only available when SVN_DEBUG is defined (ie. svn developers). Note that + we do *not* provide replacement macros/functions for proper releases. + The debug stuff should be removed before a commit. + + ### maybe we will eventually decide to allow certain debug stuff to + ### remain in the code. at that point, we can rejigger this header. */ +#ifdef SVN_DEBUG + +/* Print to stdout. Edit this line if you need stderr. */ +#define SVN_DBG_OUTPUT stdout + + +/* Defining this symbol in the source file, BEFORE INCLUDING THIS HEADER, + will switch off the output. Calls will still be made to svn_dbg__preamble() + for breakpoints. */ +#ifdef SVN_DBG_QUIET + +#define SVN_DBG(ARGS) svn_dbg__preamble(__FILE__, __LINE__, NULL) +#define SVN_DBG_PROPS(ARGS) svn_dbg__preamble(__FILE__, __LINE__, NULL) + +#else + +/** Debug aid macro that prints the file:line of the call and printf-like + * arguments to the #SVN_DBG_OUTPUT stdio stream (#stdout by default). Typical + * usage: + * + * <pre> + * SVN_DBG(("rev=%ld kind=%s\n", revnum, svn_node_kind_to_word(kind))); + * </pre> + * + * outputs: + * + * <pre> + * DBG: kitchensink.c: 42: rev=3141592 kind=file + * </pre> + * + * Note that these output lines are filtered by our test suite automatically, + * so you don't have to worry about throwing off expected output. + */ +#define SVN_DBG(ARGS) (svn_dbg__preamble(__FILE__, __LINE__, SVN_DBG_OUTPUT), \ + svn_dbg__printf ARGS) +#define SVN_DBG_PROPS(ARGS) (svn_dbg__preamble(__FILE__, __LINE__, \ + SVN_DBG_OUTPUT), \ + svn_dbg__print_props ARGS) + +#endif + +#endif /* SVN_DEBUG */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DEBUG_H */ diff --git a/subversion/include/private/svn_delta_private.h b/subversion/include/private/svn_delta_private.h new file mode 100644 index 0000000..4de85a9 --- /dev/null +++ b/subversion/include/private/svn_delta_private.h @@ -0,0 +1,128 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_delta_private.h + * @brief The Subversion delta/diff/editor library - Internal routines + */ + +#ifndef SVN_DELTA_PRIVATE_H +#define SVN_DELTA_PRIVATE_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_error.h" +#include "svn_delta.h" +#include "svn_editor.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +typedef svn_error_t *(*svn_delta__start_edit_func_t)( + void *baton, + svn_revnum_t base_revision); + +typedef svn_error_t *(*svn_delta__target_revision_func_t)( + void *baton, + svn_revnum_t target_revision, + apr_pool_t *scratch_pool); + +typedef svn_error_t *(*svn_delta__unlock_func_t)( + void *baton, + const char *path, + apr_pool_t *scratch_pool); + + +/* See svn_editor__insert_shims() for more information. */ +struct svn_delta__extra_baton +{ + svn_delta__start_edit_func_t start_edit; + svn_delta__target_revision_func_t target_revision; + void *baton; +}; + + +/** A temporary API to convert from a delta editor to an Ev2 editor. */ +svn_error_t * +svn_delta__editor_from_delta(svn_editor_t **editor_p, + struct svn_delta__extra_baton **exb, + svn_delta__unlock_func_t *unlock_func, + void **unlock_baton, + const svn_delta_editor_t *deditor, + void *dedit_baton, + svn_boolean_t *send_abs_paths, + const char *repos_root, + const char *base_relpath, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_delta_fetch_kind_func_t fetch_kind_func, + void *fetch_kind_baton, + svn_delta_fetch_props_func_t fetch_props_func, + void *fetch_props_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** A temporary API to convert from an Ev2 editor to a delta editor. */ +svn_error_t * +svn_delta__delta_from_editor(const svn_delta_editor_t **deditor, + void **dedit_baton, + svn_editor_t *editor, + svn_delta__unlock_func_t unlock_func, + void *unlock_baton, + svn_boolean_t *found_abs_paths, + const char *repos_root, + const char *base_relpath, + svn_delta_fetch_props_func_t fetch_props_func, + void *fetch_props_baton, + svn_delta_fetch_base_func_t fetch_base_func, + void *fetch_base_baton, + struct svn_delta__extra_baton *exb, + apr_pool_t *pool); + +/** + * Get the data from IN, compress it according to the specified + * COMPRESSION_LEVEL and write the result to OUT. + * SVN_DELTA_COMPRESSION_LEVEL_NONE is valid for COMPRESSION_LEVEL. + */ +svn_error_t * +svn__compress(svn_string_t *in, + svn_stringbuf_t *out, + int compression_level); + +/** + * Get the compressed data from IN, decompress it and write the result to + * OUT. Return an error if the decompressed size is larger than LIMIT. + */ +svn_error_t * +svn__decompress(svn_string_t *in, + svn_stringbuf_t *out, + apr_size_t limit); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DELTA_PRIVATE_H */ diff --git a/subversion/include/private/svn_dep_compat.h b/subversion/include/private/svn_dep_compat.h new file mode 100644 index 0000000..71c0b9a --- /dev/null +++ b/subversion/include/private/svn_dep_compat.h @@ -0,0 +1,184 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_compat.h + * @brief Compatibility macros and functions. + * @since New in 1.5.0. + */ + +#ifndef SVN_DEP_COMPAT_H +#define SVN_DEP_COMPAT_H + +#include <apr_version.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Check at compile time if the APR version is at least a certain + * level. + * @param major The major version component of the version checked + * for (e.g., the "1" of "1.3.0"). + * @param minor The minor version component of the version checked + * for (e.g., the "3" of "1.3.0"). + * @param patch The patch level component of the version checked + * for (e.g., the "0" of "1.3.0"). + * + * @since New in 1.5. + */ +#ifndef APR_VERSION_AT_LEAST /* Introduced in APR 1.3.0 */ +#define APR_VERSION_AT_LEAST(major,minor,patch) \ +(((major) < APR_MAJOR_VERSION) \ + || ((major) == APR_MAJOR_VERSION && (minor) < APR_MINOR_VERSION) \ + || ((major) == APR_MAJOR_VERSION && (minor) == APR_MINOR_VERSION && \ + (patch) <= APR_PATCH_VERSION)) +#endif /* APR_VERSION_AT_LEAST */ + +/** + * If we don't have a recent enough APR, emulate the behavior of the + * apr_array_clear() API. + */ +#if !APR_VERSION_AT_LEAST(1,3,0) +#define apr_array_clear(arr) (arr)->nelts = 0 +#endif + +#if !APR_VERSION_AT_LEAST(1,3,0) +/* Equivalent to the apr_hash_clear() function in APR >= 1.3.0. Used to + * implement the 'apr_hash_clear' macro if the version of APR that + * we build against does not provide the apr_hash_clear() function. */ +void svn_hash__clear(struct apr_hash_t *ht); + +/** + * If we don't have a recent enough APR, emulate the behavior of the + * apr_hash_clear() API. + */ +#define apr_hash_clear(ht) svn_hash__clear(ht) +#endif + +#if !APR_VERSION_AT_LEAST(1,0,0) +#define APR_UINT64_C(val) UINT64_C(val) +#define APR_FPROT_OS_DEFAULT APR_OS_DEFAULT +#endif + +#if !APR_VERSION_AT_LEAST(1,3,0) +#define APR_UINT16_MAX 0xFFFFU +#define APR_INT16_MAX 0x7FFF +#define APR_INT16_MIN (-APR_INT16_MAX-1) +#define APR_UINT32_MAX 0xFFFFFFFFU +#define APR_INT32_MAX 0x7FFFFFFF +#define APR_INT32_MIN (-APR_INT32_MAX-1) +#define APR_UINT64_MAX APR_UINT64_C(0xFFFFFFFFFFFFFFFF) +#define APR_INT64_MAX APR_INT64_C(0x7FFFFFFFFFFFFFFF) +#define APR_INT64_MIN (-APR_INT64_MAX-1) +#define APR_SIZE_MAX (~(apr_size_t)0) + +#if APR_SIZEOF_VOIDP == 8 +typedef apr_uint64_t apr_uintptr_t; +#else +typedef apr_uint32_t apr_uintptr_t; +#endif +#endif /* !APR_VERSION_AT_LEAST(1,3,0) */ + +/** + * Work around a platform dependency issue. apr_thread_rwlock_trywrlock() + * will make APR_STATUS_IS_EBUSY() return TRUE if the lock could not be + * acquired under Unix. Under Windows, this will not work. So, provide + * a more portable substitute. + * + * @since New in 1.8. + */ +#ifdef WIN32 +#define SVN_LOCK_IS_BUSY(x) \ + (APR_STATUS_IS_EBUSY(x) || (x) == APR_FROM_OS_ERROR(WAIT_TIMEOUT)) +#else +#define SVN_LOCK_IS_BUSY(x) APR_STATUS_IS_EBUSY(x) +#endif + +/** + * Check at compile time if the Serf version is at least a certain + * level. + * @param major The major version component of the version checked + * for (e.g., the "1" of "1.3.0"). + * @param minor The minor version component of the version checked + * for (e.g., the "3" of "1.3.0"). + * @param patch The patch level component of the version checked + * for (e.g., the "0" of "1.3.0"). + * + * @since New in 1.5. + */ +#ifndef SERF_VERSION_AT_LEAST /* Introduced in Serf 0.1.1 */ +#define SERF_VERSION_AT_LEAST(major,minor,patch) \ +(((major) < SERF_MAJOR_VERSION) \ + || ((major) == SERF_MAJOR_VERSION && (minor) < SERF_MINOR_VERSION) \ + || ((major) == SERF_MAJOR_VERSION && (minor) == SERF_MINOR_VERSION && \ + (patch) <= SERF_PATCH_VERSION)) +#endif /* SERF_VERSION_AT_LEAST */ + +/** + * By default, if libsvn is built against one version of SQLite + * and then run using an older version, svn will error out: + * + * svn: Couldn't perform atomic initialization + * svn: SQLite compiled for 3.7.4, but running with 3.7.3 + * + * That can be annoying when building on a modern system in order + * to deploy on a less modern one. So these constants allow one + * to specify how old the system being deployed on might be. + * For example, + * + * EXTRA_CFLAGS += -DSVN_SQLITE_MIN_VERSION_NUMBER=3007003 + * EXTRA_CFLAGS += '-DSVN_SQLITE_MIN_VERSION="3.7.3"' + * + * turns on code that works around infelicities in older versions + * as far back as 3.7.3 and relaxes the check at initialization time + * to permit them. + * + * @since New in 1.8. + */ +#ifndef SVN_SQLITE_MIN_VERSION_NUMBER +#define SVN_SQLITE_MIN_VERSION_NUMBER SQLITE_VERSION_NUMBER +#define SVN_SQLITE_MIN_VERSION SQLITE_VERSION +#endif /* SVN_SQLITE_MIN_VERSION_NUMBER */ + +/** + * Check at compile time if the SQLite version is at least a certain + * level. + * @param major The major version component of the version checked + * for (e.g., the "1" of "1.3.0"). + * @param minor The minor version component of the version checked + * for (e.g., the "3" of "1.3.0"). + * @param patch The patch level component of the version checked + * for (e.g., the "0" of "1.3.0"). + * + * @since New in 1.6. + */ +#ifndef SQLITE_VERSION_AT_LEAST +#define SQLITE_VERSION_AT_LEAST(major,minor,patch) \ +((major*1000000 + minor*1000 + patch) <= SVN_SQLITE_MIN_VERSION_NUMBER) +#endif /* SQLITE_VERSION_AT_LEAST */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DEP_COMPAT_H */ diff --git a/subversion/include/private/svn_diff_private.h b/subversion/include/private/svn_diff_private.h new file mode 100644 index 0000000..3b6e591 --- /dev/null +++ b/subversion/include/private/svn_diff_private.h @@ -0,0 +1,115 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + */ + + +#ifndef SVN_DIFF_PRIVATE_H +#define SVN_DIFF_PRIVATE_H + +#include <apr_pools.h> +#include <apr_tables.h> + +#include "svn_types.h" +#include "svn_io.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/* The separator string used below the "Index:" or similar line of + * Subversion's Unidiff-like diff format. */ +#define SVN_DIFF__EQUAL_STRING \ + "===================================================================" + +/* The separator string used below the "Properties on ..." line of + * Subversion's Unidiff-like diff format. */ +#define SVN_DIFF__UNDER_STRING \ + "___________________________________________________________________" + +/* The string used to mark a line in a hunk that doesn't end with a newline, + * when diffing a file. Intentionally not marked for translation, for wider + * interoperability with patch(1) programs. */ +#define SVN_DIFF__NO_NEWLINE_AT_END_OF_FILE \ + "\\ No newline at end of file" + +/* The string used to mark a line in a hunk that doesn't end with a newline, + * when diffing a Subversion property. */ +#define SVN_DIFF__NO_NEWLINE_AT_END_OF_PROPERTY \ + "\\ No newline at end of property" + +/* Write a unidiff "---" and "+++" header to OUTPUT_STREAM. + * + * Write "---" followed by a space and OLD_HEADER and a newline, + * then "+++" followed by a space and NEW_HEADER and a newline. + * + * The text will be encoded into HEADER_ENCODING. + */ +svn_error_t * +svn_diff__unidiff_write_header(svn_stream_t *output_stream, + const char *header_encoding, + const char *old_header, + const char *new_header, + apr_pool_t *scratch_pool); + +/* Display property changes in pseudo-Unidiff format. + * + * Write to @a outstream the changes described by @a propchanges based on + * original properties @a original_props. + * + * Write all mark-up text (headers and so on) using the character encoding + * @a encoding. + * + * ### I think the idea is: we want the output to use @a encoding, and + * we will assume the text of the user's files and the values of any + * user-defined properties are already using @a encoding, so we don't + * want to re-code the *whole* output. + * So, shouldn't we also convert all prop names and all 'svn:*' prop + * values to @a encoding, since we know those are stored in UTF-8? + * + * @a original_props is a hash mapping (const char *) property names to + * (svn_string_t *) values. @a propchanges is an array of svn_prop_t + * representing the new values for any of the properties that changed, with + * a NULL value to represent deletion. + * + * If @a pretty_print_mergeinfo is true, then describe 'svn:mergeinfo' + * property changes in a human-readable form that says what changes were + * merged or reverse merged; otherwise (or if the mergeinfo property values + * don't parse correctly) display them just like any other property. + * + * Use @a pool for temporary allocations. + */ +svn_error_t * +svn_diff__display_prop_diffs(svn_stream_t *outstream, + const char *encoding, + const apr_array_header_t *propchanges, + apr_hash_t *original_props, + svn_boolean_t pretty_print_mergeinfo, + apr_pool_t *pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DIFF_PRIVATE_H */ diff --git a/subversion/include/private/svn_diff_tree.h b/subversion/include/private/svn_diff_tree.h new file mode 100644 index 0000000..597a59b --- /dev/null +++ b/subversion/include/private/svn_diff_tree.h @@ -0,0 +1,357 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_wc.h + * @brief Generic diff handler. Replacing the old svn_wc_diff_callbacks4_t + * infrastructure + */ + +#ifndef SVN_DIFF_PROCESSOR_H +#define SVN_DIFF_PROCESSOR_H + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * About the diff tree processor. + * + * Subversion uses two kinds of editors to describe changes. One to + * describe changes on how to *exactly* transform one tree to another tree, + * as efficiently as possible and one to describe the difference between trees + * in order to review the changes, or to allow applying them on a third tree + * which is similar to those other trees. + * + * The first case was originally handled by svn_delta_editor_t and might be + * replaced by svn_editor_t in a future version. This diff processor handles + * the other case and as such forms the layer below our diff and merge + * handling. + * + * The major difference between this and the other editors is that this diff + * always provides access to the full text and/or properties in the left and + * right tree when applicable to allow processor implementers to decide how + * to interpret changes. + * + * Originally this diff processor was not formalized explicitly, but + * informally handled by the working copy diff callbacks. These callbacks just + * provided the information to drive a unified diff and a textual merge. To go + * one step further and allow full tree conflict detection we needed a better + * defined diff handling. Instead of adding yet a few more functions and + * arguments to the already overloaded diff callbacks the api was completely + * redesigned with a few points in mind. + * + * * It must be able to drive the old callbacks interface without users + * noticing the difference (100% compatible). + * (Implemented as svn_wc__wrap_diff_callbacks()) + * + * * It should provide the information that was missing in the old interface, + * but required to close existing issues. + * + * E.g. - properties and children on deleted directories. + * - revision numbers and copyfrom information on directories. + * + * To cleanup the implementation and make it easier on diff processors to + * handle the results I also added the following constraints. + * + * * Diffs should be fully reversable: anything that is deleted should be + * available, just like something that is added. + * (Proven via svn_diff__tree_processor_reverse_create) + * ### Still in doubt if *_deleted() needs a copy_to argument, for the + * ### 99% -> 100%. + * + * * Diff processors should have an easy way to communicate that they are + * not interrested in certain expensive to obtain results. + * + * * Directories should have clear open and close events to allow adding them + * before their children, but still allowing property changes to have + * defined behavior. + * + * * Files and directories should be handled as similar as possible as in + * many cases they are just nodes in a tree. + * + * * It should be easy to create diff wrappers to apply certain transforms. + * + * During the creation an additional requirement of knowing about 'some + * absent' nodes was added, to allow the merge to work on just this processor + * api. + * + * The api describes a clean open-close walk through a tree, depending on the + * driver multiple siblings can be described at the same time, but when a + * directory is closed all descendants are done. + * + * Note that it is possible for nodes to be described as a delete followed by + * an add at the same place within one parent. (Iff the diff is reversed you + * can see an add followed by a delete!) + * + * The directory batons live between the open and close events of a directory + * and are thereby guaranteed to outlive the batons of their descendants. + */ + +/* Describes the source of a merge */ +typedef struct svn_diff_source_t +{ + /* Always available */ + svn_revnum_t revision; + + /* Depending on the driver available for copyfrom */ + const char *repos_relpath; +} svn_diff_source_t; + +/** + * A callback vtable invoked by our diff-editors, as they receive diffs + * from the server. 'svn diff' and 'svn merge' implement their own versions + * of this vtable. + * + * All callbacks receive the processor and at least a parent baton. Forwarding + * the processor allows future extensions to call into the old functions without + * revving the entire API. + * + * Users must call svn_diff__tree_processor_create() to allow adding new + * callbacks later. (E.g. when we decide how to add move support) These + * extensions can then just call into other callbacks. + * + * @since New in 1.8. + */ +typedef struct svn_diff_tree_processor_t +{ + /** The value passed to svn_diff__tree_processor_create() as BATON. + */ + void *baton; /* To avoid an additional in some places */ + + /* Called before a directories children are processed. + * + * Set *SKIP_CHILDREN to TRUE, to skip calling callbacks for all + * children. + * + * Set *SKIP to TRUE to skip calling the added, deleted, changed + * or closed callback for this node only. + */ + svn_error_t * + (*dir_opened)(void **new_dir_baton, + svn_boolean_t *skip, + svn_boolean_t *skip_children, + const char *relpath, + const svn_diff_source_t *left_source, + const svn_diff_source_t *right_source, + const svn_diff_source_t *copyfrom_source, + void *parent_dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + /* Called after a directory and all its children are added + */ + svn_error_t * + (*dir_added)(const char *relpath, + const svn_diff_source_t *copyfrom_source, + const svn_diff_source_t *right_source, + /*const*/ apr_hash_t *copyfrom_props, + /*const*/ apr_hash_t *right_props, + void *dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called after all children of this node are reported as deleted. + * + * The default implementation calls dir_closed(). + */ + svn_error_t * + (*dir_deleted)(const char *relpath, + const svn_diff_source_t *left_source, + /*const*/ apr_hash_t *left_props, + void *dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called instead of dir_closed() if the properties on the directory + * were modified. + * + * The default implementation calls dir_closed(). + */ + svn_error_t * + (*dir_changed)(const char *relpath, + const svn_diff_source_t *left_source, + const svn_diff_source_t *right_source, + /*const*/ apr_hash_t *left_props, + /*const*/ apr_hash_t *right_props, + const apr_array_header_t *prop_changes, + void *dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called when a directory is closed without applying changes to + * the directory itself. + * + * When dir_changed or dir_deleted are handled by the default implementation + * they call dir_closed() + */ + svn_error_t * + (*dir_closed)(const char *relpath, + const svn_diff_source_t *left_source, + const svn_diff_source_t *right_source, + void *dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called before file_added(), file_deleted(), file_changed() and + file_closed() + */ + svn_error_t * + (*file_opened)(void **new_file_baton, + svn_boolean_t *skip, + const char *relpath, + const svn_diff_source_t *left_source, + const svn_diff_source_t *right_source, + const svn_diff_source_t *copyfrom_source, + void *dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + /* Called after file_opened() for newly added and copied files */ + svn_error_t * + (*file_added)(const char *relpath, + const svn_diff_source_t *copyfrom_source, + const svn_diff_source_t *right_source, + const char *copyfrom_file, + const char *right_file, + /*const*/ apr_hash_t *copyfrom_props, + /*const*/ apr_hash_t *right_props, + void *file_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called after file_opened() for deleted or moved away files */ + svn_error_t * + (*file_deleted)(const char *relpath, + const svn_diff_source_t *left_source, + const char *left_file, + /*const*/ apr_hash_t *left_props, + void *file_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called after file_opened() for changed files */ + svn_error_t * + (*file_changed)(const char *relpath, + const svn_diff_source_t *left_source, + const svn_diff_source_t *right_source, + const char *left_file, + const char *right_file, + /*const*/ apr_hash_t *left_props, + /*const*/ apr_hash_t *right_props, + svn_boolean_t file_modified, + const apr_array_header_t *prop_changes, + void *file_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called after file_opened() for unmodified files */ + svn_error_t * + (*file_closed)(const char *relpath, + const svn_diff_source_t *left_source, + const svn_diff_source_t *right_source, + void *file_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); + + /* Called when encountering a marker for an absent file or directory */ + svn_error_t * + (*node_absent)(const char *relpath, + void *dir_baton, + const struct svn_diff_tree_processor_t *processor, + apr_pool_t *scratch_pool); +} svn_diff_tree_processor_t; + +/** + * Create a new svn_diff_tree_processor_t instance with all functions + * set to a callback doing nothing but copying the parent baton to + * the new baton. + * + * @since New in 1.8. + */ +svn_diff_tree_processor_t * +svn_diff__tree_processor_create(void *baton, + apr_pool_t *result_pool); + +/** + * Create a new svn_diff_tree_processor_t instance with all functions setup + * to call into another svn_diff_tree_processor_t processor, but with all + * adds and deletes inverted. + * + * @since New in 1.8. + */ /* Used by libsvn clients repository diff */ +const svn_diff_tree_processor_t * +svn_diff__tree_processor_reverse_create(const svn_diff_tree_processor_t * processor, + const char *prefix_relpath, + apr_pool_t *result_pool); + +/** + * Create a new svn_diff_tree_processor_t instance with all functions setup + * to call into processor for all paths equal to and below prefix_relpath. + * + * @since New in 1.8. + */ /* Used by libsvn clients repository diff */ +const svn_diff_tree_processor_t * +svn_diff__tree_processor_filter_create(const svn_diff_tree_processor_t *processor, + const char *prefix_relpath, + apr_pool_t *result_pool); + +/** + * Create a new svn_diff_tree_processor_t instace with all function setup + * to call into processor with all adds with copyfrom information transformed + * to simple node changes. + * + * @since New in 1.8. + */ /* Used by libsvn_wc diff editor */ +const svn_diff_tree_processor_t * +svn_diff__tree_processor_copy_as_changed_create( + const svn_diff_tree_processor_t *processor, + apr_pool_t *result_pool); + + +/** + * Create a new svn_diff_tree_processor_t instance with all functions setup + * to first call into processor1 and then processor2. + * + * This function is mostly a debug and migration helper. + * + * @since New in 1.8. + */ /* Used by libsvn clients repository diff */ +const svn_diff_tree_processor_t * +svn_diff__tree_processor_tee_create(const svn_diff_tree_processor_t *processor1, + const svn_diff_tree_processor_t *processor2, + apr_pool_t *result_pool); + + +svn_diff_source_t * +svn_diff__source_create(svn_revnum_t revision, + apr_pool_t *result_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DIFF_PROCESSOR_H */ + diff --git a/subversion/include/private/svn_doxygen.h b/subversion/include/private/svn_doxygen.h new file mode 100644 index 0000000..426e3f7 --- /dev/null +++ b/subversion/include/private/svn_doxygen.h @@ -0,0 +1,32 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/** + * @mainpage Subversion Documentation + * + * This documentation covers the public APIs provided by the Subversion + * libraries. It is intended mainly for programmers, both those working + * on Subversion itself, as well as developers of 3rd-party applications + * intending to use these APIs. For more information about using Subversion, + * see the Subversion Book at http://svnbook.red-bean.com/. + * + * To learn more about Subversion, please visit http://subversion.apache.org/. + */ diff --git a/subversion/include/private/svn_editor.h b/subversion/include/private/svn_editor.h new file mode 100644 index 0000000..d714bb1 --- /dev/null +++ b/subversion/include/private/svn_editor.h @@ -0,0 +1,1194 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_editor.h + * @brief Tree editing functions and structures + */ + +#ifndef SVN_EDITOR_H +#define SVN_EDITOR_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_error.h" +#include "svn_io.h" /* for svn_stream_t */ +#include "svn_delta.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/*** Temporarily private stuff (should move to svn_delta.h when Editor + V2 is made public) ***/ + +/** Callback to retrieve a node's entire set of properties. This is + * needed by the various editor shims in order to effect backwards + * compatibility. + * + * Implementations should set @a *props to the hash of properties + * associated with @a path in @a base_revision, allocating that hash + * and its contents in @a result_pool, and should use @a scratch_pool + * for temporary allocations. + * + * @a baton is an implementation-specific closure. + */ +typedef svn_error_t *(*svn_delta_fetch_props_func_t)( + apr_hash_t **props, + void *baton, + const char *path, + svn_revnum_t base_revision, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool + ); + +/** Callback to retrieve a node's kind. This is needed by the various + * editor shims in order to effect backwards compatibility. + * + * Implementations should set @a *kind to the node kind of @a path in + * @a base_revision, using @a scratch_pool for temporary allocations. + * + * @a baton is an implementation-specific closure. + */ +typedef svn_error_t *(*svn_delta_fetch_kind_func_t)( + svn_node_kind_t *kind, + void *baton, + const char *path, + svn_revnum_t base_revision, + apr_pool_t *scratch_pool + ); + +/** Callback to fetch the name of a file to use as a delta base. + * + * Implementations should set @a *filename to the name of a file + * suitable for use as a delta base for @a path in @a base_revision + * (allocating @a *filename from @a result_pool), or to @c NULL if the + * base stream is empty. @a scratch_pool is provided for temporary + * allocations. + * + * @a baton is an implementation-specific closure. + */ +typedef svn_error_t *(*svn_delta_fetch_base_func_t)( + const char **filename, + void *baton, + const char *path, + svn_revnum_t base_revision, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool + ); + +/** Collection of callbacks used for the shim code. This structure + * may grow additional fields in the future. Therefore, always use + * svn_delta_shim_callbacks_default() to allocate new instances of it. + */ +typedef struct svn_delta_shim_callbacks_t +{ + svn_delta_fetch_props_func_t fetch_props_func; + svn_delta_fetch_kind_func_t fetch_kind_func; + svn_delta_fetch_base_func_t fetch_base_func; + void *fetch_baton; +} svn_delta_shim_callbacks_t; + +/** Return a collection of default shim functions in @a result_pool. + */ +svn_delta_shim_callbacks_t * +svn_delta_shim_callbacks_default(apr_pool_t *result_pool); + + + +/** Transforming trees ("editing"). + * + * In Subversion, we have a number of occasions where we transform a tree + * from one state into another. This process is called "editing" a tree. + * + * In processing a `commit' command: + * - The client examines its working copy data to determine the set of + * changes necessary to transform its base tree into the desired target. + * - The client networking library delivers that set of changes/operations + * across the wire as an equivalent series of network requests (for + * example, to svnserve as an ra_svn protocol stream, or to an + * Apache httpd server as WebDAV commands) + * - The server receives those requests and applies the sequence of + * operations on a revision, producing a transaction representing the + * desired target. + * - The Subversion server then commits the transaction to the filesystem. + * + * In processing an `update' command, the process is reversed: + * - The Subversion server module talks to the filesystem and computes a + * set of changes necessary to bring the client's working copy up to date. + * - The server serializes this description of changes, and delivers it to + * the client. + * - The client networking library receives that reply, producing a set + * of changes/operations to alter the working copy into the revision + * requested by the update command. + * - The working copy library applies those operations to the working copy + * to align it with the requested update target. + * + * The series of changes (or operations) necessary to transform a tree from + * one state into another is passed between subsystems using this "editor" + * interface. The "receiver" edits its tree according to the operations + * described by the "driver". + * + * Note that the driver must have a perfect understanding of the tree which + * the receiver will be applying edits upon. There is no room for error here, + * and the interface embodies assumptions/requirements that the driver has + * about the targeted tree. As a result, this interface is a standardized + * mechanism of *describing* those change operations, but the intimate + * knowledge between the driver and the receiver implies some level of + * coupling between those subsystems. + * + * The set of changes, and the data necessary to describe it entirely, is + * completely unbounded. An addition of one simple 20 GB file might be well + * past the available memory of a machine processing these operations. + * As a result, the API to describe the changes is designed to be applied + * in a sequential (and relatively random-access) model. The operations + * can be streamed from the driver to the receiver, resulting in the + * receiver editing its tree to the target state defined by the driver. + * + * + * <h3>History</h3> + * + * Classically, Subversion had a notion of a "tree delta" which could be + * passed around as an independent entity. Theory implied this delta was an + * entity in its own right, to be used when and where necessary. + * Unfortunately, this theory did not work well in practice. The producer + * and consumer of these tree deltas were (and are) tightly coupled. As noted + * above, the tree delta producer needed to be *totally* aware of the tree + * that it needed to edit. So rather than telling the delta consumer how to + * edit its tree, the classic #svn_delta_editor_t interface focused + * entirely on the tree delta, an intermediate (logical) data structure + * which was unusable outside of the particular, coupled pairing of producer + * and consumer. This generation of the API forgoes the logical tree delta + * entity and directly passes the necessary edits/changes/operations from + * the producer to the consumer. In our new parlance, one subsystem "drives" + * a set of operations describing the change, and a "receiver" accepts and + * applies them to its tree. + * + * The classic interface was named #svn_delta_editor_t and was described + * idiomatically as the "editor interface". This generation of the interface + * retains the "editor" name for that reason. All notions of a "tree delta" + * structure are no longer part of this interface. + * + * The old interface was purely vtable-based and used a number of special + * editors which could be interposed between the driver and receiver. Those + * editors provided cancellation, debugging, and other various operations. + * While the "interposition" pattern is still possible with this interface, + * the most common functionality (cancellation and debugging) have been + * integrated directly into this new editor system. + * + * + * <h3>Implementation Plan</h3> + * @note This section can be removed after Ev2 is fully implemented. + * + * The delta editor is pretty engrained throughout Subversion, so attempting + * to replace it in situ is somewhat akin to performing open heart surgery + * while the patient is running a marathon. However, a viable plan should + * make things a bit easier, and help parallelize the work. + * + * In short, the following items need to be done: + * -# Implement backward compatibility wrappers ("shims") + * -# Use shims to update editor consumers to Ev2 + * -# Update editor producers to drive Ev2 + * - This will largely involve rewriting the RA layers to accept and + * send Ev2 commands + * -# Optimize consumers and producers to leverage the features of Ev2 + * + * The shims are largely self-contained, and as of this writing, are almost + * complete. They can be released without much ado. However, they do add + * <em>significant</em> performance regressions, which make releasing code + * which is half-delta-editor and half-Ev2 inadvisable. As such, the updating + * of producers and consumers to Ev2 will probably need to wait until 1.9, + * though it could be largely parallelized. + * + * + * @defgroup svn_editor The editor interface + * @{ + */ + +/** An abstract object that edits a target tree. + * + * @note The term "follow" means at any later time in the editor drive. + * Terms such as "must", "must not", "required", "shall", "shall not", + * "should", "should not", "recommended", "may", and "optional" in this + * document are to be interpreted as described in RFC 2119. + * + * @note The editor objects are *not* reentrant. The receiver should not + * directly or indirectly invoke an editor API with the same object unless + * it has been marked as explicitly supporting reentrancy during a + * receiver's callback. This limitation extends to the cancellation + * callback, too. (This limitation is due to the scratch_pool shared by + * all callbacks, and cleared after each callback; a reentrant call could + * clear the outer call's pool). Note that the code itself is reentrant, so + * there is no problem using the APIs on different editor objects. + * + * \n + * <h3>Life-Cycle</h3> + * + * - @b Create: A receiver uses svn_editor_create() to create an + * "empty" svn_editor_t. It cannot be used yet, since it still lacks + * actual callback functions. svn_editor_create() sets the + * #svn_editor_t's callback baton and scratch pool that the callback + * functions receive, as well as a cancellation callback and baton + * (see "Cancellation" below). + * + * - @b Set callbacks: The receiver calls svn_editor_setcb_many() or a + * succession of the other svn_editor_setcb_*() functions to tell + * #svn_editor_t which functions to call when driven by the various + * operations. Callback functions are implemented by the receiver and must + * adhere to the @c svn_editor_cb_*_t function types as expected by the + * svn_editor_setcb_*() functions. See: \n + * svn_editor_cb_many_t \n + * svn_editor_setcb_many() \n + * or \n + * svn_editor_setcb_add_directory() \n + * svn_editor_setcb_add_file() \n + * svn_editor_setcb_add_symlink() \n + * svn_editor_setcb_add_absent() \n + * svn_editor_setcb_alter_directory() \n + * svn_editor_setcb_alter_file() \n + * svn_editor_setcb_alter_symlink() \n + * svn_editor_setcb_delete() \n + * svn_editor_setcb_copy() \n + * svn_editor_setcb_move() \n + * svn_editor_setcb_rotate() \n + * svn_editor_setcb_complete() \n + * svn_editor_setcb_abort() + * + * - @b Drive: The driver is provided with the completed #svn_editor_t + * instance. (It is typically passed to a generic driving + * API, which could receive the driving editor calls over the network + * by providing a proxy #svn_editor_t on the remote side.) + * The driver invokes the #svn_editor_t instance's callback functions + * according to the restrictions defined below, in order to describe the + * entire set of operations necessary to transform the receiver's tree + * into the desired target. The callbacks can be invoked using the + * svn_editor_*() functions, i.e.: \n + * svn_editor_add_directory() \n + * svn_editor_add_file() \n + * svn_editor_add_symlink() \n + * svn_editor_add_absent() \n + * svn_editor_alter_directory() \n + * svn_editor_alter_file() \n + * svn_editor_alter_symlink() \n + * svn_editor_delete() \n + * svn_editor_copy() \n + * svn_editor_move() \n + * svn_editor_rotate() + * \n\n + * Just before each callback invocation is carried out, the @a cancel_func + * that was passed to svn_editor_create() is invoked to poll any + * external reasons to cancel the sequence of operations. Unless it + * overrides the cancellation (denoted by #SVN_ERR_CANCELLED), the driver + * aborts the transmission by invoking the svn_editor_abort() callback. + * Exceptions to this are calls to svn_editor_complete() and + * svn_editor_abort(), which cannot be canceled externally. + * + * - @b Receive: While the driver invokes operations upon the editor, the + * receiver finds its callback functions called with the information + * to operate on its tree. Each actual callback function receives those + * arguments that the driver passed to the "driving" functions, plus these: + * - @a baton: This is the @a editor_baton pointer originally passed to + * svn_editor_create(). It may be freely used by the callback + * implementation to store information across all callbacks. + * - @a scratch_pool: This temporary pool is cleared directly after + * each callback returns. See "Pool Usage". + * \n\n + * If the receiver encounters an error within a callback, it returns an + * #svn_error_t*. The driver receives this and aborts transmission. + * + * - @b Complete/Abort: The driver will end transmission by calling \n + * svn_editor_complete() if successful, or \n + * svn_editor_abort() if an error or cancellation occurred. + * \n\n + * + * <h3>Driving Order Restrictions</h3> + * In order to reduce complexity of callback receivers, the editor callbacks + * must be driven in adherence to these rules: + * + * - If any path is added (with add_*) or deleted/moved/rotated, then + * an svn_editor_alter_directory() call must be made for its parent + * directory with the target/eventual set of children. + * + * - svn_editor_add_directory() -- Another svn_editor_add_*() call must + * follow for each child mentioned in the @a children argument of any + * svn_editor_add_directory() call. + * + * - For each node created with add_*, if its parent was created using + * svn_editor_add_directory(), then the new child node MUST have been + * mentioned in the @a children parameter of the parent's creation. + * This allows the parent directory to properly mark the child as + * "incomplete" until the child's add_* call arrives. + * + * - A path should never be referenced more than once by the add_*, alter_*, + * and delete operations (the "Once Rule"). The source path of a copy (and + * its children, if a directory) may be copied many times, and are + * otherwise subject to the Once Rule. The destination path of a copy + * or move may have alter_* operations applied, but not add_* or delete. + * If the destination path of a copy, move, or rotate is a directory, + * then its children are subject to the Once Rule. The source path of + * a move (and its child paths) may be referenced in add_*, or as the + * destination of a copy (where these new or copied nodes are subject + * to the Once Rule). Paths listed in a rotation are both sources and + * destinations, so they may not be referenced again in an add_* or a + * deletion; these paths may have alter_* operations applied. + * + * - The ancestor of an added, copied-here, moved-here, rotated, or + * modified node may not be deleted. The ancestor may not be moved + * (instead: perform the move, *then* the edits). + * + * - svn_editor_delete() must not be used to replace a path -- i.e. + * svn_editor_delete() must not be followed by an svn_editor_add_*() on + * the same path, nor by an svn_editor_copy() or svn_editor_move() with + * the same path as the copy/move target. + * + * Instead of a prior delete call, the add/copy/move callbacks should be + * called with the @a replaces_rev argument set to the revision number of + * the node at this path that is being replaced. Note that the path and + * revision number are the key to finding any other information about the + * replaced node, like node kind, etc. + * @todo say which function(s) to use. + * + * - svn_editor_delete() must not be used to move a path -- i.e. + * svn_editor_delete() must not delete the source path of a previous + * svn_editor_copy() call. Instead, svn_editor_move() must be used. + * Note: if the desired semantics is one (or more) copies, followed + * by a delete... that is fine. It is simply that svn_editor_move() + * should be used to describe a semantic move. + * + * - Paths mentioned in svn_editor_rotate() may have their properties + * and contents edited (via alter_* calls) by a previous or later call, + * but they may not be subject to a later move, rotate, or deletion. + * + * - One of svn_editor_complete() or svn_editor_abort() must be called + * exactly once, which must be the final call the driver invokes. + * Invoking svn_editor_complete() must imply that the set of changes has + * been transmitted completely and without errors, and invoking + * svn_editor_abort() must imply that the transformation was not completed + * successfully. + * + * - If any callback invocation (besides svn_editor_complete()) returns + * with an error, the driver must invoke svn_editor_abort() and stop + * transmitting operations. + * \n\n + * + * <h3>Receiving Restrictions</h3> + * + * All callbacks must complete their handling of a path before they return. + * Since future callbacks will never reference this path again (due to the + * Once Rule), the changes can and should be completed. + * + * This restriction is not recursive -- a directory's children may remain + * incomplete until later callback calls are received. + * + * For example, an svn_editor_add_directory() call during an 'update' + * operation will create the directory itself, including its properties, + * and will complete any client notification for the directory itself. + * The immediate children of the added directory, given in @a children, + * will be recorded in the WC as 'incomplete' and will be completed in the + * course of the same operation sequence, when the corresponding callbacks + * for these items are invoked. + * \n\n + * + * <h3>Timing and State</h3> + * The calls made by the driver to alter the state in the receiver are + * based on the receiver's *current* state, which includes all prior changes + * made during the edit. + * + * Example: copy A to B; set-props on A; copy A to C. The props on C + * should reflect the updated properties of A. + * + * Example: mv A@N to B; mv C@M to A. The second move cannot be marked as + * a "replacing" move since it is not replacing A. The node at A was moved + * away. The second operation is simply moving C to the now-empty path + * known as A. + * + * <h3>Paths</h3> + * Each driver/receiver implementation of this editor interface must + * establish the expected root for all the paths sent and received via + * the callbacks' @a relpath arguments. + * + * For example, during an "update", the driver is the repository, as a + * whole. The receiver may have just a portion of that repository. Here, + * the receiver could tell the driver which repository URL the working + * copy refers to, and thus the driver could send @a relpath arguments + * that are relative to the receiver's working copy. + * + * @note Because the source of a copy may be located *anywhere* in the + * repository, editor drives should typically use the repository root + * as the negotiated root. This allows the @a src_relpath argument in + * svn_editor_copy() to specify any possible source. + * \n\n + * + * <h3>Pool Usage</h3> + * The @a result_pool passed to svn_editor_create() is used to allocate + * the #svn_editor_t instance, and thus it must not be cleared before the + * driver has finished driving the editor. + * + * The @a scratch_pool passed to each callback invocation is derived from + * the @a result_pool that was passed to svn_editor_create(). It is + * cleared directly after each single callback invocation. + * To allocate memory with a longer lifetime from within a callback + * function, you may use your own pool kept in the @a editor_baton. + * + * The @a scratch_pool passed to svn_editor_create() may be used to help + * during construction of the #svn_editor_t instance, but it is assumed to + * live only until svn_editor_create() returns. + * \n\n + * + * <h3>Cancellation</h3> + * To allow graceful interruption by external events (like a user abort), + * svn_editor_create() can be passed an #svn_cancel_func_t that is + * polled every time the driver invokes a callback, just before the + * actual editor callback implementation is invoked. If this function + * decides to return with an error, the driver will receive this error + * as if the callback function had returned it, i.e. as the result from + * calling any of the driving functions (e.g. svn_editor_add_directory()). + * As with any other error, the driver must then invoke svn_editor_abort() + * and abort the transformation sequence. See #svn_cancel_func_t. + * + * The @a cancel_baton argument to svn_editor_create() is passed + * unchanged to each poll of @a cancel_func. + * + * The cancellation function and baton are typically provided by the client + * context. + * + * + * @todo ### TODO anything missing? + * + * @since New in 1.8. + */ +typedef struct svn_editor_t svn_editor_t; + +/** The kind of the checksum to be used throughout the #svn_editor_t APIs. + * + * @note ### This may change before Ev2 is official released, so just like + * everything else in this file, please don't rely upon it until then. + */ +#define SVN_EDITOR_CHECKSUM_KIND svn_checksum_sha1 + + +/** These function types define the callback functions a tree delta consumer + * implements. + * + * Each of these "receiving" function types matches a "driving" function, + * which has the same arguments with these differences: + * + * - These "receiving" functions have a @a baton argument, which is the + * @a editor_baton originally passed to svn_editor_create(), as well as + * a @a scratch_pool argument. + * + * - The "driving" functions have an #svn_editor_t* argument, in order to + * call the implementations of the function types defined here that are + * registered with the given #svn_editor_t instance. + * + * Note that any remaining arguments for these function types are explained + * in the comment for the "driving" functions. Each function type links to + * its corresponding "driver". + * + * @see svn_editor_t, svn_editor_cb_many_t. + * + * @defgroup svn_editor_callbacks Editor callback definitions + * @{ + */ + +/** @see svn_editor_add_directory(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_add_directory_t)( + void *baton, + const char *relpath, + const apr_array_header_t *children, + apr_hash_t *props, + svn_revnum_t replaces_rev, + apr_pool_t *scratch_pool); + +/** @see svn_editor_add_file(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_add_file_t)( + void *baton, + const char *relpath, + const svn_checksum_t *checksum, + svn_stream_t *contents, + apr_hash_t *props, + svn_revnum_t replaces_rev, + apr_pool_t *scratch_pool); + +/** @see svn_editor_add_symlink(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_add_symlink_t)( + void *baton, + const char *relpath, + const char *target, + apr_hash_t *props, + svn_revnum_t replaces_rev, + apr_pool_t *scratch_pool); + +/** @see svn_editor_add_absent(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_add_absent_t)( + void *baton, + const char *relpath, + svn_node_kind_t kind, + svn_revnum_t replaces_rev, + apr_pool_t *scratch_pool); + +/** @see svn_editor_alter_directory(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_alter_directory_t)( + void *baton, + const char *relpath, + svn_revnum_t revision, + const apr_array_header_t *children, + apr_hash_t *props, + apr_pool_t *scratch_pool); + +/** @see svn_editor_alter_file(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_alter_file_t)( + void *baton, + const char *relpath, + svn_revnum_t revision, + apr_hash_t *props, + const svn_checksum_t *checksum, + svn_stream_t *contents, + apr_pool_t *scratch_pool); + +/** @see svn_editor_alter_symlink(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_alter_symlink_t)( + void *baton, + const char *relpath, + svn_revnum_t revision, + apr_hash_t *props, + const char *target, + apr_pool_t *scratch_pool); + +/** @see svn_editor_delete(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_delete_t)( + void *baton, + const char *relpath, + svn_revnum_t revision, + apr_pool_t *scratch_pool); + +/** @see svn_editor_copy(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_copy_t)( + void *baton, + const char *src_relpath, + svn_revnum_t src_revision, + const char *dst_relpath, + svn_revnum_t replaces_rev, + apr_pool_t *scratch_pool); + +/** @see svn_editor_move(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_move_t)( + void *baton, + const char *src_relpath, + svn_revnum_t src_revision, + const char *dst_relpath, + svn_revnum_t replaces_rev, + apr_pool_t *scratch_pool); + +/** @see svn_editor_rotate(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_rotate_t)( + void *baton, + const apr_array_header_t *relpaths, + const apr_array_header_t *revisions, + apr_pool_t *scratch_pool); + +/** @see svn_editor_complete(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_complete_t)( + void *baton, + apr_pool_t *scratch_pool); + +/** @see svn_editor_abort(), svn_editor_t. + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_editor_cb_abort_t)( + void *baton, + apr_pool_t *scratch_pool); + +/** @} */ + + +/** These functions create an editor instance so that it can be driven. + * + * @defgroup svn_editor_create Editor creation + * @{ + */ + +/** Allocate an #svn_editor_t instance from @a result_pool, store + * @a editor_baton, @a cancel_func and @a cancel_baton in the new instance + * and return it in @a editor. + * @a scratch_pool is used for temporary allocations (if any). Note that + * this is NOT the same @a scratch_pool that is passed to callback functions. + * @see svn_editor_t + * @since New in 1.8. + */ +svn_error_t * +svn_editor_create(svn_editor_t **editor, + void *editor_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Return an editor's private baton. + * + * In some cases, the baton is required outside of the callbacks. This + * function returns the private baton for use. + * + * @since New in 1.8. + */ +void * +svn_editor_get_baton(const svn_editor_t *editor); + + +/** Sets the #svn_editor_cb_add_directory_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_add_directory(svn_editor_t *editor, + svn_editor_cb_add_directory_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_add_file_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_add_file(svn_editor_t *editor, + svn_editor_cb_add_file_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_add_symlink_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_add_symlink(svn_editor_t *editor, + svn_editor_cb_add_symlink_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_add_absent_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_add_absent(svn_editor_t *editor, + svn_editor_cb_add_absent_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_alter_directory_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_alter_directory(svn_editor_t *editor, + svn_editor_cb_alter_directory_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_alter_file_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_alter_file(svn_editor_t *editor, + svn_editor_cb_alter_file_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_alter_symlink_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_alter_symlink(svn_editor_t *editor, + svn_editor_cb_alter_symlink_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_delete_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_delete(svn_editor_t *editor, + svn_editor_cb_delete_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_copy_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_copy(svn_editor_t *editor, + svn_editor_cb_copy_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_move_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_move(svn_editor_t *editor, + svn_editor_cb_move_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_rotate_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_rotate(svn_editor_t *editor, + svn_editor_cb_rotate_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_complete_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_complete(svn_editor_t *editor, + svn_editor_cb_complete_t callback, + apr_pool_t *scratch_pool); + +/** Sets the #svn_editor_cb_abort_t callback in @a editor + * to @a callback. + * @a scratch_pool is used for temporary allocations (if any). + * @see also svn_editor_setcb_many(). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_abort(svn_editor_t *editor, + svn_editor_cb_abort_t callback, + apr_pool_t *scratch_pool); + + +/** Lists a complete set of editor callbacks. + * This is a convenience structure. + * @see svn_editor_setcb_many(), svn_editor_create(), svn_editor_t. + * @since New in 1.8. + */ +typedef struct svn_editor_cb_many_t +{ + svn_editor_cb_add_directory_t cb_add_directory; + svn_editor_cb_add_file_t cb_add_file; + svn_editor_cb_add_symlink_t cb_add_symlink; + svn_editor_cb_add_absent_t cb_add_absent; + svn_editor_cb_alter_directory_t cb_alter_directory; + svn_editor_cb_alter_file_t cb_alter_file; + svn_editor_cb_alter_symlink_t cb_alter_symlink; + svn_editor_cb_delete_t cb_delete; + svn_editor_cb_copy_t cb_copy; + svn_editor_cb_move_t cb_move; + svn_editor_cb_rotate_t cb_rotate; + svn_editor_cb_complete_t cb_complete; + svn_editor_cb_abort_t cb_abort; + +} svn_editor_cb_many_t; + +/** Sets all the callback functions in @a editor at once, according to the + * callback functions stored in @a many. + * @a scratch_pool is used for temporary allocations (if any). + * @since New in 1.8. + */ +svn_error_t * +svn_editor_setcb_many(svn_editor_t *editor, + const svn_editor_cb_many_t *many, + apr_pool_t *scratch_pool); + +/** @} */ + + +/** These functions are called by the tree delta driver to edit the target. + * + * @see svn_editor_t. + * + * @defgroup svn_editor_drive Driving the editor + * @{ + */ + +/** Drive @a editor's #svn_editor_cb_add_directory_t callback. + * + * Create a new directory at @a relpath. The immediate parent of @a relpath + * is expected to exist. + * + * For descriptions of @a props and @a replaces_rev, see + * svn_editor_add_file(). + * + * A complete listing of the immediate children of @a relpath that will be + * added subsequently is given in @a children. @a children is an array of + * const char*s, each giving the basename of an immediate child. It is an + * error to pass NULL for @a children; use an empty array to indicate + * the new directory will have no children. + * + * For all restrictions on driving the editor, see #svn_editor_t. + */ +svn_error_t * +svn_editor_add_directory(svn_editor_t *editor, + const char *relpath, + const apr_array_header_t *children, + apr_hash_t *props, + svn_revnum_t replaces_rev); + +/** Drive @a editor's #svn_editor_cb_add_file_t callback. + * + * Create a new file at @a relpath. The immediate parent of @a relpath + * is expected to exist. + * + * The file's contents are specified in @a contents which has a checksum + * matching @a checksum. Both values must be non-NULL. + * + * Set the properties of the new file to @a props, which is an + * apr_hash_t holding key-value pairs. Each key is a const char* of a + * property name, each value is a const svn_string_t*. If no properties are + * being set on the new file, @a props must be the empty hash. It is an + * error to pass NULL for @a props. + * + * If this add is expected to replace a previously existing file, symlink or + * directory at @a relpath, the revision number of the node to be replaced + * must be given in @a replaces_rev. Otherwise, @a replaces_rev must be + * #SVN_INVALID_REVNUM. Note: it is not allowed to call a "delete" followed + * by an "add" on the same path. Instead, an "add" with @a replaces_rev set + * accordingly MUST be used. + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_add_file(svn_editor_t *editor, + const char *relpath, + const svn_checksum_t *checksum, + svn_stream_t *contents, + apr_hash_t *props, + svn_revnum_t replaces_rev); + +/** Drive @a editor's #svn_editor_cb_add_symlink_t callback. + * + * Create a new symbolic link at @a relpath, with a link target of @a + * target. The immediate parent of @a relpath is expected to exist. + * + * For descriptions of @a props and @a replaces_rev, see + * svn_editor_add_file(). + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_add_symlink(svn_editor_t *editor, + const char *relpath, + const char *target, + apr_hash_t *props, + svn_revnum_t replaces_rev); + +/** Drive @a editor's #svn_editor_cb_add_absent_t callback. + * + * Create an "absent" node of kind @a kind at @a relpath. The immediate + * parent of @a relpath is expected to exist. + * ### TODO @todo explain "absent". + * ### JAF: What are the allowed values of 'kind'? + * + * For a description of @a replaces_rev, see svn_editor_add_file(). + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_add_absent(svn_editor_t *editor, + const char *relpath, + svn_node_kind_t kind, + svn_revnum_t replaces_rev); + +/** Drive @a editor's #svn_editor_cb_alter_directory_t callback. + * + * Alter the properties of the directory at @a relpath. + * + * @a revision specifies the revision at which the receiver should + * expect to find this node. That is, @a relpath at the start of the + * whole edit and @a relpath at @a revision must lie within the same + * node-rev (aka location history segment). This information may be used + * to catch an attempt to alter and out-of-date directory. If the + * directory does not have a corresponding revision in the repository + * (e.g. it has not yet been committed), then @a revision should be + * #SVN_INVALID_REVNUM. + * + * If any changes to the set of children will be made in the future of + * the edit drive, then @a children MUST specify the resulting set of + * children. See svn_editor_add_directory() for the format of @a children. + * If not changes will be made, then NULL may be specified. + * + * For a description of @a props, see svn_editor_add_file(). If no changes + * to the properties will be made (ie. only future changes to the set of + * children), then @a props may be NULL. + * + * It is an error to pass NULL for both @a children and @a props. + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_alter_directory(svn_editor_t *editor, + const char *relpath, + svn_revnum_t revision, + const apr_array_header_t *children, + apr_hash_t *props); + +/** Drive @a editor's #svn_editor_cb_alter_file_t callback. + * + * Alter the properties and/or the contents of the file at @a relpath + * with @a revision as its expected revision. See svn_editor_alter_directory() + * for more information about @a revision. + * + * If @a props is non-NULL, then the properties will be applied. + * + * If @a contents is non-NULL, then the stream will be copied to + * the file, and its checksum must match @a checksum (which must also + * be non-NULL). If @a contents is NULL, then @a checksum must also + * be NULL, and no change will be applied to the file's contents. + * + * The properties and/or the contents must be changed. It is an error to + * pass NULL for @a props, @a checksum, and @a contents. + * + * For a description of @a checksum and @a contents see + * svn_editor_add_file(). This function allows @a props to be NULL, but + * the parameter is otherwise described by svn_editor_add_file(). + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_alter_file(svn_editor_t *editor, + const char *relpath, + svn_revnum_t revision, + apr_hash_t *props, + const svn_checksum_t *checksum, + svn_stream_t *contents); + +/** Drive @a editor's #svn_editor_cb_alter_symlink_t callback. + * + * Alter the properties and/or the target of the symlink at @a relpath + * with @a revision as its expected revision. See svn_editor_alter_directory() + * for more information about @a revision. + * + * If @a props is non-NULL, then the properties will be applied. + * + * If @a target is non-NULL, then the symlink's target will be updated. + * + * The properties and/or the target must be changed. It is an error to + * pass NULL for @a props and @a target. + * + * This function allows @a props to be NULL, but the parameter is + * otherwise described by svn_editor_add_file(). + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_alter_symlink(svn_editor_t *editor, + const char *relpath, + svn_revnum_t revision, + apr_hash_t *props, + const char *target); + +/** Drive @a editor's #svn_editor_cb_delete_t callback. + * + * Delete the existing node at @a relpath, expected to be identical to + * revision @a revision of that path. + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_delete(svn_editor_t *editor, + const char *relpath, + svn_revnum_t revision); + +/** Drive @a editor's #svn_editor_cb_copy_t callback. + * + * Copy the node at @a src_relpath, expected to be identical to revision @a + * src_revision of that path, to @a dst_relpath. + * + * For a description of @a replaces_rev, see svn_editor_add_file(). + * + * @note See the general instructions on paths for this API. Since the + * @a src_relpath argument must generally be able to reference any node + * in the repository, the implication is that the editor's root must be + * the repository root. + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_copy(svn_editor_t *editor, + const char *src_relpath, + svn_revnum_t src_revision, + const char *dst_relpath, + svn_revnum_t replaces_rev); + +/** Drive @a editor's #svn_editor_cb_move_t callback. + * + * Move the node at @a src_relpath to @a dst_relpath. + * + * @a src_revision specifies the revision at which the receiver should + * expect to find this node. That is, @a src_relpath at the start of + * the whole edit and @a src_relpath at @a src_revision must lie within + * the same node-rev (aka history-segment). This is just like the + * revisions specified to svn_editor_delete() and svn_editor_rotate(). + * + * For a description of @a replaces_rev, see svn_editor_add_file(). + * + * ### what happens if one side of this move is not "within" the receiver's + * ### set of paths? + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_move(svn_editor_t *editor, + const char *src_relpath, + svn_revnum_t src_revision, + const char *dst_relpath, + svn_revnum_t replaces_rev); + +/** Drive @a editor's #svn_editor_cb_rotate_t callback. + * + * Perform a rotation among multiple nodes in the target tree. + * + * The @a relpaths and @a revisions arrays (pair-wise) specify nodes in the + * tree which are located at a path and expected to be at a specific + * revision. These nodes are simultaneously moved in a rotation pattern. + * For example, the node at index 0 of @a relpaths and @a revisions will + * be moved to the relpath specified at index 1 of @a relpaths. The node + * at index 1 will be moved to the location at index 2. The node at index + * N-1 will be moved to the relpath specified at index 0. + * + * The simplest form of this operation is to swap nodes A and B. One may + * think to move A to a temporary location T, then move B to A, then move + * T to B. However, this last move violations the Once Rule by moving T + * (which had already by edited by the move from A). In order to keep the + * restrictions against multiple moves of a single node, the rotation + * operation is needed for certain types of tree edits. + * + * ### what happens if one of the paths of the rotation is not "within" the + * ### receiver's set of paths? + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_rotate(svn_editor_t *editor, + const apr_array_header_t *relpaths, + const apr_array_header_t *revisions); + +/** Drive @a editor's #svn_editor_cb_complete_t callback. + * + * Send word that the edit has been completed successfully. + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_complete(svn_editor_t *editor); + +/** Drive @a editor's #svn_editor_cb_abort_t callback. + * + * Notify that the edit transmission was not successful. + * ### TODO @todo Shouldn't we add a reason-for-aborting argument? + * + * For all restrictions on driving the editor, see #svn_editor_t. + * @since New in 1.8. + */ +svn_error_t * +svn_editor_abort(svn_editor_t *editor); + +/** @} */ + +/** @} */ + +/** A temporary API which conditionally inserts a double editor shim + * into the chain of delta editors. Used for testing Editor v2. + * + * Whether or not the shims are inserted is controlled by a compile-time + * option in libsvn_delta/compat.c. + * + * @note The use of these shims and this API will likely cause all kinds + * of performance degredation. (Which is actually a moot point since they + * don't even work properly yet anyway.) + */ +svn_error_t * +svn_editor__insert_shims(const svn_delta_editor_t **deditor_out, + void **dedit_baton_out, + const svn_delta_editor_t *deditor_in, + void *dedit_baton_in, + const char *repos_root, + const char *base_dir, + svn_delta_shim_callbacks_t *shim_callbacks, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_EDITOR_H */ diff --git a/subversion/include/private/svn_eol_private.h b/subversion/include/private/svn_eol_private.h new file mode 100644 index 0000000..d2cce5c --- /dev/null +++ b/subversion/include/private/svn_eol_private.h @@ -0,0 +1,93 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_eol_private.h + * @brief Subversion's EOL functions - Internal routines + */ + +#ifndef SVN_EOL_PRIVATE_H +#define SVN_EOL_PRIVATE_H + +#include <apr_pools.h> +#include <apr_hash.h> + +#include "svn_types.h" +#include "svn_error.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Constants used by various chunky string processing functions. + */ +#if APR_SIZEOF_VOIDP == 8 +# define SVN__LOWER_7BITS_SET 0x7f7f7f7f7f7f7f7f +# define SVN__BIT_7_SET 0x8080808080808080 +# define SVN__R_MASK 0x0a0a0a0a0a0a0a0a +# define SVN__N_MASK 0x0d0d0d0d0d0d0d0d +#else +# define SVN__LOWER_7BITS_SET 0x7f7f7f7f +# define SVN__BIT_7_SET 0x80808080 +# define SVN__R_MASK 0x0a0a0a0a +# define SVN__N_MASK 0x0d0d0d0d +#endif + +/* Generic EOL character helper routines */ + +/* Look for the start of an end-of-line sequence (i.e. CR or LF) + * in the array pointed to by @a buf , of length @a len. + * If such a byte is found, return the pointer to it, else return NULL. + * + * @since New in 1.7 + */ +char * +svn_eol__find_eol_start(char *buf, apr_size_t len); + +/* Return the first eol marker found in buffer @a buf as a NUL-terminated + * string, or NULL if no eol marker is found. Do not examine more than + * @a len bytes in @a buf. + * + * If the last valid character of @a buf is the first byte of a + * potentially two-byte eol sequence, just return that single-character + * sequence, that is, assume @a buf represents a CR-only or LF-only file. + * This is correct for callers that pass an entire file at once, and is + * no more likely to be incorrect than correct for any caller that doesn't. + * + * The returned string is statically allocated, i.e. it is NOT a pointer + * to an address within @a buf. + * + * If an eol marker is found and @a eolp is not NULL, store in @a *eolp + * the address within @a buf of the first byte of the eol marker. + * This allows callers to tell whether there might be more than one eol + * sequence in @a buf, as well as detect two-byte eol sequences that + * span buffer boundaries. + * + * @since New in 1.7 + */ +const char * +svn_eol__detect_eol(char *buf, apr_size_t len, char **eolp); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_EOL_PRIVATE_H */ diff --git a/subversion/include/private/svn_error_private.h b/subversion/include/private/svn_error_private.h new file mode 100644 index 0000000..f8bd2bc --- /dev/null +++ b/subversion/include/private/svn_error_private.h @@ -0,0 +1,54 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_error_private.h + * @brief Subversion-internal error APIs. + */ + +#ifndef SVN_ERROR_PRIVATE_H +#define SVN_ERROR_PRIVATE_H + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Returns if @a err is a "tracing" error. + */ +svn_boolean_t +svn_error__is_tracing_link(svn_error_t *err); + +/** + * Converts a zlib error to an svn_error_t. zerr is the error code, + * function is the function name, message is an optional extra part + * of the error message and may be NULL. + */ +svn_error_t * +svn_error__wrap_zlib(int zerr, const char *function, const char *message); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_ERROR_PRIVATE_H */ diff --git a/subversion/include/private/svn_fs_private.h b/subversion/include/private/svn_fs_private.h new file mode 100644 index 0000000..20b70cd --- /dev/null +++ b/subversion/include/private/svn_fs_private.h @@ -0,0 +1,189 @@ +/* + * svn_fs_private.h: Private declarations for the filesystem layer to + * be consumed by libsvn_fs* and non-libsvn_fs* modules. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_FS_PRIVATE_H +#define SVN_FS_PRIVATE_H + +#include "svn_fs.h" +#include "private/svn_editor.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* The maximum length of a transaction name. The Berkeley DB backend + generates transaction names from a sequence expressed as a base 36 + number with a maximum of MAX_KEY_SIZE (currently 200) bytes. The + FSFS backend generates transaction names of the form + <rev>-<base 36-number> where the base 36 number is a sequence value + with a maximum length of MAX_KEY_SIZE bytes. The maximum length is + 212, but use 220 just to have some extra space: + 10 -> 32 bit revision number + 1 -> '-' + 200 -> 200 digit base 36 number + 1 -> '\0' + */ +#define SVN_FS__TXN_MAX_LEN 220 + +/** Retrieve the lock-tokens associated in the context @a access_ctx. + * The tokens are in a hash keyed with <tt>const char *</tt> tokens, + * and with <tt>const char *</tt> values for the paths associated. + * + * You should always use svn_fs_access_add_lock_token2() if you intend + * to use this function. The result of the function is not guaranteed + * if you use it with the deprecated svn_fs_access_add_lock_token() + * API. + * + * @since New in 1.6. */ +apr_hash_t * +svn_fs__access_get_lock_tokens(svn_fs_access_t *access_ctx); + + +/* Check whether PATH is valid for a filesystem, following (most of) the + * requirements in svn_fs.h:"Directory entry names and directory paths". + * + * Return SVN_ERR_FS_PATH_SYNTAX if PATH is not valid. + */ +svn_error_t * +svn_fs__path_valid(const char *path, apr_pool_t *pool); + + + +/** Editors + * + * ### docco + * + * @defgroup svn_fs_editor Transaction editors + * @{ + */ + +/** + * Create a new filesystem transaction, based on based on the youngest + * revision of @a fs, and return its name @a *txn_name and an @a *editor + * that can be used to make changes into it. + * + * @a flags determines transaction enforcement behaviors, and is composed + * from the constants SVN_FS_TXN_* (#SVN_FS_TXN_CHECK_OOD etc.). It is a + * property of the underlying transaction, and will not change if multiple + * editors are used to refer to that transaction (see @a autocommit, below). + * + * @note If you're building a txn for committing, you probably don't want + * to call this directly. Instead, call svn_repos__get_commit_ev2(), which + * honors the repository's hook configurations. + * + * When svn_editor_complete() is called for @a editor, internal resources + * will be cleaned and nothing more will happen. If you wish to commit the + * transaction, call svn_fs_editor_commit() instead. It is illegal to call + * both; the second call will return #SVN_ERR_FS_INCORRECT_EDITOR_COMPLETION. + * + * @see svn_fs_commit_txn() + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs__editor_create(svn_editor_t **editor, + const char **txn_name, + svn_fs_t *fs, + apr_uint32_t flags, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Like svn_fs__editor_create(), but open an existing transaction + * @a txn_name and continue editing it. + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs__editor_create_for(svn_editor_t **editor, + svn_fs_t *fs, + const char *txn_name, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Commit the transaction represented by @a editor. + * + * If the commit to the filesystem succeeds, then @a *revision will be set + * to the resulting revision number. Note that further errors may occur, + * as described below. If the commit process does not succeed, for whatever + * reason, then @a *revision will be set to #SVN_INVALID_REVNUM. + * + * If a conflict occurs during the commit, then @a *conflict_path will + * be set to a path that caused the conflict. #SVN_NO_ERROR will be returned. + * Callers may want to construct an #SVN_ERR_FS_CONFLICT error with a + * message that incorporates @a *conflict_path. + * + * If a non-conflict error occurs during the commit, then that error will + * be returned. + * As is standard with any Subversion API, @a revision, @a post_commit_err, + * and @a conflict_path (the OUT parameters) have an indeterminate value if + * an error is returned. + * + * If the commit completes (and a revision is returned in @a *revision), then + * it is still possible for an error to occur during the cleanup process. + * Any such error will be returned in @a *post_commit_err. The caller must + * properly use or clear that error. + * + * If svn_editor_complete() has already been called on @a editor, then + * #SVN_ERR_FS_INCORRECT_EDITOR_COMPLETION will be returned. + * + * @note After calling this function, @a editor will be marked as completed + * and no further operations may be performed on it. The underlying + * transaction will either be committed or aborted once this function is + * called. It cannot be recovered for additional work. + * + * @a result_pool will be used to allocate space for @a conflict_path. + * @a scratch_pool will be used for all temporary allocations. + * + * @note To summarize, there are three possible outcomes of this function: + * successful commit (with or without an associated @a *post_commit_err); + * failed commit due to a conflict (reported via @a *conflict_path); and + * failed commit for some other reason (reported via the returned error.) + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs__editor_commit(svn_revnum_t *revision, + svn_error_t **post_commit_err, + const char **conflict_path, + svn_editor_t *editor, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** @} */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_FS_PRIVATE_H */ diff --git a/subversion/include/private/svn_fs_util.h b/subversion/include/private/svn_fs_util.h new file mode 100644 index 0000000..eb0f024 --- /dev/null +++ b/subversion/include/private/svn_fs_util.h @@ -0,0 +1,217 @@ +/* + * svn_fs_util.h: Declarations for the APIs of libsvn_fs_util to be + * consumed by only fs_* libs. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_FS_UTIL_H +#define SVN_FS_UTIL_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_error.h" +#include "svn_fs.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Returns whether PATH is in canonical form as defined by + svn_fs__canonicalize_abspath(). + */ +svn_boolean_t +svn_fs__is_canonical_abspath(const char *path); + +/* Return a canonicalized version of a filesystem PATH, allocated in POOL. + + While the filesystem API is pretty flexible about the incoming paths + (they must be UTF-8 with '/' as separators, but they don't have to + begin with '/', and multiple contiguous '/'s are ignored) we want any + paths that are physically stored in the underlying database to look + consistent. Specifically, absolute filesystem paths should begin with + '/', and all redundant and trailing '/' characters be removed. + + This is similar to svn_fspath__canonicalize() but doesn't treat "." + segments as special. +*/ +const char * +svn_fs__canonicalize_abspath(const char *path, apr_pool_t *pool); + +/* If EXPECT_OPEN, verify that FS refers to an open database; + otherwise, verify that FS refers to an unopened database. Return + an appropriate error if the expectation fails to match the + reality. */ +svn_error_t * +svn_fs__check_fs(svn_fs_t *fs, svn_boolean_t expect_open); + +/* An identifier for FS to be used in the text of error messages. + (Not used anywhere but in this header.) + + Note: we log the UUID, rather than (fs)->path, since some of these + errors are marshalled to the client. */ +#define svn_fs__identifier(fs) ((fs)->uuid) + +/* Constructing nice error messages for roots. */ + +/* Build an SVN_ERR_FS_NOT_FOUND error, with a detailed error text, + for PATH in ROOT. ROOT is of type svn_fs_root_t *. */ +#define SVN_FS__NOT_FOUND(root, path) ( \ + root->is_txn_root ? \ + svn_error_createf \ + (SVN_ERR_FS_NOT_FOUND, 0, \ + _("File not found: transaction '%s', path '%s'"), \ + root->txn, path) \ + : \ + svn_error_createf \ + (SVN_ERR_FS_NOT_FOUND, 0, \ + _("File not found: revision %ld, path '%s'"), \ + root->rev, path) \ + ) + + +/* Build a detailed `file already exists' message for PATH in ROOT. + ROOT is of type svn_fs_root_t *. */ +#define SVN_FS__ALREADY_EXISTS(root, path_str) ( \ + root->is_txn_root ? \ + svn_error_createf \ + (SVN_ERR_FS_ALREADY_EXISTS, 0, \ + _("File already exists: filesystem '%s', transaction '%s', path '%s'"), \ + svn_fs__identifier(root->fs), root->txn, path_str) \ + : \ + svn_error_createf \ + (SVN_ERR_FS_ALREADY_EXISTS, 0, \ + _("File already exists: filesystem '%s', revision %ld, path '%s'"), \ + svn_fs__identifier(root->fs), root->rev, path_str) \ + ) + +/* ROOT is of type svn_fs_root_t *. */ +#define SVN_FS__NOT_TXN(root) \ + svn_error_create \ + (SVN_ERR_FS_NOT_TXN_ROOT, NULL, \ + _("Root object must be a transaction root")) + +/* SVN_FS__ERR_NOT_MUTABLE: the caller attempted to change a node + outside of a transaction. FS is of type "svn_fs_t *". */ +#define SVN_FS__ERR_NOT_MUTABLE(fs, rev, path_in_repo) \ + svn_error_createf( \ + SVN_ERR_FS_NOT_MUTABLE, 0, \ + _("File is not mutable: filesystem '%s', revision %ld, path '%s'"), \ + svn_fs__identifier(fs), rev, path_in_repo) + +/* FS is of type "svn_fs_t *".*/ +#define SVN_FS__ERR_NOT_DIRECTORY(fs, path_in_repo) \ + svn_error_createf( \ + SVN_ERR_FS_NOT_DIRECTORY, 0, \ + _("'%s' is not a directory in filesystem '%s'"), \ + path_in_repo, svn_fs__identifier(fs)) + +/* FS is of type "svn_fs_t *". */ +#define SVN_FS__ERR_NOT_FILE(fs, path_in_repo) \ + svn_error_createf( \ + SVN_ERR_FS_NOT_FILE, 0, \ + _("'%s' is not a file in filesystem '%s'"), \ + path_in_repo, svn_fs__identifier(fs)) + + +/* FS is of type "svn_fs_t *", LOCK is of type "svn_lock_t *". */ +#define SVN_FS__ERR_PATH_ALREADY_LOCKED(fs, lock) \ + svn_error_createf( \ + SVN_ERR_FS_PATH_ALREADY_LOCKED, 0, \ + _("Path '%s' is already locked by user '%s' in filesystem '%s'"), \ + (lock)->path, (lock)->owner, svn_fs__identifier(fs)) + +/* FS is of type "svn_fs_t *". */ +#define SVN_FS__ERR_NO_SUCH_LOCK(fs, path_in_repo) \ + svn_error_createf( \ + SVN_ERR_FS_NO_SUCH_LOCK, 0, \ + _("No lock on path '%s' in filesystem '%s'"), \ + path_in_repo, svn_fs__identifier(fs)) + +/* FS is of type "svn_fs_t *". */ +#define SVN_FS__ERR_LOCK_EXPIRED(fs, token) \ + svn_error_createf( \ + SVN_ERR_FS_LOCK_EXPIRED, 0, \ + _("Lock has expired: lock-token '%s' in filesystem '%s'"), \ + token, svn_fs__identifier(fs)) + +/* FS is of type "svn_fs_t *". */ +#define SVN_FS__ERR_NO_USER(fs) \ + svn_error_createf( \ + SVN_ERR_FS_NO_USER, 0, \ + _("No username is currently associated with filesystem '%s'"), \ + svn_fs__identifier(fs)) + +/* SVN_FS__ERR_LOCK_OWNER_MISMATCH: trying to use a lock whose + LOCK_OWNER doesn't match the USERNAME associated with FS. + FS is of type "svn_fs_t *". */ +#define SVN_FS__ERR_LOCK_OWNER_MISMATCH(fs, username, lock_owner) \ + svn_error_createf( \ + SVN_ERR_FS_LOCK_OWNER_MISMATCH, 0, \ + _("User '%s' is trying to use a lock owned by '%s' in " \ + "filesystem '%s'"), \ + username, lock_owner, svn_fs__identifier(fs)) + +/* Return a NULL-terminated copy of the first component of PATH, + allocated in POOL. If path is empty, or consists entirely of + slashes, return the empty string. + + If the component is followed by one or more slashes, we set *NEXT_P + to point after the slashes. If the component ends PATH, we set + *NEXT_P to zero. This means: + - If *NEXT_P is zero, then the component ends the PATH, and there + are no trailing slashes in the path. + - If *NEXT_P points at PATH's terminating NULL character, then + the component returned was the last, and PATH ends with one or more + slash characters. + - Otherwise, *NEXT_P points to the beginning of the next component + of PATH. You can pass this value to next_entry_name to extract + the next component. */ +char * +svn_fs__next_entry_name(const char **next_p, + const char *path, + apr_pool_t *pool); + +/* Allocate an svn_fs_path_change2_t structure in POOL, initialize and + return it. + + Set the node_rev_id field of the created struct to NODE_REV_ID, and + change_kind to CHANGE_KIND. Set all other fields to their _unknown, + NULL or invalid value, respectively. */ +svn_fs_path_change2_t * +svn_fs__path_change_create_internal(const svn_fs_id_t *node_rev_id, + svn_fs_path_change_kind_t change_kind, + apr_pool_t *pool); + +/* Append REL_PATH (which may contain slashes) to each path that exists in + the mergeinfo INPUT, and return a new mergeinfo in *OUTPUT. Deep + copies the values. Perform all allocations in POOL. */ +svn_error_t * +svn_fs__append_to_merged_froms(svn_mergeinfo_t *output, + svn_mergeinfo_t input, + const char *rel_path, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_FS_UTIL_H */ diff --git a/subversion/include/private/svn_fspath.h b/subversion/include/private/svn_fspath.h new file mode 100644 index 0000000..01679b9 --- /dev/null +++ b/subversion/include/private/svn_fspath.h @@ -0,0 +1,175 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_fspath.h + * @brief Implementation of path manipulation functions similar to + * those in svn_dirent_uri.h (which see for details) but for + * the private fspath class of paths. + */ + +#ifndef SVN_FSPATH_H +#define SVN_FSPATH_H + +#include <apr.h> +#include <apr_pools.h> + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Return TRUE iff @a fspath is canonical. + * @a fspath need not be canonical, of course. + * + * @since New in 1.7. + */ +svn_boolean_t +svn_fspath__is_canonical(const char *fspath); + + +/** This function is similar to svn_relpath_canonicalize(), except + * that it returns an fspath (which is essentially just a relpath + * tacked onto a leading forward slash). + * + * The returned fspath may be statically allocated or allocated from + * @a pool. + * + * This is similar to svn_fs__canonicalize_abspath() but also treats "." + * segments as special. + * + * @since New in 1.7. + */ +const char * +svn_fspath__canonicalize(const char *fspath, + apr_pool_t *pool); + +/** Return the dirname of @a fspath, defined as the path with its basename + * removed. If @a fspath is "/", return "/". + * + * Allocate the result in @a pool. + * + * @since New in 1.7. + */ +const char * +svn_fspath__dirname(const char *fspath, + apr_pool_t *pool); + +/** Return the last component of @a fspath. The returned value will have no + * slashes in it. If @a fspath is "/", return "". + * + * If @a pool is NULL, return a pointer to within @a fspath, else allocate + * the result in @a pool. + * + * @since New in 1.7. + */ +const char * +svn_fspath__basename(const char *fspath, + apr_pool_t *pool); + +/** Divide the canonical @a fspath into @a *dirpath and @a + * *base_name, allocated in @a pool. + * + * If @a dirpath or @a base_name is NULL, then don't set that one. + * + * Either @a dirpath or @a base_name may be @a fspath's own address, but they + * may not both be the same address, or the results are undefined. + * + * If @a fspath has two or more components, the separator between @a dirpath + * and @a base_name is not included in either of the new names. + * + * @since New in 1.7. + */ +void +svn_fspath__split(const char **dirpath, + const char **base_name, + const char *fspath, + apr_pool_t *result_pool); + +/** Return the fspath composed of @a fspath with @a relpath appended. + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +char * +svn_fspath__join(const char *fspath, + const char *relpath, + apr_pool_t *result_pool); + + +/** Return TRUE if @a fspath (with length @a len) is the root + * directory; return FALSE otherwise. + * + * @since New in 1.7. + */ +svn_boolean_t +svn_fspath__is_root(const char *fspath, + apr_size_t len); + +/** Return the relative path part of @a child_fspath that is below + * @a parent_fspath, or just "" if @a parent_fspath is equal to + * @a child_fspath. If @a child_fspath is not below @a parent_fspath + * or equal to it, return @c NULL. + * + * @since New in 1.7. + */ +const char * +svn_fspath__skip_ancestor(const char *parent_fspath, + const char *child_fspath); + +/** Return the longest common path shared by two fspaths, @a fspath1 and + * @a fspath2. If there's no common ancestor, return "/". + * + * @since New in 1.7. + */ +char * +svn_fspath__get_longest_ancestor(const char *fspath1, + const char *fspath2, + apr_pool_t *result_pool); + + + + +/** A faux fspath API used by the DAV modules to help us distinguish + * between real URI-decoded fspaths and URI-encoded URL path-portions. + */ +#define svn_urlpath__basename svn_fspath__basename +#define svn_urlpath__dirname svn_fspath__dirname +#define svn_urlpath__get_longest_ancestor svn_fspath__get_longest_ancestor +#define svn_urlpath__is_canonical svn_fspath__is_canonical +#define svn_urlpath__is_root svn_fspath__is_root +#define svn_urlpath__join svn_fspath__join +#define svn_urlpath__skip_ancestor svn_fspath__skip_ancestor +#define svn_urlpath__split svn_fspath__split + +/* Like svn_fspath__canonicalize(), but this one accepts both full + URLs and URL path-portions. */ +const char * +svn_urlpath__canonicalize(const char *uri, apr_pool_t *pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_FSPATH_H */ diff --git a/subversion/include/private/svn_io_private.h b/subversion/include/private/svn_io_private.h new file mode 100644 index 0000000..2fb4fa5 --- /dev/null +++ b/subversion/include/private/svn_io_private.h @@ -0,0 +1,99 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_io_private.h + * @brief Private IO API + */ + +#ifndef SVN_IO_PRIVATE_H +#define SVN_IO_PRIVATE_H + +#include <apr.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* The flags to pass to apr_stat to check for executable and/or readonly */ +#if defined(WIN32) || defined(__OS2__) +#define SVN__APR_FINFO_EXECUTABLE (0) +#define SVN__APR_FINFO_READONLY (0) +#define SVN__APR_FINFO_MASK_OUT (APR_FINFO_PROT | APR_FINFO_OWNER) +#else +#define SVN__APR_FINFO_EXECUTABLE (APR_FINFO_PROT) +#define SVN__APR_FINFO_READONLY (APR_FINFO_PROT | APR_FINFO_OWNER) +#define SVN__APR_FINFO_MASK_OUT (0) +#endif + + +/** Set @a *executable TRUE if @a file_info is executable for the + * user, FALSE otherwise. + * + * Always returns FALSE on Windows or platforms without user support. + */ +svn_error_t * +svn_io__is_finfo_executable(svn_boolean_t *executable, + apr_finfo_t *file_info, + apr_pool_t *pool); + +/** Set @a *read_only TRUE if @a file_info is read-only for the user, + * FALSE otherwise. + */ +svn_error_t * +svn_io__is_finfo_read_only(svn_boolean_t *read_only, + apr_finfo_t *file_info, + apr_pool_t *pool); + + +/** Buffer test handler function for a generic stream. @see svn_stream_t + * and svn_stream__is_buffered(). + * + * @since New in 1.7. + */ +typedef svn_boolean_t (*svn_stream__is_buffered_fn_t)(void *baton); + +/** Set @a stream's buffer test function to @a is_buffered_fn + * + * @since New in 1.7. + */ +void +svn_stream__set_is_buffered(svn_stream_t *stream, + svn_stream__is_buffered_fn_t is_buffered_fn); + +/** Return whether this generic @a stream uses internal buffering. + * This may be used to work around subtle differences between buffered + * an non-buffered APR files. A lazy-open stream cannot report the + * true buffering state until after the lazy open: a stream that + * initially reports as non-buffered may report as buffered later. + * + * @since New in 1.7. + */ +svn_boolean_t +svn_stream__is_buffered(svn_stream_t *stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* SVN_IO_PRIVATE_H */ diff --git a/subversion/include/private/svn_log.h b/subversion/include/private/svn_log.h new file mode 100644 index 0000000..bdcf32f --- /dev/null +++ b/subversion/include/private/svn_log.h @@ -0,0 +1,260 @@ +/* + * svn_log.h: Functions for assembling entries for server-side logs. + * See also tools/server-side/svn_server_log_parse.py . + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_LOG_H +#define SVN_LOG_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_tables.h> + +#include "svn_types.h" +#include "svn_mergeinfo.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Return a log string for a reparent action. + * + * @since New in 1.6. + */ +const char * +svn_log__reparent(const char *path, apr_pool_t *pool); + +/** + * Return a log string for a change-rev-prop action. + * + * @since New in 1.6. + */ +const char * +svn_log__change_rev_prop(svn_revnum_t rev, const char *name, apr_pool_t *pool); + +/** + * Return a log string for a rev-proplist action. + * + * @since New in 1.6. + */ +const char * +svn_log__rev_proplist(svn_revnum_t rev, apr_pool_t *pool); + +/** + * Return a log string for a rev-prop action. + * + * @since New in 1.6. + */ +const char * +svn_log__rev_prop(svn_revnum_t rev, const char *name, apr_pool_t *pool); + +/** + * Return a log string for a commit action. + * + * @since New in 1.6. + */ +const char * +svn_log__commit(svn_revnum_t rev, apr_pool_t *pool); + +/** + * Return a log string for a get-file action. + * + * @since New in 1.6. + */ +const char * +svn_log__get_file(const char *path, svn_revnum_t rev, + svn_boolean_t want_contents, svn_boolean_t want_props, + apr_pool_t *pool); + +/** + * Return a log string for a get-dir action. + * + * @since New in 1.6. + */ +const char * +svn_log__get_dir(const char *path, svn_revnum_t rev, + svn_boolean_t want_contents, svn_boolean_t want_props, + apr_uint64_t dirent_fields, + apr_pool_t *pool); + +/** + * Return a log string for a get-mergeinfo action. + * + * @since New in 1.6. + */ +const char * +svn_log__get_mergeinfo(const apr_array_header_t *paths, + svn_mergeinfo_inheritance_t inherit, + svn_boolean_t include_descendants, + apr_pool_t *pool); + +/** + * Return a log string for a checkout action. + * + * @since New in 1.6. + */ +const char * +svn_log__checkout(const char *path, svn_revnum_t rev, svn_depth_t depth, + apr_pool_t *pool); + +/** + * Return a log string for an update action. + * + * @since New in 1.6. + */ +const char * +svn_log__update(const char *path, svn_revnum_t rev, svn_depth_t depth, + svn_boolean_t send_copyfrom_args, + apr_pool_t *pool); + +/** + * Return a log string for a switch action. + * + * @since New in 1.6. + */ +const char * +svn_log__switch(const char *path, const char *dst_path, svn_revnum_t revnum, + svn_depth_t depth, apr_pool_t *pool); + +/** + * Return a log string for a status action. + * + * @since New in 1.6. + */ +const char * +svn_log__status(const char *path, svn_revnum_t rev, svn_depth_t depth, + apr_pool_t *pool); + +/** + * Return a log string for a diff action. + * + * @since New in 1.6. + */ +const char * +svn_log__diff(const char *path, svn_revnum_t from_revnum, + const char *dst_path, svn_revnum_t revnum, + svn_depth_t depth, svn_boolean_t ignore_ancestry, + apr_pool_t *pool); + +/** + * Return a log string for a log action. + * + * @since New in 1.6. + */ +const char * +svn_log__log(const apr_array_header_t *paths, + svn_revnum_t start, svn_revnum_t end, + int limit, svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_boolean_t include_merged_revisions, + const apr_array_header_t *revprops, apr_pool_t *pool); + +/** + * Return a log string for a get-locations action. + * + * @since New in 1.6. + */ +const char * +svn_log__get_locations(const char *path, svn_revnum_t peg_revision, + const apr_array_header_t *location_revisions, + apr_pool_t *pool); + +/** + * Return a log string for a get-location-segments action. + * + * @since New in 1.6. + */ +const char * +svn_log__get_location_segments(const char *path, svn_revnum_t peg_revision, + svn_revnum_t start, svn_revnum_t end, + apr_pool_t *pool); + +/** + * Return a log string for a get-file-revs action. + * + * @since New in 1.6. + */ +const char * +svn_log__get_file_revs(const char *path, svn_revnum_t start, svn_revnum_t end, + svn_boolean_t include_merged_revisions, + apr_pool_t *pool); + +/** + * Return a log string for a lock action. + * + * @since New in 1.6. + */ +const char * +svn_log__lock(const apr_array_header_t *paths, svn_boolean_t steal, + apr_pool_t *pool); + +/** + * Return a log string for an unlock action. + * + * @since New in 1.6. + */ +const char * +svn_log__unlock(const apr_array_header_t *paths, svn_boolean_t break_lock, + apr_pool_t *pool); + +/** + * Return a log string for a lock action on only one path; this is + * just a convenience wrapper around svn_log__lock(). + * + * @since New in 1.6. + */ +const char * +svn_log__lock_one_path(const char *path, svn_boolean_t steal, + apr_pool_t *pool); + +/** + * Return a log string for an unlock action on only one path; this is + * just a convenience wrapper around svn_log__unlock(). + * + * @since New in 1.6. + */ +const char * +svn_log__unlock_one_path(const char *path, svn_boolean_t break_lock, + apr_pool_t *pool); + +/** + * Return a log string for a replay action. + * + * @since New in 1.6. + */ +const char * +svn_log__replay(const char *path, svn_revnum_t rev, apr_pool_t *pool); + +/** + * Return a log string for a get-inherited-props action. + * + * @since New in 1.8. + */ +const char * +svn_log__get_inherited_props(const char *path, + svn_revnum_t rev, + apr_pool_t *pool); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_LOG_H */ diff --git a/subversion/include/private/svn_magic.h b/subversion/include/private/svn_magic.h new file mode 100644 index 0000000..b057e56 --- /dev/null +++ b/subversion/include/private/svn_magic.h @@ -0,0 +1,55 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_magic.h + * @brief Subversion interface to libmagic. + */ + +#ifndef SVN_MAGIC_H +#define SVN_MAGIC_H + +/* An opaque struct that wraps a libmagic cookie. */ +typedef struct svn_magic__cookie_t svn_magic__cookie_t; + +/* This routine initialises libmagic. + * Upon success a new *MAGIC_COOKIE is allocated in RESULT_POOL. + * On failure *MAGIC_COOKIE is set to NULL. + * All resources used by libmagic are freed by a cleanup handler + * installed on RESULT_POOL, i.e. *MAGIC_COOKIE becomes invalid when + * the pool is cleared! */ +void +svn_magic__init(svn_magic__cookie_t **magic_cookie, + apr_pool_t *result_pool); + +/* Detect the mime-type of the file at LOCAL_ABSPATH using MAGIC_COOKIE. + * If the mime-type is binary return the result in *MIMETYPE. + * If the file is not a binary file or if its mime-type cannot be determined + * set *MIMETYPE to NULL. Allocate *MIMETYPE in RESULT_POOL. + * Use SCRATCH_POOL for temporary allocations. */ +svn_error_t * +svn_magic__detect_binary_mimetype(const char **mimetype, + const char *local_abspath, + svn_magic__cookie_t *magic_cookie, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +#endif /* SVN_MAGIC_H */ diff --git a/subversion/include/private/svn_mergeinfo_private.h b/subversion/include/private/svn_mergeinfo_private.h new file mode 100644 index 0000000..287515a --- /dev/null +++ b/subversion/include/private/svn_mergeinfo_private.h @@ -0,0 +1,270 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_mergeinfo_private.h + * @brief Subversion-internal mergeinfo APIs. + */ + +#ifndef SVN_MERGEINFO_PRIVATE_H +#define SVN_MERGEINFO_PRIVATE_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_error.h" +#include "svn_mergeinfo.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Set inheritability of all ranges in RANGELIST to INHERITABLE. + If RANGELIST is NULL do nothing. */ +void +svn_rangelist__set_inheritance(svn_rangelist_t *rangelist, + svn_boolean_t inheritable); + +/* Parse a rangelist from the string STR. Set *RANGELIST to the result, + * allocated in RESULT_POOL. Return an error if the rangelist is not + * well-formed (for example, if it contains invalid characters or if + * R1 >= R2 in a "R1-R2" range element). + * + * Unlike svn_mergeinfo_parse(), this does not sort the ranges into order + * or combine adjacent and overlapping ranges. + * + * The compaction can be done with svn_rangelist__combine_adjacent_ranges(). + */ +svn_error_t * +svn_rangelist__parse(svn_rangelist_t **rangelist, + const char *str, + apr_pool_t *result_pool); + +/* In-place combines adjacent ranges in a rangelist. + SCRATCH_POOL is just used for providing error messages. */ +svn_error_t * +svn_rangelist__combine_adjacent_ranges(svn_rangelist_t *rangelist, + apr_pool_t *scratch_pool); + +/* Set inheritability of all rangelists in MERGEINFO to INHERITABLE. + If MERGEINFO is NULL do nothing. If a rangelist in MERGEINFO is + NULL leave it alone. */ +void +svn_mergeinfo__set_inheritance(svn_mergeinfo_t mergeinfo, + svn_boolean_t inheritable, + apr_pool_t *scratch_pool); + +/* Return whether INFO1 and INFO2 are equal in *IS_EQUAL. + + CONSIDER_INHERITANCE determines how the rangelists in the two + hashes are compared for equality. If CONSIDER_INHERITANCE is FALSE, + then the start and end revisions of the svn_merge_range_t's being + compared are the only factors considered when determining equality. + + e.g. '/trunk: 1,3-4*,5' == '/trunk: 1,3-5' + + If CONSIDER_INHERITANCE is TRUE, then the inheritability of the + svn_merge_range_t's is also considered and must be the same for two + otherwise identical ranges to be judged equal. + + e.g. '/trunk: 1,3-4*,5' != '/trunk: 1,3-5' + '/trunk: 1,3-4*,5' == '/trunk: 1,3-4*,5' + '/trunk: 1,3-4,5' == '/trunk: 1,3-4,5' + + Use POOL for temporary allocations. */ +svn_error_t * +svn_mergeinfo__equals(svn_boolean_t *is_equal, + svn_mergeinfo_t info1, + svn_mergeinfo_t info2, + svn_boolean_t consider_inheritance, + apr_pool_t *pool); + +/* Examine MERGEINFO, removing all paths from the hash which map to + empty rangelists. POOL is used only to allocate the apr_hash_index_t + iterator. Returns TRUE if any paths were removed and FALSE if none were + removed or MERGEINFO is NULL. */ +svn_boolean_t +svn_mergeinfo__remove_empty_rangelists(svn_mergeinfo_t mergeinfo, + apr_pool_t *pool); + +/* Make a shallow (ie, mergeinfos are not duped, or altered at all; + keys share storage) copy of IN_CATALOG in *OUT_CATALOG, removing + PREFIX_PATH from the beginning of each key in the catalog. + PREFIX_PATH and the keys of IN_CATALOG are absolute 'fspaths', + starting with '/'. It is illegal for any key to not start with + PREFIX_PATH. The keys of *OUT_CATALOG are relpaths. The new hash + and temporary values are allocated in POOL. (This is useful for + making the return value from svn_ra_get_mergeinfo relative to the + session root, say.) */ +svn_error_t * +svn_mergeinfo__remove_prefix_from_catalog(svn_mergeinfo_catalog_t *out_catalog, + svn_mergeinfo_catalog_t in_catalog, + const char *prefix_path, + apr_pool_t *pool); + +/* Make a shallow (ie, mergeinfos are not duped, or altered at all; + though keys are reallocated) copy of IN_CATALOG in *OUT_CATALOG, + adding PREFIX_PATH to the beginning of each key in the catalog. + + The new hash keys are allocated in RESULT_POOL. SCRATCH_POOL + is used for any temporary allocations.*/ +svn_error_t * +svn_mergeinfo__add_prefix_to_catalog(svn_mergeinfo_catalog_t *out_catalog, + svn_mergeinfo_catalog_t in_catalog, + const char *prefix_path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Set *OUT_MERGEINFO to a shallow copy of MERGEINFO with the relpath + SUFFIX_RELPATH added to the end of each key path. + + Allocate *OUT_MERGEINFO and the new keys in RESULT_POOL. Use + SCRATCH_POOL for any temporary allocations. */ +svn_error_t * +svn_mergeinfo__add_suffix_to_mergeinfo(svn_mergeinfo_t *out_mergeinfo, + svn_mergeinfo_t mergeinfo, + const char *suffix_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Create a string representation of CATALOG in *OUTPUT, allocated in POOL. + The hash keys of CATALOG and the merge source paths of each key's mergeinfo + are represented in sorted order as per svn_sort_compare_items_as_paths. + If CATALOG is empty or NULL then *OUTPUT->DATA is set to "\n". If SVN_DEBUG + is true, then a NULL or empty CATALOG causes *OUTPUT to be set to an + appropriate newline terminated string. If KEY_PREFIX is not NULL then + prepend KEY_PREFIX to each key (path) in *OUTPUT. if VAL_PREFIX is not + NULL then prepend VAL_PREFIX to each merge source:rangelist line in + *OUTPUT. + + Any relative merge source paths in the mergeinfo in CATALOG are converted + to absolute paths in *OUTPUT. */ +svn_error_t * +svn_mergeinfo__catalog_to_formatted_string(svn_string_t **output, + svn_mergeinfo_catalog_t catalog, + const char *key_prefix, + const char *val_prefix, + apr_pool_t *pool); + +/* Set *YOUNGEST_REV and *OLDEST_REV to the youngest and oldest revisions + found in the rangelists within MERGEINFO. Note that *OLDEST_REV is + exclusive and *YOUNGEST_REV is inclusive. If MERGEINFO is NULL or empty + set *YOUNGEST_REV and *OLDEST_REV to SVN_INVALID_REVNUM. */ +svn_error_t * +svn_mergeinfo__get_range_endpoints(svn_revnum_t *youngest_rev, + svn_revnum_t *oldest_rev, + svn_mergeinfo_t mergeinfo, + apr_pool_t *pool); + +/* Set *FILTERED_MERGEINFO to a deep copy of MERGEINFO, allocated in + RESULT_POOL, less any revision ranges that fall outside of the range + OLDEST_REV:YOUNGEST_REV (exclusive:inclusive) if INCLUDE_RANGE is true, + or less any ranges within OLDEST_REV:YOUNGEST_REV if INCLUDE_RANGE + is false. If all the rangelists mapped to a given path are filtered + then filter that path as well. If all paths are filtered or MERGEINFO is + empty or NULL then *FILTERED_MERGEINFO is set to an empty hash. + + Use SCRATCH_POOL for any temporary allocations. */ +svn_error_t * +svn_mergeinfo__filter_mergeinfo_by_ranges(svn_mergeinfo_t *filtered_mergeinfo, + svn_mergeinfo_t mergeinfo, + svn_revnum_t youngest_rev, + svn_revnum_t oldest_rev, + svn_boolean_t include_range, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Filter each mergeinfo in CATALOG as per + svn_mergeinfo__filter_mergeinfo_by_ranges() and put a deep copy of the + result in *FILTERED_CATALOG, allocated in RESULT_POOL. If any mergeinfo + is filtered to an empty hash then filter that path/mergeinfo as well. + If all mergeinfo is filtered or CATALOG is NULL then set *FILTERED_CATALOG + to an empty hash. + + Use SCRATCH_POOL for any temporary allocations. */ +svn_error_t* +svn_mergeinfo__filter_catalog_by_ranges( + svn_mergeinfo_catalog_t *filtered_catalog, + svn_mergeinfo_catalog_t catalog, + svn_revnum_t youngest_rev, + svn_revnum_t oldest_rev, + svn_boolean_t include_range, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* If MERGEINFO is non-inheritable return TRUE, return FALSE otherwise. + MERGEINFO may be NULL or empty. */ +svn_boolean_t +svn_mergeinfo__is_noninheritable(svn_mergeinfo_t mergeinfo, + apr_pool_t *scratch_pool); + +/* Return a rangelist with one svn_merge_range_t * element defined by START, + END, and INHERITABLE. The rangelist and its contents are allocated in + RESULT_POOL. */ +svn_rangelist_t * +svn_rangelist__initialize(svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t inheritable, + apr_pool_t *result_pool); + +/* Adjust in-place MERGEINFO's rangelists by OFFSET. If OFFSET is negative + and would adjust any part of MERGEINFO's source revisions to 0 or less, + then those revisions are dropped. If all the source revisions for a merge + source path are dropped, then the path itself is dropped. If all merge + source paths are dropped, then *ADJUSTED_MERGEINFO is set to an empty + hash. *ADJUSTED_MERGEINFO is allocated in RESULT_POOL. SCRATCH_POOL is + used for any temporary allocations. */ +svn_error_t * +svn_mergeinfo__adjust_mergeinfo_rangelists(svn_mergeinfo_t *adjusted_mergeinfo, + svn_mergeinfo_t mergeinfo, + svn_revnum_t offset, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Translates an array SEGMENTS (of svn_location_segment_t *), like the one + returned from svn_client__repos_location_segments, into a mergeinfo + *MERGEINFO_P, allocated in POOL. + + Note: A svn_location_segment_t segment may legitimately describe only revision 0, + but there is no way to describe that using svn_mergeinfo_t. Any such + segment in SEGMENTS are ignored. */ +svn_error_t * +svn_mergeinfo__mergeinfo_from_segments(svn_mergeinfo_t *mergeinfo_p, + const apr_array_header_t *segments, + apr_pool_t *pool); + +/* Merge every rangelist in MERGEINFO into the given MERGED_RANGELIST, + * ignoring the source paths of MERGEINFO. MERGED_RANGELIST may + * initially be empty. New elements added to RANGELIST are allocated in + * RESULT_POOL. See svn_rangelist_merge2() for details of inheritability + * etc. */ +svn_error_t * +svn_rangelist__merge_many(svn_rangelist_t *merged_rangelist, + svn_mergeinfo_t mergeinfo, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_MERGEINFO_PRIVATE_H */ diff --git a/subversion/include/private/svn_mutex.h b/subversion/include/private/svn_mutex.h new file mode 100644 index 0000000..85583d3 --- /dev/null +++ b/subversion/include/private/svn_mutex.h @@ -0,0 +1,117 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_mutex.h + * @brief Strutures and functions for mutual exclusion + */ + +#ifndef SVN_MUTEX_H +#define SVN_MUTEX_H + +#include <apr_thread_mutex.h> + +#include "svn_error.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * This is a simple wrapper around @c apr_thread_mutex_t and will be a + * valid identifier even if APR does not support threading. + */ +#if APR_HAS_THREADS + +/** A mutex for synchronization between threads. It may be NULL, in + * which case no synchronization will take place. The latter is useful + * when implementing some functionality with optional synchronization. + */ +typedef apr_thread_mutex_t svn_mutex__t; + +#else + +/** Dummy definition. The content will never be actually accessed. + */ +typedef void svn_mutex__t; + +#endif + +/** Initialize the @a *mutex. If @a mutex_required is TRUE, the mutex will + * actually be created with a lifetime defined by @a result_pool. Otherwise, + * the pointer will be set to @c NULL and svn_mutex__lock() as well as + * svn_mutex__unlock() will be no-ops. + * + * If threading is not supported by APR, this function is a no-op. + */ +svn_error_t * +svn_mutex__init(svn_mutex__t **mutex, + svn_boolean_t mutex_required, + apr_pool_t *result_pool); + +/** Acquire the @a mutex, if that has been enabled in svn_mutex__init(). + * Make sure to call svn_mutex__unlock() some time later in the same + * thread to release the mutex again. Recursive locking are not supported. + * + * @note You should use #SVN_MUTEX__WITH_LOCK instead of explicit lock + * aquisition and release. + */ +svn_error_t * +svn_mutex__lock(svn_mutex__t *mutex); + +/** Release the @a mutex, previously acquired using svn_mutex__lock() + * that has been enabled in svn_mutex__init(). + * + * Since this is often used as part of the calling function's exit + * sequence, we accept that function's current return code in @a err. + * If it is not #SVN_NO_ERROR, it will be used as the return value - + * irrespective of the possible internal failures during unlock. If @a err + * is #SVN_NO_ERROR, internal failures of this function will be + * reported in the return value. + * + * @note You should use #SVN_MUTEX__WITH_LOCK instead of explicit lock + * aquisition and release. + */ +svn_error_t * +svn_mutex__unlock(svn_mutex__t *mutex, + svn_error_t *err); + +/** Aquires the @a mutex, executes the expression @a expr and finally + * releases the @a mutex. If any of these steps fail, the function using + * this macro will return an #svn_error_t. This macro guarantees that + * the @a mutex will always be unlocked again if it got locked successfully + * by the first step. + * + * @note Prefer using this macro instead of explicit lock aquisition and + * release. + */ +#define SVN_MUTEX__WITH_LOCK(mutex, expr) \ +do { \ + svn_mutex__t *svn_mutex__m = (mutex); \ + SVN_ERR(svn_mutex__lock(svn_mutex__m)); \ + SVN_ERR(svn_mutex__unlock(svn_mutex__m, (expr))); \ +} while (0) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_MUTEX_H */ diff --git a/subversion/include/private/svn_named_atomic.h b/subversion/include/private/svn_named_atomic.h new file mode 100644 index 0000000..4efa255 --- /dev/null +++ b/subversion/include/private/svn_named_atomic.h @@ -0,0 +1,162 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_named_atomics.h + * @brief Structures and functions for machine-wide named atomics. + * These atomics store 64 bit signed integer values and provide + * a number of basic operations on them. Instead of an address, + * these atomics are identified by strings / names. We also support + * namespaces - mainly to separate debug from production data. + */ + +#ifndef SVN_NAMED_ATOMICS_H +#define SVN_NAMED_ATOMICS_H + +#include "svn_error.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** An opaque structure that represents a namespace, i.e. a container + * for named atomics. + */ +typedef struct svn_atomic_namespace__t svn_atomic_namespace__t; + +/** An opaque structure that represents a named, system-wide visible + * 64 bit integer with atomic access routines. + */ +typedef struct svn_named_atomic__t svn_named_atomic__t; + +/** Maximum length of the name of any atomic (excluding the terminal NUL). + */ +#define SVN_NAMED_ATOMIC__MAX_NAME_LENGTH 30 + +/** Returns #FALSE when named atomics are not available to our process + * and svn_atomic_namespace__create is likely to fail. + * + * @note The actual check will be performed only once and later + * changes in process privileges will not reflect in the outcome of future + * calls to this function. + */ +svn_boolean_t +svn_named_atomic__is_supported(void); + +/** Returns #TRUE on platforms that don't need expensive synchronization + * objects to serialize access to named atomics. If this returns #FALSE, + * reading from or modifying a #svn_named_atomic__t may be as expensive + * as a file system operation. + */ +svn_boolean_t +svn_named_atomic__is_efficient(void); + +/** Create a namespace (i.e. access object) with the given @a name and + * return it in @a *ns. + * + * Multiple access objects with the same name may be created. They access + * the same shared memory region but have independent lifetimes. + * + * The access object will be allocated in @a result_pool and atomics gotten + * from this object will become invalid when the pool is being cleared. + */ +svn_error_t * +svn_atomic_namespace__create(svn_atomic_namespace__t **ns, + const char *name, + apr_pool_t *result_pool); + +/** Removes persistent data structures (files in particular) that got + * created for the namespace given by @a name. Use @a pool for temporary + * allocations. + * + * @note You must not call this while the respective namespace is still + * in use. Calling this multiple times for the same namespace is safe. + */ +svn_error_t * +svn_atomic_namespace__cleanup(const char *name, + apr_pool_t *pool); + +/** Find the atomic with the specified @a name in namespace @a ns and + * return it in @a *atomic. If no object with that name can be found, the + * behavior depends on @a auto_create. If it is @c FALSE, @a *atomic will + * be set to @c NULL. Otherwise, a new atomic will be created, its value + * set to 0 and the access structure be returned in @a *atomic. + * + * Note that @a name must not exceed #SVN_NAMED_ATOMIC__MAX_NAME_LENGTH + * characters and an error will be returned if the specified name is longer + * than supported. + * + * @note The lifetime of the atomic object is bound to the lifetime + * of the @a ns object, i.e. the pool the latter was created in. + * The data in the namespace persists as long as at least one process + * holds an #svn_atomic_namespace__t object corresponding to it. + */ +svn_error_t * +svn_named_atomic__get(svn_named_atomic__t **atomic, + svn_atomic_namespace__t *ns, + const char *name, + svn_boolean_t auto_create); + +/** Read the @a atomic and return its current @a *value. + * An error will be returned if @a atomic is @c NULL. + */ +svn_error_t * +svn_named_atomic__read(apr_int64_t *value, + svn_named_atomic__t *atomic); + +/** Set the data in @a atomic to @a new_value and return its old content + * in @a *old_value. @a old_value may be NULL. + * + * An error will be returned if @a atomic is @c NULL. + */ +svn_error_t * +svn_named_atomic__write(apr_int64_t *old_value, + apr_int64_t new_value, + svn_named_atomic__t *atomic); + +/** Add @a delta to the data in @a atomic and return its new value in + * @a *new_value. @a new_value may be null. + * + * An error will be returned if @a atomic is @c NULL. + */ +svn_error_t * +svn_named_atomic__add(apr_int64_t *new_value, + apr_int64_t delta, + svn_named_atomic__t *atomic); + +/** If the current data in @a atomic equals @a comperand, set it to + * @a new_value. Return the initial value in @a *old_value. + * @a old_value may be NULL. + * + * An error will be returned if @a atomic is @c NULL. + */ +svn_error_t * +svn_named_atomic__cmpxchg(apr_int64_t *old_value, + apr_int64_t new_value, + apr_int64_t comperand, + svn_named_atomic__t *atomic); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_NAMED_ATOMICS_H */ diff --git a/subversion/include/private/svn_opt_private.h b/subversion/include/private/svn_opt_private.h new file mode 100644 index 0000000..6ae67a5 --- /dev/null +++ b/subversion/include/private/svn_opt_private.h @@ -0,0 +1,156 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_opt_private.h + * @brief Subversion-internal option parsing APIs. + */ + +#ifndef SVN_OPT_PRIVATE_H +#define SVN_OPT_PRIVATE_H + +#include <apr_pools.h> +#include <apr_tables.h> +#include <apr_getopt.h> + +#include "svn_error.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Extract the peg revision, if any, from UTF8_TARGET. + * + * If PEG_REVISION is not NULL, return the peg revision in *PEG_REVISION. + * *PEG_REVISION will be an empty string if no peg revision is found. + * Return the true target portion in *TRUE_TARGET. + * + * UTF8_TARGET need not be canonical. *TRUE_TARGET will not be canonical + * unless UTF8_TARGET is. + * + * It is an error if *TRUE_TARGET results in the empty string after the + * split, which happens in case UTF8_TARGET has a leading '@' character + * with no additional '@' characters to escape the first '@'. + * + * Note that *PEG_REVISION will still contain the '@' symbol as the first + * character if a peg revision was found. If a trailing '@' symbol was + * used to escape other '@' characters in UTF8_TARGET, *PEG_REVISION will + * point to the string "@", containing only a single character. + * + * All allocations are done in POOL. + */ +svn_error_t * +svn_opt__split_arg_at_peg_revision(const char **true_target, + const char **peg_revision, + const char *utf8_target, + apr_pool_t *pool); + +/* Attempt to transform URL_IN, which is a URL-like user input, into a + * valid URL: + * - escape IRI characters and some other non-URI characters + * - check that no back-path ("..") components are present + * - call svn_uri_canonicalize() + * URL_IN is in UTF-8 encoding and has no peg revision specifier. + * Set *URL_OUT to the result, allocated from POOL. + */ +svn_error_t * +svn_opt__arg_canonicalize_url(const char **url_out, + const char *url_in, + apr_pool_t *pool); + +/* + * Attempt to transform PATH_IN, which is a local path-like user input, into a + * valid local path: + * - Attempt to get the correct capitalization by trying to actually find + * the path specified. + * - If the path does not exist (which is valid) the given capitalization + * is used. + * - canonicalize the separator ("/") characters + * - call svn_dirent_canonicalize() + * PATH_IN is in UTF-8 encoding and has no peg revision specifier. + * Set *PATH_OUT to the result, allocated from POOL. + */ +svn_error_t * +svn_opt__arg_canonicalize_path(const char **path_out, + const char *path_in, + apr_pool_t *pool); + +/* + * Pull remaining target arguments from OS into *TARGETS_P, + * converting them to UTF-8, followed by targets from KNOWN_TARGETS + * (which might come from, for example, the "--targets" command line + * option), which are already in UTF-8. + * + * On each URL target, do some IRI-to-URI encoding and some + * auto-escaping. On each local path, canonicalize case and path + * separators. + * + * Allocate *TARGETS_P and its elements in POOL. + * + * If a path has the same name as a Subversion working copy + * administrative directory, return SVN_ERR_RESERVED_FILENAME_SPECIFIED; + * if multiple reserved paths are encountered, return a chain of + * errors, all of which are SVN_ERR_RESERVED_FILENAME_SPECIFIED. Do + * not return this type of error in a chain with any other type of + * error, and if this is the only type of error encountered, complete + * the operation before returning the error(s). + */ +svn_error_t * +svn_opt__args_to_target_array(apr_array_header_t **targets_p, + apr_getopt_t *os, + const apr_array_header_t *known_targets, + apr_pool_t *pool); + +/** + * Return a human-readable description of @a revision. The result + * will be allocated statically or from @a result_pool. + * + * @since New in 1.7. + */ +const char * +svn_opt__revision_to_string(const svn_opt_revision_t *revision, + apr_pool_t *result_pool); + +/** + * Create a revision range structure from two revisions. Return a new range + * allocated in @a result_pool with the start and end initialized to + * (deep copies of) @a *start_revision and @a *end_revision. + */ +svn_opt_revision_range_t * +svn_opt__revision_range_create(const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + apr_pool_t *result_pool); + +/** + * Create a revision range structure from two revnums. Return a new range + * allocated in @a result_pool with the start and end kinds initialized to + * #svn_opt_revision_number and values @a start_revnum and @a end_revnum. + */ +svn_opt_revision_range_t * +svn_opt__revision_range_from_revnums(svn_revnum_t start_revnum, + svn_revnum_t end_revnum, + apr_pool_t *result_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_OPT_PRIVATE_H */ diff --git a/subversion/include/private/svn_pseudo_md5.h b/subversion/include/private/svn_pseudo_md5.h new file mode 100644 index 0000000..34d5929 --- /dev/null +++ b/subversion/include/private/svn_pseudo_md5.h @@ -0,0 +1,83 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_pseudo_md5.h + * @brief Subversion hash sum calculation for runtime data (only) + */ + +#ifndef SVN_PSEUDO_MD5_H +#define SVN_PSEUDO_MD5_H + +#include <apr.h> /* for apr_uint32_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * Calculates a hash sum for 15 bytes in @a x and returns it in @a digest. + * The most significant byte in @a x must be 0 (independent of being on a + * little or big endian machine). + * + * @note Use for runtime data hashing only. + * + * @note The output is NOT an MD5 digest shares has the same basic + * cryptographic properties. Collisions with proper MD5 on the same + * or other input data is equally unlikely as any MD5 collision. + */ +void svn__pseudo_md5_15(apr_uint32_t digest[4], + const apr_uint32_t x[4]); + +/** + * Calculates a hash sum for 31 bytes in @a x and returns it in @a digest. + * The most significant byte in @a x must be 0 (independent of being on a + * little or big endian machine). + * + * @note Use for runtime data hashing only. + * + * @note The output is NOT an MD5 digest shares has the same basic + * cryptographic properties. Collisions with proper MD5 on the same + * or other input data is equally unlikely as any MD5 collision. + */ +void svn__pseudo_md5_31(apr_uint32_t digest[4], + const apr_uint32_t x[8]); + +/** + * Calculates a hash sum for 63 bytes in @a x and returns it in @a digest. + * The most significant byte in @a x must be 0 (independent of being on a + * little or big endian machine). + * + * @note Use for runtime data hashing only. + * + * @note The output is NOT an MD5 digest shares has the same basic + * cryptographic properties. Collisions with proper MD5 on the same + * or other input data is equally unlikely as any MD5 collision. + */ +void svn__pseudo_md5_63(apr_uint32_t digest[4], + const apr_uint32_t x[16]); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_PSEUDO_MD5_H */ diff --git a/subversion/include/private/svn_ra_private.h b/subversion/include/private/svn_ra_private.h new file mode 100644 index 0000000..4531bcb --- /dev/null +++ b/subversion/include/private/svn_ra_private.h @@ -0,0 +1,280 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_ra_private.h + * @brief The Subversion repository access library - Internal routines + */ + +#ifndef SVN_RA_PRIVATE_H +#define SVN_RA_PRIVATE_H + +#include <apr_pools.h> + +#include "svn_error.h" +#include "svn_ra.h" +#include "svn_delta.h" +#include "svn_editor.h" +#include "svn_io.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Return an error with code SVN_ERR_UNSUPPORTED_FEATURE, and an error + message referencing PATH_OR_URL, if the "server" pointed to by + RA_SESSION doesn't support Merge Tracking (e.g. is pre-1.5). + Perform temporary allocations in POOL. */ +svn_error_t * +svn_ra__assert_mergeinfo_capable_server(svn_ra_session_t *ra_session, + const char *path_or_url, + apr_pool_t *pool); + + +/*** Operational Locks ***/ + +/** This is a function type which allows svn_ra__get_operational_lock() + * to report lock attempt failures. If non-NULL, @a locktoken is the + * preexisting lock which prevented lock acquisition. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_ra__lock_retry_func_t)(void *baton, + const svn_string_t *locktoken, + apr_pool_t *pool); + +/** Acquire a lock (of sorts) on the repository associated with the + * given RA @a session, retrying as necessary up to @a num_retries + * times, and set @a *lock_string_p to the value of the acquired lock + * token. Allocate the returned token from @a pool. (See this + * function's counterpart svn_ra__release_operational_lock() for your + * lock removal needs.) + * + * @a lock_revprop_name is the name of the revision-0 property used to + * store the lock. + * + * If @a steal_lock is set, then replace any pre-existing lock on the + * repository with our own. Iff such a theft occurs and + * @a stolen_lock_p is non-NULL, set @a *stolen_lock_p to the token of + * the lock we stole. + * + * Call @a retry_func with @a retry_baton each time the retry loop + * fails to acquire a lock. + * + * Use @a cancel_func and @a cancel_baton to check for early + * cancellation. + * + * @note If the server does not support #SVN_RA_CAPABILITY_ATOMIC_REVPROPS + * (i.e., is a pre-1.7 server), then this function makes a "best effort" + * attempt to obtain the lock, but is susceptible to a race condition; see + * issue #3546. + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra__get_operational_lock(const svn_string_t **lock_string_p, + const svn_string_t **stolen_lock_p, + svn_ra_session_t *session, + const char *lock_revprop_name, + svn_boolean_t steal_lock, + int num_retries, + svn_ra__lock_retry_func_t retry_func, + void *retry_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Release an operational lock (whose value is @a mylocktoken) on the + * repository associated with RA @a session. (This is the counterpart + * to svn_ra__get_operational_lock().) + * + * @a lock_revprop_name is the name of the revision-0 property used to + * store the lock. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra__release_operational_lock(svn_ra_session_t *session, + const char *lock_revprop_name, + const svn_string_t *mylocktoken, + apr_pool_t *scratch_pool); + +/** Register CALLBACKS to be used with the Ev2 shims in RA_SESSION. */ +svn_error_t * +svn_ra__register_editor_shim_callbacks(svn_ra_session_t *ra_session, + svn_delta_shim_callbacks_t *callbacks); + + +/* Using information from BATON, provide the (file's) pristine contents + for REPOS_RELPATH. They are returned in *CONTENTS, and correspond to + *REVISION. + + If a pristine is not available (ie. a locally-added node), then set + *CONTENTS to NULL; *REVISION will not be examined in this case. + + These are allocated in RESULT_POOL. SCRATCH_POOL can be used + for temporary allocations. */ +typedef svn_error_t *(*svn_ra__provide_base_cb_t)( + svn_stream_t **contents, + svn_revnum_t *revision, + void *baton, + const char *repos_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Using information from BATON, provide the pristine properties for + REPOS_RELPATH. They are returned in *PROPS, and correspond to *REVISION. + + If properties are not available (ie. a locally-added node), then set + *PROPS to NULL; *REVISION will not be examined in this case. + + The properties are allocated in RESULT_POOL. SCRATCH_POOL can be used + for temporary allocations. */ +typedef svn_error_t *(*svn_ra__provide_props_cb_t)( + apr_hash_t **props, + svn_revnum_t *revision, + void *baton, + const char *repos_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Using information from BATON, fetch the kind of REPOS_RELPATH at revision + SRC_REVISION, returning it in *KIND. + + If the kind cannot be determined, then set *KIND to svn_node_unknown. + + Temporary allocations can be made in SCRATCH_POOL. */ +typedef svn_error_t *(*svn_ra__get_copysrc_kind_cb_t)( + svn_node_kind_t *kind, + void *baton, + const char *repos_relpath, + svn_revnum_t src_revision, + apr_pool_t *scratch_pool); + + +/* Return an Ev2-based editor for performing commits. + + The editor is associated with the given SESSION, and its implied target + repository. + + REVPROPS contains all the revision properties that should be stored onto + the newly-committed revision. SVN_PROP_REVISION_AUTHOR will be set to + the username as determined by the session; overwriting any prior value + that may be present in REVPROPS. + + COMMIT_CB/BATON contain the callback to receive post-commit information. + + LOCK_TOKENS should contain all lock tokens necessary to modify paths + within the commit. If KEEP_LOCKS is FALSE, then the paths associated + with these tokens will be unlocked. + ### today, LOCK_TOKENS is session_relpath:token_value. in the future, + ### it should be repos_relpath:token_value. + + PROVIDE_BASE_CB is a callback to fetch pristine contents, used to send + an svndiff over the wire to the server. This may be NULL, indicating + pristine contents are not available (eg. URL-based operations or import). + + PROVIDE_PROPS_CB is a callback to fetch pristine properties, used to + send property deltas over the wire to the server. This may be NULL, + indicating pristine properties are not available (eg. URL-based operations + or an import). + + GET_COPYSRC_KIND_CB is a callback to determine the kind of a copy-source. + This is necessary when an Ev2/Ev1 shim is required by the RA provider, + in order to determine whether to use delta->add_directory() or the + delta->add_file() vtable entry to perform the copy. + ### unclear on impact if this is NULL. + ### this callback will disappear when "everything" is running Ev2 + + CB_BATON is the baton used/shared by the above three callbacks. + + Cancellation is handled through the callbacks provided when SESSION + is initially opened. + + *EDITOR will be allocated in RESULT_POOL, and all temporary allocations + will be performed in SCRATCH_POOL. +*/ +svn_error_t * +svn_ra__get_commit_ev2(svn_editor_t **editor, + svn_ra_session_t *session, + apr_hash_t *revprops, + svn_commit_callback2_t commit_cb, + void *commit_baton, + apr_hash_t *lock_tokens, + svn_boolean_t keep_locks, + svn_ra__provide_base_cb_t provide_base_cb, + svn_ra__provide_props_cb_t provide_props_cb, + svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb, + void *cb_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/* Similar to #svn_ra_replay_revstart_callback_t, but with an Ev2 editor. */ +typedef svn_error_t *(*svn_ra__replay_revstart_ev2_callback_t)( + svn_revnum_t revision, + void *replay_baton, + svn_editor_t **editor, + apr_hash_t *rev_props, + apr_pool_t *pool); + +/* Similar to #svn_ra_replay_revfinish_callback_t, but with an Ev2 editor. */ +typedef svn_error_t *(*svn_ra__replay_revfinish_ev2_callback_t)( + svn_revnum_t revision, + void *replay_baton, + svn_editor_t *editor, + apr_hash_t *rev_props, + apr_pool_t *pool); + +/* Similar to svn_ra_replay_range(), but uses Ev2 versions of the callback + functions. */ +svn_error_t * +svn_ra__replay_range_ev2(svn_ra_session_t *session, + svn_revnum_t start_revision, + svn_revnum_t end_revision, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas, + svn_ra__replay_revstart_ev2_callback_t revstart_func, + svn_ra__replay_revfinish_ev2_callback_t revfinish_func, + void *replay_baton, + svn_ra__provide_base_cb_t provide_base_cb, + svn_ra__provide_props_cb_t provide_props_cb, + svn_ra__get_copysrc_kind_cb_t get_copysrc_kind_cb, + void *cb_baton, + apr_pool_t *scratch_pool); + +/* Similar to svn_ra_replay(), but with an Ev2 editor. */ +svn_error_t * +svn_ra__replay_ev2(svn_ra_session_t *session, + svn_revnum_t revision, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas, + svn_editor_t *editor, + apr_pool_t *scratch_pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_RA_PRIVATE_H */ diff --git a/subversion/include/private/svn_ra_svn_private.h b/subversion/include/private/svn_ra_svn_private.h new file mode 100644 index 0000000..b4294d0 --- /dev/null +++ b/subversion/include/private/svn_ra_svn_private.h @@ -0,0 +1,826 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_ra_svn_private.h + * @brief Functions used by the server - Internal routines + */ + +#ifndef SVN_RA_SVN_PRIVATE_H +#define SVN_RA_SVN_PRIVATE_H + +#include "svn_ra_svn.h" +#include "svn_editor.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * Set the shim callbacks to be used by @a conn to @a shim_callbacks. + */ +svn_error_t * +svn_ra_svn__set_shim_callbacks(svn_ra_svn_conn_t *conn, + svn_delta_shim_callbacks_t *shim_callbacks); + +/** + * @defgroup ra_svn_deprecated ra_svn low-level functions + * @{ + */ + +/** Write a number over the net. + * + * Writes will be buffered until the next read or flush. + */ +svn_error_t * +svn_ra_svn__write_number(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + apr_uint64_t number); + +/** Write a string over the net. + * + * Writes will be buffered until the next read or flush. + */ +svn_error_t * +svn_ra_svn__write_string(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_string_t *str); + +/** Write a cstring over the net. + * + * Writes will be buffered until the next read or flush. + */ +svn_error_t * +svn_ra_svn__write_cstring(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *s); + +/** Write a word over the net. + * + * Writes will be buffered until the next read or flush. + */ +svn_error_t * +svn_ra_svn__write_word(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *word); + +/** Write a list of properties over the net. @a props is allowed to be NULL, + * in which case an empty list will be written out. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_svn__write_proplist(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + apr_hash_t *props); + +/** Begin a list. Writes will be buffered until the next read or flush. */ +svn_error_t * +svn_ra_svn__start_list(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** End a list. Writes will be buffered until the next read or flush. */ +svn_error_t * +svn_ra_svn__end_list(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Flush the write buffer. + * + * Normally this shouldn't be necessary, since the write buffer is flushed + * when a read is attempted. + */ +svn_error_t * +svn_ra_svn__flush(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Write a tuple, using a printf-like interface. + * + * The format string @a fmt may contain: + * + *@verbatim + Spec Argument type Item type + ---- -------------------- --------- + n apr_uint64_t Number + r svn_revnum_t Number + s const svn_string_t * String + c const char * String + w const char * Word + b svn_boolean_t Word ("true" or "false") + ( Begin tuple + ) End tuple + ? Remaining elements optional + ! (at beginning or end) Suppress opening or closing of tuple + @endverbatim + * + * Inside the optional part of a tuple, 'r' values may be @c + * SVN_INVALID_REVNUM, 'n' values may be + * SVN_RA_SVN_UNSPECIFIED_NUMBER, and 's', 'c', and 'w' values may be + * @c NULL; in these cases no data will be written. 'b' and '(' may + * not appear in the optional part of a tuple. Either all or none of + * the optional values should be valid. + * + * (If we ever have a need for an optional boolean value, we should + * invent a 'B' specifier which stores a boolean into an int, using -1 + * for unspecified. Right now there is no need for such a thing.) + * + * Use the '!' format specifier to write partial tuples when you have + * to transmit an array or other unusual data. For example, to write + * a tuple containing a revision, an array of words, and a boolean: + * @code + SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "r(!", rev)); + for (i = 0; i < n; i++) + SVN_ERR(svn_ra_svn_write_word(conn, pool, words[i])); + SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "!)b", flag)); @endcode + */ +svn_error_t * +svn_ra_svn__write_tuple(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Read an item from the network into @a *item. */ +svn_error_t * +svn_ra_svn__read_item(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_ra_svn_item_t **item); + +/** Scan data on @a conn until we find something which looks like the + * beginning of an svn server greeting (an open paren followed by a + * whitespace character). This function is appropriate for beginning + * a client connection opened in tunnel mode, since people's dotfiles + * sometimes write output to stdout. It may only be called at the + * beginning of a client connection. + */ +svn_error_t * +svn_ra_svn__skip_leading_garbage(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Parse an array of @c svn_sort__item_t structures as a tuple, using a + * printf-like interface. The format string @a fmt may contain: + * + *@verbatim + Spec Argument type Item type + ---- -------------------- --------- + n apr_uint64_t * Number + r svn_revnum_t * Number + s svn_string_t ** String + c const char ** String + w const char ** Word + b svn_boolean_t * Word ("true" or "false") + B apr_uint64_t * Word ("true" or "false") + l apr_array_header_t ** List + ( Begin tuple + ) End tuple + ? Tuple is allowed to end here + @endverbatim + * + * Note that a tuple is only allowed to end precisely at a '?', or at + * the end of the specification. So if @a fmt is "c?cc" and @a list + * contains two elements, an error will result. + * + * 'B' is similar to 'b', but may be used in the optional tuple specification. + * It returns TRUE, FALSE, or SVN_RA_SVN_UNSPECIFIED_NUMBER. + * + * If an optional part of a tuple contains no data, 'r' values will be + * set to @c SVN_INVALID_REVNUM, 'n' and 'B' values will be set to + * SVN_RA_SVN_UNSPECIFIED_NUMBER, and 's', 'c', 'w', and 'l' values + * will be set to @c NULL. 'b' may not appear inside an optional + * tuple specification; use 'B' instead. + */ +svn_error_t * +svn_ra_svn__parse_tuple(const apr_array_header_t *list, + apr_pool_t *pool, + const char *fmt, ...); + +/** Read a tuple from the network and parse it as a tuple, using the + * format string notation from svn_ra_svn_parse_tuple(). + */ +svn_error_t * +svn_ra_svn__read_tuple(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Parse an array of @c svn_ra_svn_item_t structures as a list of + * properties, storing the properties in a hash table. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_svn__parse_proplist(const apr_array_header_t *list, + apr_pool_t *pool, + apr_hash_t **props); + +/** Read a command response from the network and parse it as a tuple, using + * the format string notation from svn_ra_svn_parse_tuple(). + */ +svn_error_t * +svn_ra_svn__read_cmd_response(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Accept commands over the network and handle them according to @a + * commands. Command handlers will be passed @a conn, a subpool of @a + * pool (cleared after each command is handled), the parameters of the + * command, and @a baton. Commands will be accepted until a + * terminating command is received (a command with "terminate" set in + * the command table). If a command handler returns an error wrapped + * in SVN_RA_SVN_CMD_ERR (see the @c SVN_CMD_ERR macro), the error + * will be reported to the other side of the connection and the + * command loop will continue; any other kind of error (typically a + * network or protocol error) is passed through to the caller. + * + * @since New in 1.6. + * + */ +svn_error_t * +svn_ra_svn__handle_commands2(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_ra_svn_cmd_entry_t *commands, + void *baton, + svn_boolean_t error_on_disconnect); + +/** Write a successful command response over the network, using the + * same format string notation as svn_ra_svn_write_tuple(). Do not use + * partial tuples with this function; if you need to use partial + * tuples, just write out the "success" and argument tuple by hand. + */ +svn_error_t * +svn_ra_svn__write_cmd_response(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Write an unsuccessful command response over the network. */ +svn_error_t * +svn_ra_svn__write_cmd_failure(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_error_t *err); + +/** + * @} + */ + +/** + * @defgroup svn_commands sending ra_svn commands + * @{ + */ + +/** Sets the target revision of connection @a conn to @a rev. Use @a pool + * for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_target_rev(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev); + +/** Send a "open-root" command over connection @a conn. Open the + * repository root at revision @a rev and associate it with @a token. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_open_root(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *token); + +/** Send a "delete-entry" command over connection @a conn. Delete the + * @a path at optional revision @a rev below @a parent_token. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_delete_entry(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t rev, + const char *parent_token); + +/** Send a "add-dir" command over connection @a conn. Add a new directory + * node named @a path under the directory identified by @a parent_token. + * Associate the new directory with the given @a token. * @a copy_path + * and @a copy_rev are optional and describe the copy source. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_add_dir(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *parent_token, + const char *token, + const char *copy_path, + svn_revnum_t copy_rev); + +/** Send a "open-dir" command over connection @a conn. Associate to + * @a token the directory node named @a path under the directory + * identified by @a parent_token in revision @a rev. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_open_dir(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *parent_token, + const char *token, + svn_revnum_t rev); + +/** Send a "change-dir-prop" command over connection @a conn. Set the + * property @a name to the optional @a value on the directory identified + * to @a token. Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_change_dir_prop(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token, + const char *name, + const svn_string_t *value); + +/** Send a "close-dir" command over connection @a conn. Identify the node + * to close with @a token. The latter will then no longer be associated + * with that node. Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_close_dir(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token); + +/** Send a "absent-dir" command over connection @a conn. Directory node + * named @a path under the directory identified by @a parent_token is + * absent. Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_absent_dir(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *parent_token); + +/** Send a "add-file" command over connection @a conn. Add a new file + * node named @a path under the directory identified by @a parent_token. + * Associate the new file with the given @a token. * @a copy_path and + * @a copy_rev are optional and describe the copy source. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_add_file(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *parent_token, + const char *token, + const char *copy_path, + svn_revnum_t copy_rev); + +/** Send a "open-file" command over connection @a conn. Associate to + * @a token the file node named @a path under the directory identified by + * @a parent_token in revision @a rev. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_open_file(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *parent_token, + const char *token, + svn_revnum_t rev); + +/** Send a "change-file-prop" command over connection @a conn. Set the + * property @a name to the optional @a value on the file identified to + * @a token. Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_change_file_prop(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token, + const char *name, + const svn_string_t *value); + +/** Send a "close-dir" command over connection @a conn. Identify the node + * to close with @a token and provide an optional @a check_sum. The token + * will then no longer be associated with that node. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_close_file(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token, + const char *text_checksum); + +/** Send a "absent-file" command over connection @a conn. File node + * named @a path in the directory identified by @a parent_token is + * absent. Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_absent_file(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *parent_token); + +/** Send a "apply-textdelta" command over connection @a conn. Starts a + * series of text deltas to be applied to the file identified by @a token. + * Optionally, specify the file's current checksum in @a base_checksum. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_apply_textdelta(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token, + const char *base_checksum); + +/** Send a "textdelta-chunk" command over connection @a conn. Apply + * textdelta @a chunk to the file identified by @a token. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_textdelta_chunk(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token, + const svn_string_t *chunk); + +/** Send a "textdelta-end" command over connection @a conn. Ends the + * series of text deltas to be applied to the file identified by @a token. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_textdelta_end(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *token); + +/** Send a "close-edit" command over connection @a conn. Ends the editor + * drive (successfully). Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_close_edit(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Send a "abort-edit" command over connection @a conn. Prematurely ends + * the editor drive, e.g. due to some problem on the other side. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_abort_edit(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Send a "set-path" command over connection @a conn. + * Use @a pool for allocations. + * + * @see set_path() in #svn_ra_reporter3_t for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_set_path(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t rev, + svn_boolean_t start_empty, + const char *lock_token, + svn_depth_t depth); + +/** Send a "delete-path" command over connection @a conn. + * Use @a pool for allocations. + * + * @see delete_path() in #svn_ra_reporter3_t for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_delete_path(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path); + +/** Send a "link-path" command over connection @a conn. + * Use @a pool for allocations. + * + * @see link_path() in #svn_ra_reporter3_t for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_link_path(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *url, + svn_revnum_t rev, + svn_boolean_t start_empty, + const char *lock_token, + svn_depth_t depth); + +/** Send a "finish-report" command over connection @a conn. + * Use @a pool for allocations. + * + * @see finish_report() in #svn_ra_reporter3_t for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_finish_report(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Send a "abort-report" command over connection @a conn. + * Use @a pool for allocations. + * + * @see abort_report() in #svn_ra_reporter3_t for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_abort_report(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Send a "reparent" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_reparent for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_reparent(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *url); + +/** Send a "get-latest-rev" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_latest_revnum for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_latest_rev(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Send a "get-dated-rev" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_dated_revision for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_dated_rev(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + apr_time_t tm); + +/** Send a "change-rev-prop2" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_change_rev_prop2 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_change_rev_prop2(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *name, + const svn_string_t *value, + svn_boolean_t dont_care, + const svn_string_t *old_value); + +/** Send a "change-rev-prop" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_change_rev_prop for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_change_rev_prop(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *name, + const svn_string_t *value); + +/** Send a "rev-proplist" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_rev_proplist for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_rev_proplist(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev); + +/** Send a "rev-prop" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_rev_prop for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_rev_prop(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *name); + +/** Send a "get-file" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_file for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_file(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t rev, + svn_boolean_t props, + svn_boolean_t stream); + +/** Send a "update" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_do_update3 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_update(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *target, + svn_boolean_t recurse, + svn_depth_t depth, + svn_boolean_t send_copyfrom_args, + svn_boolean_t ignore_ancestry); + +/** Send a "switch" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_do_switch3 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_switch(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *target, + svn_boolean_t recurse, + const char *switch_url, + svn_depth_t depth, + svn_boolean_t send_copyfrom_args, + svn_boolean_t ignore_ancestry); + +/** Send a "status" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_do_status2 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_status(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *target, + svn_boolean_t recurse, + svn_revnum_t rev, + svn_depth_t depth); + +/** Send a "diff" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_do_diff3 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_diff(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + const char *target, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + const char *versus_url, + svn_boolean_t text_deltas, + svn_depth_t depth); + +/** Send a "check-path" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_check_path for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_check_path(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t rev); + +/** Send a "stat" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_stat for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_stat(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t rev); + +/** Send a "get-file-revs" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_file_revs2 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_file_revs(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t include_merged_revisions); + +/** Send a "lock" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_lock for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_lock(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *comment, + svn_boolean_t steal_lock, + svn_revnum_t revnum); + +/** Send a "unlock" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_unlock for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_unlock(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + const char *token, + svn_boolean_t break_lock); + +/** Send a "get-lock" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_lock for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_lock(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path); + +/** Send a "get-locks" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_locks2 for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_locks(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_depth_t depth); + +/** Send a "replay" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_replay for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_replay(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t rev, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas); + +/** Send a "replay-range" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_replay_range for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_replay_range(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_revnum_t start_revision, + svn_revnum_t end_revision, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas); + +/** Send a "get-deleted-rev" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_deleted_rev for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_deleted_rev(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t peg_revision, + svn_revnum_t end_revision); + +/** Send a "get-iprops" command over connection @a conn. + * Use @a pool for allocations. + * + * @see #svn_ra_get_inherited_props for a description. + */ +svn_error_t * +svn_ra_svn__write_cmd_get_iprops(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *path, + svn_revnum_t revision); + +/** Send a "finish-replay" command over connection @a conn. + * Use @a pool for allocations. + */ +svn_error_t * +svn_ra_svn__write_cmd_finish_replay(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** + * @} + */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_RA_SVN_PRIVATE_H */ diff --git a/subversion/include/private/svn_repos_private.h b/subversion/include/private/svn_repos_private.h new file mode 100644 index 0000000..8e943ae --- /dev/null +++ b/subversion/include/private/svn_repos_private.h @@ -0,0 +1,121 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_repos_private.h + * @brief Subversion-internal repos APIs. + */ + +#ifndef SVN_REPOS_PRIVATE_H +#define SVN_REPOS_PRIVATE_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_repos.h" +#include "svn_editor.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Validate that property @a name is valid for use in a Subversion + * repository; return @c SVN_ERR_REPOS_BAD_ARGS if it isn't. For some + * "svn:" properties, also validate the @a value, and return + * @c SVN_ERR_BAD_PROPERTY_VALUE if it is not valid. + * + * Use @a pool for temporary allocations. + * + * @note This function is used to implement server-side validation. + * Consequently, if you make this function stricter in what it accepts, you + * (a) break svnsync'ing of existing repositories that contain now-invalid + * properties, (b) do not preclude such invalid values from entering the + * repository via tools that use the svn_fs_* API directly (possibly + * including svnadmin and svnlook). This has happened before and there + * are known (documented, but unsupported) upgrade paths in some cases. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos__validate_prop(const char *name, + const svn_string_t *value, + apr_pool_t *pool); + +/** + * Given the error @a err from svn_repos_fs_commit_txn(), return an + * string containing either or both of the svn_fs_commit_txn() error + * and the SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED wrapped error from + * the post-commit hook. Any error tracing placeholders in the error + * chain are skipped over. + * + * This function does not modify @a err. + * + * ### This method should not be necessary, but there are a few + * ### places, e.g. mod_dav_svn, where only a single error message + * ### string is returned to the caller and it is useful to have both + * ### error messages included in the message. + * + * Use @a pool to do any allocations in. + * + * @since New in 1.7. + */ +const char * +svn_repos__post_commit_error_str(svn_error_t *err, + apr_pool_t *pool); + +/* A repos version of svn_fs_type */ +svn_error_t * +svn_repos__fs_type(const char **fs_type, + const char *repos_path, + apr_pool_t *pool); + + +/* Create a commit editor for REPOS, based on REVISION. */ +svn_error_t * +svn_repos__get_commit_ev2(svn_editor_t **editor, + svn_repos_t *repos, + svn_authz_t *authz, + const char *authz_repos_name, + const char *authz_user, + apr_hash_t *revprops, + svn_commit_callback2_t commit_cb, + void *commit_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +svn_error_t * +svn_repos__replay_ev2(svn_fs_root_t *root, + const char *base_dir, + svn_revnum_t low_water_mark, + svn_editor_t *editor, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *scratch_pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_REPOS_PRIVATE_H */ diff --git a/subversion/include/private/svn_skel.h b/subversion/include/private/svn_skel.h new file mode 100644 index 0000000..5b17b21 --- /dev/null +++ b/subversion/include/private/svn_skel.h @@ -0,0 +1,236 @@ +/* svn_skel.h : interface to `skeleton' functions + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_SKEL_H +#define SVN_SKEL_H + +#include <apr_pools.h> + +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* What is a skel? */ + +/* Subversion needs to read a lot of structured data from database + records. Instead of writing a half-dozen parsers and getting lazy + about error-checking, we define a reasonably dense, open-ended + syntax for strings and lists, and then use that for the concrete + representation of files, directories, property lists, etc. This + lets us handle all the fussy character-by-character testing and + sanity checks all in one place, allowing the users of this library + to focus on higher-level consistency. + + A `skeleton' (or `skel') is either an atom, or a list. A list may + contain zero or more elements, each of which may be an atom or a + list. + + Here's a description of the syntax of a skel: + + A "whitespace" byte is 9, 10, 12, 13, or 32 (ASCII tab, newline, + form feed, carriage return, or space). + + A "digit" byte is 48 -- 57 (ASCII digits). + + A "name" byte is 65 -- 90, or 97 -- 122 (ASCII upper- and + lower-case characters). + + An atom has one the following two forms: + - any string of bytes whose first byte is a name character, and + which contains no whitespace characters, bytes 40 (ASCII '(') or + bytes 41 (ASCII ')') (`implicit-length form'), or + - a string of digit bytes, followed by exactly one whitespace + character, followed by N bytes, where N is the value of the digit + bytes as a decimal number (`explicit-length form'). + + In the first case, the `contents' of the atom are the entire string + of characters. In the second case, the contents of the atom are + the N bytes after the count and whitespace. + + A list consists of a byte 40 (ASCII '('), followed by a series of + atoms or lists, followed by a byte 41 (ASCII ')'). There may be + zero or more whitespace characters after the '(' and before the + ')', and between any pair of elements. If two consecutive elements + are atoms, they must be separated by at least one whitespace + character. */ + + +/* The `skel' structure. */ + +/* A structure representing the results of parsing an array of bytes + as a skel. */ +struct svn_skel_t { + + /* True if the string was an atom, false if it was a list. + + If the string is an atom, DATA points to the beginning of its + contents, and LEN gives the content length, in bytes. + + If the string is a list, DATA and LEN delimit the entire body of + the list. */ + svn_boolean_t is_atom; + + const char *data; + apr_size_t len; + + /* If the string is a list, CHILDREN is a pointer to a + null-terminated linked list of skel objects representing the + elements of the list, linked through their NEXT pointers. */ + struct svn_skel_t *children; + struct svn_skel_t *next; +}; +typedef struct svn_skel_t svn_skel_t; + + + +/* Operations on skels. */ + + +/* Parse the LEN bytes at DATA as the concrete representation of a + skel, and return a skel object allocated from POOL describing its + contents. If the data is not a properly-formed SKEL object, return + zero. + + The returned skel objects point into the block indicated by DATA + and LEN; we don't copy the contents. */ +svn_skel_t *svn_skel__parse(const char *data, apr_size_t len, + apr_pool_t *pool); + + +/* Create an atom skel whose contents are the C string STR, allocated + from POOL. */ +svn_skel_t *svn_skel__str_atom(const char *str, apr_pool_t *pool); + + +/* Create an atom skel whose contents are the LEN bytes at ADDR, + allocated from POOL. */ +svn_skel_t *svn_skel__mem_atom(const void *addr, apr_size_t len, + apr_pool_t *pool); + + +/* Create an empty list skel, allocated from POOL. */ +svn_skel_t *svn_skel__make_empty_list(apr_pool_t *pool); + +/* Duplicates the skel structure SRC_SKEL and if DUP_DATA is true also the + data it references in RESULT_POOL */ +svn_skel_t *svn_skel__dup(const svn_skel_t *src_skel, svn_boolean_t dup_data, + apr_pool_t *result_pool); + + +/* Prepend SKEL to LIST. */ +void svn_skel__prepend(svn_skel_t *skel, svn_skel_t *list); + + +/* Append SKEL to LIST. Note: this must traverse the LIST, so you + generally want to use svn_skel__prepend(). + + NOTE: careful of the argument order here. */ +void svn_skel__append(svn_skel_t *list, svn_skel_t *skel); + + +/* Create an atom skel whose contents are the string representation + of the integer VALUE, allocated in RESULT_POOL, and then prepend + it to SKEL. */ +void svn_skel__prepend_int(apr_int64_t value, + svn_skel_t *skel, + apr_pool_t *result_pool); + + +/* Create an atom skel (allocated from RESULT_POOL) whose contents refer + to the string VALUE, then prepend it to SKEL. + + NOTE: VALUE must have a lifetime *at least* that of RESULT_POOL. This + function does NOT copy it into RESULT_POOL. */ +void svn_skel__prepend_str(const char *value, + svn_skel_t *skel, + apr_pool_t *result_pool); + + +/* Parse SKEL as an integer and return the result in *N. + * SCRATCH_POOL is used for temporary memory. */ +svn_error_t * +svn_skel__parse_int(apr_int64_t *n, const svn_skel_t *skel, + apr_pool_t *scratch_pool); + + +/* Return a string whose contents are a concrete representation of + SKEL. Allocate the string from POOL. */ +svn_stringbuf_t *svn_skel__unparse(const svn_skel_t *skel, apr_pool_t *pool); + + +/* Return true iff SKEL is an atom whose data is the same as STR. */ +svn_boolean_t svn_skel__matches_atom(const svn_skel_t *skel, const char *str); + + +/* Return the length of the list skel SKEL. Atoms have a length of -1. */ +int svn_skel__list_length(const svn_skel_t *skel); + + +/* Parse a `PROPLIST' SKEL into a regular hash of properties, + *PROPLIST_P, which has const char * property names, and + svn_string_t * values. Use RESULT_POOL for all allocations. */ +svn_error_t * +svn_skel__parse_proplist(apr_hash_t **proplist_p, + const svn_skel_t *skel, + apr_pool_t *result_pool); + +/* Parse a `IPROPS' SKEL into a depth-first ordered array of + svn_prop_inherited_item_t * structures *IPROPS. Use RESULT_POOL + for all allocations. */ +svn_error_t * +svn_skel__parse_iprops(apr_array_header_t **iprops, + const svn_skel_t *skel, + apr_pool_t *result_pool); + +/* Parse a `PROPLIST' SKEL looking for PROPNAME. If PROPNAME is found + then return its value in *PROVAL, allocated in RESULT_POOL. */ +svn_error_t * +svn_skel__parse_prop(svn_string_t **propval, + const svn_skel_t *skel, + const char *propname, + apr_pool_t *result_pool); + +/* Unparse a PROPLIST hash (which has const char * property names and + svn_string_t * values) into a `PROPLIST' skel *SKEL_P. Use POOL + for all allocations. */ +svn_error_t * +svn_skel__unparse_proplist(svn_skel_t **skel_p, + const apr_hash_t *proplist, + apr_pool_t *pool); + +/* Unparse INHERITED_PROPS, a depth-first ordered array of + svn_prop_inherited_item_t * structures, into a `IPROPS' skel *SKEL_P. + Use RESULT_POOL for all allocations. */ +svn_error_t * +svn_skel__unparse_iproplist(svn_skel_t **skel_p, + const apr_array_header_t *inherited_props, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_SKEL_H */ diff --git a/subversion/include/private/svn_sqlite.h b/subversion/include/private/svn_sqlite.h new file mode 100644 index 0000000..c1d640b --- /dev/null +++ b/subversion/include/private/svn_sqlite.h @@ -0,0 +1,519 @@ +/* svn_sqlite.h + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + + +#ifndef SVN_SQLITE_H +#define SVN_SQLITE_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_checksum.h" +#include "svn_error.h" + +#include "private/svn_token.h" /* for svn_token_map_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Because the SQLite code can be inlined into libsvn_subre/sqlite.c, + we define accessors to its compile-time and run-time version + numbers here. */ + +/* Return the value that SQLITE_VERSION had at compile time. */ +const char *svn_sqlite__compiled_version(void); + +/* Return the value of sqlite3_libversion() at run time. */ +const char *svn_sqlite__runtime_version(void); + + +typedef struct svn_sqlite__db_t svn_sqlite__db_t; +typedef struct svn_sqlite__stmt_t svn_sqlite__stmt_t; +typedef struct svn_sqlite__context_t svn_sqlite__context_t; +typedef struct svn_sqlite__value_t svn_sqlite__value_t; + +typedef enum svn_sqlite__mode_e { + svn_sqlite__mode_readonly, /* open the database read-only */ + svn_sqlite__mode_readwrite, /* open the database read-write */ + svn_sqlite__mode_rwcreate /* open/create the database read-write */ +} svn_sqlite__mode_t; + +/* The type used for callback functions. */ +typedef svn_error_t *(*svn_sqlite__func_t)(svn_sqlite__context_t *sctx, + int argc, + svn_sqlite__value_t *values[], + apr_pool_t *scatch_pool); + + +/* Step the given statement; if it returns SQLITE_DONE, reset the statement. + Otherwise, raise an SVN error. */ +svn_error_t * +svn_sqlite__step_done(svn_sqlite__stmt_t *stmt); + +/* Step the given statement; raise an SVN error (and reset the + statement) if it doesn't return SQLITE_ROW. */ +svn_error_t * +svn_sqlite__step_row(svn_sqlite__stmt_t *stmt); + +/* Step the given statement; raise an SVN error (and reset the + statement) if it doesn't return SQLITE_DONE or SQLITE_ROW. Set + *GOT_ROW to true iff it got SQLITE_ROW. +*/ +svn_error_t * +svn_sqlite__step(svn_boolean_t *got_row, svn_sqlite__stmt_t *stmt); + +/* Perform an insert as given by the prepared and bound STMT, and set + *ROW_ID to the id of the inserted row if ROW_ID is non-NULL. + STMT will be reset prior to returning. */ +svn_error_t * +svn_sqlite__insert(apr_int64_t *row_id, svn_sqlite__stmt_t *stmt); + +/* Perform an update/delete and then return the number of affected rows. + If AFFECTED_ROWS is not NULL, then set *AFFECTED_ROWS to the + number of rows changed. + STMT will be reset prior to returning. */ +svn_error_t * +svn_sqlite__update(int *affected_rows, svn_sqlite__stmt_t *stmt); + +/* Return in *VERSION the version of the schema in DB. Use SCRATCH_POOL + for temporary allocations. */ +svn_error_t * +svn_sqlite__read_schema_version(int *version, + svn_sqlite__db_t *db, + apr_pool_t *scratch_pool); + + + +/* Open a connection in *DB to the database at PATH. Validate the schema, + creating/upgrading to LATEST_SCHEMA if needed using the instructions + in UPGRADE_SQL. The resulting DB is allocated in RESULT_POOL, and any + temporary allocations are made in SCRATCH_POOL. + + STATEMENTS is an array of strings which may eventually be executed, the + last element of which should be NULL. These strings and the array itself + are not duplicated internally, and should have a lifetime at least as long + as RESULT_POOL. + STATEMENTS itself may be NULL, in which case it has no impact. + See svn_sqlite__get_statement() for how these strings are used. + + The statements will be finalized and the SQLite database will be closed + when RESULT_POOL is cleaned up. */ +svn_error_t * +svn_sqlite__open(svn_sqlite__db_t **db, const char *repos_path, + svn_sqlite__mode_t mode, const char * const statements[], + int latest_schema, const char * const *upgrade_sql, + apr_pool_t *result_pool, apr_pool_t *scratch_pool); + +/* Explicitly close the connection in DB. */ +svn_error_t * +svn_sqlite__close(svn_sqlite__db_t *db); + +/* Add a custom function to be used with this database connection. The data + in BATON should live at least as long as the connection in DB. */ +svn_error_t * +svn_sqlite__create_scalar_function(svn_sqlite__db_t *db, + const char *func_name, + int argc, + svn_sqlite__func_t func, + void *baton); + +/* Execute the (multiple) statements in the STATEMENTS[STMT_IDX] string. */ +svn_error_t * +svn_sqlite__exec_statements(svn_sqlite__db_t *db, int stmt_idx); + +/* Return the statement in *STMT which has been prepared from the + STATEMENTS[STMT_IDX] string, where STATEMENTS is the array that was + passed to svn_sqlite__open(). This statement is allocated in the same + pool as the DB, and will be cleaned up when DB is closed. */ +svn_error_t * +svn_sqlite__get_statement(svn_sqlite__stmt_t **stmt, svn_sqlite__db_t *db, + int stmt_idx); + + +/* --------------------------------------------------------------------- + + BINDING VALUES + +*/ + +/* Bind values to SQL parameters in STMT, according to FMT. FMT may contain: + + Spec Argument type Item type + ---- ----------------- --------- + n <none, absent> Column assignment skip + d int Number + L apr_int64_t Number + i apr_int64_t Number (deprecated format spec) + s const char * String + b const void * Blob data + apr_size_t Blob length + r svn_revnum_t Revision number + t const svn_token_map_t * Token mapping table + int Token value + + Each character in FMT maps to one SQL parameter, and one or two function + parameters, in the order they appear. +*/ +svn_error_t * +svn_sqlite__bindf(svn_sqlite__stmt_t *stmt, const char *fmt, ...); + +/* Error-handling wrapper around sqlite3_bind_int. */ +svn_error_t * +svn_sqlite__bind_int(svn_sqlite__stmt_t *stmt, int slot, int val); + +/* Error-handling wrapper around sqlite3_bind_int64. */ +svn_error_t * +svn_sqlite__bind_int64(svn_sqlite__stmt_t *stmt, int slot, + apr_int64_t val); + +/* Error-handling wrapper around sqlite3_bind_text. VAL cannot contain + zero bytes; we always pass SQLITE_TRANSIENT. */ +svn_error_t * +svn_sqlite__bind_text(svn_sqlite__stmt_t *stmt, int slot, + const char *val); + +/* Error-handling wrapper around sqlite3_bind_blob. */ +svn_error_t * +svn_sqlite__bind_blob(svn_sqlite__stmt_t *stmt, + int slot, + const void *val, + apr_size_t len); + +/* Look up VALUE in MAP, and bind the resulting token word at SLOT. */ +svn_error_t * +svn_sqlite__bind_token(svn_sqlite__stmt_t *stmt, + int slot, + const svn_token_map_t *map, + int value); + +/* Bind the value to SLOT, unless SVN_IS_VALID_REVNUM(value) is false, + in which case it binds NULL. */ +svn_error_t * +svn_sqlite__bind_revnum(svn_sqlite__stmt_t *stmt, int slot, + svn_revnum_t value); + +/* Bind a set of properties to the given slot. If PROPS is NULL, then no + binding will occur. PROPS will be stored as a serialized skel. */ +svn_error_t * +svn_sqlite__bind_properties(svn_sqlite__stmt_t *stmt, + int slot, + const apr_hash_t *props, + apr_pool_t *scratch_pool); + +/* Bind a set of inherited properties to the given slot. If INHERITED_PROPS + is NULL, then no binding will occur. INHERITED_PROPS will be stored as a + serialized skel. */ +svn_error_t * +svn_sqlite__bind_iprops(svn_sqlite__stmt_t *stmt, + int slot, + const apr_array_header_t *inherited_props, + apr_pool_t *scratch_pool); + +/* Bind a checksum's value to the given slot. If CHECKSUM is NULL, then no + binding will occur. */ +svn_error_t * +svn_sqlite__bind_checksum(svn_sqlite__stmt_t *stmt, + int slot, + const svn_checksum_t *checksum, + apr_pool_t *scratch_pool); + + +/* --------------------------------------------------------------------- + + FETCHING VALUES + +*/ + +/* Wrapper around sqlite3_column_blob and sqlite3_column_bytes. The return + value will be NULL if the column is null. + + If RESULT_POOL is not NULL, allocate the return value (if any) in it. + If RESULT_POOL is NULL, the return value will be valid until an + invocation of svn_sqlite__column_* performs a data type conversion (as + described in the SQLite documentation) or the statement is stepped or + reset or finalized. */ +const void * +svn_sqlite__column_blob(svn_sqlite__stmt_t *stmt, int column, + apr_size_t *len, apr_pool_t *result_pool); + +/* Wrapper around sqlite3_column_text. If the column is null, then the + return value will be NULL. + + If RESULT_POOL is not NULL, allocate the return value (if any) in it. + If RESULT_POOL is NULL, the return value will be valid until an + invocation of svn_sqlite__column_* performs a data type conversion (as + described in the SQLite documentation) or the statement is stepped or + reset or finalized. */ +const char * +svn_sqlite__column_text(svn_sqlite__stmt_t *stmt, int column, + apr_pool_t *result_pool); + +/* Wrapper around sqlite3_column_int64. If the column is null, then the + return value will be SVN_INVALID_REVNUM. */ +svn_revnum_t +svn_sqlite__column_revnum(svn_sqlite__stmt_t *stmt, int column); + +/* Wrapper around sqlite3_column_int64. If the column is null, then the + return value will be FALSE. */ +svn_boolean_t +svn_sqlite__column_boolean(svn_sqlite__stmt_t *stmt, int column); + +/* Wrapper around sqlite3_column_int. If the column is null, then the + return value will be 0. */ +int +svn_sqlite__column_int(svn_sqlite__stmt_t *stmt, int column); + +/* Wrapper around sqlite3_column_int64. If the column is null, then the + return value will be 0. */ +apr_int64_t +svn_sqlite__column_int64(svn_sqlite__stmt_t *stmt, int column); + +/* Fetch the word at COLUMN, look it up in the MAP, and return its value. + MALFUNCTION is thrown if the column is null or contains an unknown word. */ +int +svn_sqlite__column_token(svn_sqlite__stmt_t *stmt, + int column, + const svn_token_map_t *map); + +/* Fetch the word at COLUMN, look it up in the MAP, and return its value. + Returns NULL_VAL if the column is null. MALFUNCTION is thrown if the + column contains an unknown word. */ +int +svn_sqlite__column_token_null(svn_sqlite__stmt_t *stmt, + int column, + const svn_token_map_t *map, + int null_val); + +/* Return the column as a hash of const char * => const svn_string_t *. + If the column is null, then set *PROPS to NULL. The + results will be allocated in RESULT_POOL, and any temporary allocations + will be made in SCRATCH_POOL. */ +svn_error_t * +svn_sqlite__column_properties(apr_hash_t **props, + svn_sqlite__stmt_t *stmt, + int column, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Return the column as an array of depth-first ordered array of + svn_prop_inherited_item_t * structures. If the column is null, then + set *IPROPS to NULL. The results will be allocated in RESULT_POOL, + and any temporary allocations will be made in SCRATCH_POOL. */ +svn_error_t * +svn_sqlite__column_iprops(apr_array_header_t **iprops, + svn_sqlite__stmt_t *stmt, + int column, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Return the column as a checksum. If the column is null, then NULL will + be stored into *CHECKSUM. The result will be allocated in RESULT_POOL. */ +svn_error_t * +svn_sqlite__column_checksum(const svn_checksum_t **checksum, + svn_sqlite__stmt_t *stmt, + int column, + apr_pool_t *result_pool); + +/* Return TRUE if the result of selecting the column is null, + FALSE otherwise */ +svn_boolean_t +svn_sqlite__column_is_null(svn_sqlite__stmt_t *stmt, int column); + +/* Return the number of bytes the column uses in a text or blob representation. + 0 for NULL columns. */ +int +svn_sqlite__column_bytes(svn_sqlite__stmt_t *stmt, int column); + + +/* --------------------------------------------------------------------- */ + +#define SVN_SQLITE__INTEGER 1 +#define SVN_SQLITE__FLOAT 2 +#define SVN_SQLITE__TEXT 3 +#define SVN_SQLITE__BLOB 4 +#define SVN_SQLITE__NULL 5 + +/* */ +int +svn_sqlite__value_type(svn_sqlite__value_t *val); + +/* */ +const char * +svn_sqlite__value_text(svn_sqlite__value_t *val); + + +/* --------------------------------------------------------------------- */ + +/* */ +void +svn_sqlite__result_null(svn_sqlite__context_t *sctx); + +void +svn_sqlite__result_int64(svn_sqlite__context_t *sctx, apr_int64_t val); + + +/* --------------------------------------------------------------------- */ + + +/* Error-handling wrapper around sqlite3_finalize. */ +svn_error_t * +svn_sqlite__finalize(svn_sqlite__stmt_t *stmt); + +/* Reset STMT by calling sqlite3_reset(), and also clear any bindings to it. + + Note: svn_sqlite__get_statement() calls this function automatically if + the requested statement has been used and has not yet been reset. */ +svn_error_t * +svn_sqlite__reset(svn_sqlite__stmt_t *stmt); + + +/* Begin a transaction in DB. */ +svn_error_t * +svn_sqlite__begin_transaction(svn_sqlite__db_t *db); + +/* Like svn_sqlite__begin_transaction(), but takes out a 'RESERVED' lock + immediately, instead of using the default deferred locking scheme. */ +svn_error_t * +svn_sqlite__begin_immediate_transaction(svn_sqlite__db_t *db); + +/* Begin a savepoint in DB. */ +svn_error_t * +svn_sqlite__begin_savepoint(svn_sqlite__db_t *db); + +/* Commit the current transaction in DB if ERR is SVN_NO_ERROR, otherwise + * roll back the transaction. Return a composition of ERR and any error + * that may occur during the commit or roll-back. */ +svn_error_t * +svn_sqlite__finish_transaction(svn_sqlite__db_t *db, + svn_error_t *err); + +/* Release the current savepoint in DB if EXPR is SVN_NO_ERROR, otherwise + * roll back to the savepoint and then release it. Return a composition of + * ERR and any error that may occur during the release or roll-back. */ +svn_error_t * +svn_sqlite__finish_savepoint(svn_sqlite__db_t *db, + svn_error_t *err); + +/* Evaluate the expression EXPR within a transaction. + * + * Begin a transaction in DB; evaluate the expression EXPR, which would + * typically be a function call that does some work in DB; finally commit + * the transaction if EXPR evaluated to SVN_NO_ERROR, otherwise roll back + * the transaction. + */ +#define SVN_SQLITE__WITH_TXN(expr, db) \ + do { \ + svn_sqlite__db_t *svn_sqlite__db = (db); \ + svn_error_t *svn_sqlite__err; \ + \ + SVN_ERR(svn_sqlite__begin_transaction(svn_sqlite__db)); \ + svn_sqlite__err = (expr); \ + SVN_ERR(svn_sqlite__finish_transaction(svn_sqlite__db, svn_sqlite__err)); \ + } while (0) + +/* Callback function to for use with svn_sqlite__with_transaction(). */ +typedef svn_error_t *(*svn_sqlite__transaction_callback_t)( + void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool); + +/* Helper function to handle SQLite transactions. All the work done inside + CB_FUNC will be wrapped in an SQLite transaction, which will be committed + if CB_FUNC does not return an error. If any error is returned from CB_FUNC, + the transaction will be rolled back. DB and CB_BATON will be passed to + CB_FUNC. SCRATCH_POOL will be passed to the callback (NULL is valid). */ +svn_error_t * +svn_sqlite__with_transaction(svn_sqlite__db_t *db, + svn_sqlite__transaction_callback_t cb_func, + void *cb_baton, apr_pool_t *scratch_pool); + +/* Like SVN_SQLITE__WITH_TXN(), but takes out a 'RESERVED' lock + immediately, instead of using the default deferred locking scheme. */ +#define SVN_SQLITE__WITH_IMMEDIATE_TXN(expr, db) \ + do { \ + svn_sqlite__db_t *svn_sqlite__db = (db); \ + svn_error_t *svn_sqlite__err; \ + \ + SVN_ERR(svn_sqlite__begin_immediate_transaction(svn_sqlite__db)); \ + svn_sqlite__err = (expr); \ + SVN_ERR(svn_sqlite__finish_transaction(svn_sqlite__db, svn_sqlite__err)); \ + } while (0) + +/* Like svn_sqlite__with_transaction(), but takes out a 'RESERVED' lock + immediately, instead of using the default deferred locking scheme. */ +svn_error_t * +svn_sqlite__with_immediate_transaction(svn_sqlite__db_t *db, + svn_sqlite__transaction_callback_t cb_func, + void *cb_baton, + apr_pool_t *scratch_pool); + +/* Evaluate the expression EXPR within a 'savepoint'. Savepoints can be + * nested. + * + * Begin a savepoint in DB; evaluate the expression EXPR, which would + * typically be a function call that does some work in DB; finally release + * the savepoint if EXPR evaluated to SVN_NO_ERROR, otherwise roll back + * to the savepoint and then release it. + */ +#define SVN_SQLITE__WITH_LOCK(expr, db) \ + do { \ + svn_sqlite__db_t *svn_sqlite__db = (db); \ + svn_error_t *svn_sqlite__err; \ + \ + SVN_ERR(svn_sqlite__begin_savepoint(svn_sqlite__db)); \ + svn_sqlite__err = (expr); \ + SVN_ERR(svn_sqlite__finish_savepoint(svn_sqlite__db, svn_sqlite__err)); \ + } while (0) + +/* Helper function to handle several SQLite operations inside a shared lock. + This callback is similar to svn_sqlite__with_transaction(), but can be + nested (even with a transaction). + + Using this function as a wrapper around a group of operations can give a + *huge* performance boost as the shared-read lock will be shared over + multiple statements, instead of being reobtained every time, which may + require disk and/or network io, depending on SQLite's locking strategy. + + SCRATCH_POOL will be passed to the callback (NULL is valid). + + ### Since we now require SQLite >= 3.6.18, this function has the effect of + always behaving like a defered transaction. Can it be combined with + svn_sqlite__with_transaction()? + */ +svn_error_t * +svn_sqlite__with_lock(svn_sqlite__db_t *db, + svn_sqlite__transaction_callback_t cb_func, + void *cb_baton, + apr_pool_t *scratch_pool); + + +/* Hotcopy an SQLite database from SRC_PATH to DST_PATH. */ +svn_error_t * +svn_sqlite__hotcopy(const char *src_path, + const char *dst_path, + apr_pool_t *scratch_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_SQLITE_H */ diff --git a/subversion/include/private/svn_string_private.h b/subversion/include/private/svn_string_private.h new file mode 100644 index 0000000..8579f4d --- /dev/null +++ b/subversion/include/private/svn_string_private.h @@ -0,0 +1,222 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_string_private.h + * @brief Non-public string utility functions. + */ + + +#ifndef SVN_STRING_PRIVATE_H +#define SVN_STRING_PRIVATE_H + +#include "svn_string.h" /* for svn_boolean_t, svn_error_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup svn_string String handling + * @{ + */ + + +/** Private functions. + * + * @defgroup svn_string_private Private functions + * @{ + */ + + +/** A self-contained memory buffer of known size. + * + * Intended to be used where a single variable-sized buffer is needed + * within an iteration, a scratch pool is available and we want to + * avoid the cost of creating another pool just for the iteration. + */ +typedef struct svn_membuf_t +{ + /** The a pool from which this buffer was originally allocated, and is not + * necessarily specific to this buffer. This is used only for allocating + * more memory from when the buffer needs to grow. + */ + apr_pool_t *pool; + + /** pointer to the memory */ + void *data; + + /** total size of buffer allocated */ + apr_size_t size; +} svn_membuf_t; + + +/* Initialize a memory buffer of the given size */ +void +svn_membuf__create(svn_membuf_t *membuf, apr_size_t size, apr_pool_t *pool); + +/* Ensure that the given memory buffer has at least the given size */ +void +svn_membuf__ensure(svn_membuf_t *membuf, apr_size_t size); + +/* Resize the given memory buffer, preserving its contents. */ +void +svn_membuf__resize(svn_membuf_t *membuf, apr_size_t size); + +/* Zero-fill the given memory */ +void +svn_membuf__zero(svn_membuf_t *membuf); + +/* Zero-fill the given memory buffer up to the smaller of SIZE and the + current buffer size. */ +void +svn_membuf__nzero(svn_membuf_t *membuf, apr_size_t size); + +/* Inline implementation of svn_membuf__zero. + * Note that PMEMBUF is evaluated only once. + */ +#define SVN_MEMBUF__ZERO(pmembuf) \ + do \ + { \ + svn_membuf_t *const _m_b_f_ = (pmembuf); \ + memset(_m_b_f_->data, 0, _m_b_f_->size); \ + } \ + while(0) + +/* Inline implementation of svn_membuf__nzero + * Note that PMEMBUF and PSIZE are evaluated only once. + */ +#define SVN_MEMBUF__NZERO(pmembuf, psize) \ + do \ + { \ + svn_membuf_t *const _m_b_f_ = (pmembuf); \ + const apr_size_t _s_z_ = (psize); \ + if (_s_z_ > _m_b_f_->size) \ + memset(_m_b_f_->data, 0, _m_b_f_->size); \ + else \ + memset(_m_b_f_->data, 0, _s_z_); \ + } \ + while(0) + +#ifndef SVN_DEBUG +/* In non-debug mode, just use these inlie replacements */ +#define svn_membuf__zero(B) SVN_MEMBUF__ZERO((B)) +#define svn_membuf__nzero(B, S) SVN_MEMBUF__NZERO((B), (S)) +#endif + + +/** Returns the #svn_string_t information contained in the data and + * len members of @a strbuf. This is effectively a typecast, converting + * @a strbuf into an #svn_string_t. This first will become invalid and must + * not be accessed after this function returned. + */ +svn_string_t * +svn_stringbuf__morph_into_string(svn_stringbuf_t *strbuf); + +/** Like apr_strtoff but provided here for backward compatibility + * with APR 0.9 */ +apr_status_t +svn__strtoff(apr_off_t *offset, const char *buf, char **end, int base); + +/** Number of chars needed to represent signed (19 places + sign + NUL) or + * unsigned (20 places + NUL) integers as strings. + */ +#define SVN_INT64_BUFFER_SIZE 21 + +/** Writes the @a number as string into @a dest. The latter must provide + * space for at least #SVN_INT64_BUFFER_SIZE characters. Returns the number + * chars written excluding the terminating NUL. + */ +apr_size_t +svn__ui64toa(char * dest, apr_uint64_t number); + +/** Writes the @a number as string into @a dest. The latter must provide + * space for at least #SVN_INT64_BUFFER_SIZE characters. Returns the number + * chars written excluding the terminating NUL. + */ +apr_size_t +svn__i64toa(char * dest, apr_int64_t number); + +/** Returns a decimal string for @a number allocated in @a pool. Put in + * the @a seperator at each third place. + */ +char * +svn__ui64toa_sep(apr_uint64_t number, char seperator, apr_pool_t *pool); + +/** Returns a decimal string for @a number allocated in @a pool. Put in + * the @a seperator at each third place. + */ +char * +svn__i64toa_sep(apr_int64_t number, char seperator, apr_pool_t *pool); + +/** + * Computes the similarity score of STRA and STRB. Returns the ratio + * of the length of their longest common subsequence and the average + * length of the strings, normalized to the range [0..1000]. + * The result is equivalent to Python's + * + * difflib.SequenceMatcher.ratio + * + * Optionally sets *RLCS to the length of the longest common + * subsequence of STRA and STRB. Using BUFFER for temporary storage, + * requires memory proportional to the length of the shorter string. + * + * The LCS algorithm used is described in, e.g., + * + * http://en.wikipedia.org/wiki/Longest_common_subsequence_problem + * + * Q: Why another LCS when we already have one in libsvn_diff? + * A: svn_diff__lcs is too heavyweight and too generic for the + * purposes of similarity testing. Whilst it would be possible + * to use a character-based tokenizer with it, we really only need + * the *length* of the LCS for the similarity score, not all the + * other information that svn_diff__lcs produces in order to + * make printing diffs possible. + * + * Q: Is there a limit on the length of the string parameters? + * A: Only available memory. But note that the LCS algorithm used + * has O(strlen(STRA) * strlen(STRB)) worst-case performance, + * so do keep a rein on your enthusiasm. + */ +unsigned int +svn_cstring__similarity(const char *stra, const char *strb, + svn_membuf_t *buffer, apr_size_t *rlcs); + +/** + * Like svn_cstring__similarity, but accepts svn_string_t's instead + * of NUL-terminated character strings. + */ +unsigned int +svn_string__similarity(const svn_string_t *stringa, + const svn_string_t *stringb, + svn_membuf_t *buffer, apr_size_t *rlcs); + + +/** @} */ + +/** @} */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_STRING_PRIVATE_H */ diff --git a/subversion/include/private/svn_subr_private.h b/subversion/include/private/svn_subr_private.h new file mode 100644 index 0000000..a45e664 --- /dev/null +++ b/subversion/include/private/svn_subr_private.h @@ -0,0 +1,340 @@ +/* + * svn_subr_private.h : private definitions from libsvn_subr + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_SUBR_PRIVATE_H +#define SVN_SUBR_PRIVATE_H + +#include "svn_types.h" +#include "svn_io.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Spill-to-file Buffers + * + * @defgroup svn_spillbuf_t Spill-to-file Buffers + * @{ + */ + +/** A buffer that collects blocks of content, possibly using a file. + * + * The spill-buffer is created with two basic parameters: the size of the + * blocks that will be written into the spill-buffer ("blocksize"), and + * the (approximate) maximum size that will be allowed in memory ("maxsize"). + * Once the maxsize is reached, newly written content will be "spilled" + * into a temporary file. + * + * When writing, content will be buffered into memory unless a given write + * will cause the amount of in-memory content to exceed the specified + * maxsize. At that point, the file is created, and the content will be + * written to that file. + * + * To read information back out of a spill buffer, there are two approaches + * available to the application: + * + * *) reading blocks using svn_spillbuf_read() (a "pull" model) + * *) having blocks passed to a callback via svn_spillbuf_process() + * (a "push" model to your application) + * + * In both cases, the spill-buffer will provide you with a block of N bytes + * that you must fully consume before asking for more data. The callback + * style provides for a "stop" parameter to temporarily pause the reading + * until another read is desired. The two styles of reading may be mixed, + * as the caller desires. Generally, N will be the blocksize, and will be + * less when the end of the content is reached. + * + * For a more stream-oriented style of reading, where the caller specifies + * the number of bytes to read into a caller-provided buffer, please see + * svn_spillbuf_reader_t. That overlaid type will cause more memory copies + * to be performed (whereas the bare spill-buffer type hands you a buffer + * to consume). + * + * Writes may be interleaved with reading, and content will be returned + * in a FIFO manner. Thus, if content has been placed into the spill-buffer + * you will always read the earliest-written data, and any newly-written + * content will be appended to the buffer. + * + * Note: the file is created in the same pool where the spill-buffer was + * created. If the content is completely read from that file, it will be + * closed and deleted. Should writing further content cause another spill + * file to be created, that will increase the size of the pool. There is + * no bound on the amount of file-related resources that may be consumed + * from the pool. It is entirely related to the read/write pattern and + * whether spill files are repeatedly created. + */ +typedef struct svn_spillbuf_t svn_spillbuf_t; + + +/* Create a spill buffer. */ +svn_spillbuf_t * +svn_spillbuf__create(apr_size_t blocksize, + apr_size_t maxsize, + apr_pool_t *result_pool); + + +/* Determine how much content is stored in the spill buffer. */ +svn_filesize_t +svn_spillbuf__get_size(const svn_spillbuf_t *buf); + + +/* Write some data into the spill buffer. */ +svn_error_t * +svn_spillbuf__write(svn_spillbuf_t *buf, + const char *data, + apr_size_t len, + apr_pool_t *scratch_pool); + + +/* Read a block of memory from the spill buffer. @a *data will be set to + NULL if no content remains. Otherwise, @a data and @a len will point to + data that must be fully-consumed by the caller. This data will remain + valid until another call to svn_spillbuf_write(), svn_spillbuf_read(), + or svn_spillbuf_process(), or if the spill buffer's pool is cleared. */ +svn_error_t * +svn_spillbuf__read(const char **data, + apr_size_t *len, + svn_spillbuf_t *buf, + apr_pool_t *scratch_pool); + + +/* Callback for reading content out of the spill buffer. Set @a stop if + you want to stop the processing (and will call svn_spillbuf_process + again, at a later time). */ +typedef svn_error_t * (*svn_spillbuf_read_t)(svn_boolean_t *stop, + void *baton, + const char *data, + apr_size_t len, + apr_pool_t *scratch_pool); + + +/* Process the content stored in the spill buffer. @a exhausted will be + set to TRUE if all of the content is processed by @a read_func. This + function may return early if the callback returns TRUE for its 'stop' + parameter. */ +svn_error_t * +svn_spillbuf__process(svn_boolean_t *exhausted, + svn_spillbuf_t *buf, + svn_spillbuf_read_t read_func, + void *read_baton, + apr_pool_t *scratch_pool); + + +/** Classic stream reading layer on top of spill-buffers. + * + * This type layers upon a spill-buffer to enable a caller to read a + * specified number of bytes into the caller's provided buffer. This + * implies more memory copies than the standard spill-buffer reading + * interface, but is sometimes required by spill-buffer users. + */ +typedef struct svn_spillbuf_reader_t svn_spillbuf_reader_t; + + +/* Create a spill-buffer and a reader for it. */ +svn_spillbuf_reader_t * +svn_spillbuf__reader_create(apr_size_t blocksize, + apr_size_t maxsize, + apr_pool_t *result_pool); + + +/* Read @a len bytes from @a reader into @a data. The number of bytes + actually read is stored in @a amt. If the content is exhausted, then + @a amt is set to zero. It will always be non-zero if the spill-buffer + contains content. + + If @a len is zero, then SVN_ERR_INCORRECT_PARAMS is returned. */ +svn_error_t * +svn_spillbuf__reader_read(apr_size_t *amt, + svn_spillbuf_reader_t *reader, + char *data, + apr_size_t len, + apr_pool_t *scratch_pool); + + +/* Read a single character from @a reader, and place it in @a c. If there + is no content in the spill-buffer, then SVN_ERR_STREAM_UNEXPECTED_EOF + is returned. */ +svn_error_t * +svn_spillbuf__reader_getc(char *c, + svn_spillbuf_reader_t *reader, + apr_pool_t *scratch_pool); + + +/* Write @a len bytes from @a data into the spill-buffer in @a reader. */ +svn_error_t * +svn_spillbuf__reader_write(svn_spillbuf_reader_t *reader, + const char *data, + apr_size_t len, + apr_pool_t *scratch_pool); + + +/* Return a stream built on top of a spillbuf, using the same arguments as + svn_spillbuf__create(). This stream can be used for reading and writing, + but implements the same basic sematics of a spillbuf for the underlying + storage. */ +svn_stream_t * +svn_stream__from_spillbuf(apr_size_t blocksize, + apr_size_t maxsize, + apr_pool_t *result_pool); + +/** @} */ + +/** + * Internal function for creating a MD5 checksum from a binary digest. + * + * @since New in 1.8 + */ +svn_checksum_t * +svn_checksum__from_digest_md5(const unsigned char *digest, + apr_pool_t *result_pool); + +/** + * Internal function for creating a SHA1 checksum from a binary + * digest. + * + * @since New in 1.8 + */ +svn_checksum_t * +svn_checksum__from_digest_sha1(const unsigned char *digest, + apr_pool_t *result_pool); + + +/** + * @defgroup svn_hash_support Hash table serialization support + * @{ + */ + +/*----------------------------------------------------*/ + +/** + * @defgroup svn_hash_misc Miscellaneous hash APIs + * @{ + */ + +/** @} */ + + +/** + * @defgroup svn_hash_getters Specialized getter APIs for hashes + * @{ + */ + +/** Find the value of a @a key in @a hash, return the value. + * + * If @a hash is @c NULL or if the @a key cannot be found, the + * @a default_value will be returned. + * + * @since New in 1.7. + */ +const char * +svn_hash__get_cstring(apr_hash_t *hash, + const char *key, + const char *default_value); + +/** Like svn_hash_get_cstring(), but for boolean values. + * + * Parses the value as a boolean value. The recognized representations + * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not + * matter. + * + * @since New in 1.7. + */ +svn_boolean_t +svn_hash__get_bool(apr_hash_t *hash, + const char *key, + svn_boolean_t default_value); + +/** @} */ + +/** + * @defgroup svn_hash_create Create optimized APR hash tables + * @{ + */ + +/** Returns a hash table, allocated in @a pool, with the same ordering of + * elements as APR 1.4.5 or earlier (using apr_hashfunc_default) but uses + * a faster hash function implementation. + * + * @since New in 1.8. + */ +apr_hash_t * +svn_hash__make(apr_pool_t *pool); + +/** @} */ + +/** @} */ + + +/** Apply the changes described by @a prop_changes to @a original_props and + * return the result. The inverse of svn_prop_diffs(). + * + * Allocate the resulting hash from @a pool, but allocate its keys and + * values from @a pool and/or by reference to the storage of the inputs. + * + * Note: some other APIs use an array of pointers to svn_prop_t. + * + * @since New in 1.8. + */ +apr_hash_t * +svn_prop__patch(const apr_hash_t *original_props, + const apr_array_header_t *prop_changes, + apr_pool_t *pool); + + +/** + * @defgroup svn_version Version number dotted triplet parsing + * @{ + */ + +/* Set @a *version to a version structure parsed from the version + * string representation in @a version_string. Return + * @c SVN_ERR_MALFORMED_VERSION_STRING if the string fails to parse + * cleanly. + * + * @since New in 1.8. + */ +svn_error_t * +svn_version__parse_version_string(svn_version_t **version, + const char *version_string, + apr_pool_t *result_pool); + +/* Return true iff @a version represents a version number of at least + * the level represented by @a major, @a minor, and @a patch. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_version__at_least(svn_version_t *version, + int major, + int minor, + int patch); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_SUBR_PRIVATE_H */ diff --git a/subversion/include/private/svn_temp_serializer.h b/subversion/include/private/svn_temp_serializer.h new file mode 100644 index 0000000..7a007c3 --- /dev/null +++ b/subversion/include/private/svn_temp_serializer.h @@ -0,0 +1,207 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_temp_serializer.h + * @brief Helper API for serializing _temporarily_ data structures. + * + * @note This API is intended for efficient serialization and duplication + * of temporary, e.g. cached, data structures ONLY. It is not + * suitable for persistent data. + */ + +#ifndef SVN_TEMP_SERIALIZER_H +#define SVN_TEMP_SERIALIZER_H + +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* forward declaration */ +struct svn_stringbuf_t; + +/** + * The amount of extra memory allocated by #svn_temp_serializer__init for + * the internal buffer in addition to its suggested_buffer_size parameter. + * To allocate a 512 buffer, including overhead, just specify a size of + * 512 - SVN_TEMP_SERIALIZER__OVERHEAD. + */ +#define SVN_TEMP_SERIALIZER__OVERHEAD (sizeof(svn_stringbuf_t) + 1) + +/** + * Opaque structure controlling the serialization process and holding the + * intermediate as well as final results. + */ +typedef struct svn_temp_serializer__context_t svn_temp_serializer__context_t; + +/** + * Begin the serialization process for the @a source_struct and all objects + * referenced from it. @a struct_size must match the result of @c sizeof() + * of the actual structure. Due to the generic nature of the init function + * we can't determine the structure size as part of the function. + * + * It is possible to specify a @c NULL source_struct in which case the first + * call to svn_temp_serializer__push() will provide the root struct. + * Alternatively, one may even call svn_temp_serializer__add_string() + * but there is generally no point in doing so because the result will be + * simple string object in a #svn_stringbuf_t. + * + * You may suggest a larger initial buffer size in @a suggested_buffer_size + * to minimize the number of internal buffer re-allocations during the + * serialization process. All allocations will be made from @a pool. + * + * Pointers within the structure will be replaced by their serialized + * representation when the respective strings or sub-structures get + * serialized. This scheme allows only for tree-like, i.e. non-circular + * data structures. + * + * @return the serialization context. + */ +svn_temp_serializer__context_t * +svn_temp_serializer__init(const void *source_struct, + apr_size_t struct_size, + apr_size_t suggested_buffer_size, + apr_pool_t *pool); + +/** + * Continue the serialization process of the @a source_struct that has + * already been serialized to @a buffer but contains references to new + * objects yet to serialize. I.e. this function allows you to append + * data to serialized structures returned by svn_temp_serializer__get(). + * + * The current size of the serialized data is given in @a currently_used. + * If the allocated data buffer is actually larger, you may specifiy that + * size in @a currently_allocated to prevent unnecessary re-allocations. + * Otherwise, set it to 0. + * + * All allocations will be made from @a pool. + * + * Please note that only sub-structures of @a source_struct may be added. + * To add item referenced from other parts of the buffer, serialize from + * @a source_struct first, get the result from svn_temp_serializer__get() + * and call svn_temp_serializer__init_append for the next part. + * + * @return the serialization context. + */ +svn_temp_serializer__context_t * +svn_temp_serializer__init_append(void *buffer, + void *source_struct, + apr_size_t currently_used, + apr_size_t currently_allocated, + apr_pool_t *pool); + +/** + * Begin serialization of a referenced sub-structure within the + * serialization @a context. @a source_struct must be a reference to the + * pointer in the original parent structure so that the correspondence in + * the serialized structure can be established. @a struct_size must match + * the result of @c sizeof() of the actual structure. + * + * Only in case that svn_temp_serializer__init() has not been provided + * with a root structure and this is the first call after the initialization, + * @a source_struct will point to a reference to the root structure instead + * of being related to some other. + * + * Sub-structures and strings will be added in a FIFO fashion. If you need + * add further sub-structures on the same level, you need to call + * svn_serializer__pop() to realign the serialization context. + */ +void +svn_temp_serializer__push(svn_temp_serializer__context_t *context, + const void * const * source_struct, + apr_size_t struct_size); + +/** + * End the serialization of the current sub-structure. The serialization + * @a context will be focused back on the parent structure. You may then + * add further sub-structures starting from that level. + * + * It is not necessary to call this function just for symmetry at the end + * of the serialization process. + */ +void +svn_temp_serializer__pop(svn_temp_serializer__context_t *context); + +/** + * Serialize a string referenced from the current structure within the + * serialization @a context. @a s must be a reference to the @c char* + * pointer in the original structure so that the correspondence in the + * serialized structure can be established. + * + * Only in case that svn_temp_serializer__init() has not been provided + * with a root structure and this is the first call after the initialization, + * @a s will not be related to some struct. + */ +void +svn_temp_serializer__add_string(svn_temp_serializer__context_t *context, + const char * const * s); + +/** + * Set the serialized representation of the pointer @a ptr inside the + * current structure within the serialization @a context to @c NULL. + * This is particularly useful if the pointer is not @c NULL in the + * source structure. + */ +void +svn_temp_serializer__set_null(svn_temp_serializer__context_t *context, + const void * const * ptr); + +/** + * @return the number of bytes currently used in the serialization buffer + * of the given serialization @a context. + */ +apr_size_t +svn_temp_serializer__get_length(svn_temp_serializer__context_t *context); + +/** + * @return a reference to the data buffer containing the data serialialized + * so far in the given serialization @a context. + */ +struct svn_stringbuf_t * +svn_temp_serializer__get(svn_temp_serializer__context_t *context); + +/** + * Deserialization is straightforward: just copy the serialized buffer to + * a natively aligned memory location (APR pools will take care of that + * automatically) and resolve all pointers to sub-structures. + * + * To do the latter, call this function for each of these pointers, giving + * the start address of the copied buffer in @a buffer and a reference to + * the pointer to resolve in @a ptr. + */ +void +svn_temp_deserializer__resolve(void *buffer, void **ptr); + +/** + * Similar to svn_temp_deserializer__resolve() but instead of modifying + * the buffer content, the resulting pointer is passed back to the caller + * as the return value. + */ +const void * +svn_temp_deserializer__ptr(const void *buffer, const void *const *ptr); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_TEMP_SERIALIZER_H */ diff --git a/subversion/include/private/svn_token.h b/subversion/include/private/svn_token.h new file mode 100644 index 0000000..c7c1c2c --- /dev/null +++ b/subversion/include/private/svn_token.h @@ -0,0 +1,98 @@ +/* svn_token.h : value/string-token functions + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ + +#ifndef SVN_TOKEN_H +#define SVN_TOKEN_H + + +#include "svn_error.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** A mapping between a string STR and an enumeration value VAL. + * + * Maps are an array of these, terminated with a struct where STR == NULL. + */ +typedef struct svn_token_map_t +{ + const char *str; + int val; +} svn_token_map_t; + + +/* A value used by some token functions to indicate an unrecognized token. */ +#define SVN_TOKEN_UNKNOWN (-9999) + + +/* Return the string form of the given VALUE as found in MAP. If the value + is not recognized, then a MALFUNCTION will occur. */ +const char * +svn_token__to_word(const svn_token_map_t *map, + int value); + + +/* NOTE: in the following functions, if WORD is NULL, then SVN_TOKEN_UNKNOWN + will be returned, or will cause the appropriate MALFUNCTION or ERROR. */ + +/* Return the integer value of the given token WORD, as found in MAP. If the + string is not recognized, then a MALFUNCTION will occur. + + Note: this function is for persisted string values. Because this function + will throw a MALFUNCTION, it should not be used for network input or + user input. */ +int +svn_token__from_word_strict(const svn_token_map_t *map, + const char *word); + + +/* Store the integer value of WORD into *VALUE. If the string is not + recognized, then SVN_ERR_BAD_TOKEN is returned. */ +svn_error_t * +svn_token__from_word_err(int *value, + const svn_token_map_t *map, + const char *word); + + +/* Return the integer value of the given token WORD as found in MAP. If the + string is not recognized, then SVN_TOKEN_UNKNOWN will be returned. */ +int +svn_token__from_word(const svn_token_map_t *map, + const char *word); + + +/* Return the integer value of the given token WORD/LEN as found in MAP. If + the string is not recognized, then SVN_TOKEN_UNKNOWN will be returned. */ +int +svn_token__from_mem(const svn_token_map_t *map, + const char *word, + apr_size_t len); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_TOKEN_H */ diff --git a/subversion/include/private/svn_utf_private.h b/subversion/include/private/svn_utf_private.h new file mode 100644 index 0000000..9f5a4ad --- /dev/null +++ b/subversion/include/private/svn_utf_private.h @@ -0,0 +1,87 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_utf_private.h + * @brief UTF validation routines + */ + +#ifndef SVN_UTF_PRIVATE_H +#define SVN_UTF_PRIVATE_H + +#include <apr.h> +#include <apr_pools.h> + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Return TRUE if the string SRC of length LEN is a valid UTF-8 encoding + * according to the rules laid down by the Unicode 4.0 standard, FALSE + * otherwise. This function is faster than svn_utf__last_valid(). + */ +svn_boolean_t +svn_utf__is_valid(const char *src, apr_size_t len); + +/* As for svn_utf__is_valid but SRC is NULL terminated. */ +svn_boolean_t +svn_utf__cstring_is_valid(const char *src); + +/* Return a pointer to the first character after the last valid UTF-8 + * potentially multi-byte character in the string SRC of length LEN. + * Validity of bytes from SRC to SRC+LEN-1, inclusively, is checked. + * If SRC is a valid UTF-8, the return value will point to the byte SRC+LEN, + * otherwise it will point to the start of the first invalid character. + * In either case all the characters between SRC and the return pointer - 1, + * inclusively, are valid UTF-8. + * + * See also svn_utf__is_valid(). + */ +const char * +svn_utf__last_valid(const char *src, apr_size_t len); + +/* As for svn_utf__last_valid but uses a different implementation without + lookup tables. It avoids the table memory use (about 400 bytes) but the + function is longer (about 200 bytes extra) and likely to be slower when + the string is valid. If the string is invalid this function may be + faster since it returns immediately rather than continuing to the end of + the string. The main reason this function exists is to test the table + driven implementation. */ +const char * +svn_utf__last_valid2(const char *src, apr_size_t len); + +const char * +svn_utf__cstring_from_utf8_fuzzy(const char *src, + apr_pool_t *pool, + svn_error_t *(*convert_from_utf8) + (const char **, + const char *, + apr_pool_t *)); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_UTF_PRIVATE_H */ diff --git a/subversion/include/private/svn_wc_private.h b/subversion/include/private/svn_wc_private.h new file mode 100644 index 0000000..fce42b0 --- /dev/null +++ b/subversion/include/private/svn_wc_private.h @@ -0,0 +1,1847 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_wc_private.h + * @brief The Subversion Working Copy Library - Internal routines + * + * Requires: + * - A working copy + * + * Provides: + * - Ability to manipulate working copy's versioned data. + * - Ability to manipulate working copy's administrative files. + * + * Used By: + * - Clients. + */ + +#ifndef SVN_WC_PRIVATE_H +#define SVN_WC_PRIVATE_H + +#include "svn_types.h" +#include "svn_wc.h" +#include "private/svn_diff_tree.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Return TRUE iff CLHASH (a hash whose keys are const char * + changelist names) is NULL or if LOCAL_ABSPATH is part of a changelist in + CLHASH. */ +svn_boolean_t +svn_wc__changelist_match(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const apr_hash_t *clhash, + apr_pool_t *scratch_pool); + +/* Like svn_wc_get_update_editorX and svn_wc_get_status_editorX, but only + allows updating a file external LOCAL_ABSPATH. + + Since this only deals with files, the WCROOT_IPROPS argument in + svn_wc_get_update_editorX and svn_wc_get_status_editorX (hashes mapping + const char * absolute working copy paths, which are working copy roots, to + depth-first ordered arrays of svn_prop_inherited_item_t * structures) is + simply IPROPS here, a depth-first ordered arrays of + svn_prop_inherited_item_t * structs. */ +svn_error_t * +svn_wc__get_file_external_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_revnum_t *target_revision, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *wri_abspath, + const char *url, + const char *repos_root_url, + const char *repos_uuid, + apr_array_header_t *iprops, + svn_boolean_t use_commit_times, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + const char *record_ancestor_abspath, + const char *recorded_url, + const svn_opt_revision_t *recorded_peg_rev, + const svn_opt_revision_t *recorded_rev, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Like svn_wc_crawl_revisionsX, but only supports updating a file external + LOCAL_ABSPATH which may or may not exist yet. */ +svn_error_t * +svn_wc__crawl_file_external(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const svn_ra_reporter3_t *reporter, + void *report_baton, + svn_boolean_t restore_files, + svn_boolean_t use_commit_times, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/* Check if LOCAL_ABSPATH is an external in the working copy identified + by WRI_ABSPATH. If not return SVN_ERR_WC_PATH_NOT_FOUND. + + If it is an external return more information on this external. + + If IGNORE_ENOENT, then set *external_kind to svn_node_none, when + LOCAL_ABSPATH is not an external instead of returning an error. + + Here is an overview of how DEFINING_REVISION and + DEFINING_OPERATIONAL_REVISION would be set for which kinds of externals + definitions: + + svn:externals line DEFINING_REV. DEFINING_OP._REV. + + ^/foo@2 bar 2 2 + -r1 ^/foo@2 bar 1 2 + -r1 ^/foo bar 1 SVN_INVALID_REVNUM + ^/foo bar SVN_INVALID_REVNUM SVN_INVALID_REVNUM + ^/foo@HEAD bar SVN_INVALID_REVNUM SVN_INVALID_REVNUM + -rHEAD ^/foo bar -- not a valid externals definition -- +*/ +svn_error_t * +svn_wc__read_external_info(svn_node_kind_t *external_kind, + const char **defining_abspath, + const char **defining_url, + svn_revnum_t *defining_operational_revision, + svn_revnum_t *defining_revision, + svn_wc_context_t *wc_ctx, + const char *wri_abspath, + const char *local_abspath, + svn_boolean_t ignore_enoent, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** See svn_wc__committable_externals_below(). */ +typedef struct svn_wc__committable_external_info_t { + + /* The local absolute path where the external should be checked out. */ + const char *local_abspath; + + /* The relpath part of the source URL the external should be checked out + * from. */ + const char *repos_relpath; + + /* The root URL part of the source URL the external should be checked out + * from. */ + const char *repos_root_url; + + /* Set to either svn_node_file or svn_node_dir. */ + svn_node_kind_t kind; + +} svn_wc__committable_external_info_t; + +/* Add svn_wc__committable_external_info_t* items to *EXTERNALS, describing + * 'committable' externals checked out below LOCAL_ABSPATH. Recursively find + * all nested externals (externals defined inside externals). + * + * In this context, a 'committable' external belongs to the same repository as + * LOCAL_ABSPATH, is not revision-pegged and is currently checked out in the + * WC. (Local modifications are not tested for.) + * + * *EXTERNALS must be initialized either to NULL or to a pointer created with + * apr_array_make(..., sizeof(svn_wc__committable_external_info_t *)). If + * *EXTERNALS is initialized to NULL, an array will be allocated from + * RESULT_POOL as necessary. If no committable externals are found, + * *EXTERNALS is left unchanged. + * + * DEPTH limits the recursion below LOCAL_ABSPATH. + * + * This function will not find externals defined in some parent WC above + * LOCAL_ABSPATH's WC-root. + * + * ###TODO: Add a WRI_ABSPATH (wc root indicator) separate from LOCAL_ABSPATH, + * to allow searching any wc-root for externals under LOCAL_ABSPATH, not only + * LOCAL_ABSPATH's most immediate wc-root. */ +svn_error_t * +svn_wc__committable_externals_below(apr_array_header_t **externals, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Gets a mapping from const char * local abspaths of externals to the const + char * local abspath of where they are defined for all externals defined + at or below LOCAL_ABSPATH. + + ### Returns NULL in *EXTERNALS until we bumped to format 29. + + Allocate the result in RESULT_POOL and perform temporary allocations in + SCRATCH_POOL. */ +svn_error_t * +svn_wc__externals_defined_below(apr_hash_t **externals, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/* Registers a new external at LOCAL_ABSPATH in the working copy containing + DEFINING_ABSPATH. + + The node is registered as defined on DEFINING_ABSPATH (must be an ancestor + of LOCAL_ABSPATH) of kind KIND. + + The external is registered as from repository REPOS_ROOT_URL with uuid + REPOS_UUID and the defining relative path REPOS_RELPATH. + + If the revision of the node is locked OPERATIONAL_REVISION and REVISION + are the peg and normal revision; otherwise their value is + SVN_INVALID_REVNUM. + + ### Only KIND svn_node_dir is supported. + + Perform temporary allocations in SCRATCH_POOL. + */ +svn_error_t * +svn_wc__external_register(svn_wc_context_t *wc_ctx, + const char *defining_abspath, + const char *local_abspath, + svn_node_kind_t kind, + const char *repos_root_url, + const char *repos_uuid, + const char *repos_relpath, + svn_revnum_t operational_revision, + svn_revnum_t revision, + apr_pool_t *scratch_pool); + +/* Remove the external at LOCAL_ABSPATH from the working copy identified by + WRI_ABSPATH using WC_CTX. + + If DECLARATION_ONLY is TRUE, only remove the registration and leave the + on-disk structure untouched. + + If not NULL, call CANCEL_FUNC with CANCEL_BATON to allow canceling while + removing the working copy files. + + ### This function wraps svn_wc_remove_from_revision_control2(). + */ +svn_error_t * +svn_wc__external_remove(svn_wc_context_t *wc_ctx, + const char *wri_abspath, + const char *local_abspath, + svn_boolean_t declaration_only, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/* Gather all svn:externals property values from the actual properties on + directories below LOCAL_ABSPATH as a mapping of const char *local_abspath + to const char * values. + + Use DEPTH as how it would be used to limit the externals property results + on update. (So any depth < infinity will only read svn:externals on + LOCAL_ABSPATH itself) + + If DEPTHS is not NULL, set *depths to an apr_hash_t* mapping the same + local_abspaths to the const char * ambient depth of the node. + + Allocate the result in RESULT_POOL and perform temporary allocations in + SCRATCH_POOL. */ +svn_error_t * +svn_wc__externals_gather_definitions(apr_hash_t **externals, + apr_hash_t **ambient_depths, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Close the DB for LOCAL_ABSPATH. Perform temporary allocations in + SCRATCH_POOL. + + Wraps svn_wc__db_drop_root(). */ +svn_error_t * +svn_wc__close_db(const char *external_abspath, + svn_wc_context_t *wc_ctx, + apr_pool_t *scratch_pool); + +/** Set @a *tree_conflict to a newly allocated @c + * svn_wc_conflict_description_t structure describing the tree + * conflict state of @a victim_abspath, or to @c NULL if @a victim_abspath + * is not in a state of tree conflict. @a wc_ctx is a working copy context + * used to access @a victim_path. Allocate @a *tree_conflict in @a result_pool, + * use @a scratch_pool for temporary allocations. + */ +svn_error_t * +svn_wc__get_tree_conflict(const svn_wc_conflict_description2_t **tree_conflict, + svn_wc_context_t *wc_ctx, + const char *victim_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Record the tree conflict described by @a conflict in the WC for + * @a conflict->local_abspath. Use @a scratch_pool for all temporary + * allocations. + * + * Returns an SVN_ERR_WC_PATH_UNEXPECTED_STATUS error when + * CONFLICT->LOCAL_ABSPATH is already tree conflicted. + * + * ### This function can't set moved_away, moved_here conflicts for + * any operation, except merges. + */ +svn_error_t * +svn_wc__add_tree_conflict(svn_wc_context_t *wc_ctx, + const svn_wc_conflict_description2_t *conflict, + apr_pool_t *scratch_pool); + +/* Remove any tree conflict on victim @a victim_abspath using @a wc_ctx. + * (If there is no such conflict recorded, do nothing and return success.) + * + * Do all temporary allocations in @a scratch_pool. + */ +svn_error_t * +svn_wc__del_tree_conflict(svn_wc_context_t *wc_ctx, + const char *victim_abspath, + apr_pool_t *scratch_pool); + +/** Check whether LOCAL_ABSPATH has a parent directory that knows about its + * existence. Set *IS_WCROOT to FALSE if a parent is found, and to TRUE + * if there is no such parent. + * + * Like svn_wc_is_wc_root2(), but doesn't consider switched subdirs or + * deleted entries as working copy roots. + */ +svn_error_t * +svn_wc__is_wcroot(svn_boolean_t *is_wcroot, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + + +/** Set @a *wcroot_abspath to the local abspath of the root of the + * working copy in which @a local_abspath resides. + */ +svn_error_t * +svn_wc__get_wcroot(const char **wcroot_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * The following are temporary APIs to aid in the transition from wc-1 to + * wc-ng. Use them for new development now, but they may be disappearing + * before the 1.7 release. + */ + + +/* + * Convert from svn_wc_conflict_description2_t to + * svn_wc_conflict_description_t. This is needed by some backwards-compat + * code in libsvn_client/ctx.c + * + * Allocate the result in RESULT_POOL. + */ +svn_wc_conflict_description_t * +svn_wc__cd2_to_cd(const svn_wc_conflict_description2_t *conflict, + apr_pool_t *result_pool); + + +/* + * Convert from svn_wc_status3_t to svn_wc_status2_t. + * Allocate the result in RESULT_POOL. + */ +svn_error_t * +svn_wc__status2_from_3(svn_wc_status2_t **status, + const svn_wc_status3_t *old_status, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Set @a *children to a new array of the immediate children of the working + * node at @a dir_abspath. The elements of @a *children are (const char *) + * absolute paths. + * + * Include children that are scheduled for deletion. Iff @a show_hidden + * is true, also include children that are 'excluded' or 'server-excluded' or + * 'not-present'. + * + * Return every path that refers to a child of the working node at + * @a dir_abspath. Do not include a path just because it was a child of a + * deleted directory that existed at @a dir_abspath if that directory is now + * sheduled to be replaced by the working node at @a dir_abspath. + * + * Allocate @a *children in @a result_pool. Use @a wc_ctx to access the + * working copy, and @a scratch_pool for all temporary allocations. + */ +svn_error_t * +svn_wc__node_get_children_of_working_node(const apr_array_header_t **children, + svn_wc_context_t *wc_ctx, + const char *dir_abspath, + svn_boolean_t show_hidden, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Like svn_wc__node_get_children_of_working_node(), except also include any + * path that was a child of a deleted directory that existed at + * @a dir_abspath, even if that directory is now scheduled to be replaced by + * the working node at @a dir_abspath. + */ +svn_error_t * +svn_wc__node_get_children(const apr_array_header_t **children, + svn_wc_context_t *wc_ctx, + const char *dir_abspath, + svn_boolean_t show_hidden, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Fetch the repository information for the working version + * of the node at @a local_abspath into @a *revision, @a *repos_relpath, + * @a *repos_root_url and @a *repos_uuid. Use @a wc_ctx to access the working + * copy. Allocate results in @a result_pool. + * + * @a *revision will be set to SVN_INVALID_REVNUM for any shadowed node (including + * added and deleted nodes). All other output values will be set to the current + * values or those they would have after a commit. + * + * All output argument may be NULL, indicating no interest. + */ +svn_error_t * +svn_wc__node_get_repos_info(svn_revnum_t *revision, + const char **repos_relpath, + const char **repos_root_url, + const char **repos_uuid, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + + +/** + * Get the depth of @a local_abspath using @a wc_ctx. If @a local_abspath is + * not in the working copy, return @c SVN_ERR_WC_PATH_NOT_FOUND. + */ +svn_error_t * +svn_wc__node_get_depth(svn_depth_t *depth, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** + * Get the changed revision, date and author for @a local_abspath using @a + * wc_ctx. Allocate the return values in @a result_pool; use @a scratch_pool + * for temporary allocations. Any of the return pointers may be @c NULL, in + * which case they are not set. + * + * If @a local_abspath is not in the working copy, return + * @c SVN_ERR_WC_PATH_NOT_FOUND. + */ +svn_error_t * +svn_wc__node_get_changed_info(svn_revnum_t *changed_rev, + apr_time_t *changed_date, + const char **changed_author, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Set @a *url to the corresponding url for @a local_abspath, using @a wc_ctx. + * If the node is added, return the url it will have in the repository. + * + * If @a local_abspath is not in the working copy, return + * @c SVN_ERR_WC_PATH_NOT_FOUND. + */ +svn_error_t * +svn_wc__node_get_url(const char **url, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Retrieves the origin of the node as it is known in the repository. For + * a copied node this retrieves where the node is copied from, for an added + * node this returns NULL/INVALID outputs, and for any other node this + * retrieves the repository location. + * + * All output arguments may be NULL. + * + * If @a is_copy is not NULL, sets @a *is_copy to TRUE if the origin is a copy + * of the original node. + * + * If not NULL, sets @a revision, @a repos_relpath, @a repos_root_url and + * @a repos_uuid to the original (if a copy) or their current values. + * + * If @a copy_root_abspath is not NULL, and @a *is_copy indicates that the + * node was copied, set @a *copy_root_abspath to the local absolute path of + * the root of the copied subtree containing the node. If the copied node is + * a root by itself, @a *copy_root_abspath will match @a local_abspath (but + * won't necessarily point to the same string in memory). + * + * If @a scan_deleted is TRUE, determine the origin of the deleted node. If + * @a scan_deleted is FALSE, return NULL, SVN_INVALID_REVNUM or FALSE for + * deleted nodes. + * + * Allocate the result in @a result_pool. Perform temporary allocations in + * @a scratch_pool */ +svn_error_t * +svn_wc__node_get_origin(svn_boolean_t *is_copy, + svn_revnum_t *revision, + const char **repos_relpath, + const char **repos_root_url, + const char **repos_uuid, + const char **copy_root_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t scan_deleted, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Set @a *is_deleted to TRUE if @a local_abspath is deleted, using + * @a wc_ctx. If @a local_abspath is not in the working copy, return + * @c SVN_ERR_WC_PATH_NOT_FOUND. Use @a scratch_pool for all temporary + * allocations. + */ +svn_error_t * +svn_wc__node_is_status_deleted(svn_boolean_t *is_deleted, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** + * Set @a *deleted_ancestor_abspath to the root of the delete operation + * that deleted @a local_abspath. If @a local_abspath itself was deleted + * and has no deleted ancestor, @a *deleted_ancestor_abspath will equal + * @a local_abspath. If @a local_abspath was not deleted, + * set @a *deleted_ancestor_abspath to @c NULL. + * + * A node is considered 'deleted' if it is deleted or moved-away, and is + * not replaced. + * + * @a *deleted_ancestor_abspath is allocated in @a result_pool. + * Use @a scratch_pool for all temporary allocations. + */ +svn_error_t * +svn_wc__node_get_deleted_ancestor(const char **deleted_ancestor_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Set @a *not_present to TRUE when @a local_abspath has status + * svn_wc__db_status_not_present. Set @a *user_excluded to TRUE when + * @a local_abspath has status svn_wc__db_status_excluded. Set + * @a *server_excluded to TRUE when @a local_abspath has status + * svn_wc__db_status_server_excluded. Otherwise set these values to FALSE. + * If @a base_only is TRUE then only the base node will be examined, + * otherwise the current base or working node will be examined. + * + * If a value is not interesting you can pass #NULL. + * + * If @a local_abspath is not in the working copy, return + * @c SVN_ERR_WC_PATH_NOT_FOUND. Use @a scratch_pool for all temporary + * allocations. + */ +svn_error_t * +svn_wc__node_is_not_present(svn_boolean_t *not_present, + svn_boolean_t *user_excluded, + svn_boolean_t *server_excluded, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t base_only, + apr_pool_t *scratch_pool); + +/** + * Set @a *is_added to whether @a local_abspath is added, using + * @a wc_ctx. If @a local_abspath is not in the working copy, return + * @c SVN_ERR_WC_PATH_NOT_FOUND. Use @a scratch_pool for all temporary + * allocations. + * + * NOTE: "added" in this sense, means it was added, copied-here, or + * moved-here. This function provides NO information on whether this + * addition has replaced another node. + * + * To be clear, this does NOT correspond to svn_wc_schedule_add. + */ +svn_error_t * +svn_wc__node_is_added(svn_boolean_t *is_added, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** + * Set @a *has_working to whether @a local_abspath has a working node (which + * might shadow BASE nodes) + * + * This is a check similar to status = added or status = deleted. + */ +svn_error_t * +svn_wc__node_has_working(svn_boolean_t *has_working, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + + +/** + * Get the repository location of the base node at @a local_abspath. + * + * Set *REVISION, *REPOS_RELPATH, *REPOS_ROOT_URL *REPOS_UUID and *LOCK_TOKEN + * to the location that this node was checked out at or last updated/switched + * to, regardless of any uncommitted changes (delete, replace and/or copy-here/ + * move-here). + * + * If there is no BASE node at @a local_abspath or if @a show_hidden is FALSE, + * no status 'normal' or 'incomplete' BASE node report + * SVN_ERR_WC_PATH_NOT_FOUND, or if @a ignore_enoent is TRUE, @a kind + * svn_node_unknown, @a revision SVN_INVALID_REVNUM and all other values NULL. + * + * All output arguments may be NULL. + * + * Allocate the results in @a result_pool. Perform temporary allocations in + * @a scratch_pool. + */ +svn_error_t * +svn_wc__node_get_base(svn_node_kind_t *kind, + svn_revnum_t *revision, + const char **repos_relpath, + const char **repos_root_url, + const char **repos_uuid, + const char **lock_token, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t ignore_enoent, + svn_boolean_t show_hidden, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/* Get the working revision of @a local_abspath using @a wc_ctx. If @a + * local_abspath is not in the working copy, return @c + * SVN_ERR_WC_PATH_NOT_FOUND. + * + * This function is meant as a temporary solution for using the old-style + * semantics of entries. It will handle any uncommitted changes (delete, + * replace and/or copy-here/move-here). + * + * For a delete the @a revision is the BASE node of the operation root, e.g + * the path that was deleted. But if the delete is below an add, the + * revision is set to SVN_INVALID_REVNUM. For an add, copy or move we return + * SVN_INVALID_REVNUM. In case of a replacement, we return the BASE + * revision. + * + * The @a changed_rev is set to the latest committed change to @a + * local_abspath before or equal to @a revision, unless the node is + * copied-here or moved-here. Then it is the revision of the latest committed + * change before or equal to the copyfrom_rev. NOTE, that we use + * SVN_INVALID_REVNUM for a scheduled copy or move. + * + * The @a changed_date and @a changed_author are the ones associated with @a + * changed_rev. + */ +svn_error_t * +svn_wc__node_get_pre_ng_status_data(svn_revnum_t *revision, + svn_revnum_t *changed_rev, + apr_time_t *changed_date, + const char **changed_author, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Acquire a recursive write lock for @a local_abspath. If @a lock_anchor + * is true, determine if @a local_abspath has an anchor that should be locked + * instead; otherwise, @a local_abspath must be a versioned directory. + * Store the obtained lock in @a wc_ctx. + * + * If @a lock_root_abspath is not NULL, store the root of the lock in + * @a *lock_root_abspath. If @a lock_root_abspath is NULL, then @a + * lock_anchor must be FALSE. + * + * Returns @c SVN_ERR_WC_LOCKED if an existing lock is encountered, in + * which case any locks acquired will have been released. + * + * If @a lock_anchor is TRUE and @a lock_root_abspath is not NULL, @a + * lock_root_abspath will be set even when SVN_ERR_WC_LOCKED is returned. + */ +svn_error_t * +svn_wc__acquire_write_lock(const char **lock_root_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t lock_anchor, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Recursively release write locks for @a local_abspath, using @a wc_ctx + * for working copy access. Only locks held by @a wc_ctx are released. + * Locks are not removed if work queue items are present. + * + * If @a local_abspath is not the root of an owned SVN_ERR_WC_NOT_LOCKED + * is returned. + */ +svn_error_t * +svn_wc__release_write_lock(svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** A callback invoked by the svn_wc__call_with_write_lock() function. */ +typedef svn_error_t *(*svn_wc__with_write_lock_func_t)(void *baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Call function @a func while holding a write lock on + * @a local_abspath. The @a baton, and @a result_pool and + * @a scratch_pool, is passed @a func. + * + * If @a lock_anchor is TRUE, determine if @a local_abspath has an anchor + * that should be locked instead. + * + * Use @a wc_ctx for working copy access. + * The lock is guaranteed to be released after @a func returns. + */ +svn_error_t * +svn_wc__call_with_write_lock(svn_wc__with_write_lock_func_t func, + void *baton, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t lock_anchor, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Evaluate the expression @a expr while holding a write lock on + * @a local_abspath. + * + * @a expr must yield an (svn_error_t *) error code. If the error code + * is not #SVN_NO_ERROR, cause the function using this macro to return + * the error to its caller. + * + * If @a lock_anchor is TRUE, determine if @a local_abspath has an anchor + * that should be locked instead. + * + * Use @a wc_ctx for working copy access. + * + * The lock is guaranteed to be released after evaluating @a expr. + */ +#define SVN_WC__CALL_WITH_WRITE_LOCK(expr, wc_ctx, local_abspath, \ + lock_anchor, scratch_pool) \ + do { \ + svn_error_t *svn_wc__err1, *svn_wc__err2; \ + const char *svn_wc__lock_root_abspath; \ + SVN_ERR(svn_wc__acquire_write_lock(&svn_wc__lock_root_abspath, wc_ctx, \ + local_abspath, lock_anchor, \ + scratch_pool, scratch_pool)); \ + svn_wc__err1 = (expr); \ + svn_wc__err2 = svn_wc__release_write_lock( \ + wc_ctx, svn_wc__lock_root_abspath, scratch_pool); \ + SVN_ERR(svn_error_compose_create(svn_wc__err1, svn_wc__err2)); \ + } while (0) + + +/** + * Calculates the schedule and copied status of a node as that would + * have been stored in an svn_wc_entry_t instance. + * + * If not @c NULL, @a schedule and @a copied are set to their calculated + * values. + */ +svn_error_t * +svn_wc__node_get_schedule(svn_wc_schedule_t *schedule, + svn_boolean_t *copied, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** A callback invoked by svn_wc__prop_list_recursive(). + * It is equivalent to svn_proplist_receiver_t declared in svn_client.h, + * but kept private within the svn_wc__ namespace because it is used within + * the bowels of libsvn_wc which don't include svn_client.h. + * + * @since New in 1.7. */ +typedef svn_error_t *(*svn_wc__proplist_receiver_t)(void *baton, + const char *local_abspath, + apr_hash_t *props, + apr_pool_t *scratch_pool); + +/** Call @a receiver_func, passing @a receiver_baton, an absolute path, and + * a hash table mapping <tt>const char *</tt> names onto <tt>const + * svn_string_t *</tt> values for all the regular properties of the node + * at @a local_abspath and any node beneath @a local_abspath within the + * specified @a depth. @a receiver_fun must not be NULL. + * + * If @a propname is not NULL, the passed hash table will only contain + * the property @a propname. + * + * If @a pristine is not @c TRUE, and @a base_props is FALSE show local + * modifications to the properties. + * + * If a node has no properties, @a receiver_func is not called for the node. + * + * If @a changelists are non-NULL and non-empty, filter by them. + * + * Use @a wc_ctx to access the working copy, and @a scratch_pool for + * temporary allocations. + * + * If the node at @a local_abspath does not exist, + * #SVN_ERR_WC_PATH_NOT_FOUND is returned. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc__prop_list_recursive(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *propname, + svn_depth_t depth, + svn_boolean_t pristine, + const apr_array_header_t *changelists, + svn_wc__proplist_receiver_t receiver_func, + void *receiver_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Set @a *inherited_props to a depth-first ordered array of + * #svn_prop_inherited_item_t * structures representing the properties + * inherited by @a local_abspath from the ACTUAL tree above + * @a local_abspath (looking through to the WORKING or BASE tree as + * required), up to and including the root of the working copy and + * any cached inherited properties inherited by the root. + * + * The #svn_prop_inherited_item_t->path_or_url members of the + * #svn_prop_inherited_item_t * structures in @a *inherited_props are + * paths relative to the repository root URL for cached inherited + * properties and absolute working copy paths otherwise. + * + * Allocate @a *inherited_props in @a result_pool. Use @a scratch_pool + * for temporary allocations. + */ +svn_error_t * +svn_wc__get_iprops(apr_array_header_t **inherited_props, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *propname, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Obtain a mapping of const char * local_abspaths to const svn_string_t* + * property values in *VALUES, of all PROPNAME properties on LOCAL_ABSPATH + * and its descendants. + * + * Allocate the result in RESULT_POOL, and perform temporary allocations in + * SCRATCH_POOL. + */ +svn_error_t * +svn_wc__prop_retrieve_recursive(apr_hash_t **values, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *propname, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Set @a *iprops_paths to a hash mapping const char * absolute working + * copy paths to the nodes repository root relative path for each path + * in the working copy at or below @a local_abspath, limited by @a depth, + * that has cached inherited properties for the base node of the path. + * + * Allocate @a *iprop_paths + * in @a result_pool. Use @a scratch_pool for temporary allocations. + */ +svn_error_t * +svn_wc__get_cached_iprop_children(apr_hash_t **iprop_paths, + svn_depth_t depth, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * For use by entries.c and entries-dump.c to read old-format working copies. + */ +svn_error_t * +svn_wc__read_entries_old(apr_hash_t **entries, + const char *dir_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Recursively clear the dav cache (wcprops) in @a wc_ctx for the tree + * rooted at @a local_abspath. + */ +svn_error_t * +svn_wc__node_clear_dav_cache_recursive(svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** + * Set @a lock_tokens to a hash mapping <tt>const char *</tt> URL + * to <tt>const char *</tt> lock tokens for every path at or under + * @a local_abspath in @a wc_ctx which has such a lock token set on it. + * Allocate the hash and all items therein from @a result_pool. + */ +svn_error_t * +svn_wc__node_get_lock_tokens_recursive(apr_hash_t **lock_tokens, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Set @a *min_revision and @a *max_revision to the lowest and highest revision + * numbers found within @a local_abspath, using context @a wc_ctx. + * If @a committed is TRUE, set @a *min_revision and @a *max_revision + * to the lowest and highest comitted (i.e. "last changed") revision numbers, + * respectively. Use @a scratch_pool for temporary allocations. + * + * Either of MIN_REVISION and MAX_REVISION may be passed as NULL if + * the caller doesn't care about that return value. + * + * This function provides a subset of the functionality of + * svn_wc_revision_status2() and is more efficient if the caller + * doesn't need all information returned by svn_wc_revision_status2(). */ +svn_error_t * +svn_wc__min_max_revisions(svn_revnum_t *min_revision, + svn_revnum_t *max_revision, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t committed, + apr_pool_t *scratch_pool); + +/* Indicate in @a is_switched whether any node beneath @a local_abspath + * is switched, using context @a wc_ctx. + * Use @a scratch_pool for temporary allocations. + * + * If @a trail_url is non-NULL, use it to determine if @a local_abspath itself + * is switched. It should be any trailing portion of @a local_abspath's + * expected URL, long enough to include any parts that the caller considers + * might be changed by a switch. If it does not match the end of + * @a local_abspath's actual URL, then report a "switched" status. + * + * This function provides a subset of the functionality of + * svn_wc_revision_status2() and is more efficient if the caller + * doesn't need all information returned by svn_wc_revision_status2(). */ +svn_error_t * +svn_wc__has_switched_subtrees(svn_boolean_t *is_switched, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *trail_url, + apr_pool_t *scratch_pool); + +/* Set @a *excluded_subtrees to a hash mapping <tt>const char *</tt> + * local * absolute paths to <tt>const char *</tt> local absolute paths for + * every path under @a local_abspath in @a wc_ctx which are excluded + * by the server (e.g. because of authz) or the users. + * If no excluded paths are found then @a *server_excluded_subtrees + * is set to @c NULL. + * Allocate the hash and all items therein from @a result_pool. + */ +svn_error_t * +svn_wc__get_excluded_subtrees(apr_hash_t **server_excluded_subtrees, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Indicate in @a *is_modified whether the working copy has local + * modifications, using context @a wc_ctx. + * Use @a scratch_pool for temporary allocations. + * + * This function provides a subset of the functionality of + * svn_wc_revision_status2() and is more efficient if the caller + * doesn't need all information returned by svn_wc_revision_status2(). */ +svn_error_t * +svn_wc__has_local_mods(svn_boolean_t *is_modified, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/* Renames a working copy from @a from_abspath to @a dst_abspath and makes sure + open handles are closed to allow this on all platforms. + + Summary: This avoids a file lock problem on wc.db on Windows, that is + triggered by libsvn_client'ss copy to working copy code. */ +svn_error_t * +svn_wc__rename_wc(svn_wc_context_t *wc_ctx, + const char *from_abspath, + const char *dst_abspath, + apr_pool_t *scratch_pool); + +/* Set *TMPDIR_ABSPATH to a directory that is suitable for temporary + files which may need to be moved (atomically and same-device) into + the working copy indicated by WRI_ABSPATH. */ +svn_error_t * +svn_wc__get_tmpdir(const char **tmpdir_abspath, + svn_wc_context_t *wc_ctx, + const char *wri_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Gets information needed by the commit harvester. + * + * ### Currently this API is work in progress and is designed for just this + * ### caller. It is certainly possible (and likely) that this function and + * ### it's caller will eventually move into a wc and maybe wc_db api. + */ +svn_error_t * +svn_wc__node_get_commit_status(svn_boolean_t *added, + svn_boolean_t *deleted, + svn_boolean_t *is_replace_root, + svn_boolean_t *is_op_root, + svn_revnum_t *revision, + svn_revnum_t *original_revision, + const char **original_repos_relpath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Gets the md5 checksum for the pristine file identified by a sha1_checksum in the + working copy identified by wri_abspath. + + Wraps svn_wc__db_pristine_get_md5(). + */ +svn_error_t * +svn_wc__node_get_md5_from_sha1(const svn_checksum_t **md5_checksum, + svn_wc_context_t *wc_ctx, + const char *wri_abspath, + const svn_checksum_t *sha1_checksum, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Like svn_wc_get_pristine_contents2(), but keyed on the CHECKSUM + rather than on the local absolute path of the working file. + WRI_ABSPATH is any versioned path of the working copy in whose + pristine database we'll be looking for these contents. */ +svn_error_t * +svn_wc__get_pristine_contents_by_checksum(svn_stream_t **contents, + svn_wc_context_t *wc_ctx, + const char *wri_abspath, + const svn_checksum_t *checksum, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* Gets an array of const char *repos_relpaths of descendants of LOCAL_ABSPATH, + * which must be the op root of an addition, copy or move. The descendants + * returned are at the same op_depth, but are to be deleted by the commit + * processing because they are not present in the local copy. + */ +svn_error_t * +svn_wc__get_not_present_descendants(const apr_array_header_t **descendants, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/* Checks a node LOCAL_ABSPATH in WC_CTX for several kinds of obstructions + * for tasks like merge processing. + * + * If a node is not obstructed it sets *OBSTRUCTION_STATE to + * svn_wc_notify_state_inapplicable. If a node is obstructed or when its + * direct parent does not exist or is deleted return _state_obstructed. When + * a node doesn't exist but should exist return svn_wc_notify_state_missing. + * + * A node is also obstructed if it is marked excluded or server-excluded or when + * an unversioned file or directory exists. And if NO_WCROOT_CHECK is FALSE, + * the root of a working copy is also obstructed; this to allow detecting + * obstructing working copies. + * + * If KIND is not NULL, set *KIND to the kind of node registered in the working + * copy, or SVN_NODE_NONE if the node doesn't + * + * If DELETED is not NULL, set *DELETED to TRUE if the node is marked as + * deleted in the working copy. + * + * If EXCLUDED is not NULL, set *EXCLUDED to TRUE if the node is marked as + * user or server excluded. + * + * If PARENT_DEPTH is not NULL, set *PARENT_DEPTH to the depth stored on the + * parent. (Set to svn_depth_unknown if LOCAL_ABSPATH itself exists as node) + * + * All output arguments except OBSTRUCTION_STATE can be NULL to ommit the + * result. + * + * This function performs temporary allocations in SCRATCH_POOL. + */ +svn_error_t * +svn_wc__check_for_obstructions(svn_wc_notify_state_t *obstruction_state, + svn_node_kind_t *kind, + svn_boolean_t *deleted, + svn_boolean_t *excluded, + svn_depth_t *parent_depth, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t no_wcroot_check, + apr_pool_t *scratch_pool); + + +/** + * A structure which describes various system-generated metadata about + * a working-copy path or URL. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, users shouldn't allocate structures of this + * type, to preserve binary compatibility. + * + * @since New in 1.7. + */ +typedef struct svn_wc__info2_t +{ + /** Where the item lives in the repository. */ + const char *URL; + + /** The root URL of the repository. */ + const char *repos_root_URL; + + /** The repository's UUID. */ + const char *repos_UUID; + + /** The revision of the object. If the target is a working-copy + * path, then this is its current working revision number. If the target + * is a URL, then this is the repository revision that it lives in. */ + svn_revnum_t rev; + + /** The node's kind. */ + svn_node_kind_t kind; + + /** The size of the file in the repository (untranslated, + * e.g. without adjustment of line endings and keyword + * expansion). Only applicable for file -- not directory -- URLs. + * For working copy paths, @a size will be #SVN_INVALID_FILESIZE. */ + svn_filesize_t size; + + /** The last revision in which this object changed. */ + svn_revnum_t last_changed_rev; + + /** The date of the last_changed_rev. */ + apr_time_t last_changed_date; + + /** The author of the last_changed_rev. */ + const char *last_changed_author; + + /** An exclusive lock, if present. Could be either local or remote. */ + svn_lock_t *lock; + + /* Possible information about the working copy, NULL if not valid. */ + struct svn_wc_info_t *wc_info; + +} svn_wc__info2_t; + +/** The callback invoked by info retrievers. Each invocation + * describes @a local_abspath with the information present in @a info. + * Use @a scratch_pool for all temporary allocation. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_wc__info_receiver2_t)(void *baton, + const char *local_abspath, + const svn_wc__info2_t *info, + apr_pool_t *scratch_pool); + +/* Walk the children of LOCAL_ABSPATH and push svn_wc__info2_t's through + RECEIVER/RECEIVER_BATON. Honor DEPTH while crawling children, and + filter the pushed items against CHANGELISTS. + + If FETCH_EXCLUDED is TRUE, also fetch excluded nodes. + If FETCH_ACTUAL_ONLY is TRUE, also fetch actual-only nodes. */ +svn_error_t * +svn_wc__get_info(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + svn_boolean_t fetch_excluded, + svn_boolean_t fetch_actual_only, + const apr_array_header_t *changelists, + svn_wc__info_receiver2_t receiver, + void *receiver_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/* Alternative version of svn_wc_delete4(). + * It can delete multiple TARGETS more efficiently (within a single sqlite + * transaction per working copy), but lacks support for moves. + * + * ### Inconsistency: if DELETE_UNVERSIONED_TARGET is FALSE and a target is + * unversioned, svn_wc__delete_many() will continue whereas + * svn_wc_delete4() will throw an error. + */ +svn_error_t * +svn_wc__delete_many(svn_wc_context_t *wc_ctx, + const apr_array_header_t *targets, + svn_boolean_t keep_local, + svn_boolean_t delete_unversioned_target, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/* If the node at LOCAL_ABSPATH was moved away set *MOVED_TO_ABSPATH to + * the absolute path of the copied move-target node, and *COPY_OP_ROOT_ABSPATH + * to the absolute path of the root node of the copy operation. + * + * If the node was not moved, set *MOVED_TO_ABSPATH and *COPY_OP_ROOT_ABSPATH + * to NULL. + * + * Either MOVED_TO_ABSPATH or OP_ROOT_ABSPATH may be NULL to indicate + * that the caller is not interested in the result. + */ +svn_error_t * +svn_wc__node_was_moved_away(const char **moved_to_abspath, + const char **copy_op_root_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* If the node at LOCAL_ABSPATH was moved here set *MOVED_FROM_ABSPATH to + * the absolute path of the deleted move-source node, and set + * *DELETE_OP_ROOT_ABSPATH to the absolute path of the root node of the + * delete operation. + * + * If the node was not moved, set *MOVED_FROM_ABSPATH and + * *DELETE_OP_ROOT_ABSPATH to NULL. + * + * Either MOVED_FROM_ABSPATH or OP_ROOT_ABSPATH may be NULL to indicate + * that the caller is not interested in the result. + */ +svn_error_t * +svn_wc__node_was_moved_here(const char **moved_from_abspath, + const char **delete_op_root_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/* During an upgrade to wc-ng, supply known details about an existing + * external. The working copy will suck in and store the information supplied + * about the existing external at @a local_abspath. */ +svn_error_t * +svn_wc__upgrade_add_external_info(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_node_kind_t kind, + const char *def_local_abspath, + const char *repos_relpath, + const char *repos_root_url, + const char *repos_uuid, + svn_revnum_t def_peg_revision, + svn_revnum_t def_revision, + apr_pool_t *scratch_pool); + +/* If the URL for @a item is relative, then using the repository root + URL @a repos_root_url and the parent directory URL @parent_dir_url, + resolve it into an absolute URL and save it in @a *resolved_url. + + Regardless if the URL is absolute or not, if there are no errors, + the URL returned in @a *resolved_url will be canonicalized. + + The following relative URL formats are supported: + + ../ relative to the parent directory of the external + ^/ relative to the repository root + // relative to the scheme + / relative to the server's hostname + + The ../ and ^/ relative URLs may use .. to remove path elements up + to the server root. + + The external URL should not be canonicalized before calling this function, + as otherwise the scheme relative URL '//host/some/path' would have been + canonicalized to '/host/some/path' and we would not be able to match on + the leading '//'. */ +svn_error_t * +svn_wc__resolve_relative_external_url(const char **resolved_url, + const svn_wc_external_item2_t *item, + const char *repos_root_url, + const char *parent_dir_url, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Set @a *editor and @a *edit_baton to an editor that generates + * #svn_wc_status3_t structures and sends them through @a status_func / + * @a status_baton. @a anchor_abspath is a working copy directory + * directory which will be used as the root of our editor. If @a + * target_basename is not "", it represents a node in the @a anchor_abspath + * which is the subject of the editor drive (otherwise, the @a + * anchor_abspath is the subject). + * + * If @a set_locks_baton is non-@c NULL, it will be set to a baton that can + * be used in a call to the svn_wc_status_set_repos_locks() function. + * + * Callers drive this editor to describe working copy out-of-dateness + * with respect to the repository. If this information is not + * available or not desired, callers should simply call the + * close_edit() function of the @a editor vtable. + * + * If the editor driver calls @a editor's set_target_revision() vtable + * function, then when the edit drive is completed, @a *edit_revision + * will contain the revision delivered via that interface. + * + * Assuming the target is a directory, then: + * + * - If @a get_all is FALSE, then only locally-modified entries will be + * returned. If TRUE, then all entries will be returned. + * + * - If @a depth is #svn_depth_empty, a status structure will + * be returned for the target only; if #svn_depth_files, for the + * target and its immediate file children; if + * #svn_depth_immediates, for the target and its immediate + * children; if #svn_depth_infinity, for the target and + * everything underneath it, fully recursively. + * + * If @a depth is #svn_depth_unknown, take depths from the + * working copy and behave as above in each directory's case. + * + * If the given @a depth is incompatible with the depth found in a + * working copy directory, the found depth always governs. + * + * If @a no_ignore is set, statuses that would typically be ignored + * will instead be reported. + * + * @a ignore_patterns is an array of file patterns matching + * unversioned files to ignore for the purposes of status reporting, + * or @c NULL if the default set of ignorable file patterns should be used. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton while building + * the @a statushash to determine if the client has canceled the operation. + * + * If @a depth_as_sticky is set handle @a depth like when depth_is_sticky is + * passed for updating. This will show excluded nodes show up as added in the + * repository. + * + * If @a server_performs_filtering is TRUE, assume that the server handles + * the ambient depth filtering, so this doesn't have to be handled in the + * editor. + * + * Allocate the editor itself in @a result_pool, and use @a scratch_pool + * for temporary allocations. The editor will do its temporary allocations + * in a subpool of @a result_pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc__get_status_editor(const svn_delta_editor_t **editor, + void **edit_baton, + void **set_locks_baton, + svn_revnum_t *edit_revision, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target_basename, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + svn_boolean_t depth_as_sticky, + svn_boolean_t server_performs_filtering, + const apr_array_header_t *ignore_patterns, + svn_wc_status_func4_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Set @a *editor and @a *edit_baton to an editor and baton for updating a + * working copy. + * + * @a anchor_abspath is a local working copy directory, with a fully recursive + * write lock in @a wc_ctx, which will be used as the root of our editor. + * + * @a target_basename is the entry in @a anchor_abspath that will actually be + * updated, or the empty string if all of @a anchor_abspath should be updated. + * + * The editor invokes @a notify_func with @a notify_baton as the update + * progresses, if @a notify_func is non-NULL. + * + * If @a cancel_func is non-NULL, the editor will invoke @a cancel_func with + * @a cancel_baton as the update progresses to see if it should continue. + * + * If @a conflict_func is non-NULL, then invoke it with @a + * conflict_baton whenever a conflict is encountered, giving the + * callback a chance to resolve the conflict before the editor takes + * more drastic measures (such as marking a file conflicted, or + * bailing out of the update). + * + * If @a external_func is non-NULL, then invoke it with @a external_baton + * whenever external changes are encountered, giving the callback a chance + * to store the external information for processing. + * + * If @a diff3_cmd is non-NULL, then use it as the diff3 command for + * any merging; otherwise, use the built-in merge code. + * + * @a preserved_exts is an array of filename patterns which, when + * matched against the extensions of versioned files, determine for + * which such files any related generated conflict files will preserve + * the original file's extension as their own. If a file's extension + * does not match any of the patterns in @a preserved_exts (which is + * certainly the case if @a preserved_exts is @c NULL or empty), + * generated conflict files will carry Subversion's custom extensions. + * + * @a target_revision is a pointer to a revision location which, after + * successful completion of the drive of this editor, will be + * populated with the revision to which the working copy was updated. + * + * @a wcroot_iprops is a hash mapping const char * absolute working copy + * paths which are working copy roots (at or under the target within the + * constraints dictated by @a depth) to depth-first ordered arrays of + * svn_prop_inherited_item_t * structures which represent the inherited + * properties for the base of those paths at @a target_revision. After a + * successful drive of this editor, the base nodes for these paths will + * have their inherited properties cache updated with the values from + * @a wcroot_iprops. + * + * If @a use_commit_times is TRUE, then all edited/added files will + * have their working timestamp set to the last-committed-time. If + * FALSE, the working files will be touched with the 'now' time. + * + * If @a allow_unver_obstructions is TRUE, then allow unversioned + * obstructions when adding a path. + * + * If @a adds_as_modification is TRUE, a local addition at the same path + * as an incoming addition of the same node kind results in a normal node + * with a possible local modification, instead of a tree conflict. + * + * If @a depth is #svn_depth_infinity, update fully recursively. + * Else if it is #svn_depth_immediates, update the uppermost + * directory, its file entries, and the presence or absence of + * subdirectories (but do not descend into the subdirectories). + * Else if it is #svn_depth_files, update the uppermost directory + * and its immediate file entries, but not subdirectories. + * Else if it is #svn_depth_empty, update exactly the uppermost + * target, and don't touch its entries. + * + * If @a depth_is_sticky is set and @a depth is not + * #svn_depth_unknown, then in addition to updating PATHS, also set + * their sticky ambient depth value to @a depth. + * + * If @a server_performs_filtering is TRUE, assume that the server handles + * the ambient depth filtering, so this doesn't have to be handled in the + * editor. + * + * If @a clean_checkout is TRUE, assume that we are checking out into an + * empty directory, and so bypass a number of conflict checks that are + * unnecessary in this case. + * + * If @a fetch_dirents_func is not NULL, the update editor may call this + * callback, when asked to perform a depth restricted update. It will do this + * before returning the editor to allow using the primary ra session for this. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc__get_update_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_revnum_t *target_revision, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target_basename, + apr_hash_t *wcroot_iprops, + svn_boolean_t use_commit_times, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t allow_unver_obstructions, + svn_boolean_t adds_as_modification, + svn_boolean_t server_performs_filtering, + svn_boolean_t clean_checkout, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + svn_wc_dirents_func_t fetch_dirents_func, + void *fetch_dirents_baton, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_wc_external_update_t external_func, + void *external_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * A variant of svn_wc__get_update_editor(). + * + * Set @a *editor and @a *edit_baton to an editor and baton for "switching" + * a working copy to a new @a switch_url. (Right now, this URL must be + * within the same repository that the working copy already comes + * from.) @a switch_url must not be @c NULL. + * + * All other parameters behave as for svn_wc__get_update_editor(). + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc__get_switch_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_revnum_t *target_revision, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target_basename, + const char *switch_url, + apr_hash_t *wcroot_iprops, + svn_boolean_t use_commit_times, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t allow_unver_obstructions, + svn_boolean_t server_performs_filtering, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + svn_wc_dirents_func_t fetch_dirents_func, + void *fetch_dirents_baton, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_wc_external_update_t external_func, + void *external_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + + +/** + * Return an @a editor/@a edit_baton for diffing a working copy against the + * repository. The editor is allocated in @a result_pool; temporary + * calculations are performed in @a scratch_pool. + * + * This editor supports diffing either the actual files and properties in the + * working copy (when @a use_text_base is #FALSE), or the current pristine + * information (when @a use_text_base is #TRUE) against the editor driver. + * + * @a anchor_abspath/@a target represent the base of the hierarchy to be + * compared. The diff callback paths will be relative to this path. + * + * Diffs will be reported as valid relpaths, with @a anchor_abspath being + * the root (""). + * + * @a callbacks/@a callback_baton is the callback table to use. + * + * If @a depth is #svn_depth_empty, just diff exactly @a target or + * @a anchor_path if @a target is empty. If #svn_depth_files then do the same + * and for top-level file entries as well (if any). If + * #svn_depth_immediates, do the same as #svn_depth_files but also diff + * top-level subdirectories at #svn_depth_empty. If #svn_depth_infinity, + * then diff fully recursively. If @a depth is #svn_depth_unknown, then... + * + * ### ... then the @a server_performs_filtering option is meaningful. + * ### But what does this depth mean exactly? Something about 'ambient' + * ### depth? How does it compare with depth 'infinity'? + * + * @a ignore_ancestry determines whether paths that have discontinuous node + * ancestry are treated as delete/add or as simple modifications. If + * @a ignore_ancestry is @c FALSE, then any discontinuous node ancestry will + * result in the diff given as a full delete followed by an add. + * + * @a show_copies_as_adds determines whether paths added with history will + * appear as a diff against their copy source, or whether such paths will + * appear as if they were newly added in their entirety. + * + * If @a use_git_diff_format is TRUE, copied paths will be treated as added + * if they weren't modified after being copied. This allows the callbacks + * to generate appropriate --git diff headers for such files. + * + * Normally, the difference from repository->working_copy is shown. + * If @a reverse_order is TRUE, then show working_copy->repository diffs. + * + * If @a cancel_func is non-NULL, it will be used along with @a cancel_baton + * to periodically check if the client has canceled the operation. + * + * @a changelist_filter is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose differences are + * reported; that is, don't generate diffs about any item unless + * it's a member of one of those changelists. If @a changelist_filter is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * If @a server_performs_filtering is TRUE, assume that the server handles + * the ambient depth filtering, so this doesn't have to be handled in the + * editor. + * + * + * A diagram illustrating how this function is used. + * + * Steps 1 and 2 create the chain; step 3 drives it. + * + * 1. svn_wc__get_diff_editor(diff_cbs) + * | ^ + * 2. svn_ra_do_diff3(editor) | | + * | ^ | | + * v | v | + * +----------+ +----------+ +----------+ + * | | | | | | + * +--> | reporter | ----> | editor | ----> | diff_cbs | ----> text + * | | | | | | | out + * | +----------+ +----------+ +----------+ + * | + * 3. svn_wc_crawl_revisions5(WC,reporter) + * + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc__get_diff_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t show_copies_as_adds, + svn_boolean_t use_git_diff_format, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_boolean_t server_performs_filtering, + const apr_array_header_t *changelist_filter, + const svn_wc_diff_callbacks4_t *callbacks, + void *callback_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Callback for the svn_diff_tree_processor_t wrapper, to allow handling + * notifications like how the repos diff in libsvn_client does. + * + * Probably only necessary while transitioning to svn_diff_tree_processor_t + */ +typedef svn_error_t * + (*svn_wc__diff_state_handle_t)(svn_boolean_t tree_conflicted, + svn_wc_notify_state_t *state, + svn_wc_notify_state_t *prop_state, + const char *relpath, + svn_node_kind_t kind, + svn_boolean_t before_op, + svn_boolean_t for_add, + svn_boolean_t for_delete, + void *state_baton, + apr_pool_t *scratch_pool); + +/** Callback for the svn_diff_tree_processor_t wrapper, to allow handling + * notifications like how the repos diff in libsvn_client does. + * + * Probably only necessary while transitioning to svn_diff_tree_processor_t + */ +typedef svn_error_t * + (*svn_wc__diff_state_close_t)(const char *relpath, + svn_node_kind_t kind, + void *state_baton, + apr_pool_t *scratch_pool); + +/** Callback for the svn_diff_tree_processor_t wrapper, to allow handling + * absent nodes. + * + * Probably only necessary while transitioning to svn_diff_tree_processor_t + */ +typedef svn_error_t * + (*svn_wc__diff_state_absent_t)(const char *relpath, + void *state_baton, + apr_pool_t *scratch_pool); + +/** Obtains a diff processor that will drive the diff callbacks when it + * is invoked. + */ +svn_error_t * +svn_wc__wrap_diff_callbacks(const svn_diff_tree_processor_t **diff_processor, + const svn_wc_diff_callbacks4_t *callbacks, + void *callback_baton, + svn_boolean_t walk_deleted_dirs, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Assuming @a local_abspath itself or any of its children are under version + * control or a tree conflict victim and in a state of conflict, take these + * nodes out of this state. + * + * If @a resolve_text is TRUE then any text conflict is resolved, + * if @a resolve_tree is TRUE then any tree conflicts are resolved. + * If @a resolve_prop is set to "" all property conflicts are resolved, + * if it is set to any other string value, conflicts on that specific + * property are resolved and when resolve_prop is NULL, no property + * conflicts are resolved. + * + * If @a depth is #svn_depth_empty, act only on @a local_abspath; if + * #svn_depth_files, resolve @a local_abspath and its conflicted file + * children (if any); if #svn_depth_immediates, resolve @a local_abspath + * and all its immediate conflicted children (both files and directories, + * if any); if #svn_depth_infinity, resolve @a local_abspath and every + * conflicted file or directory anywhere beneath it. + * + * If @a conflict_choice is #svn_wc_conflict_choose_base, resolve the + * conflict with the old file contents; if + * #svn_wc_conflict_choose_mine_full, use the original working contents; + * if #svn_wc_conflict_choose_theirs_full, the new contents; and if + * #svn_wc_conflict_choose_merged, don't change the contents at all, + * just remove the conflict status, which is the pre-1.5 behavior. + * + * If @a conflict_choice is #svn_wc_conflict_choose_unspecified, invoke the + * @a conflict_func with the @a conflict_baton argument to obtain a + * resolution decision for each conflict. + * + * #svn_wc_conflict_choose_theirs_conflict and + * #svn_wc_conflict_choose_mine_conflict are not legal for binary + * files or properties. + * + * @a wc_ctx is a working copy context, with a write lock, for @a + * local_abspath. + * + * The implementation details are opaque, as our "conflicted" criteria + * might change over time. (At the moment, this routine removes the + * three fulltext 'backup' files and any .prej file created in a conflict, + * and modifies @a local_abspath's entry.) + * + * If @a local_abspath is not under version control and not a tree + * conflict, return #SVN_ERR_ENTRY_NOT_FOUND. If @a path isn't in a + * state of conflict to begin with, do nothing, and return #SVN_NO_ERROR. + * + * If @c local_abspath was successfully taken out of a state of conflict, + * report this information to @c notify_func (if non-@c NULL.) If only + * text, only property, or only tree conflict resolution was requested, + * and it was successful, then success gets reported. + * + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc__resolve_conflicts(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + svn_boolean_t resolve_text, + const char *resolve_prop, + svn_boolean_t resolve_tree, + svn_wc_conflict_choice_t conflict_choice, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** + * Move @a src_abspath to @a dst_abspath, by scheduling @a dst_abspath + * for addition to the repository, remembering the history. Mark @a src_abspath + * as deleted after moving.@a wc_ctx is used for accessing the working copy and + * must contain a write lock for the parent directory of @a src_abspath and + * @a dst_abspath. + * + * If @a metadata_only is TRUE then this is a database-only operation and + * the working directories and files are not changed. + * + * @a src_abspath must be a file or directory under version control; + * the parent of @a dst_abspath must be a directory under version control + * in the same working copy; @a dst_abspath will be the name of the copied + * item, and it must not exist already if @a metadata_only is FALSE. Note that + * when @a src points to a versioned file, the working file doesn't + * necessarily exist in which case its text-base is used instead. + * + * If @a allow_mixed_revisions is @c FALSE, #SVN_ERR_WC_MIXED_REVISIONS + * will be raised if the move source is a mixed-revision subtree. + * If @a allow_mixed_revisions is TRUE, a mixed-revision move source is + * allowed but the move will degrade to a copy and a delete without local + * move tracking. This parameter should be set to FALSE except where backwards + * compatibility to svn_wc_move() is required. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the operation. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * If @a notify_func is non-NULL, call it with @a notify_baton and the path + * of the root node (only) of the destination. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc__move2(svn_wc_context_t *wc_ctx, + const char *src_abspath, + const char *dst_abspath, + svn_boolean_t metadata_only, + svn_boolean_t allow_mixed_revisions, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/* During merge when we encounter added directories, we add them using + svn_wc_add4(), recording its original location, etc. But at that time + we don't have its original properties. This function allows updating the + BASE properties of such a special added node, but only before it receives + other changes. + + NEW_ORIGINAL_PROPS is a new set of properties, including entry props that + will be applied to LOCAL_ABSPATH as pristine properties. + + The copyfrom_* arguments are used to verify (some of) the assumptions of + this function */ +svn_error_t * +svn_wc__complete_directory_add(svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_hash_t *new_original_props, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + apr_pool_t *scratch_pool); + + +/* Acquire a write lock on LOCAL_ABSPATH or an ancestor that covers + all possible paths affected by resolving the conflicts in the tree + LOCAL_ABSPATH. Set *LOCK_ROOT_ABSPATH to the path of the lock + obtained. */ +svn_error_t * +svn_wc__acquire_write_lock_for_resolve(const char **lock_root_abspath, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_WC_PRIVATE_H */ diff --git a/subversion/include/svn_auth.h b/subversion/include/svn_auth.h new file mode 100644 index 0000000..dadc1cf --- /dev/null +++ b/subversion/include/svn_auth.h @@ -0,0 +1,1282 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_auth.h + * @brief Subversion's authentication system + */ + +#ifndef SVN_AUTH_H +#define SVN_AUTH_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> + +#include "svn_types.h" +#include "svn_config.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Overview of the svn authentication system. + * + * We define an authentication "provider" as a module that is able to + * return a specific set of credentials. (e.g. username/password, + * certificate, etc.) Each provider implements a vtable that + * + * - can fetch initial credentials + * - can retry the fetch (or try to fetch something different) + * - can store the credentials for future use + * + * For any given type of credentials, there can exist any number of + * separate providers -- each provider has a different method of + * fetching. (i.e. from a disk store, by prompting the user, etc.) + * + * The application begins by creating an auth baton object, and + * "registers" some number of providers with the auth baton, in a + * specific order. (For example, it may first register a + * username/password provider that looks in disk store, then register + * a username/password provider that prompts the user.) + * + * Later on, when any svn library is challenged, it asks the auth + * baton for the specific credentials. If the initial credentials + * fail to authenticate, the caller keeps requesting new credentials. + * Under the hood, libsvn_auth effectively "walks" over each provider + * (in order of registry), one at a time, until all the providers have + * exhausted all their retry options. + * + * This system allows an application to flexibly define authentication + * behaviors (by changing registration order), and very easily write + * new authentication providers. + * + * An auth_baton also contains an internal hashtable of run-time + * parameters; any provider or library layer can set these run-time + * parameters at any time, so that the provider has access to the + * data. (For example, certain run-time data may not be available + * until an authentication challenge is made.) Each credential type + * must document the run-time parameters that are made available to + * its providers. + * + * @defgroup auth_fns Authentication functions + * @{ + */ + + +/** The type of a Subversion authentication object */ +typedef struct svn_auth_baton_t svn_auth_baton_t; + +/** The type of a Subversion authentication-iteration object */ +typedef struct svn_auth_iterstate_t svn_auth_iterstate_t; + + +/** The main authentication "provider" vtable. */ +typedef struct svn_auth_provider_t +{ + /** The kind of credentials this provider knows how to retrieve. */ + const char *cred_kind; + + /** Get an initial set of credentials. + * + * Set @a *credentials to a set of valid credentials within @a + * realmstring, or NULL if no credentials are available. Set @a + * *iter_baton to context that allows a subsequent call to @c + * next_credentials, in case the first credentials fail to + * authenticate. @a provider_baton is general context for the + * vtable, @a parameters contains any run-time data that the + * provider may need, and @a realmstring comes from the + * svn_auth_first_credentials() call. + */ + svn_error_t * (*first_credentials)(void **credentials, + void **iter_baton, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + apr_pool_t *pool); + + /** Get a different set of credentials. + * + * Set @a *credentials to another set of valid credentials (using @a + * iter_baton as the context from previous call to first_credentials + * or next_credentials). If no more credentials are available, set + * @a *credentials to NULL. If the provider only has one set of + * credentials, this function pointer should simply be NULL. @a + * provider_baton is general context for the vtable, @a parameters + * contains any run-time data that the provider may need, and @a + * realmstring comes from the svn_auth_first_credentials() call. + */ + svn_error_t * (*next_credentials)(void **credentials, + void *iter_baton, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + apr_pool_t *pool); + + /** Save credentials. + * + * Store @a credentials for future use. @a provider_baton is + * general context for the vtable, and @a parameters contains any + * run-time data the provider may need. Set @a *saved to TRUE if + * the save happened, or FALSE if not. The provider is not required + * to save; if it refuses or is unable to save for non-fatal + * reasons, return FALSE. If the provider never saves data, then + * this function pointer should simply be NULL. @a realmstring comes + * from the svn_auth_first_credentials() call. + */ + svn_error_t * (*save_credentials)(svn_boolean_t *saved, + void *credentials, + void *provider_baton, + apr_hash_t *parameters, + const char *realmstring, + apr_pool_t *pool); + +} svn_auth_provider_t; + + +/** A provider object, ready to be put into an array and given to + svn_auth_open(). */ +typedef struct svn_auth_provider_object_t +{ + const svn_auth_provider_t *vtable; + void *provider_baton; + +} svn_auth_provider_object_t; + +/** The type of function returning authentication provider. */ +typedef void (*svn_auth_simple_provider_func_t)( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Specific types of credentials **/ + +/** Simple username/password pair credential kind. + * + * The following auth parameters are available to the providers: + * + * - @c SVN_AUTH_PARAM_CONFIG_CATEGORY_CONFIG (@c svn_config_t*) + * - @c SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS (@c svn_config_t*) + * + * The following auth parameters may be available to the providers: + * + * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*) + * - @c SVN_AUTH_PARAM_DEFAULT_USERNAME (@c char*) + * - @c SVN_AUTH_PARAM_DEFAULT_PASSWORD (@c char*) + */ +#define SVN_AUTH_CRED_SIMPLE "svn.simple" + +/** @c SVN_AUTH_CRED_SIMPLE credentials. */ +typedef struct svn_auth_cred_simple_t +{ + /** Username */ + const char *username; + /** Password */ + const char *password; + /** Indicates if the credentials may be saved (to disk). For example, a + * GUI prompt implementation with a remember password checkbox shall set + * @a may_save to TRUE if the checkbox is checked. + */ + svn_boolean_t may_save; +} svn_auth_cred_simple_t; + + +/** Username credential kind. + * + * The following optional auth parameters are relevant to the providers: + * + * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*) + * - @c SVN_AUTH_PARAM_DEFAULT_USERNAME (@c char*) + */ +#define SVN_AUTH_CRED_USERNAME "svn.username" + +/** @c SVN_AUTH_CRED_USERNAME credentials. */ +typedef struct svn_auth_cred_username_t +{ + /** Username */ + const char *username; + /** Indicates if the credentials may be saved (to disk). For example, a + * GUI prompt implementation with a remember username checkbox shall set + * @a may_save to TRUE if the checkbox is checked. + */ + svn_boolean_t may_save; +} svn_auth_cred_username_t; + + +/** SSL client certificate credential type. + * + * The following auth parameters are available to the providers: + * + * - @c SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS (@c svn_config_t*) + * - @c SVN_AUTH_PARAM_SERVER_GROUP (@c char*) + * + * The following optional auth parameters are relevant to the providers: + * + * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*) + */ +#define SVN_AUTH_CRED_SSL_CLIENT_CERT "svn.ssl.client-cert" + +/** @c SVN_AUTH_CRED_SSL_CLIENT_CERT credentials. */ +typedef struct svn_auth_cred_ssl_client_cert_t +{ + /** Absolute path to the certificate file */ + const char *cert_file; + /** Indicates if the credentials may be saved (to disk). For example, a + * GUI prompt implementation with a remember certificate checkbox shall + * set @a may_save to TRUE if the checkbox is checked. + */ + svn_boolean_t may_save; +} svn_auth_cred_ssl_client_cert_t; + + +/** A function returning an SSL client certificate passphrase provider. */ +typedef void (*svn_auth_ssl_client_cert_pw_provider_func_t)( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +/** SSL client certificate passphrase credential type. + * + * @note The realmstring used with this credential type must be a name that + * makes it possible for the user to identify the certificate. + * + * The following auth parameters are available to the providers: + * + * - @c SVN_AUTH_PARAM_CONFIG_CATEGORY_CONFIG (@c svn_config_t*) + * - @c SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS (@c svn_config_t*) + * - @c SVN_AUTH_PARAM_SERVER_GROUP (@c char*) + * + * The following optional auth parameters are relevant to the providers: + * + * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*) + */ +#define SVN_AUTH_CRED_SSL_CLIENT_CERT_PW "svn.ssl.client-passphrase" + +/** @c SVN_AUTH_CRED_SSL_CLIENT_CERT_PW credentials. */ +typedef struct svn_auth_cred_ssl_client_cert_pw_t +{ + /** Certificate password */ + const char *password; + /** Indicates if the credentials may be saved (to disk). For example, a + * GUI prompt implementation with a remember password checkbox shall set + * @a may_save to TRUE if the checkbox is checked. + */ + svn_boolean_t may_save; +} svn_auth_cred_ssl_client_cert_pw_t; + + +/** SSL server verification credential type. + * + * The following auth parameters are available to the providers: + * + * - @c SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS (@c svn_config_t*) + * - @c SVN_AUTH_PARAM_SERVER_GROUP (@c char*) + * - @c SVN_AUTH_PARAM_SSL_SERVER_FAILURES (@c apr_uint32_t*) + * - @c SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO + * (@c svn_auth_ssl_server_cert_info_t*) + * + * The following optional auth parameters are relevant to the providers: + * + * - @c SVN_AUTH_PARAM_NO_AUTH_CACHE (@c void*) + */ +#define SVN_AUTH_CRED_SSL_SERVER_TRUST "svn.ssl.server" + +/** SSL server certificate information used by @c + * SVN_AUTH_CRED_SSL_SERVER_TRUST providers. + */ +typedef struct svn_auth_ssl_server_cert_info_t +{ + /** Primary CN */ + const char *hostname; + /** ASCII fingerprint */ + const char *fingerprint; + /** ASCII date from which the certificate is valid */ + const char *valid_from; + /** ASCII date until which the certificate is valid */ + const char *valid_until; + /** DN of the certificate issuer */ + const char *issuer_dname; + /** Base-64 encoded DER certificate representation */ + const char *ascii_cert; +} svn_auth_ssl_server_cert_info_t; + +/** + * Return a deep copy of @a info, allocated in @a pool. + * + * @since New in 1.3. + */ +svn_auth_ssl_server_cert_info_t * +svn_auth_ssl_server_cert_info_dup(const svn_auth_ssl_server_cert_info_t *info, + apr_pool_t *pool); + +/** @c SVN_AUTH_CRED_SSL_SERVER_TRUST credentials. */ +typedef struct svn_auth_cred_ssl_server_trust_t +{ + /** Indicates if the credentials may be saved (to disk). For example, a + * GUI prompt implementation with a checkbox to accept the certificate + * permanently shall set @a may_save to TRUE if the checkbox is checked. + */ + svn_boolean_t may_save; + /** Bit mask of the accepted failures */ + apr_uint32_t accepted_failures; +} svn_auth_cred_ssl_server_trust_t; + + + +/** Credential-constructing prompt functions. **/ + +/** These exist so that different client applications can use + * different prompt mechanisms to supply the same credentials. For + * example, if authentication requires a username and password, a + * command-line client's prompting function might prompt first for the + * username and then for the password, whereas a GUI client's would + * present a single dialog box asking for both, and a telepathic + * client's would read all the information directly from the user's + * mind. All these prompting functions return the same type of + * credential, but the information used to construct the credential is + * gathered in an interface-specific way in each case. + */ + +/** Set @a *cred by prompting the user, allocating @a *cred in @a pool. + * @a baton is an implementation-specific closure. + * + * If @a realm is non-NULL, maybe use it in the prompt string. + * + * If @a username is non-NULL, then the user might be prompted only + * for a password, but @a *cred would still be filled with both + * username and password. For example, a typical usage would be to + * pass @a username on the first call, but then leave it NULL for + * subsequent calls, on the theory that if credentials failed, it's + * as likely to be due to incorrect username as incorrect password. + * + * If @a may_save is FALSE, the auth system does not allow the credentials + * to be saved (to disk). A prompt function shall not ask the user if the + * credentials shall be saved if @a may_save is FALSE. For example, a GUI + * client with a remember password checkbox would grey out the checkbox if + * @a may_save is FALSE. + */ +typedef svn_error_t *(*svn_auth_simple_prompt_func_t)( + svn_auth_cred_simple_t **cred, + void *baton, + const char *realm, + const char *username, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** Set @a *cred by prompting the user, allocating @a *cred in @a pool. + * @a baton is an implementation-specific closure. + * + * If @a realm is non-NULL, maybe use it in the prompt string. + * + * If @a may_save is FALSE, the auth system does not allow the credentials + * to be saved (to disk). A prompt function shall not ask the user if the + * credentials shall be saved if @a may_save is FALSE. For example, a GUI + * client with a remember username checkbox would grey out the checkbox if + * @a may_save is FALSE. + */ +typedef svn_error_t *(*svn_auth_username_prompt_func_t)( + svn_auth_cred_username_t **cred, + void *baton, + const char *realm, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** @name SSL server certificate failure bits + * + * @note These values are stored in the on disk auth cache by the SSL + * server certificate auth provider, so the meaning of these bits must + * not be changed. + * @{ + */ +/** Certificate is not yet valid. */ +#define SVN_AUTH_SSL_NOTYETVALID 0x00000001 +/** Certificate has expired. */ +#define SVN_AUTH_SSL_EXPIRED 0x00000002 +/** Certificate's CN (hostname) does not match the remote hostname. */ +#define SVN_AUTH_SSL_CNMISMATCH 0x00000004 +/** @brief Certificate authority is unknown (i.e. not trusted) */ +#define SVN_AUTH_SSL_UNKNOWNCA 0x00000008 +/** @brief Other failure. This can happen if an unknown failure occurs + * that we do not handle yet. */ +#define SVN_AUTH_SSL_OTHER 0x40000000 +/** @} */ + +/** Set @a *cred by prompting the user, allocating @a *cred in @a pool. + * @a baton is an implementation-specific closure. + * + * @a cert_info is a structure describing the server cert that was + * presented to the client, and @a failures is a bitmask that + * describes exactly why the cert could not be automatically validated, + * composed from the constants SVN_AUTH_SSL_* (@c SVN_AUTH_SSL_NOTYETVALID + * etc.). @a realm is a string that can be used in the prompt string. + * + * If @a may_save is FALSE, the auth system does not allow the credentials + * to be saved (to disk). A prompt function shall not ask the user if the + * credentials shall be saved if @a may_save is FALSE. For example, a GUI + * client with a trust permanently checkbox would grey out the checkbox if + * @a may_save is FALSE. + */ +typedef svn_error_t *(*svn_auth_ssl_server_trust_prompt_func_t)( + svn_auth_cred_ssl_server_trust_t **cred, + void *baton, + const char *realm, + apr_uint32_t failures, + const svn_auth_ssl_server_cert_info_t *cert_info, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** Set @a *cred by prompting the user, allocating @a *cred in @a pool. + * @a baton is an implementation-specific closure. @a realm is a string + * that can be used in the prompt string. + * + * If @a may_save is FALSE, the auth system does not allow the credentials + * to be saved (to disk). A prompt function shall not ask the user if the + * credentials shall be saved if @a may_save is FALSE. For example, a GUI + * client with a remember certificate checkbox would grey out the checkbox + * if @a may_save is FALSE. + */ +typedef svn_error_t *(*svn_auth_ssl_client_cert_prompt_func_t)( + svn_auth_cred_ssl_client_cert_t **cred, + void *baton, + const char *realm, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** Set @a *cred by prompting the user, allocating @a *cred in @a pool. + * @a baton is an implementation-specific closure. @a realm is a string + * identifying the certificate, and can be used in the prompt string. + * + * If @a may_save is FALSE, the auth system does not allow the credentials + * to be saved (to disk). A prompt function shall not ask the user if the + * credentials shall be saved if @a may_save is FALSE. For example, a GUI + * client with a remember password checkbox would grey out the checkbox if + * @a may_save is FALSE. + */ +typedef svn_error_t *(*svn_auth_ssl_client_cert_pw_prompt_func_t)( + svn_auth_cred_ssl_client_cert_pw_t **cred, + void *baton, + const char *realm, + svn_boolean_t may_save, + apr_pool_t *pool); + +/** A type of callback function for asking whether storing a password to + * disk in plaintext is allowed. + * + * In this callback, the client should ask the user whether storing + * a password for the realm identified by @a realmstring to disk + * in plaintext is allowed. + * + * The answer is returned in @a *may_save_plaintext. + * @a baton is an implementation-specific closure. + * All allocations should be done in @a pool. + * + * @since New in 1.6 + */ +typedef svn_error_t *(*svn_auth_plaintext_prompt_func_t)( + svn_boolean_t *may_save_plaintext, + const char *realmstring, + void *baton, + apr_pool_t *pool); + +/** A type of callback function for asking whether storing a passphrase to + * disk in plaintext is allowed. + * + * In this callback, the client should ask the user whether storing + * a passphrase for the realm identified by @a realmstring to disk + * in plaintext is allowed. + * + * The answer is returned in @a *may_save_plaintext. + * @a baton is an implementation-specific closure. + * All allocations should be done in @a pool. + * + * @since New in 1.6 + */ +typedef svn_error_t *(*svn_auth_plaintext_passphrase_prompt_func_t)( + svn_boolean_t *may_save_plaintext, + const char *realmstring, + void *baton, + apr_pool_t *pool); + + +/** Initialize an authentication system. + * + * Return an authentication object in @a *auth_baton (allocated in @a + * pool) that represents a particular instance of the svn + * authentication system. @a providers is an array of @c + * svn_auth_provider_object_t pointers, already allocated in @a pool + * and intentionally ordered. These pointers will be stored within @a + * *auth_baton, grouped by credential type, and searched in this exact + * order. + */ +void +svn_auth_open(svn_auth_baton_t **auth_baton, + const apr_array_header_t *providers, + apr_pool_t *pool); + +/** Set an authentication run-time parameter. + * + * Store @a name / @a value pair as a run-time parameter in @a + * auth_baton, making the data accessible to all providers. @a name + * and @a value will NOT be duplicated into the auth_baton's pool. + * To delete a run-time parameter, pass NULL for @a value. + */ +void +svn_auth_set_parameter(svn_auth_baton_t *auth_baton, + const char *name, + const void *value); + +/** Get an authentication run-time parameter. + * + * Return a value for run-time parameter @a name from @a auth_baton. + * Return NULL if the parameter doesn't exist. + */ +const void * +svn_auth_get_parameter(svn_auth_baton_t *auth_baton, + const char *name); + +/** Universal run-time parameters, made available to all providers. + + If you are writing a new provider, then to be a "good citizen", + you should notice these global parameters! Note that these + run-time params should be treated as read-only by providers; the + application is responsible for placing them into the auth_baton + hash. */ + +/** The auth-hash prefix indicating that the parameter is global. */ +#define SVN_AUTH_PARAM_PREFIX "svn:auth:" + +/** + * @name Default credentials defines + * Property values are const char *. + * @{ */ +/** Default username provided by the application itself (e.g. --username) */ +#define SVN_AUTH_PARAM_DEFAULT_USERNAME SVN_AUTH_PARAM_PREFIX "username" +/** Default password provided by the application itself (e.g. --password) */ +#define SVN_AUTH_PARAM_DEFAULT_PASSWORD SVN_AUTH_PARAM_PREFIX "password" +/** @} */ + +/** @brief The application doesn't want any providers to prompt + * users. Property value is irrelevant; only property's existence + * matters. */ +#define SVN_AUTH_PARAM_NON_INTERACTIVE SVN_AUTH_PARAM_PREFIX "non-interactive" + +/** @brief The application doesn't want any providers to save passwords + * to disk. Property value is irrelevant; only property's existence + * matters. */ +#define SVN_AUTH_PARAM_DONT_STORE_PASSWORDS SVN_AUTH_PARAM_PREFIX \ + "dont-store-passwords" + +/** @brief Indicates whether providers may save passwords to disk in + * plaintext. Property value can be either SVN_CONFIG_TRUE, + * SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. + * @since New in 1.6. + */ +#define SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS SVN_AUTH_PARAM_PREFIX \ + "store-plaintext-passwords" + +/** @brief The application doesn't want any providers to save passphrase + * to disk. Property value is irrelevant; only property's existence + * matters. + * @since New in 1.6. + */ +#define SVN_AUTH_PARAM_DONT_STORE_SSL_CLIENT_CERT_PP \ + SVN_AUTH_PARAM_PREFIX "dont-store-ssl-client-cert-pp" + +/** @brief Indicates whether providers may save passphrase to disk in + * plaintext. Property value can be either SVN_CONFIG_TRUE, + * SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. + * @since New in 1.6. + */ +#define SVN_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ + SVN_AUTH_PARAM_PREFIX "store-ssl-client-cert-pp-plaintext" + +/** @brief The application doesn't want any providers to save credentials + * to disk. Property value is irrelevant; only property's existence + * matters. */ +#define SVN_AUTH_PARAM_NO_AUTH_CACHE SVN_AUTH_PARAM_PREFIX "no-auth-cache" + +/** @brief The following property is for SSL server cert providers. This + * provides a pointer to an @c apr_uint32_t containing the failures + * detected by the certificate validator. */ +#define SVN_AUTH_PARAM_SSL_SERVER_FAILURES SVN_AUTH_PARAM_PREFIX \ + "ssl:failures" + +/** @brief The following property is for SSL server cert providers. This + * provides the cert info (svn_auth_ssl_server_cert_info_t). */ +#define SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO SVN_AUTH_PARAM_PREFIX \ + "ssl:cert-info" + +/** This provides a pointer to a @c svn_config_t containting the config + * category. */ +#define SVN_AUTH_PARAM_CONFIG_CATEGORY_CONFIG SVN_AUTH_PARAM_PREFIX \ + "config-category-config" + +/** This provides a pointer to a @c svn_config_t containting the servers + * category. */ +#define SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS SVN_AUTH_PARAM_PREFIX \ + "config-category-servers" + +/** @deprecated Provided for backward compatibility with the 1.5 API. */ +#define SVN_AUTH_PARAM_CONFIG SVN_AUTH_PARAM_CONFIG_CATEGORY_SERVERS + +/** The current server group. */ +#define SVN_AUTH_PARAM_SERVER_GROUP SVN_AUTH_PARAM_PREFIX "server-group" + +/** @brief A configuration directory that overrides the default + * ~/.subversion. */ +#define SVN_AUTH_PARAM_CONFIG_DIR SVN_AUTH_PARAM_PREFIX "config-dir" + +/** Get an initial set of credentials. + * + * Ask @a auth_baton to set @a *credentials to a set of credentials + * defined by @a cred_kind and valid within @a realmstring, or NULL if + * no credentials are available. Otherwise, return an iteration state + * in @a *state, so that the caller can call + * svn_auth_next_credentials(), in case the first set of credentials + * fails to authenticate. + * + * Use @a pool to allocate @a *state, and for temporary allocation. + * Note that @a *credentials will be allocated in @a auth_baton's pool. + */ +svn_error_t * +svn_auth_first_credentials(void **credentials, + svn_auth_iterstate_t **state, + const char *cred_kind, + const char *realmstring, + svn_auth_baton_t *auth_baton, + apr_pool_t *pool); + +/** Get another set of credentials, assuming previous ones failed to + * authenticate. + * + * Use @a state to fetch a different set of @a *credentials, as a + * follow-up to svn_auth_first_credentials() or + * svn_auth_next_credentials(). If no more credentials are available, + * set @a *credentials to NULL. + * + * Note that @a *credentials will be allocated in @c auth_baton's pool. + */ +svn_error_t * +svn_auth_next_credentials(void **credentials, + svn_auth_iterstate_t *state, + apr_pool_t *pool); + +/** Save a set of credentials. + * + * Ask @a state to store the most recently returned credentials, + * presumably because they successfully authenticated. + * All allocations should be done in @a pool. + * + * If no credentials were ever returned, do nothing. + */ +svn_error_t * +svn_auth_save_credentials(svn_auth_iterstate_t *state, + apr_pool_t *pool); + +/** Forget a set (or all) memory-cached credentials. + * + * Remove references (if any) in @a auth_baton to credentials cached + * therein. If @a cred_kind and @a realmstring are non-NULL, forget + * only the credentials associated with those credential types and + * realm. Otherwise @a cred_kind and @a realmstring must both be + * NULL, and this function will forget all credentials cached within + * @a auth_baton. + * + * @note This function does not affect persisted authentication + * credential storage at all. It is merely a way to cause Subversion + * to forget about credentials already fetched from a provider, + * forcing them to be fetched again later should they be required. + * + * @since New in 1.8. + */ +svn_error_t * +svn_auth_forget_credentials(svn_auth_baton_t *auth_baton, + const char *cred_kind, + const char *realmstring, + apr_pool_t *pool); + +/** @} */ + +/** Set @a *provider to an authentication provider of type + * svn_auth_cred_simple_t that gets information by prompting the user + * with @a prompt_func and @a prompt_baton. Allocate @a *provider in + * @a pool. + * + * If both @c SVN_AUTH_PARAM_DEFAULT_USERNAME and + * @c SVN_AUTH_PARAM_DEFAULT_PASSWORD are defined as runtime + * parameters in the @c auth_baton, then @a *provider will return the + * default arguments when svn_auth_first_credentials() is called. If + * svn_auth_first_credentials() fails, then @a *provider will + * re-prompt @a retry_limit times (via svn_auth_next_credentials()). + * For infinite retries, set @a retry_limit to value less than 0. + * + * @since New in 1.4. + */ +void +svn_auth_get_simple_prompt_provider(svn_auth_provider_object_t **provider, + svn_auth_simple_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_username_t that gets information by prompting the + * user with @a prompt_func and @a prompt_baton. Allocate @a *provider + * in @a pool. + * + * If @c SVN_AUTH_PARAM_DEFAULT_USERNAME is defined as a runtime + * parameter in the @c auth_baton, then @a *provider will return the + * default argument when svn_auth_first_credentials() is called. If + * svn_auth_first_credentials() fails, then @a *provider will + * re-prompt @a retry_limit times (via svn_auth_next_credentials()). + * For infinite retries, set @a retry_limit to value less than 0. + * + * @since New in 1.4. + */ +void +svn_auth_get_username_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_username_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. + * + * If the provider is going to save the password unencrypted, it calls @a + * plaintext_prompt_func, passing @a prompt_baton, before saving the + * password. + * + * If @a plaintext_prompt_func is NULL it is not called and the answer is + * assumed to be TRUE. This matches the deprecated behaviour of storing + * unencrypted passwords by default, and is only done this way for backward + * compatibility reasons. + * Client developers are highly encouraged to provide this callback + * to ensure their users are made aware of the fact that their password + * is going to be stored unencrypted. In the future, providers may + * default to not storing the password unencrypted if this callback is NULL. + * + * Clients can however set the callback to NULL and set + * SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS to SVN_CONFIG_FALSE or + * SVN_CONFIG_TRUE to enforce a certain behaviour. + * + * Allocate @a *provider in @a pool. + * + * If a default username or password is available, @a *provider will + * honor them as well, and return them when + * svn_auth_first_credentials() is called. (see @c + * SVN_AUTH_PARAM_DEFAULT_USERNAME and @c + * SVN_AUTH_PARAM_DEFAULT_PASSWORD). + * + * @since New in 1.6. + */ +void +svn_auth_get_simple_provider2( + svn_auth_provider_object_t **provider, + svn_auth_plaintext_prompt_func_t plaintext_prompt_func, + void *prompt_baton, + apr_pool_t *pool); + +/** Like svn_auth_get_simple_provider2, but without the ability to + * call the svn_auth_plaintext_prompt_func_t callback, and the provider + * always assumes that it is allowed to store the password in plaintext. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. + * @since New in 1.4. + */ +SVN_DEPRECATED +void +svn_auth_get_simple_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_provider_object_t, or return @c NULL if the provider is not + * available for the requested platform or the requested provider is unknown. + * + * Valid @a provider_name values are: "gnome_keyring", "keychain", "kwallet", + * "gpg_agent", and "windows". + * + * Valid @a provider_type values are: "simple", "ssl_client_cert_pw" and + * "ssl_server_trust". + * + * Allocate @a *provider in @a pool. + * + * What actually happens is we invoke the appropriate provider function to + * supply the @a provider, like so: + * + * svn_auth_get_<name>_<type>_provider(@a provider, @a pool); + * + * @since New in 1.6. + */ +svn_error_t * +svn_auth_get_platform_specific_provider( + svn_auth_provider_object_t **provider, + const char *provider_name, + const char *provider_type, + apr_pool_t *pool); + +/** Set @a *providers to an array of <tt>svn_auth_provider_object_t *</tt> + * objects. + * Only client authentication providers available for the current platform are + * returned. Order of the platform-specific authentication providers is + * determined by the 'password-stores' configuration option which is retrieved + * from @a config. @a config can be NULL. + * + * Create and allocate @a *providers in @a pool. + * + * Default order of the platform-specific authentication providers: + * 1. gnome-keyring + * 2. kwallet + * 3. keychain + * 4. gpg-agent + * 5. windows-cryptoapi + * + * @since New in 1.6. + */ +svn_error_t * +svn_auth_get_platform_specific_client_providers( + apr_array_header_t **providers, + svn_config_t *config, + apr_pool_t *pool); + +#if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN) +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_auth_get_simple_provider(), except that, when + * running on Window 2000 or newer (or any other Windows version that + * includes the CryptoAPI), the provider encrypts the password before + * storing it to disk. On earlier versions of Windows, the provider + * does nothing. + * + * @since New in 1.4. + * @note This function is only available on Windows. + * + * @note An administrative password reset may invalidate the account's + * secret key. This function will detect that situation and behave as + * if the password were not cached at all. + */ +void +svn_auth_get_windows_simple_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the + * user's ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_auth_get_ssl_client_cert_pw_file_provider(), except that + * when running on Window 2000 or newer, the provider encrypts the password + * before storing it to disk. On earlier versions of Windows, the provider + * does nothing. + * + * @since New in 1.6 + * @note This function is only available on Windows. + * + * @note An administrative password reset may invalidate the account's + * secret key. This function will detect that situation and behave as + * if the password were not cached at all. + */ +void +svn_auth_get_windows_ssl_client_cert_pw_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_server_trust_t, allocated in @a pool. + * + * This provider automatically validates ssl server certificates with + * the CryptoApi, like Internet Explorer and the Windows network API do. + * This allows the rollout of root certificates via Windows Domain + * policies, instead of Subversion specific configuration. + * + * @since New in 1.5. + * @note This function is only available on Windows. + */ +void +svn_auth_get_windows_ssl_server_trust_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +#endif /* WIN32 && !__MINGW32__ || DOXYGEN */ + +#if defined(DARWIN) || defined(DOXYGEN) +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_auth_get_simple_provider(), except that the + * password is stored in the Mac OS KeyChain. + * + * @since New in 1.4 + * @note This function is only available on Mac OS 10.2 and higher. + */ +void +svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the + * user's ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_auth_get_ssl_client_cert_pw_file_provider(), except + * that the password is stored in the Mac OS KeyChain. + * + * @since New in 1.6 + * @note This function is only available on Mac OS 10.2 and higher. + */ +void +svn_auth_get_keychain_ssl_client_cert_pw_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); +#endif /* DARWIN || DOXYGEN */ + +#if (!defined(DARWIN) && !defined(WIN32)) || defined(DOXYGEN) +/** A type of callback function for obtaining the GNOME Keyring password. + * + * In this callback, the client should ask the user for default keyring + * @a keyring_name password. + * + * The answer is returned in @a *keyring_password. + * @a baton is an implementation-specific closure. + * All allocations should be done in @a pool. + * + * @since New in 1.6 + */ +typedef svn_error_t *(*svn_auth_gnome_keyring_unlock_prompt_func_t)( + char **keyring_password, + const char *keyring_name, + void *baton, + apr_pool_t *pool); + + +/** libsvn_auth_gnome_keyring-specific run-time parameters. */ + +/** @brief The pointer to function which prompts user for GNOME Keyring + * password. + * The type of this pointer should be svn_auth_gnome_keyring_unlock_prompt_func_t. */ +#define SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC "gnome-keyring-unlock-prompt-func" + +/** @brief The baton which is passed to + * @c *SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC. */ +#define SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_BATON "gnome-keyring-unlock-prompt-baton" + + +/** + * Get libsvn_auth_gnome_keyring version information. + * + * @since New in 1.6 + */ +const svn_version_t * +svn_auth_gnome_keyring_version(void); + + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. + * + * This is like svn_client_get_simple_provider(), except that the + * password is stored in GNOME Keyring. + * + * If the GNOME Keyring is locked the provider calls + * @c *SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC in order to unlock + * the keyring. + * + * @c SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_BATON is passed to + * @c *SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC. + * + * Allocate @a *provider in @a pool. + * + * @since New in 1.6 + * @note This function actually works only on systems with + * libsvn_auth_gnome_keyring and GNOME Keyring installed. + */ +void +svn_auth_get_gnome_keyring_simple_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the + * user's ~/.subversion configuration directory. + * + * This is like svn_client_get_ssl_client_cert_pw_file_provider(), except + * that the password is stored in GNOME Keyring. + * + * If the GNOME Keyring is locked the provider calls + * @c *SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC in order to unlock + * the keyring. + * + * @c SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_BATON is passed to + * @c *SVN_AUTH_PARAM_GNOME_KEYRING_UNLOCK_PROMPT_FUNC. + * + * Allocate @a *provider in @a pool. + * + * @since New in 1.6 + * @note This function actually works only on systems with + * libsvn_auth_gnome_keyring and GNOME Keyring installed. + */ +void +svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** + * Get libsvn_auth_kwallet version information. + * + * @since New in 1.6 + */ +const svn_version_t * +svn_auth_kwallet_version(void); + + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_client_get_simple_provider(), except that the + * password is stored in KWallet. + * + * @since New in 1.6 + * @note This function actually works only on systems with libsvn_auth_kwallet + * and KWallet installed. + */ +void +svn_auth_get_kwallet_simple_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the + * user's ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_client_get_ssl_client_cert_pw_file_provider(), except + * that the password is stored in KWallet. + * + * @since New in 1.6 + * @note This function actually works only on systems with libsvn_auth_kwallet + * and KWallet installed. + */ +void +svn_auth_get_kwallet_ssl_client_cert_pw_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); +#endif /* (!DARWIN && !WIN32) || DOXYGEN */ + +#if !defined(WIN32) || defined(DOXYGEN) +/** + * Set @a *provider to an authentication provider of type @c + * svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. + * + * This is like svn_client_get_simple_provider(), except that the + * password is obtained from gpg_agent, which will keep it in + * a memory cache. + * + * Allocate @a *provider in @a pool. + * + * @since New in 1.8 + * @note This function actually works only on systems with + * GNU Privacy Guard installed. + */ +void +svn_auth_get_gpg_agent_simple_provider + (svn_auth_provider_object_t **provider, + apr_pool_t *pool); +#endif /* !defined(WIN32) || defined(DOXYGEN) */ + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_username_t that gets/sets information from a user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * If a default username is available, @a *provider will honor it, + * and return it when svn_auth_first_credentials() is called. (See + * @c SVN_AUTH_PARAM_DEFAULT_USERNAME.) + * + * @since New in 1.4. + */ +void +svn_auth_get_username_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_server_trust_t, allocated in @a pool. + * + * @a *provider retrieves its credentials from the configuration + * mechanism. The returned credential is used to override SSL + * security on an error. + * + * @since New in 1.4. + */ +void +svn_auth_get_ssl_server_trust_file_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_t, allocated in @a pool. + * + * @a *provider retrieves its credentials from the configuration + * mechanism. The returned credential is used to load the appropriate + * client certificate for authentication when requested by a server. + * + * @since New in 1.4. + */ +void +svn_auth_get_ssl_client_cert_file_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_pw_t that gets/sets information from the user's + * ~/.subversion configuration directory. + * + * If the provider is going to save the passphrase unencrypted, + * it calls @a plaintext_passphrase_prompt_func, passing @a + * prompt_baton, before saving the passphrase. + * + * If @a plaintext_passphrase_prompt_func is NULL it is not called + * and the passphrase is not stored in plaintext. + * Client developers are highly encouraged to provide this callback + * to ensure their users are made aware of the fact that their passphrase + * is going to be stored unencrypted. + * + * Clients can however set the callback to NULL and set + * SVN_AUTH_PARAM_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT to SVN_CONFIG_FALSE or + * SVN_CONFIG_TRUE to enforce a certain behaviour. + * + * Allocate @a *provider in @a pool. + * + * @since New in 1.6. + */ +void +svn_auth_get_ssl_client_cert_pw_file_provider2( + svn_auth_provider_object_t **provider, + svn_auth_plaintext_passphrase_prompt_func_t plaintext_passphrase_prompt_func, + void *prompt_baton, + apr_pool_t *pool); + +/** Like svn_auth_get_ssl_client_cert_pw_file_provider2, but without + * the ability to call the svn_auth_plaintext_passphrase_prompt_func_t + * callback, and the provider always assumes that it is not allowed + * to store the passphrase in plaintext. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. + * @since New in 1.4. + */ +SVN_DEPRECATED +void +svn_auth_get_ssl_client_cert_pw_file_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_server_trust_t, allocated in @a pool. + * + * @a *provider retrieves its credentials by using the @a prompt_func + * and @a prompt_baton. The returned credential is used to override + * SSL security on an error. + * + * @since New in 1.4. + */ +void +svn_auth_get_ssl_server_trust_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_ssl_server_trust_prompt_func_t prompt_func, + void *prompt_baton, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_t, allocated in @a pool. + * + * @a *provider retrieves its credentials by using the @a prompt_func + * and @a prompt_baton. The returned credential is used to load the + * appropriate client certificate for authentication when requested by + * a server. The prompt will be retried @a retry_limit times. For + * infinite retries, set @a retry_limit to value less than 0. + * + * @since New in 1.4. + */ +void +svn_auth_get_ssl_client_cert_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_ssl_client_cert_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +/** Set @a *provider to an authentication provider of type @c + * svn_auth_cred_ssl_client_cert_pw_t, allocated in @a pool. + * + * @a *provider retrieves its credentials by using the @a prompt_func + * and @a prompt_baton. The returned credential is used when a loaded + * client certificate is protected by a passphrase. The prompt will + * be retried @a retry_limit times. For infinite retries, set + * @a retry_limit to value less than 0. + * + * @since New in 1.4. + */ +void +svn_auth_get_ssl_client_cert_pw_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_ssl_client_cert_pw_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_AUTH_H */ diff --git a/subversion/include/svn_base64.h b/subversion/include/svn_base64.h new file mode 100644 index 0000000..cc1820f --- /dev/null +++ b/subversion/include/svn_base64.h @@ -0,0 +1,123 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_base64.h + * @brief Base64 encoding and decoding functions + */ + +#ifndef SVN_BASE64_H +#define SVN_BASE64_H + +#include <apr_pools.h> + +#include "svn_types.h" +#include "svn_io.h" /* for svn_stream_t */ +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * + * + * @defgroup base64 Base64 encoding/decoding functions + * + * @{ + */ + +/** Return a writable generic stream which will encode binary data in + * base64 format and write the encoded data to @a output. Be sure to + * close the stream when done writing in order to squeeze out the last + * bit of encoded data. The stream is allocated in @a pool. + */ +svn_stream_t * +svn_base64_encode(svn_stream_t *output, + apr_pool_t *pool); + +/** Return a writable generic stream which will decode base64-encoded + * data and write the decoded data to @a output. The stream is allocated + * in @a pool. + */ +svn_stream_t * +svn_base64_decode(svn_stream_t *output, + apr_pool_t *pool); + + +/** Encode an @c svn_stringbuf_t into base64. + * + * A simple interface for encoding base64 data assuming we have all of + * it present at once. If @a break_lines is true, newlines will be + * inserted periodically; otherwise the string will only consist of + * base64 encoding characters. The returned string will be allocated + * from @a pool. + * + * @since New in 1.6. + */ +const svn_string_t * +svn_base64_encode_string2(const svn_string_t *str, + svn_boolean_t break_lines, + apr_pool_t *pool); + +/** + * Same as svn_base64_encode_string2, but with @a break_lines always + * TRUE. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +const svn_string_t * +svn_base64_encode_string(const svn_string_t *str, + apr_pool_t *pool); + +/** Decode an @c svn_stringbuf_t from base64. + * + * A simple interface for decoding base64 data assuming we have all of + * it present at once. The returned string will be allocated from @c + * pool. + * + */ +const svn_string_t * +svn_base64_decode_string(const svn_string_t *str, + apr_pool_t *pool); + + +/** Return a base64-encoded checksum for finalized @a digest. + * + * @a digest contains @c APR_MD5_DIGESTSIZE bytes of finalized data. + * Allocate the returned checksum in @a pool. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_stringbuf_t * +svn_base64_from_md5(unsigned char digest[], + apr_pool_t *pool); + + +/** @} end group: Base64 encoding/decoding functions */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_BASE64_H */ diff --git a/subversion/include/svn_cache_config.h b/subversion/include/svn_cache_config.h new file mode 100644 index 0000000..b03a079 --- /dev/null +++ b/subversion/include/svn_cache_config.h @@ -0,0 +1,90 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_cache_config.h + * @brief Configuration interface to internal Subversion caches. + */ + +#ifndef SVN_CACHE_CONFIG_H +#define SVN_CACHE_CONFIG_H + +#include <apr.h> +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** @defgroup svn_fs_cache_config caching configuration + * @{ + * @since New in 1.7. */ + +/** Cache resource settings. It controls what caches, in what size and + how they will be created. The settings apply for the whole process. + + @since New in 1.7. + */ +typedef struct svn_cache_config_t +{ + /** total cache size in bytes. Please note that this is only soft limit + to the total application memory usage and will be exceeded due to + temporary objects and other program state. + May be 0, resulting in default caching code being used. */ + apr_uint64_t cache_size; + + /** maximum number of files kept open */ + apr_size_t file_handle_count; + + /** is this application guaranteed to be single-threaded? */ + svn_boolean_t single_threaded; +} svn_cache_config_t; + +/** Get the current cache configuration. If it has not been set, + this function will return the default settings. + + @since New in 1.7. + */ +const svn_cache_config_t * +svn_cache_config_get(void); + +/** Set the cache configuration. Please note that it may not change + the actual configuration *in use*. Therefore, call it before reading + data from any repo and call it only once. + + This function is not thread-safe. Therefore, it should be called + from the processes' initialization code only. + + @since New in 1.7. + */ +void +svn_cache_config_set(const svn_cache_config_t *settings); + +/** @} */ + +/** @} */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CACHE_CONFIG_H */ diff --git a/subversion/include/svn_checksum.h b/subversion/include/svn_checksum.h new file mode 100644 index 0000000..d3271f5 --- /dev/null +++ b/subversion/include/svn_checksum.h @@ -0,0 +1,278 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_checksum.h + * @brief Subversion checksum routines + */ + +#ifndef SVN_CHECKSUM_H +#define SVN_CHECKSUM_H + +#include <apr.h> /* for apr_size_t */ +#include <apr_pools.h> /* for apr_pool_t */ + +#include "svn_types.h" /* for svn_boolean_t, svn_error_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * Various types of checksums. + * + * @since New in 1.6. + */ +typedef enum svn_checksum_kind_t +{ + /** The checksum is (or should be set to) an MD5 checksum. */ + svn_checksum_md5, + + /** The checksum is (or should be set to) a SHA1 checksum. */ + svn_checksum_sha1 +} svn_checksum_kind_t; + +/** + * A generic checksum representation. + * + * @since New in 1.6. + */ +typedef struct svn_checksum_t +{ + /** The bytes of the checksum. */ + const unsigned char *digest; + + /** The type of the checksum. This should never be changed by consumers + of the APIs. */ + svn_checksum_kind_t kind; +} svn_checksum_t; + +/** + * Opaque type for creating checksums of data. + */ +typedef struct svn_checksum_ctx_t svn_checksum_ctx_t; + +/** Return a new checksum structure of type @a kind, initialized to the all- + * zeros value, allocated in @a pool. + * + * @since New in 1.6. + */ +svn_checksum_t * +svn_checksum_create(svn_checksum_kind_t kind, + apr_pool_t *pool); + +/** Set @a checksum->digest to all zeros, which, by convention, matches + * all other checksums. + * + * @since New in 1.6. + */ +svn_error_t * +svn_checksum_clear(svn_checksum_t *checksum); + +/** Compare checksums @a checksum1 and @a checksum2. If their kinds do not + * match or if neither is all zeros, and their content does not match, then + * return FALSE; else return TRUE. + * + * @since New in 1.6. + */ +svn_boolean_t +svn_checksum_match(const svn_checksum_t *checksum1, + const svn_checksum_t *checksum2); + + +/** + * Return a deep copy of @a checksum, allocated in @a pool. If @a + * checksum is NULL then NULL is returned. + * + * @since New in 1.6. + */ +svn_checksum_t * +svn_checksum_dup(const svn_checksum_t *checksum, + apr_pool_t *pool); + + +/** Return the hex representation of @a checksum, allocating the string + * in @a pool. + * + * @since New in 1.6. + */ +const char * +svn_checksum_to_cstring_display(const svn_checksum_t *checksum, + apr_pool_t *pool); + + +/** Return the hex representation of @a checksum, allocating the + * string in @a pool. If @a checksum->digest is all zeros (that is, + * 0, not '0') then return NULL. In 1.7+, @a checksum may be NULL + * and NULL will be returned in that case. + * + * @since New in 1.6. + * @note Passing NULL for @a checksum in 1.6 will cause a segfault. + */ +const char * +svn_checksum_to_cstring(const svn_checksum_t *checksum, + apr_pool_t *pool); + + +/** Return a serialized representation of @a checksum, allocated in + * @a result_pool. Temporary allocations are performed in @a scratch_pool. + * + * Note that @a checksum may not be NULL. + * + * @since New in 1.7. + */ +const char * +svn_checksum_serialize(const svn_checksum_t *checksum, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Return @a checksum from the serialized format at @a data. The checksum + * will be allocated in @a result_pool, with any temporary allocations + * performed in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_checksum_deserialize(const svn_checksum_t **checksum, + const char *data, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Parse the hex representation @a hex of a checksum of kind @a kind and + * set @a *checksum to the result, allocating in @a pool. + * + * If @a hex is @c NULL or is the all-zeros checksum, then set @a *checksum + * to @c NULL. + * + * @since New in 1.6. + */ +svn_error_t * +svn_checksum_parse_hex(svn_checksum_t **checksum, + svn_checksum_kind_t kind, + const char *hex, + apr_pool_t *pool); + +/** + * Return in @a *checksum the checksum of type @a kind for the bytes beginning + * at @a data, and going for @a len. @a *checksum is allocated in @a pool. + * + * @since New in 1.6. + */ +svn_error_t * +svn_checksum(svn_checksum_t **checksum, + svn_checksum_kind_t kind, + const void *data, + apr_size_t len, + apr_pool_t *pool); + + +/** + * Return in @a pool a newly allocated checksum populated with the checksum + * of type @a kind for the empty string. + * + * @since New in 1.6. + */ +svn_checksum_t * +svn_checksum_empty_checksum(svn_checksum_kind_t kind, + apr_pool_t *pool); + + +/** + * Create a new @c svn_checksum_ctx_t structure, allocated from @a pool for + * calculating checksums of type @a kind. @see svn_checksum_final() + * + * @since New in 1.6. + */ +svn_checksum_ctx_t * +svn_checksum_ctx_create(svn_checksum_kind_t kind, + apr_pool_t *pool); + +/** + * Update the checksum represented by @a ctx, with @a len bytes starting at + * @a data. + * + * @since New in 1.6. + */ +svn_error_t * +svn_checksum_update(svn_checksum_ctx_t *ctx, + const void *data, + apr_size_t len); + + +/** + * Finalize the checksum used when creating @a ctx, and put the resultant + * checksum in @a *checksum, allocated in @a pool. + * + * @since New in 1.6. + */ +svn_error_t * +svn_checksum_final(svn_checksum_t **checksum, + const svn_checksum_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Return the digest size of @a checksum. + * + * @since New in 1.6. + */ +apr_size_t +svn_checksum_size(const svn_checksum_t *checksum); + +/** + * Return @c TRUE iff @a checksum matches the checksum for the empty + * string. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_checksum_is_empty_checksum(svn_checksum_t *checksum); + + +/** + * Return an error of type #SVN_ERR_CHECKSUM_MISMATCH for @a actual and + * @a expected checksums which do not match. Use @a fmt, and the following + * parameters to populate the error message. + * + * @note This function does not actually check for the mismatch, it just + * constructs the error. + * + * @a scratch_pool is used for temporary allocations; the returned error + * will be allocated in its own pool (as is typical). + * + * @since New in 1.7. + */ +svn_error_t * +svn_checksum_mismatch_err(const svn_checksum_t *expected, + const svn_checksum_t *actual, + apr_pool_t *scratch_pool, + const char *fmt, + ...) + __attribute__ ((format(printf, 4, 5))); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CHECKSUM_H */ diff --git a/subversion/include/svn_client.h b/subversion/include/svn_client.h new file mode 100644 index 0000000..d8eacdf --- /dev/null +++ b/subversion/include/svn_client.h @@ -0,0 +1,6475 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_client.h + * @brief Subversion's client library + * + * Requires: The working copy library and repository access library. + * Provides: Broad wrappers around working copy library functionality. + * Used By: Client programs. + */ + +#ifndef SVN_CLIENT_H +#define SVN_CLIENT_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_getopt.h> +#include <apr_file_io.h> +#include <apr_time.h> + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_wc.h" +#include "svn_opt.h" +#include "svn_ra.h" +#include "svn_diff.h" +#include "svn_auth.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** + * Get libsvn_client version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_client_version(void); + +/** Client supporting functions + * + * @defgroup clnt_support Client supporting subsystem + * + * @{ + */ + + +/*** Authentication stuff ***/ + +/** The new authentication system allows the RA layer to "pull" + * information as needed from libsvn_client. + * + * @deprecated Replaced by the svn_auth_* functions. + * @see auth_fns + * + * @defgroup auth_fns_depr (deprecated) AuthZ client subsystem + * + * @{ + */ + +/** Create and return @a *provider, an authentication provider of type + * svn_auth_cred_simple_t that gets information by prompting the user + * with @a prompt_func and @a prompt_baton. Allocate @a *provider in + * @a pool. + * + * If both #SVN_AUTH_PARAM_DEFAULT_USERNAME and + * #SVN_AUTH_PARAM_DEFAULT_PASSWORD are defined as runtime + * parameters in the @c auth_baton, then @a *provider will return the + * default arguments when svn_auth_first_credentials() is called. If + * svn_auth_first_credentials() fails, then @a *provider will + * re-prompt @a retry_limit times (via svn_auth_next_credentials()). + * For infinite retries, set @a retry_limit to value less than 0. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_simple_prompt_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_simple_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_simple_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_username_t that gets information by prompting the + * user with @a prompt_func and @a prompt_baton. Allocate @a *provider + * in @a pool. + * + * If #SVN_AUTH_PARAM_DEFAULT_USERNAME is defined as a runtime + * parameter in the @c auth_baton, then @a *provider will return the + * default argument when svn_auth_first_credentials() is called. If + * svn_auth_first_credentials() fails, then @a *provider will + * re-prompt @a retry_limit times (via svn_auth_next_credentials()). + * For infinite retries, set @a retry_limit to value less than 0. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_username_prompt_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_username_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_username_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * If a default username or password is available, @a *provider will + * honor them as well, and return them when + * svn_auth_first_credentials() is called. (see + * #SVN_AUTH_PARAM_DEFAULT_USERNAME and #SVN_AUTH_PARAM_DEFAULT_PASSWORD). + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_simple_provider2() instead. + */ +SVN_DEPRECATED +void +svn_client_get_simple_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +#if (defined(WIN32) && !defined(__MINGW32__)) || defined(DOXYGEN) || defined(CTYPESGEN) || defined(SWIG) +/** + * Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_simple_t that gets/sets information from the user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * This is like svn_client_get_simple_provider(), except that, when + * running on Window 2000 or newer (or any other Windows version that + * includes the CryptoAPI), the provider encrypts the password before + * storing it to disk. On earlier versions of Windows, the provider + * does nothing. + * + * @since New in 1.2. + * @note This function is only available on Windows. + * + * @note An administrative password reset may invalidate the account's + * secret key. This function will detect that situation and behave as + * if the password were not cached at all. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_windows_simple_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_windows_simple_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); +#endif /* WIN32 && !__MINGW32__ || DOXYGEN || CTYPESGEN || SWIG */ + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_username_t that gets/sets information from a user's + * ~/.subversion configuration directory. Allocate @a *provider in + * @a pool. + * + * If a default username is available, @a *provider will honor it, + * and return it when svn_auth_first_credentials() is called. (see + * #SVN_AUTH_PARAM_DEFAULT_USERNAME). + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_username_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_username_provider(svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_ssl_server_trust_t, allocated in @a pool. + * + * @a *provider retrieves its credentials from the configuration + * mechanism. The returned credential is used to override SSL + * security on an error. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_ssl_server_trust_file_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_ssl_server_trust_file_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_ssl_client_cert_t, allocated in @a pool. + * + * @a *provider retrieves its credentials from the configuration + * mechanism. The returned credential is used to load the appropriate + * client certificate for authentication when requested by a server. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_ssl_client_cert_file_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_ssl_client_cert_file_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_ssl_client_cert_pw_t, allocated in @a pool. + * + * @a *provider retrieves its credentials from the configuration + * mechanism. The returned credential is used when a loaded client + * certificate is protected by a passphrase. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_ssl_client_cert_pw_file_provider2() instead. + */ +SVN_DEPRECATED +void +svn_client_get_ssl_client_cert_pw_file_provider( + svn_auth_provider_object_t **provider, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_ssl_server_trust_t, allocated in @a pool. + * + * @a *provider retrieves its credentials by using the @a prompt_func + * and @a prompt_baton. The returned credential is used to override + * SSL security on an error. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_ssl_server_trust_prompt_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_ssl_server_trust_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_ssl_server_trust_prompt_func_t prompt_func, + void *prompt_baton, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_ssl_client_cert_t, allocated in @a pool. + * + * @a *provider retrieves its credentials by using the @a prompt_func + * and @a prompt_baton. The returned credential is used to load the + * appropriate client certificate for authentication when requested by + * a server. The prompt will be retried @a retry_limit times. + * For infinite retries, set @a retry_limit to value less than 0. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_ssl_client_cert_prompt_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_ssl_client_cert_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_ssl_client_cert_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + + +/** Create and return @a *provider, an authentication provider of type + * #svn_auth_cred_ssl_client_cert_pw_t, allocated in @a pool. + * + * @a *provider retrieves its credentials by using the @a prompt_func + * and @a prompt_baton. The returned credential is used when a loaded + * client certificate is protected by a passphrase. The prompt will + * be retried @a retry_limit times. For infinite retries, set @a retry_limit + * to value less than 0. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_auth_get_ssl_client_cert_pw_prompt_provider() instead. + */ +SVN_DEPRECATED +void +svn_client_get_ssl_client_cert_pw_prompt_provider( + svn_auth_provider_object_t **provider, + svn_auth_ssl_client_cert_pw_prompt_func_t prompt_func, + void *prompt_baton, + int retry_limit, + apr_pool_t *pool); + +/** @} */ + +/** + * Revisions and Peg Revisions + * + * @defgroup clnt_revisions Revisions and Peg Revisions + * + * A brief word on operative and peg revisions. + * + * If the kind of the peg revision is #svn_opt_revision_unspecified, then it + * defaults to #svn_opt_revision_head for URLs and #svn_opt_revision_working + * for local paths. + * + * For deeper insight, please see the + * <a href="http://svnbook.red-bean.com/nightly/en/svn.advanced.pegrevs.html"> + * Peg and Operative Revisions</a> section of the Subversion Book. + */ + +/** + * Commit operations + * + * @defgroup clnt_commit Client commit subsystem + * + * @{ + */ + +/** This is a structure which stores a filename and a hash of property + * names and values. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +typedef struct svn_client_proplist_item_t +{ + /** The name of the node on which these properties are set. */ + svn_stringbuf_t *node_name; + + /** A hash of (const char *) property names, and (svn_string_t *) property + * values. */ + apr_hash_t *prop_hash; + +} svn_client_proplist_item_t; + +/** + * The callback invoked by svn_client_proplist4(). Each invocation + * provides the regular and/or inherited properties of @a path, which is + * either a working copy path or a URL. If @a prop_hash is not @c NULL, then + * it maps explicit <tt>const char *</tt> property names to + * <tt>svn_string_t *</tt> explicit property values. If @a inherited_props + * is not @c NULL, then it is a depth-first ordered array of + * #svn_prop_inherited_item_t * structures representing the + * properties inherited by @a path. Use @a scratch_pool for all temporary + * allocations. + * + * The #svn_prop_inherited_item_t->path_or_url members of the + * #svn_prop_inherited_item_t * structures in @a inherited_props are + * URLs if @a path is a URL or if @a path is a working copy path but the + * property represented by the structure is above the working copy root (i.e. + * the inherited property is from the cache). In all other cases the + * #svn_prop_inherited_item_t->path_or_url members are absolute working copy + * paths. + * + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_proplist_receiver2_t)( + void *baton, + const char *path, + apr_hash_t *prop_hash, + apr_array_header_t *inherited_props, + apr_pool_t *scratch_pool); + +/** + * Similar to #svn_proplist_receiver2_t, but doesn't return inherited + * properties. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_proplist_receiver_t)( + void *baton, + const char *path, + apr_hash_t *prop_hash, + apr_pool_t *pool); + +/** + * Return a duplicate of @a item, allocated in @a pool. No part of the new + * structure will be shared with @a item. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_client_proplist_item_t * +svn_client_proplist_item_dup(const svn_client_proplist_item_t *item, + apr_pool_t *pool); + +/** Information about commits passed back to client from this module. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +typedef struct svn_client_commit_info_t +{ + /** just-committed revision. */ + svn_revnum_t revision; + + /** server-side date of the commit. */ + const char *date; + + /** author of the commit. */ + const char *author; + +} svn_client_commit_info_t; + + +/** + * @name Commit state flags + * @brief State flags for use with the #svn_client_commit_item3_t structure + * (see the note about the namespace for that structure, which also + * applies to these flags). + * @{ + */ +#define SVN_CLIENT_COMMIT_ITEM_ADD 0x01 +#define SVN_CLIENT_COMMIT_ITEM_DELETE 0x02 +#define SVN_CLIENT_COMMIT_ITEM_TEXT_MODS 0x04 +#define SVN_CLIENT_COMMIT_ITEM_PROP_MODS 0x08 +#define SVN_CLIENT_COMMIT_ITEM_IS_COPY 0x10 +/** @since New in 1.2. */ +#define SVN_CLIENT_COMMIT_ITEM_LOCK_TOKEN 0x20 +/** @since New in 1.8. */ +#define SVN_CLIENT_COMMIT_ITEM_MOVED_HERE 0x40 +/** @} */ + +/** The commit candidate structure. + * + * In order to avoid backwards compatibility problems clients should use + * svn_client_commit_item3_create() to allocate and initialize this + * structure instead of doing so themselves. + * + * @since New in 1.5. + */ +typedef struct svn_client_commit_item3_t +{ + /* IMPORTANT: If you extend this structure, add new fields to the end. */ + + /** absolute working-copy path of item */ + const char *path; + + /** node kind (dir, file) */ + svn_node_kind_t kind; + + /** commit URL for this item */ + const char *url; + + /** revision of textbase */ + svn_revnum_t revision; + + /** copyfrom-url or NULL if not a copied item */ + const char *copyfrom_url; + + /** copyfrom-rev, valid when copyfrom_url != NULL */ + svn_revnum_t copyfrom_rev; + + /** state flags */ + apr_byte_t state_flags; + + /** An array of #svn_prop_t *'s, which are incoming changes from + * the repository to WC properties. These changes are applied + * post-commit. + * + * When adding to this array, allocate the #svn_prop_t and its + * contents in @c incoming_prop_changes->pool, so that it has the + * same lifetime as this data structure. + * + * See http://subversion.tigris.org/issues/show_bug.cgi?id=806 for a + * description of what would happen if the post-commit process + * didn't group these changes together with all other changes to the + * item. + */ + apr_array_header_t *incoming_prop_changes; + + /** An array of #svn_prop_t *'s, which are outgoing changes to + * make to properties in the repository. These extra property + * changes are declared pre-commit, and applied to the repository as + * part of a commit. + * + * When adding to this array, allocate the #svn_prop_t and its + * contents in @c outgoing_prop_changes->pool, so that it has the + * same lifetime as this data structure. + */ + apr_array_header_t *outgoing_prop_changes; + + /** + * When processing the commit this contains the relative path for + * the commit session. #NULL until the commit item is preprocessed. + * @since New in 1.7. + */ + const char *session_relpath; + + /** + * When committing a move, this contains the absolute path where + * the node was directly moved from. (If an ancestor at the original + * location was moved then it points to where the node itself was + * moved from; not the original location.) + * @since New in 1.8. + */ + const char *moved_from_abspath; + +} svn_client_commit_item3_t; + +/** The commit candidate structure. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +typedef struct svn_client_commit_item2_t +{ + /** absolute working-copy path of item */ + const char *path; + + /** node kind (dir, file) */ + svn_node_kind_t kind; + + /** commit URL for this item */ + const char *url; + + /** revision of textbase */ + svn_revnum_t revision; + + /** copyfrom-url or NULL if not a copied item */ + const char *copyfrom_url; + + /** copyfrom-rev, valid when copyfrom_url != NULL */ + svn_revnum_t copyfrom_rev; + + /** state flags */ + apr_byte_t state_flags; + + /** Analogous to the #svn_client_commit_item3_t.incoming_prop_changes + * field. + */ + apr_array_header_t *wcprop_changes; +} svn_client_commit_item2_t; + +/** The commit candidate structure. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +typedef struct svn_client_commit_item_t +{ + /** absolute working-copy path of item */ + const char *path; + + /** node kind (dir, file) */ + svn_node_kind_t kind; + + /** commit URL for this item */ + const char *url; + + /** revision (copyfrom-rev if _IS_COPY) */ + svn_revnum_t revision; + + /** copyfrom-url */ + const char *copyfrom_url; + + /** state flags */ + apr_byte_t state_flags; + + /** Analogous to the #svn_client_commit_item3_t.incoming_prop_changes + * field. + */ + apr_array_header_t *wcprop_changes; + +} svn_client_commit_item_t; + +/** Return a new commit item object, allocated in @a pool. + * + * In order to avoid backwards compatibility problems, this function + * is used to initialize and allocate the #svn_client_commit_item3_t + * structure rather than doing so explicitly, as the size of this + * structure may change in the future. + * + * @since New in 1.6. + */ +svn_client_commit_item3_t * +svn_client_commit_item3_create(apr_pool_t *pool); + +/** Like svn_client_commit_item3_create() but with a stupid "const" + * qualifier on the returned structure, and it returns an error that + * will never happen. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_commit_item_create(const svn_client_commit_item3_t **item, + apr_pool_t *pool); + +/** + * Return a duplicate of @a item, allocated in @a pool. No part of the + * new structure will be shared with @a item, except for the adm_access + * member. + * + * @since New in 1.5. + */ +svn_client_commit_item3_t * +svn_client_commit_item3_dup(const svn_client_commit_item3_t *item, + apr_pool_t *pool); + +/** + * Return a duplicate of @a item, allocated in @a pool. No part of the new + * structure will be shared with @a item. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_client_commit_item2_t * +svn_client_commit_item2_dup(const svn_client_commit_item2_t *item, + apr_pool_t *pool); + +/** Callback type used by commit-y operations to get a commit log message + * from the caller. + * + * Set @a *log_msg to the log message for the commit, allocated in @a + * pool, or @c NULL if wish to abort the commit process. Set @a *tmp_file + * to the path of any temporary file which might be holding that log + * message, or @c NULL if no such file exists (though, if @a *log_msg is + * @c NULL, this value is undefined). The log message MUST be a UTF8 + * string with LF line separators. + * + * @a commit_items is a read-only array of #svn_client_commit_item3_t + * structures, which may be fully or only partially filled-in, + * depending on the type of commit operation. + * + * @a baton is provided along with the callback for use by the handler. + * + * All allocations should be performed in @a pool. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_client_get_commit_log3_t)( + const char **log_msg, + const char **tmp_file, + const apr_array_header_t *commit_items, + void *baton, + apr_pool_t *pool); + +/** Callback type used by commit-y operations to get a commit log message + * from the caller. + * + * Set @a *log_msg to the log message for the commit, allocated in @a + * pool, or @c NULL if wish to abort the commit process. Set @a *tmp_file + * to the path of any temporary file which might be holding that log + * message, or @c NULL if no such file exists (though, if @a *log_msg is + * @c NULL, this value is undefined). The log message MUST be a UTF8 + * string with LF line separators. + * + * @a commit_items is a read-only array of #svn_client_commit_item2_t + * structures, which may be fully or only partially filled-in, + * depending on the type of commit operation. + * + * @a baton is provided along with the callback for use by the handler. + * + * All allocations should be performed in @a pool. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +typedef svn_error_t *(*svn_client_get_commit_log2_t)( + const char **log_msg, + const char **tmp_file, + const apr_array_header_t *commit_items, + void *baton, + apr_pool_t *pool); + +/** Callback type used by commit-y operations to get a commit log message + * from the caller. + * + * Set @a *log_msg to the log message for the commit, allocated in @a + * pool, or @c NULL if wish to abort the commit process. Set @a *tmp_file + * to the path of any temporary file which might be holding that log + * message, or @c NULL if no such file exists (though, if @a *log_msg is + * @c NULL, this value is undefined). The log message MUST be a UTF8 + * string with LF line separators. + * + * @a commit_items is a read-only array of #svn_client_commit_item_t + * structures, which may be fully or only partially filled-in, + * depending on the type of commit operation. + * + * @a baton is provided along with the callback for use by the handler. + * + * All allocations should be performed in @a pool. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +typedef svn_error_t *(*svn_client_get_commit_log_t)( + const char **log_msg, + const char **tmp_file, + apr_array_header_t *commit_items, + void *baton, + apr_pool_t *pool); + +/** @} */ + +/** + * Client blame + * + * @defgroup clnt_blame Client blame functionality + * + * @{ + */ + +/** Callback type used by svn_client_blame5() to notify the caller + * that line @a line_no of the blamed file was last changed in @a revision + * which has the revision properties @a rev_props, and that the contents were + * @a line. + * + * @a start_revnum and @a end_revnum contain the start and end revision + * number of the entire blame operation, as determined from the repository + * inside svn_client_blame5(). This can be useful for the blame receiver + * to format the blame output. + * + * If svn_client_blame5() was called with @a include_merged_revisions set to + * TRUE, @a merged_revision, @a merged_rev_props and @a merged_path will be + * set, otherwise they will be NULL. @a merged_path will be set to the + * absolute repository path. + * + * All allocations should be performed in @a pool. + * + * @note If there is no blame information for this line, @a revision will be + * invalid and @a rev_props will be NULL. In this case @a local_change + * will be true if the reason there is no blame information is that the line + * was modified locally. In all other cases @a local_change will be false. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_client_blame_receiver3_t)( + void *baton, + svn_revnum_t start_revnum, + svn_revnum_t end_revnum, + apr_int64_t line_no, + svn_revnum_t revision, + apr_hash_t *rev_props, + svn_revnum_t merged_revision, + apr_hash_t *merged_rev_props, + const char *merged_path, + const char *line, + svn_boolean_t local_change, + apr_pool_t *pool); + +/** + * Similar to #svn_client_blame_receiver3_t, but with separate author and + * date revision properties instead of all revision properties, and without + * information about local changes. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_client_blame_receiver2_t)( + void *baton, + apr_int64_t line_no, + svn_revnum_t revision, + const char *author, + const char *date, + svn_revnum_t merged_revision, + const char *merged_author, + const char *merged_date, + const char *merged_path, + const char *line, + apr_pool_t *pool); + +/** + * Similar to #svn_client_blame_receiver2_t, but without @a merged_revision, + * @a merged_author, @a merged_date, or @a merged_path members. + * + * @note New in 1.4 is that the line is defined to contain only the line + * content (and no [partial] EOLs; which was undefined in older versions). + * Using this callback with svn_client_blame() or svn_client_blame2() + * will still give you the old behaviour. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +typedef svn_error_t *(*svn_client_blame_receiver_t)( + void *baton, + apr_int64_t line_no, + svn_revnum_t revision, + const char *author, + const char *date, + const char *line, + apr_pool_t *pool); + + +/** @} */ + +/** + * Client diff + * + * @defgroup clnt_diff Client diff functionality + * + * @{ + */ +/** The difference type in an svn_diff_summarize_t structure. + * + * @since New in 1.4. + */ +typedef enum svn_client_diff_summarize_kind_t +{ + /** An item with no text modifications */ + svn_client_diff_summarize_kind_normal, + + /** An added item */ + svn_client_diff_summarize_kind_added, + + /** An item with text modifications */ + svn_client_diff_summarize_kind_modified, + + /** A deleted item */ + svn_client_diff_summarize_kind_deleted +} svn_client_diff_summarize_kind_t; + + +/** A struct that describes the diff of an item. Passed to + * #svn_client_diff_summarize_func_t. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, users shouldn't allocate structures of this + * type, to preserve binary compatibility. + * + * @since New in 1.4. + */ +typedef struct svn_client_diff_summarize_t +{ + /** Path relative to the target. If the target is a file, path is + * the empty string. */ + const char *path; + + /** Change kind */ + svn_client_diff_summarize_kind_t summarize_kind; + + /** Properties changed? For consistency with 'svn status' output, + * this should be false if summarize_kind is _added or _deleted. */ + svn_boolean_t prop_changed; + + /** File or dir */ + svn_node_kind_t node_kind; +} svn_client_diff_summarize_t; + +/** + * Return a duplicate of @a diff, allocated in @a pool. No part of the new + * structure will be shared with @a diff. + * + * @since New in 1.4. + */ +svn_client_diff_summarize_t * +svn_client_diff_summarize_dup(const svn_client_diff_summarize_t *diff, + apr_pool_t *pool); + + +/** A callback used in svn_client_diff_summarize2() and + * svn_client_diff_summarize_peg2() for reporting a @a diff summary. + * + * All allocations should be performed in @a pool. + * + * @a baton is a closure object; it should be provided by the implementation, + * and passed by the caller. + * + * @since New in 1.4. + */ +typedef svn_error_t *(*svn_client_diff_summarize_func_t)( + const svn_client_diff_summarize_t *diff, + void *baton, + apr_pool_t *pool); + + + +/** @} */ + + +/** + * Client context + * + * @defgroup clnt_ctx Client context management + * + * @{ + */ + +/** A client context structure, which holds client specific callbacks, + * batons, serves as a cache for configuration options, and other various + * and sundry things. In order to avoid backwards compatibility problems + * clients should use svn_client_create_context() to allocate and + * initialize this structure instead of doing so themselves. + */ +typedef struct svn_client_ctx_t +{ + /** main authentication baton. */ + svn_auth_baton_t *auth_baton; + + /** notification callback function. + * This will be called by notify_func2() by default. + * @deprecated Provided for backward compatibility with the 1.1 API. + * Use @c notify_func2 instead. */ + svn_wc_notify_func_t notify_func; + + /** notification callback baton for notify_func() + * @deprecated Provided for backward compatibility with the 1.1 API. + * Use @c notify_baton2 instead */ + void *notify_baton; + + /** Log message callback function. NULL means that Subversion + * should try not attempt to fetch a log message. + * @deprecated Provided for backward compatibility with the 1.2 API. + * Use @c log_msg_func2 instead. */ + svn_client_get_commit_log_t log_msg_func; + + /** log message callback baton + * @deprecated Provided for backward compatibility with the 1.2 API. + * Use @c log_msg_baton2 instead. */ + void *log_msg_baton; + + /** a hash mapping of <tt>const char *</tt> configuration file names to + * #svn_config_t *'s. For example, the '~/.subversion/config' file's + * contents should have the key "config". May be left unset (or set to + * NULL) to use the built-in default settings and not use any configuration. + */ + apr_hash_t *config; + + /** a callback to be used to see if the client wishes to cancel the running + * operation. */ + svn_cancel_func_t cancel_func; + + /** a baton to pass to the cancellation callback. */ + void *cancel_baton; + + /** notification function, defaulting to a function that forwards + * to notify_func(). If @c NULL, it will not be invoked. + * @since New in 1.2. */ + svn_wc_notify_func2_t notify_func2; + + /** notification baton for notify_func2(). + * @since New in 1.2. */ + void *notify_baton2; + + /** Log message callback function. NULL means that Subversion + * should try log_msg_func. + * @since New in 1.3. */ + svn_client_get_commit_log2_t log_msg_func2; + + /** callback baton for log_msg_func2 + * @since New in 1.3. */ + void *log_msg_baton2; + + /** Notification callback for network progress information. + * May be NULL if not used. + * @since New in 1.3. */ + svn_ra_progress_notify_func_t progress_func; + + /** Callback baton for progress_func. + * @since New in 1.3. */ + void *progress_baton; + + /** Log message callback function. NULL means that Subversion + * should try @c log_msg_func2, then @c log_msg_func. + * @since New in 1.5. */ + svn_client_get_commit_log3_t log_msg_func3; + + /** The callback baton for @c log_msg_func3. + * @since New in 1.5. */ + void *log_msg_baton3; + + /** MIME types map. + * @since New in 1.5. */ + apr_hash_t *mimetypes_map; + + /** Conflict resolution callback and baton, if available. + * @since New in 1.5. */ + svn_wc_conflict_resolver_func_t conflict_func; + void *conflict_baton; + + /** Custom client name string, or @c NULL. + * @since New in 1.5. */ + const char *client_name; + + /** Conflict resolution callback and baton, if available. NULL means that + * subversion should try @c conflict_func. + * @since New in 1.7. */ + svn_wc_conflict_resolver_func2_t conflict_func2; + void *conflict_baton2; + + /** A working copy context for the client operation to use. + * This is initialized by svn_client_create_context() and should never + * be @c NULL. + * + * @since New in 1.7. */ + svn_wc_context_t *wc_ctx; + +} svn_client_ctx_t; + +/** Initialize a client context. + * Set @a *ctx to a client context object, allocated in @a pool, that + * represents a particular instance of an svn client. @a cfg_hash is used + * to initialise the config member of the returned context object and should + * remain valid for the lifetime of the object. @a cfg_hash may be @c NULL, + * in which case it is ignored. + * + * In order to avoid backwards compatibility problems, clients must + * use this function to initialize and allocate the + * #svn_client_ctx_t structure rather than doing so themselves, as + * the size of this structure may change in the future. + * + * The current implementation never returns error, but callers should + * still check for error, for compatibility with future versions. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_create_context2(svn_client_ctx_t **ctx, + apr_hash_t *cfg_hash, + apr_pool_t *pool); + + +/** Similar to svn_client_create_context2 but passes a NULL @a cfg_hash. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_create_context(svn_client_ctx_t **ctx, + apr_pool_t *pool); + +/** @} end group: Client context management */ + +/** + * @name Authentication information file names + * + * Names of files that contain authentication information. + * + * These filenames are decided by libsvn_client, since this library + * implements all the auth-protocols; libsvn_wc does nothing but + * blindly store and retrieve these files from protected areas. + * + * @defgroup clnt_auth_filenames Client authentication file names + * @{ + */ +#define SVN_CLIENT_AUTH_USERNAME "username" +#define SVN_CLIENT_AUTH_PASSWORD "password" +/** @} group end: Authentication information file names */ + +/** Client argument processing + * + * @defgroup clnt_cmdline Client command-line processing + * + * @{ + */ + +/** + * Pull remaining target arguments from @a os into @a *targets_p, + * converting them to UTF-8, followed by targets from @a known_targets + * (which might come from, for example, the "--targets" command line option). + * + * Process each target in one of the following ways. For a repository- + * relative URL: resolve to a full URL, contacting the repository if + * necessary to do so, and then treat as a full URL. For a URL: do some + * IRI-to-URI encoding and some auto-escaping, and canonicalize. For a + * local path: canonicalize case and path separators. + * + * If @a keep_last_origpath_on_truepath_collision is TRUE, and there are + * exactly two targets which both case-canonicalize to the same path, the last + * target will be returned in the original non-case-canonicalized form. + * + * Allocate @a *targets_p and its elements in @a pool. + * + * @a ctx is required for possible repository authentication. + * + * If a path has the same name as a Subversion working copy + * administrative directory, return #SVN_ERR_RESERVED_FILENAME_SPECIFIED; + * if multiple reserved paths are encountered, return a chain of + * errors, all of which are #SVN_ERR_RESERVED_FILENAME_SPECIFIED. Do + * not return this type of error in a chain with any other type of + * error, and if this is the only type of error encountered, complete + * the operation before returning the error(s). + * + * @since New in 1.7 + */ +svn_error_t * +svn_client_args_to_target_array2(apr_array_header_t **targets_p, + apr_getopt_t *os, + const apr_array_header_t *known_targets, + svn_client_ctx_t *ctx, + svn_boolean_t keep_last_origpath_on_truepath_collision, + apr_pool_t *pool); + +/** + * Similar to svn_client_args_to_target_array2() but with + * @a keep_last_origpath_on_truepath_collision always set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_args_to_target_array(apr_array_header_t **targets_p, + apr_getopt_t *os, + const apr_array_header_t *known_targets, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} group end: Client command-line processing */ + +/** @} */ + +/** + * Client working copy management functions + * + * @defgroup clnt_wc Client working copy management + * + * @{ + */ + +/** + * @defgroup clnt_wc_checkout Checkout + * + * @{ + */ + + +/** + * Checkout a working copy from a repository. + * + * @param[out] result_rev If non-NULL, the value of the revision checked + * out from the repository. + * @param[in] URL The repository URL of the checkout source. + * @param[in] path The root of the new working copy. + * @param[in] peg_revision The peg revision. + * @param[in] revision The operative revision. + * @param[in] depth The depth of the operation. If #svn_depth_unknown, + * then behave as if for #svn_depth_infinity, except in the case + * of resuming a previous checkout of @a path (i.e., updating), + * in which case use the depth of the existing working copy. + * @param[in] ignore_externals If @c TRUE, don't process externals + * definitions as part of this operation. + * @param[in] allow_unver_obstructions If @c TRUE, then tolerate existing + * unversioned items that obstruct incoming paths. Only + * obstructions of the same type (file or dir) as the added + * item are tolerated. The text of obstructing files is left + * as-is, effectively treating it as a user modification after + * the checkout. Working properties of obstructing items are + * set equal to the base properties. <br> + * If @c FALSE, then abort if there are any unversioned + * obstructing items. + * @param[in] ctx The standard client context, used for authentication and + * notification. + * @param[in] pool Used for any temporary allocation. + * + * @return A pointer to an #svn_error_t of the type (this list is not + * exhaustive): <br> + * #SVN_ERR_UNSUPPORTED_FEATURE if @a URL refers to a file rather + * than a directory; <br> + * #SVN_ERR_RA_ILLEGAL_URL if @a URL does not exist; <br> + * #SVN_ERR_CLIENT_BAD_REVISION if @a revision is not one of + * #svn_opt_revision_number, #svn_opt_revision_head, or + * #svn_opt_revision_date. <br> + * If no error occurred, return #SVN_NO_ERROR. + * + * @since New in 1.5. + * + * @see #svn_depth_t <br> #svn_client_ctx_t <br> @ref clnt_revisions for + * a discussion of operative and peg revisions. + */ +svn_error_t * +svn_client_checkout3(svn_revnum_t *result_rev, + const char *URL, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t ignore_externals, + svn_boolean_t allow_unver_obstructions, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_checkout3() but with @a allow_unver_obstructions + * always set to FALSE, and @a depth set according to @a recurse: if + * @a recurse is TRUE, @a depth is #svn_depth_infinity, if @a recurse + * is FALSE, @a depth is #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_checkout2(svn_revnum_t *result_rev, + const char *URL, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_boolean_t ignore_externals, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_checkout2(), but with @a peg_revision + * always set to #svn_opt_revision_unspecified and + * @a ignore_externals always set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_checkout(svn_revnum_t *result_rev, + const char *URL, + const char *path, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); +/** @} */ + +/** + * @defgroup Update Bring a working copy up-to-date with a repository + * + * @{ + * + */ + +/** + * Update working trees @a paths to @a revision, authenticating with the + * authentication baton cached in @a ctx. @a paths is an array of const + * char * paths to be updated. Unversioned paths that are direct children + * of a versioned path will cause an update that attempts to add that path; + * other unversioned paths are skipped. If @a result_revs is not NULL, + * @a *result_revs will be set to an array of svn_revnum_t with each + * element set to the revision to which @a revision was resolved for the + * corresponding element of @a paths. + * + * @a revision must be of kind #svn_opt_revision_number, + * #svn_opt_revision_head, or #svn_opt_revision_date. If @a + * revision does not meet these requirements, return the error + * #SVN_ERR_CLIENT_BAD_REVISION. + * + * The paths in @a paths can be from multiple working copies from multiple + * repositories, but even if they all come from the same repository there + * is no guarantee that revision represented by #svn_opt_revision_head + * will remain the same as each path is updated. + * + * If @a ignore_externals is set, don't process externals definitions + * as part of this operation. + * + * If @a depth is #svn_depth_infinity, update fully recursively. + * Else if it is #svn_depth_immediates or #svn_depth_files, update + * each target and its file entries, but not its subdirectories. Else + * if #svn_depth_empty, update exactly each target, nonrecursively + * (essentially, update the target's properties). + * + * If @a depth is #svn_depth_unknown, take the working depth from + * @a paths and then behave as described above. + * + * If @a depth_is_sticky is set and @a depth is not + * #svn_depth_unknown, then in addition to updating PATHS, also set + * their sticky ambient depth value to @a depth. + * + * If @a allow_unver_obstructions is TRUE then the update tolerates + * existing unversioned items that obstruct added paths. Only + * obstructions of the same type (file or dir) as the added item are + * tolerated. The text of obstructing files is left as-is, effectively + * treating it as a user modification after the update. Working + * properties of obstructing items are set equal to the base properties. + * If @a allow_unver_obstructions is FALSE then the update will abort + * if there are any unversioned obstructing items. + * + * If @a adds_as_modification is TRUE, a local addition at the same path + * as an incoming addition of the same node kind results in a normal node + * with a possible local modification, instead of a tree conflict. + * + * If @a make_parents is TRUE, create any non-existent parent + * directories also by checking them out at depth=empty. + * + * If @a ctx->notify_func2 is non-NULL, invoke @a ctx->notify_func2 with + * @a ctx->notify_baton2 for each item handled by the update, and also for + * files restored from text-base. If @a ctx->cancel_func is non-NULL, invoke + * it passing @a ctx->cancel_baton at various places during the update. + * + * Use @a pool for any temporary allocation. + * + * @todo Multiple Targets + * - Up for debate: an update on multiple targets is *not* atomic. + * Right now, svn_client_update only takes one path. What's + * debatable is whether this should ever change. On the one hand, + * it's kind of losing to have the client application loop over + * targets and call svn_client_update() on each one; each call to + * update initializes a whole new repository session (network + * overhead, etc.) On the other hand, it's a very simple + * implementation, and allows for the possibility that different + * targets may come from different repositories. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_update4(apr_array_header_t **result_revs, + const apr_array_header_t *paths, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t ignore_externals, + svn_boolean_t allow_unver_obstructions, + svn_boolean_t adds_as_modification, + svn_boolean_t make_parents, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_update4() but with @a make_parents always set + * to FALSE and @a adds_as_modification set to TRUE. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_update3(apr_array_header_t **result_revs, + const apr_array_header_t *paths, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t ignore_externals, + svn_boolean_t allow_unver_obstructions, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_update3() but with @a allow_unver_obstructions + * always set to FALSE, @a depth_is_sticky to FALSE, and @a depth set + * according to @a recurse: if @a recurse is TRUE, set @a depth to + * #svn_depth_infinity, if @a recurse is FALSE, set @a depth to + * #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_update2(apr_array_header_t **result_revs, + const apr_array_header_t *paths, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_boolean_t ignore_externals, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_update2() except that it accepts only a single + * target in @a path, returns a single revision if @a result_rev is + * not NULL, and @a ignore_externals is always set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_update(svn_revnum_t *result_rev, + const char *path, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); +/** @} */ + +/** + * @defgroup Switch Switch a working copy to another location. + * + * @{ + */ + +/** + * Switch an existing working copy directory to a different repository + * location. + * + * This is normally used to switch a working copy directory over to another + * line of development, such as a branch or a tag. Switching an existing + * working copy directory is more efficient than checking out @a url from + * scratch. + * + * @param[out] result_rev If non-NULL, the value of the revision to which + * the working copy was actually switched. + * @param[in] path The directory to be switched. This need not be the + * root of a working copy. + * @param[in] url The repository URL to switch to. + * @param[in] peg_revision The peg revision. + * @param[in] revision The operative revision. + * @param[in] depth The depth of the operation. If #svn_depth_infinity, + * switch fully recursively. Else if #svn_depth_immediates, + * switch @a path and its file children (if any), and + * switch subdirectories but do not update them. Else if + * #svn_depth_files, switch just file children, ignoring + * subdirectories completely. Else if #svn_depth_empty, + * switch just @a path and touch nothing underneath it. + * @param[in] depth_is_sticky If @c TRUE, and @a depth is not + * #svn_depth_unknown, then in addition to switching @a path, also + * set its sticky ambient depth value to @a depth. + * @param[in] ignore_externals If @c TRUE, don't process externals + * definitions as part of this operation. + * @param[in] allow_unver_obstructions If @c TRUE, then tolerate existing + * unversioned items that obstruct incoming paths. Only + * obstructions of the same type (file or dir) as the added + * item are tolerated. The text of obstructing files is left + * as-is, effectively treating it as a user modification after + * the checkout. Working properties of obstructing items are + * set equal to the base properties. <br> + * If @c FALSE, then abort if there are any unversioned + * obstructing items. + * @param[in] ignore_ancestry If @c FALSE, then verify that the file + * or directory at @a path shares some common version control + * ancestry with the switch URL location (represented by the + * combination of @a url, @a peg_revision, and @a revision), + * and returning #SVN_ERR_CLIENT_UNRELATED_RESOURCES if they + * do not. If @c TRUE, no such sanity checks are performed. + * + * @param[in] ctx The standard client context, used for authentication and + * notification. The notifier is invoked for paths affected by + * the switch, and also for files which may be restored from the + * pristine store after being previously removed from the working + * copy. + * @param[in] pool Used for any temporary allocation. + * + * @return A pointer to an #svn_error_t of the type (this list is not + * exhaustive): <br> + * #SVN_ERR_CLIENT_BAD_REVISION if @a revision is not one of + * #svn_opt_revision_number, #svn_opt_revision_head, or + * #svn_opt_revision_date. <br> + * If no error occurred, return #SVN_NO_ERROR. + * + * @since New in 1.7. + * + * @see #svn_depth_t <br> #svn_client_ctx_t <br> @ref clnt_revisions for + * a discussion of operative and peg revisions. + */ +svn_error_t * +svn_client_switch3(svn_revnum_t *result_rev, + const char *path, + const char *url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t ignore_externals, + svn_boolean_t allow_unver_obstructions, + svn_boolean_t ignore_ancestry, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_switch3() but with @a ignore_ancestry always + * set to TRUE. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_switch2(svn_revnum_t *result_rev, + const char *path, + const char *url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t ignore_externals, + svn_boolean_t allow_unver_obstructions, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_switch2() but with @a allow_unver_obstructions, + * @a ignore_externals, and @a depth_is_sticky always set to FALSE, + * and @a depth set according to @a recurse: if @a recurse is TRUE, + * set @a depth to #svn_depth_infinity, if @a recurse is FALSE, set + * @a depth to #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_switch(svn_revnum_t *result_rev, + const char *path, + const char *url, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Add Begin versioning files/directories in a working copy. + * + * @{ + */ + +/** + * Schedule a working copy @a path for addition to the repository. + * + * If @a depth is #svn_depth_empty, add just @a path and nothing + * below it. If #svn_depth_files, add @a path and any file + * children of @a path. If #svn_depth_immediates, add @a path, any + * file children, and any immediate subdirectories (but nothing + * underneath those subdirectories). If #svn_depth_infinity, add + * @a path and everything under it fully recursively. + * + * @a path's parent must be under revision control already (unless + * @a add_parents is TRUE), but @a path is not. + * + * If @a force is not set and @a path is already under version + * control, return the error #SVN_ERR_ENTRY_EXISTS. If @a force is + * set, do not error on already-versioned items. When used on a + * directory in conjunction with a @a depth value greater than + * #svn_depth_empty, this has the effect of scheduling for addition + * any unversioned files and directories scattered within even a + * versioned tree (up to @a depth). + * + * If @a ctx->notify_func2 is non-NULL, then for each added item, call + * @a ctx->notify_func2 with @a ctx->notify_baton2 and the path of the + * added item. + * + * If @a no_ignore is FALSE, don't add any file or directory (or recurse + * into any directory) that is unversioned and found by recursion (as + * opposed to being the explicit target @a path) and whose name matches the + * svn:ignore property on its parent directory or the global-ignores list in + * @a ctx->config. If @a no_ignore is TRUE, do include such files and + * directories. (Note that an svn:ignore property can influence this + * behaviour only when recursing into an already versioned directory with @a + * force.) + * + * If @a no_autoprops is TRUE, don't set any autoprops on added files. If + * @a no_autoprops is FALSE then all added files have autprops set as per + * the auto-props list in @a ctx->config and the value of any + * @c SVN_PROP_INHERITABLE_AUTO_PROPS properties inherited by the nearest + * parents of @a path which are already under version control. + * + * If @a add_parents is TRUE, recurse up @a path's directory and look for + * a versioned directory. If found, add all intermediate paths between it + * and @a path. If not found, return #SVN_ERR_CLIENT_NO_VERSIONED_PARENT. + * + * @a scratch_pool is used for temporary allocations only. + * + * @par Important: + * This is a *scheduling* operation. No changes will + * happen to the repository until a commit occurs. This scheduling + * can be removed with svn_client_revert2(). + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_add5(const char *path, + svn_depth_t depth, + svn_boolean_t force, + svn_boolean_t no_ignore, + svn_boolean_t no_autoprops, + svn_boolean_t add_parents, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_add5(), but with @a no_autoprops always set to + * FALSE. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_add4(const char *path, + svn_depth_t depth, + svn_boolean_t force, + svn_boolean_t no_ignore, + svn_boolean_t add_parents, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_add4(), but with @a add_parents always set to + * FALSE and @a depth set according to @a recursive: if TRUE, then + * @a depth is #svn_depth_infinity, if FALSE, then #svn_depth_empty. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_add3(const char *path, + svn_boolean_t recursive, + svn_boolean_t force, + svn_boolean_t no_ignore, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_add3(), but with @a no_ignore always set to + * FALSE. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_add2(const char *path, + svn_boolean_t recursive, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_add2(), but with @a force always set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_add(const char *path, + svn_boolean_t recursive, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Mkdir Create directories in a working copy or repository. + * + * @{ + */ + +/** Create a directory, either in a repository or a working copy. + * + * @a paths is an array of (const char *) paths, either all local WC paths + * or all URLs. + * + * If @a paths contains URLs, use the authentication baton in @a ctx + * and @a message to immediately attempt to commit the creation of the + * directories in @a paths in the repository. + * + * Else, create the directories on disk, and attempt to schedule them + * for addition (using svn_client_add(), whose docstring you should + * read). + * + * If @a make_parents is TRUE, create any non-existent parent directories + * also. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision in + * the event that this is a committing operation. This table cannot + * contain any standard Subversion properties. + * + * @a ctx->log_msg_func3/@a ctx->log_msg_baton3 are a callback/baton + * combo that this function can use to query for a commit log message + * when one is needed. + * + * If @a ctx->notify_func2 is non-NULL, when the directory has been created + * (successfully) in the working copy, call @a ctx->notify_func2 with + * @a ctx->notify_baton2 and the path of the new directory. Note that this is + * only called for items added to the working copy. + * + * If @a commit_callback is non-NULL, then for each successful commit, call + * @a commit_callback with @a commit_baton and a #svn_commit_info_t for + * the commit. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_mkdir4(const apr_array_header_t *paths, + svn_boolean_t make_parents, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_mkdir4(), but returns the commit info in + * @a *commit_info_p rather than through a callback function. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_mkdir3(svn_commit_info_t **commit_info_p, + const apr_array_header_t *paths, + svn_boolean_t make_parents, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Same as svn_client_mkdir3(), but with @a make_parents always FALSE, + * and @a revprop_table always NULL. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_mkdir2(svn_commit_info_t **commit_info_p, + const apr_array_header_t *paths, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Same as svn_client_mkdir2(), but takes the #svn_client_commit_info_t + * type for @a commit_info_p. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_mkdir(svn_client_commit_info_t **commit_info_p, + const apr_array_header_t *paths, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Delete Remove files/directories from a working copy or repository. + * + * @{ + */ + +/** Delete items from a repository or working copy. + * + * @a paths is an array of (const char *) paths, either all local WC paths + * or all URLs. + * + * If the paths in @a paths are URLs, use the authentication baton in + * @a ctx and @a ctx->log_msg_func3/@a ctx->log_msg_baton3 to + * immediately attempt to commit a deletion of the URLs from the + * repository. Every path must belong to the same repository. + * + * Else, schedule the working copy paths in @a paths for removal from + * the repository. Each path's parent must be under revision control. + * This is just a *scheduling* operation. No changes will happen to + * the repository until a commit occurs. This scheduling can be + * removed with svn_client_revert2(). If a path is a file it is + * immediately removed from the working copy. If the path is a + * directory it will remain in the working copy but all the files, and + * all unversioned items, it contains will be removed. If @a force is + * not set then this operation will fail if any path contains locally + * modified and/or unversioned items. If @a force is set such items + * will be deleted. + * + * If the paths are working copy paths and @a keep_local is TRUE then + * the paths will not be removed from the working copy, only scheduled + * for removal from the repository. Once the scheduled deletion is + * committed, they will appear as unversioned paths in the working copy. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision in + * the event that this is a committing operation. This table cannot + * contain any standard Subversion properties. + * + * @a ctx->log_msg_func3/@a ctx->log_msg_baton3 are a callback/baton + * combo that this function can use to query for a commit log message + * when one is needed. + * + * If @a ctx->notify_func2 is non-NULL, then for each item deleted, call + * @a ctx->notify_func2 with @a ctx->notify_baton2 and the path of the deleted + * item. + * + * If @a commit_callback is non-NULL, then for each successful commit, call + * @a commit_callback with @a commit_baton and a #svn_commit_info_t for + * the commit. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_delete4(const apr_array_header_t *paths, + svn_boolean_t force, + svn_boolean_t keep_local, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_delete4(), but returns the commit info in + * @a *commit_info_p rather than through a callback function. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_delete3(svn_commit_info_t **commit_info_p, + const apr_array_header_t *paths, + svn_boolean_t force, + svn_boolean_t keep_local, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_delete3(), but with @a keep_local always set + * to FALSE, and @a revprop_table passed as NULL. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_delete2(svn_commit_info_t **commit_info_p, + const apr_array_header_t *paths, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_delete2(), but takes the #svn_client_commit_info_t + * type for @a commit_info_p. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_delete(svn_client_commit_info_t **commit_info_p, + const apr_array_header_t *paths, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** @} */ + +/** + * @defgroup Import Import files into the repository. + * + * @{ + */ + +/** + * The callback invoked by svn_client_import5() before adding a node to the + * list of nodes to be imported. + * + * @a baton is the value passed to @a svn_client_import5 as filter_baton. + * + * The callback receives the @a local_abspath for each node and the @a dirent + * for it when walking the directory tree. Only the kind of node, including + * special status is available in @a dirent. + * + * Implementations can set @a *filtered to TRUE, to make the import + * process omit the node and (if the node is a directory) all its + * descendants. + * + * @a scratch_pool can be used for temporary allocations. + * + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_client_import_filter_func_t)( + void *baton, + svn_boolean_t *filtered, + const char *local_abspath, + const svn_io_dirent2_t *dirent, + apr_pool_t *scratch_pool); + +/** Import file or directory @a path into repository directory @a url at + * head, authenticating with the authentication baton cached in @a ctx, + * and using @a ctx->log_msg_func3/@a ctx->log_msg_baton3 to get a log message + * for the (implied) commit. If some components of @a url do not exist + * then create parent directories as necessary. + * + * This function reads an unversioned tree from disk and skips any ".svn" + * directories. Even if a file or directory being imported is part of an + * existing WC, this function sees it as unversioned and does not notice any + * existing Subversion properties in it. + * + * If @a path is a directory, the contents of that directory are + * imported directly into the directory identified by @a url. Note that the + * directory @a path itself is not imported -- that is, the basename of + * @a path is not part of the import. + * + * If @a path is a file, then the dirname of @a url is the directory + * receiving the import. The basename of @a url is the filename in the + * repository. In this case if @a url already exists, return error. + * + * If @a ctx->notify_func2 is non-NULL, then call @a ctx->notify_func2 with + * @a ctx->notify_baton2 as the import progresses, with any of the following + * actions: #svn_wc_notify_commit_added, + * #svn_wc_notify_commit_postfix_txdelta. + * + * Use @a scratch_pool for any temporary allocation. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision. + * This table cannot contain any standard Subversion properties. + * + * @a ctx->log_msg_func3/@a ctx->log_msg_baton3 are a callback/baton + * combo that this function can use to query for a commit log message + * when one is needed. + * + * If @a depth is #svn_depth_empty, import just @a path and nothing + * below it. If #svn_depth_files, import @a path and any file + * children of @a path. If #svn_depth_immediates, import @a path, any + * file children, and any immediate subdirectories (but nothing + * underneath those subdirectories). If #svn_depth_infinity, import + * @a path and everything under it fully recursively. + * + * If @a no_ignore is @c FALSE, don't import any file or directory (or + * recurse into any directory) that is found by recursion (as opposed to + * being the explicit target @a path) and whose name matches the + * global-ignores list in @a ctx->config. If @a no_ignore is @c TRUE, do + * include such files and directories. (Note that svn:ignore properties are + * not involved, as auto-props cannot set properties on directories and even + * if the target is part of a WC the import ignores any existing + * properties.) + * + * If @a no_autoprops is TRUE, don't set any autoprops on imported files. If + * @a no_autoprops is FALSE then all imported files have autprops set as per + * the auto-props list in @a ctx->config and the value of any + * @c SVN_PROP_INHERITABLE_AUTO_PROPS properties inherited by and explicitly set + * on @a url if @a url is already under versioned control, or the nearest parents + * of @a path which are already under version control if not. + * + * If @a ignore_unknown_node_types is @c FALSE, ignore files of which the + * node type is unknown, such as device files and pipes. + * + * If @a filter_callback is non-NULL, call it for each node that isn't ignored + * for other reasons with @a filter_baton, to allow third party to ignore + * specific nodes during importing. + * + * If @a commit_callback is non-NULL, then for each successful commit, call + * @a commit_callback with @a commit_baton and a #svn_commit_info_t for + * the commit. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_import5(const char *path, + const char *url, + svn_depth_t depth, + svn_boolean_t no_ignore, + svn_boolean_t no_autoprops, + svn_boolean_t ignore_unknown_node_types, + const apr_hash_t *revprop_table, + svn_client_import_filter_func_t filter_callback, + void *filter_baton, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_import5(), but without support for an optional + * @a filter_callback and @a no_autoprops always set to FALSE. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_import4(const char *path, + const char *url, + svn_depth_t depth, + svn_boolean_t no_ignore, + svn_boolean_t ignore_unknown_node_types, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_import4(), but returns the commit info in + * @a *commit_info_p rather than through a callback function. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_import3(svn_commit_info_t **commit_info_p, + const char *path, + const char *url, + svn_depth_t depth, + svn_boolean_t no_ignore, + svn_boolean_t ignore_unknown_node_types, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_import3(), but with @a ignore_unknown_node_types + * always set to @c FALSE, @a revprop_table passed as NULL, and @a + * depth set according to @a nonrecursive: if TRUE, then @a depth is + * #svn_depth_files, else #svn_depth_infinity. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.4 API + */ +SVN_DEPRECATED +svn_error_t * +svn_client_import2(svn_commit_info_t **commit_info_p, + const char *path, + const char *url, + svn_boolean_t nonrecursive, + svn_boolean_t no_ignore, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_import2(), but with @a no_ignore always set + * to FALSE and using the #svn_client_commit_info_t type for + * @a commit_info_p. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_import(svn_client_commit_info_t **commit_info_p, + const char *path, + const char *url, + svn_boolean_t nonrecursive, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Commit Commit local modifications to the repository. + * + * @{ + */ + +/** + * Commit files or directories into repository, authenticating with + * the authentication baton cached in @a ctx, and using + * @a ctx->log_msg_func3/@a ctx->log_msg_baton3 to obtain the log message. + * Set @a *commit_info_p to the results of the commit, allocated in @a pool. + * + * @a targets is an array of <tt>const char *</tt> paths to commit. They + * need not be canonicalized nor condensed; this function will take care of + * that. If @a targets has zero elements, then do nothing and return + * immediately without error. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision. + * This table cannot contain any standard Subversion properties. + * + * If @a ctx->notify_func2 is non-NULL, then call @a ctx->notify_func2 with + * @a ctx->notify_baton2 as the commit progresses, with any of the following + * actions: #svn_wc_notify_commit_modified, #svn_wc_notify_commit_added, + * #svn_wc_notify_commit_deleted, #svn_wc_notify_commit_replaced, + * #svn_wc_notify_commit_copied, #svn_wc_notify_commit_copied_replaced, + * #svn_wc_notify_commit_postfix_txdelta. + * + * If @a depth is #svn_depth_infinity, commit all changes to and + * below named targets. If @a depth is #svn_depth_empty, commit + * only named targets (that is, only property changes on named + * directory targets, and property and content changes for named file + * targets). If @a depth is #svn_depth_files, behave as above for + * named file targets, and for named directory targets, commit + * property changes on a named directory and all changes to files + * directly inside that directory. If #svn_depth_immediates, behave + * as for #svn_depth_files, and for subdirectories of any named + * directory target commit as though for #svn_depth_empty. + * + * Unlock paths in the repository, unless @a keep_locks is TRUE. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items that are committed; + * that is, don't commit anything unless it's a member of one of those + * changelists. After the commit completes successfully, remove + * changelist associations from the targets, unless @a + * keep_changelists is set. If @a changelists is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * If @a commit_as_operations is set to FALSE, when a copy is committed + * all changes below the copy are always committed at the same time + * (independent of the value of @a depth). If @a commit_as_operations is + * #TRUE, changes to descendants are only committed if they are itself + * included via @a depth and targets. + * + * If @a include_file_externals and/or @a include_dir_externals are #TRUE, + * also commit all file and/or dir externals (respectively) that are reached + * by recursion, except for those externals which: + * - have a fixed revision, or + * - come from a different repository root URL (dir externals). + * These flags affect only recursion; externals that directly appear in @a + * targets are always included in the commit. + * + * ### TODO: currently, file externals hidden inside an unversioned dir are + * skipped deliberately, because we can't commit those yet. + * See STMT_SELECT_COMMITTABLE_EXTERNALS_BELOW. + * + * ### TODO: With @c depth_immediates, this function acts as if + * @a include_dir_externals was passed #FALSE, but caller expects + * immediate child dir externals to be included @c depth_empty. + * + * When @a commit_as_operations is #TRUE it is possible to delete a node and + * all its descendants by selecting just the root of the deletion. If it is + * set to #FALSE this will raise an error. + * + * If @a commit_callback is non-NULL, then for each successful commit, call + * @a commit_callback with @a commit_baton and a #svn_commit_info_t for + * the commit. + * + * @note #svn_depth_unknown and #svn_depth_exclude must not be passed + * for @a depth. + * + * Use @a pool for any temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_commit6(const apr_array_header_t *targets, + svn_depth_t depth, + svn_boolean_t keep_locks, + svn_boolean_t keep_changelists, + svn_boolean_t commit_as_operations, + svn_boolean_t include_file_externals, + svn_boolean_t include_dir_externals, + const apr_array_header_t *changelists, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_commit6(), but passes @a include_file_externals as + * FALSE and @a include_dir_externals as FALSE. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_commit5(const apr_array_header_t *targets, + svn_depth_t depth, + svn_boolean_t keep_locks, + svn_boolean_t keep_changelists, + svn_boolean_t commit_as_operations, + const apr_array_header_t *changelists, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_commit5(), but returns the commit info in + * @a *commit_info_p rather than through a callback function. Does not use + * #svn_wc_notify_commit_copied or #svn_wc_notify_commit_copied_replaced + * (preferring #svn_wc_notify_commit_added and + * #svn_wc_notify_commit_replaced, respectively, instead). + * + * Also, if no error is returned and @a (*commit_info_p)->revision is set to + * #SVN_INVALID_REVNUM, then the commit was a no-op; nothing needed to + * be committed. + * + * Sets @a commit_as_operations to FALSE to match Subversion 1.6's behavior. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_commit4(svn_commit_info_t **commit_info_p, + const apr_array_header_t *targets, + svn_depth_t depth, + svn_boolean_t keep_locks, + svn_boolean_t keep_changelists, + const apr_array_header_t *changelists, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_commit4(), but always with NULL for + * @a changelist_name, FALSE for @a keep_changelist, NULL for @a + * revprop_table, and @a depth set according to @a recurse: if @a + * recurse is TRUE, use #svn_depth_infinity, else #svn_depth_empty. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * + * @since New in 1.3. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_commit3(svn_commit_info_t **commit_info_p, + const apr_array_header_t *targets, + svn_boolean_t recurse, + svn_boolean_t keep_locks, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_commit3(), but uses #svn_client_commit_info_t + * for @a commit_info_p. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_commit2(svn_client_commit_info_t **commit_info_p, + const apr_array_header_t *targets, + svn_boolean_t recurse, + svn_boolean_t keep_locks, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_commit2(), but with @a keep_locks set to + * TRUE and @a nonrecursive instead of @a recurse. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_commit(svn_client_commit_info_t **commit_info_p, + const apr_array_header_t *targets, + svn_boolean_t nonrecursive, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Status Report interesting information about paths in the \ + * working copy. + * + * @{ + */ + +/** + * Structure for holding the "status" of a working copy item. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type. + * + * @since New in 1.7. + */ +typedef struct svn_client_status_t +{ + /** The kind of node as recorded in the working copy */ + svn_node_kind_t kind; + + /** The absolute path to the node */ + const char *local_abspath; + + /** The actual size of the working file on disk, or SVN_INVALID_FILESIZE + * if unknown (or if the item isn't a file at all). */ + svn_filesize_t filesize; + + /** If the path is under version control, versioned is TRUE, otherwise + * FALSE. */ + svn_boolean_t versioned; + + /** Set to TRUE if the node is the victim of some kind of conflict. */ + svn_boolean_t conflicted; + + /** The status of the node, based on the restructuring changes and if the + * node has no restructuring changes the text and prop status. */ + enum svn_wc_status_kind node_status; + + /** The status of the text of the node, not including restructuring changes. + * Valid values are: svn_wc_status_none, svn_wc_status_normal, + * svn_wc_status_modified and svn_wc_status_conflicted. */ + enum svn_wc_status_kind text_status; + + /** The status of the node's properties. + * Valid values are: svn_wc_status_none, svn_wc_status_normal, + * svn_wc_status_modified and svn_wc_status_conflicted. */ + enum svn_wc_status_kind prop_status; + + /** A node can be 'locked' if a working copy update is in progress or + * was interrupted. */ + svn_boolean_t wc_is_locked; + + /** A file or directory can be 'copied' if it's scheduled for + * addition-with-history (or part of a subtree that is scheduled as such.). + */ + svn_boolean_t copied; + + /** The URL of the repository root. */ + const char *repos_root_url; + + /** The UUID of the repository */ + const char *repos_uuid; + + /** The in-repository path relative to the repository root. */ + const char *repos_relpath; + + /** Base revision. */ + svn_revnum_t revision; + + /** Last revision this was changed */ + svn_revnum_t changed_rev; + + /** Date of last commit. */ + apr_time_t changed_date; + + /** Last commit author of this item */ + const char *changed_author; + + /** A file or directory can be 'switched' if the switch command has been + * used. If this is TRUE, then file_external will be FALSE. + */ + svn_boolean_t switched; + + /** If the item is a file that was added to the working copy with an + * svn:externals; if file_external is TRUE, then switched is always + * FALSE. + */ + svn_boolean_t file_external; + + /** The locally present lock. (Values of path, token, owner, comment and + * are available if a lock is present) */ + const svn_lock_t *lock; + + /** Which changelist this item is part of, or NULL if not part of any. */ + const char *changelist; + + /** The depth of the node as recorded in the working copy + * (#svn_depth_unknown for files or when no depth is recorded) */ + svn_depth_t depth; + + /** + * @defgroup svn_wc_status_ood WC out-of-date info from the repository + * @{ + * + * When the working copy item is out-of-date compared to the + * repository, the following fields represent the state of the + * youngest revision of the item in the repository. If the working + * copy is not out of date, the fields are initialized as described + * below. + */ + + /** Set to the node kind of the youngest commit, or #svn_node_none + * if not out of date. */ + svn_node_kind_t ood_kind; + + /** The status of the node, based on the text status if the node has no + * restructuring changes */ + enum svn_wc_status_kind repos_node_status; + + /** The node's text status in the repository. */ + enum svn_wc_status_kind repos_text_status; + + /** The node's property status in the repository. */ + enum svn_wc_status_kind repos_prop_status; + + /** The node's lock in the repository, if any. */ + const svn_lock_t *repos_lock; + + /** Set to the youngest committed revision, or #SVN_INVALID_REVNUM + * if not out of date. */ + svn_revnum_t ood_changed_rev; + + /** Set to the most recent commit date, or @c 0 if not out of date. */ + apr_time_t ood_changed_date; + + /** Set to the user name of the youngest commit, or @c NULL if not + * out of date or non-existent. Because a non-existent @c + * svn:author property has the same behavior as an out-of-date + * working copy, examine @c ood_changed_rev to determine whether + * the working copy is out of date. */ + const char *ood_changed_author; + + /** @} */ + + /** Reserved for libsvn_client's internal use; this value is only to be used + * for libsvn_client backwards compatibility wrappers. This value may be NULL + * or to other data in future versions. */ + const void *backwards_compatibility_baton; + + /** Set to the local absolute path that this node was moved from, if this + * file or directory has been moved here locally and is the root of that + * move. Otherwise set to NULL. + * + * This will be NULL for moved-here nodes that are just part of a subtree + * that was moved along (and are not themselves a root of a different move + * operation). + * + * @since New in 1.8. */ + const char *moved_from_abspath; + + /** Set to the local absolute path that this node was moved to, if this file + * or directory has been moved away locally and corresponds to the root + * of the destination side of the move. Otherwise set to NULL. + * + * Note: Saying just "root" here could be misleading. For example: + * svn mv A AA; + * svn mv AA/B BB; + * creates a situation where A/B is moved-to BB, but one could argue that + * the move source's root actually was AA/B. Note that, as far as the + * working copy is concerned, above case is exactly identical to: + * svn mv A/B BB; + * svn mv A AA; + * In both situations, @a moved_to_abspath would be set for nodes A (moved + * to AA) and A/B (moved to BB), only. + * + * This will be NULL for moved-away nodes that were just part of a subtree + * that was moved along (and are not themselves a root of a different move + * operation). + * + * @since New in 1.8. */ + const char *moved_to_abspath; + + /* NOTE! Please update svn_client_status_dup() when adding new fields here. */ +} svn_client_status_t; + +/** + * Return a duplicate of @a status, allocated in @a result_pool. No part of the new + * structure will be shared with @a status. + * + * @since New in 1.7. + */ +svn_client_status_t * +svn_client_status_dup(const svn_client_status_t *status, + apr_pool_t *result_pool); + +/** + * A callback for reporting a @a status about @a path (which may be an + * absolute or relative path). + * + * @a baton is a closure object; it should be provided by the + * implementation, and passed by the caller. + * + * @a scratch_pool will be cleared between invocations to the callback. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_client_status_func_t)( + void *baton, + const char *path, + const svn_client_status_t *status, + apr_pool_t *scratch_pool); + +/** + * Given @a path to a working copy directory (or single file), call + * @a status_func/status_baton with a set of #svn_wc_status_t * + * structures which describe the status of @a path, and its children + * (recursing according to @a depth). + * + * - If @a get_all is set, retrieve all entries; otherwise, + * retrieve only "interesting" entries (local mods and/or + * out of date). + * + * - If @a update is set, contact the repository and augment the + * status structures with information about out-of-dateness (with + * respect to @a revision). Also, if @a result_rev is not @c NULL, + * set @a *result_rev to the actual revision against which the + * working copy was compared (@a *result_rev is not meaningful unless + * @a update is set). + * + * If @a no_ignore is @c FALSE, don't report any file or directory (or + * recurse into any directory) that is found by recursion (as opposed to + * being the explicit target @a path) and whose name matches the + * svn:ignore property on its parent directory or the global-ignores + * list in @a ctx->config. If @a no_ignore is @c TRUE, report each such + * file or directory with the status code #svn_wc_status_ignored. + * + * If @a ignore_externals is not set, then recurse into externals + * definitions (if any exist) after handling the main target. This + * calls the client notification function (in @a ctx) with the + * #svn_wc_notify_status_external action before handling each externals + * definition, and with #svn_wc_notify_status_completed + * after each. + * + * If @a depth_as_sticky is set and @a depth is not + * #svn_depth_unknown, then the status is calculated as if depth_is_sticky + * was passed to an equivalent update command. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose statuses are + * reported; that is, don't report status about any item unless + * it's a member of one of those changelists. If @a changelists is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * If @a path is an absolute path then the @c path parameter passed in each + * call to @a status_func will be an absolute path. + * + * All temporary allocations are performed in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_status5(svn_revnum_t *result_rev, + svn_client_ctx_t *ctx, + const char *path, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t update, + svn_boolean_t no_ignore, + svn_boolean_t ignore_externals, + svn_boolean_t depth_as_sticky, + const apr_array_header_t *changelists, + svn_client_status_func_t status_func, + void *status_baton, + apr_pool_t *scratch_pool); + +/** + * Same as svn_client_status5(), but using #svn_wc_status_func3_t + * instead of #svn_client_status_func_t and depth_as_sticky set to TRUE. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_status4(svn_revnum_t *result_rev, + const char *path, + const svn_opt_revision_t *revision, + svn_wc_status_func3_t status_func, + void *status_baton, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t update, + svn_boolean_t no_ignore, + svn_boolean_t ignore_externals, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Same as svn_client_status4(), but using an #svn_wc_status_func2_t + * instead of an #svn_wc_status_func3_t. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_status3(svn_revnum_t *result_rev, + const char *path, + const svn_opt_revision_t *revision, + svn_wc_status_func2_t status_func, + void *status_baton, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t update, + svn_boolean_t no_ignore, + svn_boolean_t ignore_externals, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Like svn_client_status3(), except with @a changelists passed as @c + * NULL, and with @a recurse instead of @a depth. If @a recurse is + * TRUE, behave as if for #svn_depth_infinity; else if @a recurse is + * FALSE, behave as if for #svn_depth_immediates. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_status2(svn_revnum_t *result_rev, + const char *path, + const svn_opt_revision_t *revision, + svn_wc_status_func2_t status_func, + void *status_baton, + svn_boolean_t recurse, + svn_boolean_t get_all, + svn_boolean_t update, + svn_boolean_t no_ignore, + svn_boolean_t ignore_externals, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_status2(), but with @a ignore_externals + * always set to FALSE, taking the #svn_wc_status_func_t type + * instead of the #svn_wc_status_func2_t type for @a status_func, + * and requiring @a *revision to be non-const even though it is + * treated as constant. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_status(svn_revnum_t *result_rev, + const char *path, + svn_opt_revision_t *revision, + svn_wc_status_func_t status_func, + void *status_baton, + svn_boolean_t recurse, + svn_boolean_t get_all, + svn_boolean_t update, + svn_boolean_t no_ignore, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Log View information about previous revisions of an object. + * + * @{ + */ + +/** + * Invoke @a receiver with @a receiver_baton on each log message from + * each (#svn_opt_revision_range_t *) range in @a revision_ranges in turn, + * inclusive (but never invoke @a receiver on a given log message more + * than once). + * + * @a targets contains either a URL followed by zero or more relative + * paths, or 1 working copy path, as <tt>const char *</tt>, for which log + * messages are desired. @a receiver is invoked only on messages whose + * revisions involved a change to some path in @a targets. @a peg_revision + * indicates in which revision @a targets are valid. If @a peg_revision is + * #svn_opt_revision_unspecified, it defaults to #svn_opt_revision_head + * for URLs or #svn_opt_revision_working for WC paths. + * + * If @a limit is non-zero only invoke @a receiver on the first @a limit + * logs. + * + * If @a discover_changed_paths is set, then the @c changed_paths and @c + * changed_paths2 fields in the @c log_entry argument to @a receiver will be + * populated on each invocation. @note The @c text_modified and @c + * props_modified fields of the changed paths structure may have the value + * #svn_tristate_unknown if the repository does not report that information. + * + * If @a strict_node_history is set, copy history (if any exists) will + * not be traversed while harvesting revision logs for each target. + * + * If @a include_merged_revisions is set, log information for revisions + * which have been merged to @a targets will also be returned. + * + * If @a revprops is NULL, retrieve all revision properties; else, retrieve + * only the revision properties named by the (const char *) array elements + * (i.e. retrieve none if the array is empty). + * + * Use @a pool for any temporary allocation. + * + * If @a ctx->notify_func2 is non-NULL, then call @a ctx->notify_func2/baton2 + * with a 'skip' signal on any unversioned targets. + * + * @since New in 1.6. + */ +svn_error_t * +svn_client_log5(const apr_array_header_t *targets, + const svn_opt_revision_t *peg_revision, + const apr_array_header_t *revision_ranges, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_boolean_t include_merged_revisions, + const apr_array_header_t *revprops, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_log5(), but takes explicit start and end parameters + * instead of an array of revision ranges. + * + * @deprecated Provided for compatibility with the 1.5 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_log4(const apr_array_header_t *targets, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_boolean_t include_merged_revisions, + const apr_array_header_t *revprops, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_log4(), but using #svn_log_message_receiver_t + * instead of #svn_log_entry_receiver_t. Also, @a + * include_merged_revisions is set to @c FALSE and @a revprops is + * svn:author, svn:date, and svn:log. + * + * @deprecated Provided for compatibility with the 1.4 API. + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_log3(const apr_array_header_t *targets, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_log_message_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_log3(), but with the @c kind field of + * @a peg_revision set to #svn_opt_revision_unspecified. + * + * @par Important: + * A special case for the revision range HEAD:1, which was present + * in svn_client_log(), has been removed from svn_client_log2(). Instead, it + * is expected that callers will specify the range HEAD:0, to avoid a + * #SVN_ERR_FS_NO_SUCH_REVISION error when invoked against an empty repository + * (i.e. one not containing a revision 1). + * + * @deprecated Provided for compatibility with the 1.3 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_log2(const apr_array_header_t *targets, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_log_message_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_log2(), but with @a limit set to 0, and the + * following special case: + * + * Special case for repositories at revision 0: + * + * If @a start->kind is #svn_opt_revision_head, and @a end->kind is + * #svn_opt_revision_number && @a end->number is @c 1, then handle an + * empty (no revisions) repository specially: instead of erroring + * because requested revision 1 when the highest revision is 0, just + * invoke @a receiver on revision 0, passing @c NULL for changed paths and + * empty strings for the author and date. This is because that + * particular combination of @a start and @a end usually indicates the + * common case of log invocation -- the user wants to see all log + * messages from youngest to oldest, where the oldest commit is + * revision 1. That works fine, except when there are no commits in + * the repository, hence this special case. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_log(const apr_array_header_t *targets, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_log_message_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Blame Show modification information about lines in a file. + * + * @{ + */ + +/** + * Invoke @a receiver with @a receiver_baton on each line-blame item + * associated with revision @a end of @a path_or_url, using @a start + * as the default source of all blame. @a peg_revision indicates in + * which revision @a path_or_url is valid. If @a peg_revision->kind + * is #svn_opt_revision_unspecified, then it defaults to + * #svn_opt_revision_head for URLs or #svn_opt_revision_working for + * WC targets. + * + * If @a start->kind or @a end->kind is #svn_opt_revision_unspecified, + * return the error #SVN_ERR_CLIENT_BAD_REVISION. If either are + * #svn_opt_revision_working, return the error + * #SVN_ERR_UNSUPPORTED_FEATURE. If any of the revisions of @a + * path_or_url have a binary mime-type, return the error + * #SVN_ERR_CLIENT_IS_BINARY_FILE, unless @a ignore_mime_type is TRUE, + * in which case blame information will be generated regardless of the + * MIME types of the revisions. + * + * Use @a diff_options to determine how to compare different revisions of the + * target. + * + * If @a include_merged_revisions is TRUE, also return data based upon + * revisions which have been merged to @a path_or_url. + * + * Use @a pool for any temporary allocation. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_blame5(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + const svn_diff_file_options_t *diff_options, + svn_boolean_t ignore_mime_type, + svn_boolean_t include_merged_revisions, + svn_client_blame_receiver3_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_blame5(), but with #svn_client_blame_receiver3_t + * as the receiver. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + * + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_blame4(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + const svn_diff_file_options_t *diff_options, + svn_boolean_t ignore_mime_type, + svn_boolean_t include_merged_revisions, + svn_client_blame_receiver2_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_blame4(), but with @a include_merged_revisions set + * to FALSE, and using a #svn_client_blame_receiver2_t as the receiver. + * + * @deprecated Provided for backwards compatibility with the 1.4 API. + * + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_blame3(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + const svn_diff_file_options_t *diff_options, + svn_boolean_t ignore_mime_type, + svn_client_blame_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_blame3(), but with @a diff_options set to + * default options as returned by svn_diff_file_options_parse() and + * @a ignore_mime_type set to FALSE. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + * + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_blame2(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + svn_client_blame_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_blame2() except that @a peg_revision is always + * the same as @a end. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_blame(const char *path_or_url, + const svn_opt_revision_t *start, + const svn_opt_revision_t *end, + svn_client_blame_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Diff Generate differences between paths. + * + * @{ + */ + +/** + * Produce diff output which describes the delta between + * @a path_or_url1/@a revision1 and @a path_or_url2/@a revision2. Print + * the output of the diff to @a outstream, and any errors to @a + * errstream. @a path_or_url1 and @a path_or_url2 can be either + * working-copy paths or URLs. + * + * If @a relative_to_dir is not @c NULL, the original path and + * modified path will have the @a relative_to_dir stripped from the + * front of the respective paths. If @a relative_to_dir is @c NULL, + * paths will not be modified. If @a relative_to_dir is not + * @c NULL but @a relative_to_dir is not a parent path of the target, + * an error is returned. Finally, if @a relative_to_dir is a URL, an + * error will be returned. + * + * If either @a revision1 or @a revision2 has an `unspecified' or + * unrecognized `kind', return #SVN_ERR_CLIENT_BAD_REVISION. + * + * @a path_or_url1 and @a path_or_url2 must both represent the same node + * kind -- that is, if @a path_or_url1 is a directory, @a path_or_url2 + * must also be, and if @a path_or_url1 is a file, @a path_or_url2 must + * also be. + * + * If @a depth is #svn_depth_infinity, diff fully recursively. + * Else if it is #svn_depth_immediates, diff the named paths and + * their file children (if any), and diff properties of + * subdirectories, but do not descend further into the subdirectories. + * Else if #svn_depth_files, behave as if for #svn_depth_immediates + * except don't diff properties of subdirectories. If + * #svn_depth_empty, diff exactly the named paths but nothing + * underneath them. + * + * Use @a ignore_ancestry to control whether or not items being + * diffed will be checked for relatedness first. Unrelated items + * are typically transmitted to the editor as a deletion of one thing + * and the addition of another, but if this flag is TRUE, unrelated + * items will be diffed as if they were related. + * + * If @a no_diff_added is TRUE, then no diff output will be generated + * on added files. + * + * If @a no_diff_deleted is TRUE, then no diff output will be + * generated on deleted files. + * + * If @a show_copies_as_adds is TRUE, then copied files will not be diffed + * against their copyfrom source, and will appear in the diff output + * in their entirety, as if they were newly added. + * ### BUGS: For a repos-repos diff, this is ignored. Instead, a file is + * diffed against its copyfrom source iff the file is the diff target + * and not if some parent directory is the diff target. For a repos-WC + * diff, this is ignored if the file is the diff target. + * + * If @a use_git_diff_format is TRUE, then the git's extended diff format + * will be used. + * ### Do we need to say more about the format? A reference perhaps? + * + * If @a ignore_properties is TRUE, do not show property differences. + * If @a properties_only is TRUE, show only property changes. + * The above two options are mutually exclusive. It is an error to set + * both to TRUE. + * + * Generated headers are encoded using @a header_encoding. + * + * Diff output will not be generated for binary files, unless @a + * ignore_content_type is TRUE, in which case diffs will be shown + * regardless of the content types. + * + * @a diff_options (an array of <tt>const char *</tt>) is used to pass + * additional command line options to the diff processes invoked to compare + * files. @a diff_options is allowed to be @c NULL, in which case a value + * for this option might still be obtained from the Subversion configuration + * file via client context @a ctx. + * + * The authentication baton cached in @a ctx is used to communicate with + * the repository. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose differences are + * reported; that is, don't generate diffs about any item unless + * it's a member of one of those changelists. If @a changelists is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * @note Changelist filtering only applies to diffs in which at least + * one side of the diff represents working copy data. + * + * @note @a header_encoding doesn't affect headers generated by external + * diff programs. + * + * @note @a relative_to_dir doesn't affect the path index generated by + * external diff programs. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_diff6(const apr_array_header_t *diff_options, + const char *path_or_url1, + const svn_opt_revision_t *revision1, + const char *path_or_url2, + const svn_opt_revision_t *revision2, + const char *relative_to_dir, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_added, + svn_boolean_t no_diff_deleted, + svn_boolean_t show_copies_as_adds, + svn_boolean_t ignore_content_type, + svn_boolean_t ignore_properties, + svn_boolean_t properties_only, + svn_boolean_t use_git_diff_format, + const char *header_encoding, + svn_stream_t *outstream, + svn_stream_t *errstream, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Similar to svn_client_diff6(), but with @a outfile and @a errfile, + * instead of @a outstream and @a errstream, and with @a + * no_diff_added, @a ignore_properties, and @a properties_only always + * passed as @c FALSE (which means that additions and property changes + * are always transmitted). + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.7. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff5(const apr_array_header_t *diff_options, + const char *path1, + const svn_opt_revision_t *revision1, + const char *path2, + const svn_opt_revision_t *revision2, + const char *relative_to_dir, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t show_copies_as_adds, + svn_boolean_t ignore_content_type, + svn_boolean_t use_git_diff_format, + const char *header_encoding, + apr_file_t *outfile, + apr_file_t *errfile, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff5(), but with @a show_copies_as_adds set to + * @c FALSE and @a use_git_diff_format set to @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff4(const apr_array_header_t *diff_options, + const char *path1, + const svn_opt_revision_t *revision1, + const char *path2, + const svn_opt_revision_t *revision2, + const char *relative_to_dir, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t ignore_content_type, + const char *header_encoding, + apr_file_t *outfile, + apr_file_t *errfile, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff4(), but with @a changelists passed as @c + * NULL, and @a depth set according to @a recurse: if @a recurse is + * TRUE, set @a depth to #svn_depth_infinity, if @a recurse is + * FALSE, set @a depth to #svn_depth_empty. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * @since New in 1.3. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff3(const apr_array_header_t *diff_options, + const char *path1, + const svn_opt_revision_t *revision1, + const char *path2, + const svn_opt_revision_t *revision2, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t ignore_content_type, + const char *header_encoding, + apr_file_t *outfile, + apr_file_t *errfile, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_diff3(), but with @a header_encoding set to + * @c APR_LOCALE_CHARSET. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff2(const apr_array_header_t *diff_options, + const char *path1, + const svn_opt_revision_t *revision1, + const char *path2, + const svn_opt_revision_t *revision2, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t ignore_content_type, + apr_file_t *outfile, + apr_file_t *errfile, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff2(), but with @a ignore_content_type + * always set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff(const apr_array_header_t *diff_options, + const char *path1, + const svn_opt_revision_t *revision1, + const char *path2, + const svn_opt_revision_t *revision2, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + apr_file_t *outfile, + apr_file_t *errfile, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Produce diff output which describes the delta between the filesystem + * object @a path_or_url in peg revision @a peg_revision, as it changed + * between @a start_revision and @a end_revision. @a path_or_url can + * be either a working-copy path or URL. + * + * If @a peg_revision is #svn_opt_revision_unspecified, behave + * identically to svn_client_diff6(), using @a path_or_url for both of that + * function's @a path_or_url1 and @a path_or_url2 arguments. + * + * All other options are handled identically to svn_client_diff6(). + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_diff_peg6(const apr_array_header_t *diff_options, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + const char *relative_to_dir, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_added, + svn_boolean_t no_diff_deleted, + svn_boolean_t show_copies_as_adds, + svn_boolean_t ignore_content_type, + svn_boolean_t ignore_properties, + svn_boolean_t properties_only, + svn_boolean_t use_git_diff_format, + const char *header_encoding, + svn_stream_t *outstream, + svn_stream_t *errstream, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Similar to svn_client_diff6_peg6(), but with @a outfile and @a errfile, + * instead of @a outstream and @a errstream, and with @a + * no_diff_added, @a ignore_properties, and @a properties_only always + * passed as @c FALSE (which means that additions and property changes + * are always transmitted). + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.7. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_peg5(const apr_array_header_t *diff_options, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + const char *relative_to_dir, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t show_copies_as_adds, + svn_boolean_t ignore_content_type, + svn_boolean_t use_git_diff_format, + const char *header_encoding, + apr_file_t *outfile, + apr_file_t *errfile, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff_peg5(), but with @a show_copies_as_adds set to + * @c FALSE and @a use_git_diff_format set to @c FALSE. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_peg4(const apr_array_header_t *diff_options, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + const char *relative_to_dir, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t ignore_content_type, + const char *header_encoding, + apr_file_t *outfile, + apr_file_t *errfile, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff_peg4(), but with @a changelists passed + * as @c NULL, and @a depth set according to @a recurse: if @a recurse + * is TRUE, set @a depth to #svn_depth_infinity, if @a recurse is + * FALSE, set @a depth to #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * @since New in 1.3. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_peg3(const apr_array_header_t *diff_options, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t ignore_content_type, + const char *header_encoding, + apr_file_t *outfile, + apr_file_t *errfile, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff_peg3(), but with @a header_encoding set to + * @c APR_LOCALE_CHARSET. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_peg2(const apr_array_header_t *diff_options, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + svn_boolean_t ignore_content_type, + apr_file_t *outfile, + apr_file_t *errfile, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff_peg2(), but with @a ignore_content_type + * always set to FALSE. + * + * @since New in 1.1. + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_peg(const apr_array_header_t *diff_options, + const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t no_diff_deleted, + apr_file_t *outfile, + apr_file_t *errfile, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Produce a diff summary which lists the changed items between + * @a path_or_url1/@a revision1 and @a path_or_url2/@a revision2 without + * creating text deltas. @a path_or_url1 and @a path_or_url2 can be + * either working-copy paths or URLs. + * + * The function may report false positives if @a ignore_ancestry is false, + * since a file might have been modified between two revisions, but still + * have the same contents. + * + * Calls @a summarize_func with @a summarize_baton for each difference + * with a #svn_client_diff_summarize_t structure describing the difference. + * + * See svn_client_diff6() for a description of the other parameters. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_diff_summarize2(const char *path_or_url1, + const svn_opt_revision_t *revision1, + const char *path_or_url2, + const svn_opt_revision_t *revision2, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + const apr_array_header_t *changelists, + svn_client_diff_summarize_func_t summarize_func, + void *summarize_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff_summarize2(), but with @a changelists + * passed as @c NULL, and @a depth set according to @a recurse: if @a + * recurse is TRUE, set @a depth to #svn_depth_infinity, if @a + * recurse is FALSE, set @a depth to #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_summarize(const char *path1, + const svn_opt_revision_t *revision1, + const char *path2, + const svn_opt_revision_t *revision2, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_client_diff_summarize_func_t summarize_func, + void *summarize_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Produce a diff summary which lists the changed items between the + * filesystem object @a path_or_url in peg revision @a peg_revision, as it + * changed between @a start_revision and @a end_revision. @a path_or_url can + * be either a working-copy path or URL. + * + * If @a peg_revision is #svn_opt_revision_unspecified, behave + * identically to svn_client_diff_summarize2(), using @a path_or_url for + * both of that function's @a path_or_url1 and @a path_or_url2 arguments. + * + * The function may report false positives if @a ignore_ancestry is false, + * as described in the documentation for svn_client_diff_summarize2(). + * + * Call @a summarize_func with @a summarize_baton for each difference + * with a #svn_client_diff_summarize_t structure describing the difference. + * + * See svn_client_diff_peg5() for a description of the other parameters. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_diff_summarize_peg2(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + const apr_array_header_t *changelists, + svn_client_diff_summarize_func_t summarize_func, + void *summarize_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_diff_summarize_peg2(), but with @a + * changelists passed as @c NULL, and @a depth set according to @a + * recurse: if @a recurse is TRUE, set @a depth to + * #svn_depth_infinity, if @a recurse is FALSE, set @a depth to + * #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_diff_summarize_peg(const char *path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *start_revision, + const svn_opt_revision_t *end_revision, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_client_diff_summarize_func_t summarize_func, + void *summarize_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Merge Merge changes between branches. + * + * @{ + */ + +/** Get information about the state of merging between two branches. + * + * The source is specified by @a source_path_or_url at @a source_revision. + * The target is specified by @a target_path_or_url at @a target_revision, + * which refers to either a WC or a repository location. + * + * Set @a *needs_reintegration to true if an automatic merge from source + * to target would be a reintegration merge: that is, if the last automatic + * merge was in the opposite direction; or to false otherwise. + * + * Set @a *yca_url, @a *yca_rev, @a *base_url, @a *base_rev, @a *right_url, + * @a *right_rev, @a *target_url, @a *target_rev to the repository locations + * of, respectively: the youngest common ancestor of the branches, the base + * chosen for 3-way merge, the right-hand side of the source diff, and the + * target. + * + * Set @a repos_root_url to the URL of the repository root. This is a + * common prefix of all four URL outputs. + * + * Allocate the results in @a result_pool. Any of the output pointers may + * be NULL if not wanted. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_get_merging_summary(svn_boolean_t *needs_reintegration, + const char **yca_url, svn_revnum_t *yca_rev, + const char **base_url, svn_revnum_t *base_rev, + const char **right_url, svn_revnum_t *right_rev, + const char **target_url, svn_revnum_t *target_rev, + const char **repos_root_url, + const char *source_path_or_url, + const svn_opt_revision_t *source_revision, + const char *target_path_or_url, + const svn_opt_revision_t *target_revision, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Merge changes from @a source1/@a revision1 to @a source2/@a revision2 into + * the working-copy path @a target_wcpath. + * + * @a source1 and @a source2 are either URLs that refer to entries in the + * repository, or paths to entries in the working copy. + * + * By "merging", we mean: apply file differences using + * svn_wc_merge(), and schedule additions & deletions when appropriate. + * + * @a source1 and @a source2 must both represent the same node kind -- that + * is, if @a source1 is a directory, @a source2 must also be, and if @a source1 + * is a file, @a source2 must also be. + * + * If either @a revision1 or @a revision2 has an `unspecified' or + * unrecognized `kind', return #SVN_ERR_CLIENT_BAD_REVISION. + * + * If @a depth is #svn_depth_infinity, merge fully recursively. + * Else if #svn_depth_immediates, merge changes at most to files + * that are immediate children of @a target_wcpath and to directory + * properties of @a target_wcpath and its immediate subdirectory children. + * Else if #svn_depth_files, merge at most to immediate file + * children of @a target_wcpath and to @a target_wcpath itself. + * Else if #svn_depth_empty, apply changes only to @a target_wcpath + * (i.e., directory property changes only) + * + * If @a depth is #svn_depth_unknown, use the depth of @a target_wcpath. + * + * If @a ignore_mergeinfo is true, disable merge tracking, by treating the + * two sources as unrelated even if they actually have a common ancestor. + * + * If @a diff_ignore_ancestry is true, diff unrelated nodes as if related: + * that is, diff the 'left' and 'right' versions of a node as if they were + * related (if they are the same kind) even if they are not related. + * Otherwise, diff unrelated items as a deletion of one thing and the + * addition of another. + * + * If @a force_delete is false and the merge involves deleting a file whose + * content differs from the source-left version, or a locally modified + * directory, or an unversioned item, then the operation will fail. If + * @a force_delete is true then all such items will be deleted. + * + * @a merge_options (an array of <tt>const char *</tt>), if non-NULL, + * is used to pass additional command line arguments to the merge + * processes (internal or external). @see + * svn_diff_file_options_parse(). + * + * If @a ctx->notify_func2 is non-NULL, then call @a ctx->notify_func2 with @a + * ctx->notify_baton2 once for each merged target, passing the target's local + * path. + * + * If @a record_only is TRUE, the merge is performed, but is limited only to + * mergeinfo property changes on existing paths in @a target_wcpath. + * + * If @a dry_run is TRUE, the merge is carried out, and full notification + * feedback is provided, but the working copy is not modified. + * + * If allow_mixed_rev is @c FALSE, and @a merge_target is a mixed-revision + * working copy, raise @c SVN_ERR_CLIENT_MERGE_UPDATE_REQUIRED. + * Because users rarely intend to merge into mixed-revision working copies, + * it is recommended to set this parameter to FALSE by default unless the + * user has explicitly requested a merge into a mixed-revision working copy. + * + * The authentication baton cached in @a ctx is used to communicate with the + * repository. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_merge5(const char *source1, + const svn_opt_revision_t *revision1, + const char *source2, + const svn_opt_revision_t *revision2, + const char *target_wcpath, + svn_depth_t depth, + svn_boolean_t ignore_mergeinfo, + svn_boolean_t diff_ignore_ancestry, + svn_boolean_t force_delete, + svn_boolean_t record_only, + svn_boolean_t dry_run, + svn_boolean_t allow_mixed_rev, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge5(), but the single @a ignore_ancestry + * parameter maps to both @c ignore_mergeinfo and @c diff_ignore_ancestry. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.7. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge4(const char *source1, + const svn_opt_revision_t *revision1, + const char *source2, + const svn_opt_revision_t *revision2, + const char *target_wcpath, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t force_delete, + svn_boolean_t record_only, + svn_boolean_t dry_run, + svn_boolean_t allow_mixed_rev, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge4(), but with @a allow_mixed_rev set to + * @c TRUE. The @a force parameter maps to the @c force_delete parameter + * of svn_client_merge4(). + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge3(const char *source1, + const svn_opt_revision_t *revision1, + const char *source2, + const svn_opt_revision_t *revision2, + const char *target_wcpath, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t force, + svn_boolean_t record_only, + svn_boolean_t dry_run, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge3(), but with @a record_only set to @c + * FALSE, and @a depth set according to @a recurse: if @a recurse is + * TRUE, set @a depth to #svn_depth_infinity, if @a recurse is + * FALSE, set @a depth to #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge2(const char *source1, + const svn_opt_revision_t *revision1, + const char *source2, + const svn_opt_revision_t *revision2, + const char *target_wcpath, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t force, + svn_boolean_t dry_run, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_merge2(), but with @a merge_options set to NULL. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge(const char *source1, + const svn_opt_revision_t *revision1, + const char *source2, + const svn_opt_revision_t *revision2, + const char *target_wcpath, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t force, + svn_boolean_t dry_run, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Perform a reintegration merge of @a source_path_or_url at @a source_peg_revision + * into @a target_wcpath. + * @a target_wcpath must be a single-revision, #svn_depth_infinity, + * pristine, unswitched working copy -- in other words, it must + * reflect a single revision tree, the "target". The mergeinfo on @a + * source_path_or_url must reflect that all of the target has been merged into it. + * Then this behaves like a merge with svn_client_merge5() from the + * target's URL to the source. + * + * All other options are handled identically to svn_client_merge5(). + * The depth of the merge is always #svn_depth_infinity. + * + * @since New in 1.5. + * @deprecated Provided for backwards compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge_reintegrate(const char *source_path_or_url, + const svn_opt_revision_t *source_peg_revision, + const char *target_wcpath, + svn_boolean_t dry_run, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Merge changes from the source branch identified by + * @a source_path_or_url in peg revision @a source_peg_revision, + * into the target branch working copy at @a target_wcpath. + * + * If @a ranges_to_merge is NULL then perform an automatic merge of + * all the eligible changes up to @a source_peg_revision. If the merge + * required is a reintegrate merge, then return an error if the WC has + * mixed revisions, local modifications and/or switched subtrees; if + * the merge is determined to be of the non-reintegrate kind, then + * return an error if @a allow_mixed_rev is false and the WC contains + * mixed revisions. + * + * If @a ranges_to_merge is not NULL then merge the changes specified + * by the revision ranges in @a ranges_to_merge, or, when honouring + * mergeinfo, only the eligible parts of those revision ranges. + * @a ranges_to_merge is an array of <tt>svn_opt_revision_range_t + * *</tt> ranges. These ranges may describe additive and/or + * subtractive merge ranges, they may overlap fully or partially, + * and/or they may partially or fully negate each other. This + * rangelist is not required to be sorted. If any revision in the + * list of provided ranges has an `unspecified' or unrecognized + * `kind', return #SVN_ERR_CLIENT_BAD_REVISION. + * + * If @a ranges_to_merge is an empty array, then do nothing. + * + * All other options are handled identically to svn_client_merge5(). + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_merge_peg5(const char *source_path_or_url, + const apr_array_header_t *ranges_to_merge, + const svn_opt_revision_t *source_peg_revision, + const char *target_wcpath, + svn_depth_t depth, + svn_boolean_t ignore_mergeinfo, + svn_boolean_t diff_ignore_ancestry, + svn_boolean_t force_delete, + svn_boolean_t record_only, + svn_boolean_t dry_run, + svn_boolean_t allow_mixed_rev, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge_peg5(), but automatic merge is not available + * (@a ranges_to_merge must not be NULL), and the single @a ignore_ancestry + * parameter maps to both @c ignore_mergeinfo and @c diff_ignore_ancestry. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.7. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge_peg4(const char *source_path_or_url, + const apr_array_header_t *ranges_to_merge, + const svn_opt_revision_t *source_peg_revision, + const char *target_wcpath, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t force_delete, + svn_boolean_t record_only, + svn_boolean_t dry_run, + svn_boolean_t allow_mixed_rev, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge_peg4(), but with @a allow_mixed_rev set to + * @c TRUE. The @a force parameter maps to the @c force_delete parameter + * of svn_client_merge_peg4(). + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge_peg3(const char *source, + const apr_array_header_t *ranges_to_merge, + const svn_opt_revision_t *peg_revision, + const char *target_wcpath, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t force, + svn_boolean_t record_only, + svn_boolean_t dry_run, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge_peg3(), but with @a record_only set to + * @c FALSE, and @a depth set according to @a recurse: if @a recurse + * is TRUE, set @a depth to #svn_depth_infinity, if @a recurse is + * FALSE, set @a depth to #svn_depth_files. + * + * @deprecated Provided for backwards compatibility with the 1.4 API. + * + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge_peg2(const char *source, + const svn_opt_revision_t *revision1, + const svn_opt_revision_t *revision2, + const svn_opt_revision_t *peg_revision, + const char *target_wcpath, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t force, + svn_boolean_t dry_run, + const apr_array_header_t *merge_options, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_merge_peg2(), but with @a merge_options set to + * NULL. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + * + * @since New in 1.1. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_merge_peg(const char *source, + const svn_opt_revision_t *revision1, + const svn_opt_revision_t *revision2, + const svn_opt_revision_t *peg_revision, + const char *target_wcpath, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t force, + svn_boolean_t dry_run, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** Set @a suggestions to an ordered array of @c const char * + * potential merge sources (expressed as full repository URLs) for @a + * path_or_url at @a peg_revision. @a path_or_url is a working copy + * path or repository URL. @a ctx is a context used for + * authentication in the repository case. Use @a pool for all + * allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_suggest_merge_sources(apr_array_header_t **suggestions, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Get the mergeinfo for a single target node (ignoring any subtrees). + * + * Set @a *mergeinfo to a hash mapping <tt>const char *</tt> merge source + * URLs to <tt>svn_rangelist_t *</tt> rangelists describing the ranges which + * have been merged into @a path_or_url as of @a peg_revision, per + * @a path_or_url's explicit mergeinfo or inherited mergeinfo if no + * explicit mergeinfo if found. If no explicit or inherited mergeinfo + * is found, then set @a *mergeinfo to NULL. + * + * Use @a pool for all necessary allocations. + * + * If the server doesn't support retrieval of mergeinfo (which will + * never happen for file:// URLs), return an + * #SVN_ERR_UNSUPPORTED_FEATURE error. + * + * @note Unlike most APIs which deal with mergeinfo, this one returns + * data where the keys of the hash are absolute repository URLs rather + * than repository filesystem paths. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_mergeinfo_get_merged(apr_hash_t **mergeinfo, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Describe the revisions that either have or have not been merged from + * one source branch (or subtree) into another. + * + * If @a finding_merged is TRUE, then drive log entry callbacks + * @a receiver / @a receiver_baton with the revisions merged from + * @a source_path_or_url (as of @a source_peg_revision) into + * @a target_path_or_url (as of @a target_peg_revision). If @a + * finding_merged is FALSE then find the revisions eligible for merging. + * + * If both @a source_start_revision and @a source_end_revision are + * unspecified (that is, of kind @c svn_opt_revision_unspecified), + * @a receiver will be called the requested revisions from 0 to + * @a source_peg_revision and in that order (that is, oldest to + * youngest). Otherwise, both @a source_start_revision and + * @a source_end_revision must be specified, which has two effects: + * + * - @a receiver will be called only with revisions which fall + * within range of @a source_start_revision to + * @a source_end_revision, inclusive, and + * + * - those revisions will be ordered in the same "direction" as the + * walk from @a source_start_revision to @a source_end_revision. + * (If @a source_start_revision is the younger of the two, @a + * receiver will be called with revisions in youngest-to-oldest + * order; otherwise, the reverse occurs.) + * + * If @a depth is #svn_depth_empty consider only the explicit or + * inherited mergeinfo on @a target_path_or_url when calculating merged + * revisions from @a source_path_or_url. If @a depth is #svn_depth_infinity + * then also consider the explicit subtree mergeinfo under @a + * target_path_or_url. + * If a depth other than #svn_depth_empty or #svn_depth_infinity is + * requested then return a #SVN_ERR_UNSUPPORTED_FEATURE error. + * + * @a discover_changed_paths and @a revprops are the same as for + * svn_client_log5(). Use @a scratch_pool for all temporary allocations. + * + * @a ctx is a context used for authentication. + * + * If the server doesn't support retrieval of mergeinfo, return an + * #SVN_ERR_UNSUPPORTED_FEATURE error. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_mergeinfo_log2(svn_boolean_t finding_merged, + const char *target_path_or_url, + const svn_opt_revision_t *target_peg_revision, + const char *source_path_or_url, + const svn_opt_revision_t *source_peg_revision, + const svn_opt_revision_t *source_start_revision, + const svn_opt_revision_t *source_end_revision, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + svn_boolean_t discover_changed_paths, + svn_depth_t depth, + const apr_array_header_t *revprops, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_mergeinfo_log2(), but with @a source_start_revision + * and @a source_end_revision always of kind @c svn_opt_revision_unspecified; + * + * @deprecated Provided for backwards compatibility with the 1.7 API. + * @since New in 1.7. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_mergeinfo_log(svn_boolean_t finding_merged, + const char *target_path_or_url, + const svn_opt_revision_t *target_peg_revision, + const char *source_path_or_url, + const svn_opt_revision_t *source_peg_revision, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + svn_boolean_t discover_changed_paths, + svn_depth_t depth, + const apr_array_header_t *revprops, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_mergeinfo_log(), but finds only merged revisions + * and always operates at @a depth #svn_depth_empty. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. Use + * svn_client_mergeinfo_log() instead. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_mergeinfo_log_merged(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const char *merge_source_path_or_url, + const svn_opt_revision_t *src_peg_revision, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + svn_boolean_t discover_changed_paths, + const apr_array_header_t *revprops, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_mergeinfo_log(), but finds only eligible revisions + * and always operates at @a depth #svn_depth_empty. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. Use + * svn_client_mergeinfo_log() instead. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_mergeinfo_log_eligible(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const char *merge_source_path_or_url, + const svn_opt_revision_t *src_peg_revision, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + svn_boolean_t discover_changed_paths, + const apr_array_header_t *revprops, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Cleanup Cleanup an abnormally terminated working copy. + * + * @{ + */ + +/** Recursively cleanup a working copy directory @a dir, finishing any + * incomplete operations, removing lockfiles, etc. + * + * If @a ctx->cancel_func is non-NULL, invoke it with @a + * ctx->cancel_baton at various points during the operation. If it + * returns an error (typically #SVN_ERR_CANCELLED), return that error + * immediately. + * + * Use @a scratch_pool for any temporary allocations. + */ +svn_error_t * +svn_client_cleanup(const char *dir, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + + +/** @} */ + +/** + * @defgroup Upgrade Upgrade a working copy. + * + * @{ + */ + +/** Recursively upgrade a working copy from any older format to the current + * WC metadata storage format. @a wcroot_dir is the path to the WC root. + * + * Use @a scratch_pool for any temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_upgrade(const char *wcroot_dir, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + + +/** @} */ + +/** + * @defgroup Relocate Switch a working copy to a different repository. + * + * @{ + */ + +/** + * Recursively modify a working copy rooted at @a wcroot_dir, changing + * any repository URLs that begin with @a from_prefix to begin with @a + * to_prefix instead. + * + * @param wcroot_dir Working copy root directory + * @param from_prefix Original URL + * @param to_prefix New URL + * @param ignore_externals If not set, recurse into external working + * copies after relocating the primary working copy + * @param ctx svn_client_ctx_t + * @param pool The pool from which to perform memory allocations + * + * @since New in 1.7 + */ +svn_error_t * +svn_client_relocate2(const char *wcroot_dir, + const char *from_prefix, + const char *to_prefix, + svn_boolean_t ignore_externals, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_relocate2(), but with @a ignore_externals + * always TRUE. + * + * @note As of the 1.7 API, @a dir is required to be a working copy + * root directory, and @a recurse is required to be TRUE. + * + * @deprecated Provided for limited backwards compatibility with the + * 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_relocate(const char *dir, + const char *from_prefix, + const char *to_prefix, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Revert Remove local changes in a repository. + * + * @{ + */ + +/** + * Restore the pristine version of working copy @a paths, + * effectively undoing any local mods. For each path in @a paths, + * revert it if it is a file. Else if it is a directory, revert + * according to @a depth: + * + * @a paths is an array of (const char *) local WC paths. + * + * If @a depth is #svn_depth_empty, revert just the properties on + * the directory; else if #svn_depth_files, revert the properties + * and any files immediately under the directory; else if + * #svn_depth_immediates, revert all of the preceding plus + * properties on immediate subdirectories; else if #svn_depth_infinity, + * revert path and everything under it fully recursively. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items reverted; that is, + * don't revert any item unless it's a member of one of those + * changelists. If @a changelists is empty (or altogether @c NULL), + * no changelist filtering occurs. + * + * If @a ctx->notify_func2 is non-NULL, then for each item reverted, + * call @a ctx->notify_func2 with @a ctx->notify_baton2 and the path of + * the reverted item. + * + * If an item specified for reversion is not under version control, + * then do not error, just invoke @a ctx->notify_func2 with @a + * ctx->notify_baton2, using notification code #svn_wc_notify_skip. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_revert2(const apr_array_header_t *paths, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_revert2(), but with @a changelists passed as + * @c NULL, and @a depth set according to @a recurse: if @a recurse is + * TRUE, @a depth is #svn_depth_infinity, else if @a recurse is + * FALSE, @a depth is #svn_depth_empty. + * + * @note Most APIs map @a recurse==FALSE to @a depth==svn_depth_files; + * revert is deliberately different. + * + * @deprecated Provided for backwards compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_revert(const apr_array_header_t *paths, + svn_boolean_t recursive, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** @} */ + +/** + * @defgroup Resolved Mark conflicted paths as resolved. + * + * @{ + */ + +/** + * Similar to svn_client_resolve(), but without automatic conflict + * resolution support. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * Use svn_client_resolve() with @a conflict_choice == @c + * svn_wc_conflict_choose_merged instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_resolved(const char *path, + svn_boolean_t recursive, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Perform automatic conflict resolution on a working copy @a path. + * + * If @a conflict_choice is + * + * - #svn_wc_conflict_choose_base: + * resolve the conflict with the old file contents + * + * - #svn_wc_conflict_choose_mine_full: + * use the original working contents + * + * - #svn_wc_conflict_choose_theirs_full: + * use the new contents + * + * - #svn_wc_conflict_choose_merged: + * don't change the contents at all, just remove the conflict + * status, which is the pre-1.5 behavior. + * + * - #svn_wc_conflict_choose_theirs_conflict + * ###... + * + * - #svn_wc_conflict_choose_mine_conflict + * ###... + * + * - svn_wc_conflict_choose_unspecified + * invoke @a ctx->conflict_func2 with @a ctx->conflict_baton2 to obtain + * a resolution decision for each conflict. This can be used to + * implement interactive conflict resolution. + * + * #svn_wc_conflict_choose_theirs_conflict and + * #svn_wc_conflict_choose_mine_conflict are not legal for binary + * files or properties. + * + * If @a path is not in a state of conflict to begin with, do nothing. + * If @a path's conflict state is removed and @a ctx->notify_func2 is non-NULL, + * call @a ctx->notify_func2 with @a ctx->notify_baton2 and @a path. + * ### with what notification parameters? + * + * If @a depth is #svn_depth_empty, act only on @a path; if + * #svn_depth_files, resolve @a path and its conflicted file + * children (if any); if #svn_depth_immediates, resolve @a path and + * all its immediate conflicted children (both files and directories, + * if any); if #svn_depth_infinity, resolve @a path and every + * conflicted file or directory anywhere beneath it. + * + * Note that this operation will try to lock the parent directory of + * @a path in order to be able to resolve tree-conflicts on @a path. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_resolve(const char *path, + svn_depth_t depth, + svn_wc_conflict_choice_t conflict_choice, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** @} */ + +/** + * @defgroup Copy Copy paths in the working copy and repository. + * + * @{ + */ + +/** + * A structure which describes the source of a copy operation--its path, + * revision, and peg revision. + * + * @since New in 1.5. + */ +typedef struct svn_client_copy_source_t +{ + /** The source path or URL. */ + const char *path; + + /** The source operational revision. */ + const svn_opt_revision_t *revision; + + /** The source peg revision. */ + const svn_opt_revision_t *peg_revision; +} svn_client_copy_source_t; + +/** Copy each source in @a sources to @a dst_path. + * + * If multiple @a sources are given, @a dst_path must be a directory, + * and @a sources will be copied as children of @a dst_path. + * + * @a sources is an array of <tt>svn_client_copy_source_t *</tt> elements, + * either all referring to local WC items or all referring to versioned + * items in the repository. + * + * If @a sources has only one item, attempt to copy it to @a dst_path. If + * @a copy_as_child is TRUE and @a dst_path already exists, attempt to copy the + * item as a child of @a dst_path. If @a copy_as_child is FALSE and + * @a dst_path already exists, fail with #SVN_ERR_ENTRY_EXISTS if @a dst_path + * is a working copy path and #SVN_ERR_FS_ALREADY_EXISTS if @a dst_path is a + * URL. + * + * If @a sources has multiple items, and @a copy_as_child is TRUE, all + * @a sources are copied as children of @a dst_path. If any child of + * @a dst_path already exists with the same name any item in @a sources, + * fail with #SVN_ERR_ENTRY_EXISTS if @a dst_path is a working copy path and + * #SVN_ERR_FS_ALREADY_EXISTS if @a dst_path is a URL. + * + * If @a sources has multiple items, and @a copy_as_child is FALSE, fail + * with #SVN_ERR_CLIENT_MULTIPLE_SOURCES_DISALLOWED. + * + * If @a dst_path is a URL, use the authentication baton + * in @a ctx and @a ctx->log_msg_func3/@a ctx->log_msg_baton3 to immediately + * attempt to commit the copy action in the repository. + * + * If @a dst_path is not a URL, then this is just a variant of + * svn_client_add(), where the @a sources are scheduled for addition + * as copies. No changes will happen to the repository until a commit occurs. + * This scheduling can be removed with svn_client_revert2(). + * + * If @a make_parents is TRUE, create any non-existent parent directories + * also. Otherwise the parent of @a dst_path must already exist. + * + * If @a ignore_externals is set, don't process externals definitions + * as part of this operation. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision in + * the event that this is a committing operation. This table cannot + * contain any standard Subversion properties. + * + * @a ctx->log_msg_func3/@a ctx->log_msg_baton3 are a callback/baton combo + * that this function can use to query for a commit log message when one is + * needed. + * + * If @a ctx->notify_func2 is non-NULL, invoke it with @a ctx->notify_baton2 + * for each item added at the new location, passing the new, relative path of + * the added item. + * + * If @a commit_callback is non-NULL, then for each successful commit, call + * @a commit_callback with @a commit_baton and a #svn_commit_info_t for + * the commit. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_copy6(const apr_array_header_t *sources, + const char *dst_path, + svn_boolean_t copy_as_child, + svn_boolean_t make_parents, + svn_boolean_t ignore_externals, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_copy6(), but returns the commit info in + * @a *commit_info_p rather than through a callback function. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_copy5(svn_commit_info_t **commit_info_p, + const apr_array_header_t *sources, + const char *dst_path, + svn_boolean_t copy_as_child, + svn_boolean_t make_parents, + svn_boolean_t ignore_externals, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_copy5(), with @a ignore_externals set to @c FALSE. + * + * @since New in 1.5. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_copy4(svn_commit_info_t **commit_info_p, + const apr_array_header_t *sources, + const char *dst_path, + svn_boolean_t copy_as_child, + svn_boolean_t make_parents, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_copy4(), with only one @a src_path, @a + * copy_as_child set to @c FALSE, @a revprop_table passed as NULL, and + * @a make_parents set to @c FALSE. Also, use @a src_revision as both + * the operational and peg revision. + * + * @since New in 1.4. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_copy3(svn_commit_info_t **commit_info_p, + const char *src_path, + const svn_opt_revision_t *src_revision, + const char *dst_path, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_copy3(), with the difference that if @a dst_path + * already exists and is a directory, copy the item into that directory, + * keeping its name (the last component of @a src_path). + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_copy2(svn_commit_info_t **commit_info_p, + const char *src_path, + const svn_opt_revision_t *src_revision, + const char *dst_path, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_copy2(), but uses #svn_client_commit_info_t + * for @a commit_info_p. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_copy(svn_client_commit_info_t **commit_info_p, + const char *src_path, + const svn_opt_revision_t *src_revision, + const char *dst_path, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** @} */ + +/** + * @defgroup Move Move paths in the working copy or repository. + * + * @{ + */ + +/** + * Move @a src_paths to @a dst_path. + * + * @a src_paths is an array of (const char *) paths -- either all WC paths + * or all URLs -- of versioned items. If multiple @a src_paths are given, + * @a dst_path must be a directory and @a src_paths will be moved as + * children of @a dst_path. + * + * If @a src_paths are repository URLs: + * + * - @a dst_path must also be a repository URL. + * + * - The authentication baton in @a ctx and @a ctx->log_msg_func/@a + * ctx->log_msg_baton are used to commit the move. + * + * - The move operation will be immediately committed. + * + * If @a src_paths are working copy paths: + * + * - @a dst_path must also be a working copy path. + * + * - @a ctx->log_msg_func3 and @a ctx->log_msg_baton3 are ignored. + * + * - This is a scheduling operation. No changes will happen to the + * repository until a commit occurs. This scheduling can be removed + * with svn_client_revert2(). If one of @a src_paths is a file it is + * removed from the working copy immediately. If one of @a src_path + * is a directory it will remain in the working copy but all the files, + * and unversioned items, it contains will be removed. + * + * If @a src_paths has only one item, attempt to move it to @a dst_path. If + * @a move_as_child is TRUE and @a dst_path already exists, attempt to move the + * item as a child of @a dst_path. If @a move_as_child is FALSE and + * @a dst_path already exists, fail with #SVN_ERR_ENTRY_EXISTS if @a dst_path + * is a working copy path and #SVN_ERR_FS_ALREADY_EXISTS if @a dst_path is a + * URL. + * + * If @a src_paths has multiple items, and @a move_as_child is TRUE, all + * @a src_paths are moved as children of @a dst_path. If any child of + * @a dst_path already exists with the same name any item in @a src_paths, + * fail with #SVN_ERR_ENTRY_EXISTS if @a dst_path is a working copy path and + * #SVN_ERR_FS_ALREADY_EXISTS if @a dst_path is a URL. + * + * If @a src_paths has multiple items, and @a move_as_child is FALSE, fail + * with #SVN_ERR_CLIENT_MULTIPLE_SOURCES_DISALLOWED. + * + * If @a make_parents is TRUE, create any non-existent parent directories + * also. Otherwise, the parent of @a dst_path must already exist. + * + * If @a allow_mixed_revisions is @c FALSE, #SVN_ERR_WC_MIXED_REVISIONS + * will be raised if the move source is a mixed-revision subtree. + * If @a allow_mixed_revisions is TRUE, a mixed-revision move source is + * allowed but the move will degrade to a copy and a delete without local + * move tracking. This parameter should be set to FALSE except where backwards + * compatibility to svn_client_move6() is required. + * + * If @a metadata_only is @c TRUE and moving a file in a working copy, + * everything in the metadata is updated as if the node is moved, but the + * actual disk move operation is not performed. This feature is useful for + * clients that want to keep the working copy in sync while the actual working + * copy is updated by some other task. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision in + * the event that this is a committing operation. This table cannot + * contain any standard Subversion properties. + * + * @a ctx->log_msg_func3/@a ctx->log_msg_baton3 are a callback/baton combo that + * this function can use to query for a commit log message when one is needed. + * + * If @a ctx->notify_func2 is non-NULL, then for each item moved, call + * @a ctx->notify_func2 with the @a ctx->notify_baton2 twice, once to indicate + * the deletion of the moved thing, and once to indicate the addition of + * the new location of the thing. + * + * ### Is this really true? What about svn_wc_notify_commit_replaced()? ### + * + * If @a commit_callback is non-NULL, then for each successful commit, call + * @a commit_callback with @a commit_baton and a #svn_commit_info_t for + * the commit. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_move7(const apr_array_header_t *src_paths, + const char *dst_path, + svn_boolean_t move_as_child, + svn_boolean_t make_parents, + svn_boolean_t allow_mixed_revisions, + svn_boolean_t metadata_only, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_move7(), but with @a allow_mixed_revisions always + * set to @c TRUE and @a metadata_only always to @c FALSE. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_move6(const apr_array_header_t *src_paths, + const char *dst_path, + svn_boolean_t move_as_child, + svn_boolean_t make_parents, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_move6(), but returns the commit info in + * @a *commit_info_p rather than through a callback function. + * + * A WC-to-WC move will include any modified and/or unversioned children. + * @a force is ignored. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_move5(svn_commit_info_t **commit_info_p, + const apr_array_header_t *src_paths, + const char *dst_path, + svn_boolean_t force, + svn_boolean_t move_as_child, + svn_boolean_t make_parents, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_move5(), with only one @a src_path, @a + * move_as_child set to @c FALSE, @a revprop_table passed as NULL, and + * @a make_parents set to @c FALSE. + * + * Note: The behaviour of @a force changed in 1.5 (r860885 and r861421), when + * the 'move' semantics were improved to just move the source including any + * modified and/or unversioned items in it. Before that, @a force + * controlled what happened to such items, but now @a force is ignored. + * + * @since New in 1.4. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_move4(svn_commit_info_t **commit_info_p, + const char *src_path, + const char *dst_path, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_move4(), with the difference that if @a dst_path + * already exists and is a directory, move the item into that directory, + * keeping its name (the last component of @a src_path). + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_move3(svn_commit_info_t **commit_info_p, + const char *src_path, + const char *dst_path, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_move3(), but uses #svn_client_commit_info_t + * for @a commit_info_p. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_move2(svn_client_commit_info_t **commit_info_p, + const char *src_path, + const char *dst_path, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_move2(), but an extra argument @a src_revision + * must be passed. This has no effect, but must be of kind + * #svn_opt_revision_unspecified or #svn_opt_revision_head, + * otherwise error #SVN_ERR_UNSUPPORTED_FEATURE is returned. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_move(svn_client_commit_info_t **commit_info_p, + const char *src_path, + const svn_opt_revision_t *src_revision, + const char *dst_path, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + + +/** Properties + * + * Note that certain svn-controlled properties must always have their + * values set and stored in UTF8 with LF line endings. When + * retrieving these properties, callers must convert the values back + * to native locale and native line-endings before displaying them to + * the user. For help with this task, see + * svn_prop_needs_translation(), svn_subst_translate_string(), and + * svn_subst_detranslate_string(). + * + * @defgroup svn_client_prop_funcs Property functions + * @{ + */ + + +/** + * Set @a propname to @a propval on @a url. A @a propval of @c NULL will + * delete the property. + * + * Immediately attempt to commit the property change in the repository, + * using the authentication baton in @a ctx and @a + * ctx->log_msg_func3/@a ctx->log_msg_baton3. + * + * If the property has changed on @a url since revision + * @a base_revision_for_url (which must not be #SVN_INVALID_REVNUM), no + * change will be made and an error will be returned. + * + * If non-NULL, @a revprop_table is a hash table holding additional, + * custom revision properties (<tt>const char *</tt> names mapped to + * <tt>svn_string_t *</tt> values) to be set on the new revision. This + * table cannot contain any standard Subversion properties. + * + * If @a commit_callback is non-NULL, then call @a commit_callback with + * @a commit_baton and a #svn_commit_info_t for the commit. + * + * If @a propname is an svn-controlled property (i.e. prefixed with + * #SVN_PROP_PREFIX), then the caller is responsible for ensuring that + * the value is UTF8-encoded and uses LF line-endings. + * + * If @a skip_checks is TRUE, do no validity checking. But if @a + * skip_checks is FALSE, and @a propname is not a valid property for @a + * url, return an error, either #SVN_ERR_ILLEGAL_TARGET (if the property is + * not appropriate for @a url), or * #SVN_ERR_BAD_MIME_TYPE (if @a propname + * is "svn:mime-type", but @a propval is not a valid mime-type). + * + * Use @a scratch_pool for all memory allocation. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_propset_remote(const char *propname, + const svn_string_t *propval, + const char *url, + svn_boolean_t skip_checks, + svn_revnum_t base_revision_for_url, + const apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * Set @a propname to @a propval on each (const char *) target in @a + * targets. The targets must be all working copy paths. A @a propval + * of @c NULL will delete the property. + * + * If @a depth is #svn_depth_empty, set the property on each member of + * @a targets only; if #svn_depth_files, set it on @a targets and their + * file children (if any); if #svn_depth_immediates, on @a targets and all + * of their immediate children (both files and directories); if + * #svn_depth_infinity, on @a targets and everything beneath them. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose properties are + * set; that is, don't set properties on any item unless it's a member + * of one of those changelists. If @a changelists is empty (or + * altogether @c NULL), no changelist filtering occurs. + * + * If @a propname is an svn-controlled property (i.e. prefixed with + * #SVN_PROP_PREFIX), then the caller is responsible for ensuring that + * the value is UTF8-encoded and uses LF line-endings. + * + * If @a skip_checks is TRUE, do no validity checking. But if @a + * skip_checks is FALSE, and @a propname is not a valid property for @a + * targets, return an error, either #SVN_ERR_ILLEGAL_TARGET (if the + * property is not appropriate for @a targets), or + * #SVN_ERR_BAD_MIME_TYPE (if @a propname is "svn:mime-type", but @a + * propval is not a valid mime-type). + * + * If @a ctx->cancel_func is non-NULL, invoke it passing @a + * ctx->cancel_baton at various places during the operation. + * + * Use @a scratch_pool for all memory allocation. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_propset_local(const char *propname, + const svn_string_t *propval, + const apr_array_header_t *targets, + svn_depth_t depth, + svn_boolean_t skip_checks, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * An amalgamation of svn_client_propset_local() and + * svn_client_propset_remote() that takes only a single target, and + * returns the commit info in @a *commit_info_p rather than through a + * callback function. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propset3(svn_commit_info_t **commit_info_p, + const char *propname, + const svn_string_t *propval, + const char *target, + svn_depth_t depth, + svn_boolean_t skip_checks, + svn_revnum_t base_revision_for_url, + const apr_array_header_t *changelists, + const apr_hash_t *revprop_table, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Like svn_client_propset3(), but with @a base_revision_for_url + * always #SVN_INVALID_REVNUM; @a commit_info_p always @c NULL; @a + * changelists always @c NULL; @a revprop_table always @c NULL; and @a + * depth set according to @a recurse: if @a recurse is TRUE, @a depth + * is #svn_depth_infinity, else #svn_depth_empty. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propset2(const char *propname, + const svn_string_t *propval, + const char *target, + svn_boolean_t recurse, + svn_boolean_t skip_checks, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Like svn_client_propset2(), but with @a skip_checks always FALSE and a + * newly created @a ctx. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propset(const char *propname, + const svn_string_t *propval, + const char *target, + svn_boolean_t recurse, + apr_pool_t *pool); + +/** Set @a propname to @a propval on revision @a revision in the repository + * represented by @a URL. Use the authentication baton in @a ctx for + * authentication, and @a pool for all memory allocation. Return the actual + * rev affected in @a *set_rev. A @a propval of @c NULL will delete the + * property. + * + * If @a original_propval is non-NULL, then just before setting the + * new value, check that the old value matches @a original_propval; + * if they do not match, return the error #SVN_ERR_RA_OUT_OF_DATE. + * This is to help clients support interactive editing of revprops: + * without this check, the window during which the property may change + * underneath the user is as wide as the amount of time the user + * spends editing the property. With this check, the window is + * reduced to a small, constant amount of time right before we set the + * new value. (To check that an old value is still non-existent, set + * @a original_propval->data to NULL, and @a original_propval->len is + * ignored.) + * If the server advertises #SVN_RA_CAPABILITY_ATOMIC_REVPROPS, the + * check of @a original_propval is done atomically. + * + * Note: the representation of "property is not set" in @a + * original_propval differs from the representation in other APIs + * (such as svn_fs_change_rev_prop2() and svn_ra_change_rev_prop2()). + * + * If @a force is TRUE, allow newlines in the author property. + * + * If @a propname is an svn-controlled property (i.e. prefixed with + * #SVN_PROP_PREFIX), then the caller is responsible for ensuring that + * the value UTF8-encoded and uses LF line-endings. + * + * Note that unlike its cousin svn_client_propset3(), this routine + * doesn't affect the working copy at all; it's a pure network + * operation that changes an *unversioned* property attached to a + * revision. This can be used to tweak log messages, dates, authors, + * and the like. Be careful: it's a lossy operation. + + * @a ctx->notify_func2 and @a ctx->notify_baton2 are the notification + * functions and baton which are called upon successful setting of the + * property. + * + * Also note that unless the administrator creates a + * pre-revprop-change hook in the repository, this feature will fail. + * + * @since New in 1.6. + */ +svn_error_t * +svn_client_revprop_set2(const char *propname, + const svn_string_t *propval, + const svn_string_t *original_propval, + const char *URL, + const svn_opt_revision_t *revision, + svn_revnum_t *set_rev, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_revprop_set2(), but with @a original_propval + * always @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_revprop_set(const char *propname, + const svn_string_t *propval, + const char *URL, + const svn_opt_revision_t *revision, + svn_revnum_t *set_rev, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Set @a *props to a hash table whose keys are absolute paths or URLs + * of items on which property @a propname is explicitly set, and whose + * values are <tt>svn_string_t *</tt> representing the property value for + * @a propname at that path. + * + * If @a inherited_props is not @c NULL, then set @a *inherited_props to a + * depth-first ordered array of #svn_prop_inherited_item_t * structures + * representing the properties inherited by @a target. If @a target is a + * working copy path, then properties inherited by @a target as far as the + * root of the working copy are obtained from the working copy's actual + * property values. Properties inherited from above the working copy root + * come from the inherited properties cache. If @a target is a URL, then + * the inherited properties come from the repository. If @a inherited_props + * is not @c NULL and no inheritable properties are found, then set + * @a *inherited_props to an empty array. + * + * The #svn_prop_inherited_item_t->path_or_url members of the + * #svn_prop_inherited_item_t * structures in @a *inherited_props are + * URLs if @a target is a URL or if @a target is a working copy path but the + * property represented by the structure is above the working copy root (i.e. + * the inherited property is from the cache). In all other cases the + * #svn_prop_inherited_item_t->path_or_url members are absolute working copy + * paths. + * + * Allocate @a *props (including keys and values) and @a *inherited_props + * (including its elements) in @a result_pool, use @a scratch_pool for + * temporary allocations. + * + * @a target is a WC absolute path or a URL. + * + * Don't store any path, not even @a target, if it does not have a + * property named @a propname. + * + * If @a revision->kind is #svn_opt_revision_unspecified, then: get + * properties from the working copy if @a target is a working copy + * path, or from the repository head if @a target is a URL. Else get + * the properties as of @a revision. The actual node revision + * selected is determined by the path as it exists in @a peg_revision. + * If @a peg_revision->kind is #svn_opt_revision_unspecified, then + * it defaults to #svn_opt_revision_head for URLs or + * #svn_opt_revision_working for WC targets. Use the authentication + * baton in @a ctx for authentication if contacting the repository. + * If @a actual_revnum is not @c NULL, the actual revision number used + * for the fetch is stored in @a *actual_revnum. + * + * If @a depth is #svn_depth_empty, fetch the property from + * @a target only; if #svn_depth_files, fetch from @a target and its + * file children (if any); if #svn_depth_immediates, from @a target + * and all of its immediate children (both files and directories); if + * #svn_depth_infinity, from @a target and everything beneath it. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose properties are + * gotten; that is, don't get @a propname on any item unless it's a member + * of one of those changelists. If @a changelists is empty (or + * altogether @c NULL), no changelist filtering occurs. + * + * If error, don't touch @a *props, otherwise @a *props is a hash table + * even if empty. + * + * This function returns SVN_ERR_UNVERSIONED_RESOURCE when it is called on + * unversioned nodes. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_propget5(apr_hash_t **props, + apr_array_header_t **inherited_props, + const char *propname, + const char *target, /* abspath or URL */ + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_revnum_t *actual_revnum, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_propget5 but with @a inherited_props always + * passed as NULL. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propget4(apr_hash_t **props, + const char *propname, + const char *target, /* abspath or URL */ + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_revnum_t *actual_revnum, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_propget4(), but with the following change to the + * output hash keys: keys are `<tt>char *</tt>' paths, prefixed by + * @a target, which is a working copy path or a URL. + * + * This function returns SVN_ERR_ENTRY_NOT_FOUND where svn_client_propget4 + * would return SVN_ERR_UNVERSIONED_RESOURCE. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propget3(apr_hash_t **props, + const char *propname, + const char *target, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_revnum_t *actual_revnum, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_propget3(), except that @a actual_revnum and + * @a changelists are always @c NULL, and @a depth is set according to + * @a recurse: if @a recurse is TRUE, then @a depth is + * #svn_depth_infinity, else #svn_depth_empty. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propget2(apr_hash_t **props, + const char *propname, + const char *target, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_propget2(), except that @a peg_revision is + * always the same as @a revision. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_propget(apr_hash_t **props, + const char *propname, + const char *target, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Set @a *propval to the value of @a propname on revision @a revision + * in the repository represented by @a URL. Use the authentication baton + * in @a ctx for authentication, and @a pool for all memory allocation. + * Return the actual rev queried in @a *set_rev. + * + * Note that unlike its cousin svn_client_propget(), this routine + * doesn't affect the working copy at all; it's a pure network + * operation that queries an *unversioned* property attached to a + * revision. This can query log messages, dates, authors, and the + * like. + */ +svn_error_t * +svn_client_revprop_get(const char *propname, + svn_string_t **propval, + const char *URL, + const svn_opt_revision_t *revision, + svn_revnum_t *set_rev, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Invoke @a receiver with @a receiver_baton to return the regular explicit, and + * possibly the inherited, properties of @a target, a URL or working copy path. + * @a receiver will be called for each path encountered. + * + * @a target is a WC path or a URL. + * + * If @a revision->kind is #svn_opt_revision_unspecified, then get the + * explicit (and possibly the inherited) properties from the working copy, + * if @a target is a working copy path, or from the repository head if + * @a target is a URL. Else get the properties as of @a revision. + * The actual node revision selected is determined by the path as it exists + * in @a peg_revision. If @a peg_revision->kind is + * #svn_opt_revision_unspecified, then it defaults to #svn_opt_revision_head + * for URLs or #svn_opt_revision_working for WC targets. Use the + * authentication baton cached in @a ctx for authentication if contacting + * the repository. + * + * If @a depth is #svn_depth_empty, list only the properties of + * @a target itself. If @a depth is #svn_depth_files, and + * @a target is a directory, list the properties of @a target + * and its file entries. If #svn_depth_immediates, list the properties + * of its immediate file and directory entries. If #svn_depth_infinity, + * list the properties of its file entries and recurse (with + * #svn_depth_infinity) on directory entries. #svn_depth_unknown is + * equivalent to #svn_depth_empty. All other values produce undefined + * results. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose properties are + * listed; that is, don't list properties on any item unless it's a member + * of one of those changelists. If @a changelists is empty (or + * altogether @c NULL), no changelist filtering occurs. + * + * If @a get_target_inherited_props is true, then also return any inherited + * properties when @a receiver is called for @a target. If @a target is a + * working copy path, then properties inherited by @a target as far as the + * root of the working copy are obtained from the working copy's actual + * property values. Properties inherited from above the working copy + * root come from the inherited properties cache. If @a target is a URL, + * then the inherited properties come from the repository. + * If @a get_target_inherited_props is false, then no inherited properties + * are returned to @a receiver. + * + * If @a target is not found, return the error #SVN_ERR_ENTRY_NOT_FOUND. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_proplist4(const char *target, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_boolean_t get_target_inherited_props, + svn_proplist_receiver2_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_client_proplist4(), except that the @a receiver type + * is a #svn_proplist_receiver_t, @a get_target_inherited_props is + * always passed NULL, and there is no separate scratch pool. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_proplist3(const char *target, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_proplist_receiver_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_proplist3(), except the properties are + * returned as an array of #svn_client_proplist_item_t * structures + * instead of by invoking the receiver function, there's no support + * for @a changelists filtering, and @a recurse is used instead of a + * #svn_depth_t parameter (FALSE corresponds to #svn_depth_empty, + * and TRUE to #svn_depth_infinity). + * + * @since New in 1.2. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_proplist2(apr_array_header_t **props, + const char *target, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_proplist2(), except that @a peg_revision is + * always the same as @a revision. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_proplist(apr_array_header_t **props, + const char *target, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Set @a *props to a hash of the revision props attached to @a revision in + * the repository represented by @a URL. Use the authentication baton cached + * in @a ctx for authentication, and @a pool for all memory allocation. + * Return the actual rev queried in @a *set_rev. + * + * The allocated hash maps (<tt>const char *</tt>) property names to + * (#svn_string_t *) property values. + * + * Note that unlike its cousin svn_client_proplist(), this routine + * doesn't read a working copy at all; it's a pure network operation + * that reads *unversioned* properties attached to a revision. + */ +svn_error_t * +svn_client_revprop_list(apr_hash_t **props, + const char *URL, + const svn_opt_revision_t *revision, + svn_revnum_t *set_rev, + svn_client_ctx_t *ctx, + apr_pool_t *pool); +/** @} */ + + +/** + * @defgroup Export Export a tree from version control. + * + * @{ + */ + +/** + * Export the contents of either a subversion repository or a + * subversion working copy into a 'clean' directory (meaning a + * directory with no administrative directories). If @a result_rev + * is not @c NULL and the path being exported is a repository URL, set + * @a *result_rev to the value of the revision actually exported (set + * it to #SVN_INVALID_REVNUM for local exports). + * + * @a from_path_or_url is either the path the working copy on disk, or + * a URL to the repository you wish to export. + * + * When exporting a directory, @a to_path is the path to the directory + * where you wish to create the exported tree; when exporting a file, it + * is the path of the file that will be created. If @a to_path is the + * empty path, then the basename of the export file/directory in the repository + * will be used. If @a to_path represents an existing directory, and a + * file is being exported, then a file with the that basename will be + * created under that directory (as with 'copy' operations). + * + * @a peg_revision is the revision where the path is first looked up + * when exporting from a repository. If @a peg_revision->kind is + * #svn_opt_revision_unspecified, then it defaults to #svn_opt_revision_head + * for URLs or #svn_opt_revision_working for WC targets. + * + * @a revision is the revision that should be exported, which is only used + * when exporting from a repository. + * + * @a peg_revision and @a revision must not be @c NULL. + * + * @a ctx->notify_func2 and @a ctx->notify_baton2 are the notification + * functions and baton which are passed to svn_client_checkout() when + * exporting from a repository. + * + * @a ctx is a context used for authentication in the repository case. + * + * @a overwrite if TRUE will cause the export to overwrite files or + * directories. + * + * If @a ignore_externals is set, don't process externals definitions + * as part of this operation. + * + * If @a ignore_keywords is set, don't expand keywords as part of this + * operation. + * + * @a native_eol allows you to override the standard eol marker on the + * platform you are running on. Can be either "LF", "CR" or "CRLF" or + * NULL. If NULL will use the standard eol marker. Any other value + * will cause the #SVN_ERR_IO_UNKNOWN_EOL error to be returned. + * + * If @a depth is #svn_depth_infinity, export fully recursively. Else + * if it is #svn_depth_immediates, export @a from_path_or_url and its + * immediate children (if any), but with subdirectories empty and at + * #svn_depth_empty. Else if #svn_depth_files, export @a + * from_path_or_url and its immediate file children (if any) only. If + * @a depth is #svn_depth_empty, then export exactly @a + * from_path_or_url and none of its children. + * + * All allocations are done in @a pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_export5(svn_revnum_t *result_rev, + const char *from_path_or_url, + const char *to_path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t overwrite, + svn_boolean_t ignore_externals, + svn_boolean_t ignore_keywords, + svn_depth_t depth, + const char *native_eol, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_export5(), but with @a ignore_keywords set + * to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_export4(svn_revnum_t *result_rev, + const char *from_path_or_url, + const char *to_path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t overwrite, + svn_boolean_t ignore_externals, + svn_depth_t depth, + const char *native_eol, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_export4(), but with @a depth set according to + * @a recurse: if @a recurse is TRUE, set @a depth to + * #svn_depth_infinity, if @a recurse is FALSE, set @a depth to + * #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_export3(svn_revnum_t *result_rev, + const char *from_path_or_url, + const char *to_path, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t overwrite, + svn_boolean_t ignore_externals, + svn_boolean_t recurse, + const char *native_eol, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_export3(), but with @a peg_revision + * always set to #svn_opt_revision_unspecified, @a overwrite set to + * the value of @a force, @a ignore_externals always FALSE, and + * @a recurse always TRUE. + * + * @since New in 1.1. + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_export2(svn_revnum_t *result_rev, + const char *from_path_or_url, + const char *to_path, + svn_opt_revision_t *revision, + svn_boolean_t force, + const char *native_eol, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_export2(), but with @a native_eol always set + * to NULL. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_export(svn_revnum_t *result_rev, + const char *from_path_or_url, + const char *to_path, + svn_opt_revision_t *revision, + svn_boolean_t force, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup List List / ls + * + * @{ + */ + +/** The type of function invoked by svn_client_list3() to report the details + * of each directory entry being listed. + * + * @a baton is the baton that was passed to the caller. @a path is the + * entry's path relative to @a abs_path; it is the empty path when reporting + * the top node of the list operation. @a dirent contains some or all of + * the directory entry's details, as determined by the caller. @a lock is + * the entry's lock, if it is locked and if lock information is being + * reported by the caller; otherwise @a lock is NULL. @a abs_path is the + * repository path of the top node of the list operation; it is relative to + * the repository root and begins with "/". + * + * If svn_client_list3() was called with @a include_externals set to TRUE, + * @a external_parent_url and @a external_target will be set. + * @a external_parent_url is url of the directory which has the + * externals definitions. @a external_target is the target subdirectory of + * externals definitions which is relative to the parent directory that holds + * the external item. + * + * If external_parent_url and external_target are defined, the item being + * listed is part of the external described by external_parent_url and + * external_target. Else, the item is not part of any external. + * Moreover, we will never mix items which are part of separate + * externals, and will always finish listing an external before listing + * the next one. + * + * @a scratch_pool may be used for temporary allocations. + * + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_client_list_func2_t)( + void *baton, + const char *path, + const svn_dirent_t *dirent, + const svn_lock_t *lock, + const char *abs_path, + const char *external_parent_url, + const char *external_target, + apr_pool_t *scratch_pool); + +/** + * Similar to #svn_client_list_func2_t, but without any information about + * externals definitions. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * + * @since New in 1.4 + * + * */ +typedef svn_error_t *(*svn_client_list_func_t)(void *baton, + const char *path, + const svn_dirent_t *dirent, + const svn_lock_t *lock, + const char *abs_path, + apr_pool_t *pool); + +/** + * Report the directory entry, and possibly children, for @a + * path_or_url at @a revision. The actual node revision selected is + * determined by the path as it exists in @a peg_revision. If @a + * peg_revision->kind is #svn_opt_revision_unspecified, then it defaults + * to #svn_opt_revision_head for URLs or #svn_opt_revision_working + * for WC targets. + * + * Report directory entries by invoking @a list_func/@a baton with @a path + * relative to @a path_or_url. The dirent for @a path_or_url is reported + * using an empty @a path. If @a path_or_url is a directory, also report + * its children. If @a path_or_url is non-existent, return + * #SVN_ERR_FS_NOT_FOUND. + * + * If @a fetch_locks is TRUE, include locks when reporting directory entries. + * + * If @a include_externals is TRUE, also list all external items + * reached by recursion. @a depth value passed to the original list target + * applies for the externals also. + * + * Use @a pool for temporary allocations. + * + * Use authentication baton cached in @a ctx to authenticate against the + * repository. + * + * If @a depth is #svn_depth_empty, list just @a path_or_url itself. + * If @a depth is #svn_depth_files, list @a path_or_url and its file + * entries. If #svn_depth_immediates, list its immediate file and + * directory entries. If #svn_depth_infinity, list file entries and + * recurse (with #svn_depth_infinity) on directory entries. + * + * @a dirent_fields controls which fields in the #svn_dirent_t's are + * filled in. To have them totally filled in use #SVN_DIRENT_ALL, + * otherwise simply bitwise OR together the combination of @c SVN_DIRENT_ + * fields you care about. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_list3(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + apr_uint32_t dirent_fields, + svn_boolean_t fetch_locks, + svn_boolean_t include_externals, + svn_client_list_func2_t list_func, + void *baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** Similar to svn_client_list3(), but with @a include_externals set + * to FALSE, and using a #svn_client_list_func_t as callback. + * + * @deprecated Provided for backwards compatibility with the 1.7 API. + * + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_list2(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + apr_uint32_t dirent_fields, + svn_boolean_t fetch_locks, + svn_client_list_func_t list_func, + void *baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_list2(), but with @a recurse instead of @a depth. + * If @a recurse is TRUE, pass #svn_depth_files for @a depth; else + * pass #svn_depth_infinity. + * + * @since New in 1.4. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_list(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + apr_uint32_t dirent_fields, + svn_boolean_t fetch_locks, + svn_client_list_func_t list_func, + void *baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Same as svn_client_list(), but always passes #SVN_DIRENT_ALL for + * the @a dirent_fields argument and returns all information in two + * hash tables instead of invoking a callback. + * + * Set @a *dirents to a newly allocated hash of directory entries. + * The @a dirents hash maps entry names (<tt>const char *</tt>) to + * #svn_dirent_t *'s. + * + * If @a locks is not @c NULL, set @a *locks to a hash table mapping + * entry names (<tt>const char *</tt>) to #svn_lock_t *'s. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * Use svn_client_list2() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_ls3(apr_hash_t **dirents, + apr_hash_t **locks, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Same as svn_client_ls3(), but without the ability to get locks. + * + * @since New in 1.2. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * Use svn_client_list2() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_ls2(apr_hash_t **dirents, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_ls2() except that @a peg_revision is always + * the same as @a revision. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + * Use svn_client_list2() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_ls(apr_hash_t **dirents, + const char *path_or_url, + svn_opt_revision_t *revision, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** @} */ + +/** + * @defgroup Cat View the contents of a file in the repository. + * + * @{ + */ + +/** + * Output the content of a file. + * + * @param[in] out The stream to which the content will be written. + * @param[in] path_or_url The path or URL of the file. + * @param[in] peg_revision The peg revision. + * @param[in] revision The operative revision. + * @param[in] ctx The standard client context, used for possible + * authentication. + * @param[in] pool Used for any temporary allocation. + * + * @todo Add an expansion/translation flag? + * + * @return A pointer to an #svn_error_t of the type (this list is not + * exhaustive): <br> + * An unspecified error if @a revision is of kind + * #svn_opt_revision_previous (or some other kind that requires + * a local path), because the desired revision cannot be + * determined. <br> + * If no error occurred, return #SVN_NO_ERROR. + * + * @since New in 1.2. + * + * @see #svn_client_ctx_t <br> @ref clnt_revisions for + * a discussion of operative and peg revisions. + */ +svn_error_t * +svn_client_cat2(svn_stream_t *out, + const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Similar to svn_client_cat2() except that the peg revision is always + * the same as @a revision. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_cat(svn_stream_t *out, + const char *path_or_url, + const svn_opt_revision_t *revision, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} end group: cat */ + + + +/** Changelist commands + * + * @defgroup svn_client_changelist_funcs Client Changelist Functions + * @{ + */ + +/** Implementation note: + * + * For now, changelists are implemented by scattering the + * associations across multiple .svn/entries files in a working copy. + * However, this client API was written so that we have the option of + * changing the underlying implementation -- we may someday want to + * store changelist definitions in a centralized database. + */ + +/** + * Add each path in @a paths (recursing to @a depth as necessary) to + * @a changelist. If a path is already a member of another + * changelist, then remove it from the other changelist and add it to + * @a changelist. (For now, a path cannot belong to two changelists + * at once.) + * + * @a paths is an array of (const char *) local WC paths. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose changelist + * assignments are adjusted; that is, don't tweak the changeset of any + * item unless it's currently a member of one of those changelists. + * If @a changelists is empty (or altogether @c NULL), no changelist + * filtering occurs. + * + * @note This metadata is purely a client-side "bookkeeping" + * convenience, and is entirely managed by the working copy. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_add_to_changelist(const apr_array_header_t *paths, + const char *changelist, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Remove each path in @a paths (recursing to @a depth as necessary) + * from changelists to which they are currently assigned. + * + * @a paths is an array of (const char *) local WC paths. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose changelist + * assignments are removed; that is, don't remove from a changeset any + * item unless it's currently a member of one of those changelists. + * If @a changelists is empty (or altogether @c NULL), all changelist + * assignments in and under each path in @a paths (to @a depth) will + * be removed. + * + * @note This metadata is purely a client-side "bookkeeping" + * convenience, and is entirely managed by the working copy. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_remove_from_changelists(const apr_array_header_t *paths, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** + * Beginning at @a path, crawl to @a depth to discover every path in + * or under @a path which belongs to one of the changelists in @a + * changelists (an array of <tt>const char *</tt> changelist names). + * If @a changelists is @c NULL, discover paths with any changelist. + * Call @a callback_func (with @a callback_baton) each time a + * changelist-having path is discovered. + * + * @a path is a local WC path. + * + * If @a ctx->cancel_func is not @c NULL, invoke it passing @a + * ctx->cancel_baton during the recursive walk. + * + * @since New in 1.5. + */ +svn_error_t * +svn_client_get_changelists(const char *path, + const apr_array_header_t *changelists, + svn_depth_t depth, + svn_changelist_receiver_t callback_func, + void *callback_baton, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + + + +/** Locking commands + * + * @defgroup svn_client_locking_funcs Client Locking Functions + * @{ + */ + +/** + * Lock @a targets in the repository. @a targets is an array of + * <tt>const char *</tt> paths - either all working copy paths or all URLs. + * All targets must be in the same repository. + * + * If a target is already locked in the repository, no lock will be + * acquired unless @a steal_lock is TRUE, in which case the locks are + * stolen. @a comment, if non-NULL, is an xml-escapable description + * stored with each lock in the repository. Each acquired lock will + * be stored in the working copy if the targets are WC paths. + * + * For each target @a ctx->notify_func2/notify_baton2 will be used to indicate + * whether it was locked. An action of #svn_wc_notify_locked + * means that the path was locked. If the path was not locked because + * it was out of date or there was already a lock in the repository, + * the notification function will be called with + * #svn_wc_notify_failed_lock, and the error passed in the notification + * structure. + * + * Use @a pool for temporary allocations. + * + * @since New in 1.2. + */ +svn_error_t * +svn_client_lock(const apr_array_header_t *targets, + const char *comment, + svn_boolean_t steal_lock, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Unlock @a targets in the repository. @a targets is an array of + * <tt>const char *</tt> paths - either all working copy paths or all URLs. + * All targets must be in the same repository. + * + * If the targets are WC paths, and @a break_lock is FALSE, the working + * copy must contain a lock for each target. + * If this is not the case, or the working copy lock doesn't match the + * lock token in the repository, an error will be signaled. + * + * If the targets are URLs, the locks may be broken even if @a break_lock + * is FALSE, but only if the lock owner is the same as the + * authenticated user. + * + * If @a break_lock is TRUE, the locks will be broken in the + * repository. In both cases, the locks, if any, will be removed from + * the working copy if the targets are WC paths. + * + * The notification functions in @a ctx will be called for each + * target. If the target was successfully unlocked, + * #svn_wc_notify_unlocked will be used. Else, if the error is + * directly related to unlocking the path (see + * #SVN_ERR_IS_UNLOCK_ERROR), #svn_wc_notify_failed_unlock will be + * used and the error will be passed in the notification structure. + + * Use @a pool for temporary allocations. + * + * @since New in 1.2. + */ +svn_error_t * +svn_client_unlock(const apr_array_header_t *targets, + svn_boolean_t break_lock, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** @} */ + +/** + * @defgroup Info Show repository information about a working copy. + * + * @{ + */ + +/** The size of the file is unknown. + * Used as value in fields of type @c apr_size_t in #svn_info_t. + * + * @since New in 1.5 + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +#define SVN_INFO_SIZE_UNKNOWN ((apr_size_t) -1) + +/** + * A structure which describes various system-generated metadata about + * a working-copy path or URL. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, users shouldn't allocate structures of this + * type, to preserve binary compatibility. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. The new + * API is #svn_client_info2_t. + */ +typedef struct svn_info_t +{ + /** Where the item lives in the repository. */ + const char *URL; + + /** The revision of the object. If path_or_url is a working-copy + * path, then this is its current working revnum. If path_or_url + * is a URL, then this is the repos revision that path_or_url lives in. */ + svn_revnum_t rev; + + /** The node's kind. */ + svn_node_kind_t kind; + + /** The root URL of the repository. */ + const char *repos_root_URL; + + /** The repository's UUID. */ + const char *repos_UUID; + + /** The last revision in which this object changed. */ + svn_revnum_t last_changed_rev; + + /** The date of the last_changed_rev. */ + apr_time_t last_changed_date; + + /** The author of the last_changed_rev. */ + const char *last_changed_author; + + /** An exclusive lock, if present. Could be either local or remote. */ + svn_lock_t *lock; + + /** Whether or not to ignore the next 10 wc-specific fields. */ + svn_boolean_t has_wc_info; + + /** + * @name Working-copy path fields + * These things only apply to a working-copy path. + * See svn_wc_entry_t for explanations. + * @{ + */ + svn_wc_schedule_t schedule; + const char *copyfrom_url; + svn_revnum_t copyfrom_rev; + apr_time_t text_time; + apr_time_t prop_time; /* will always be 0 for svn 1.4 and later */ + const char *checksum; + const char *conflict_old; + const char *conflict_new; + const char *conflict_wrk; + const char *prejfile; + /** @since New in 1.5. */ + const char *changelist; + /** @since New in 1.5. */ + svn_depth_t depth; + + /** + * Similar to working_size64, but will be #SVN_INFO_SIZE_UNKNOWN when + * its value would overflow apr_size_t (so when size >= 4 GB - 1 byte). + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ + apr_size_t working_size; + + /** @} */ + + /** + * Similar to size64, but size will be #SVN_INFO_SIZE_UNKNOWN when + * its value would overflow apr_size_t (so when size >= 4 GB - 1 byte). + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ + apr_size_t size; + + /** + * The size of the file in the repository (untranslated, + * e.g. without adjustment of line endings and keyword + * expansion). Only applicable for file -- not directory -- URLs. + * For working copy paths, size64 will be #SVN_INVALID_FILESIZE. + * @since New in 1.6. + */ + svn_filesize_t size64; + + /** + * The size of the file after being translated into its local + * representation, or #SVN_INVALID_FILESIZE if unknown. + * Not applicable for directories. + * @since New in 1.6. + * @name Working-copy path fields + * @{ + */ + svn_filesize_t working_size64; + + /** + * Info on any tree conflict of which this node is a victim. Otherwise NULL. + * @since New in 1.6. + */ + svn_wc_conflict_description_t *tree_conflict; + + /** @} */ + +} svn_info_t; + + +/** + * The callback invoked by svn_client_info2(). Each invocation + * describes @a path with the information present in @a info. Note + * that any fields within @a info may be NULL if information is + * unavailable. Use @a pool for all temporary allocation. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. The new + * API is #svn_client_info_receiver2_t. + */ +typedef svn_error_t *(*svn_info_receiver_t)( + void *baton, + const char *path, + const svn_info_t *info, + apr_pool_t *pool); + +/** + * Return a duplicate of @a info, allocated in @a pool. No part of the new + * structure will be shared with @a info. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.6 API. The new + * API is #svn_client_info2_dup(). + */ +SVN_DEPRECATED +svn_info_t * +svn_info_dup(const svn_info_t *info, + apr_pool_t *pool); + +/** + * A structure which describes various system-generated metadata about + * a working-copy path or URL. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, users shouldn't allocate structures of this + * type, to preserve binary compatibility. + * + * @since New in 1.7. + */ +typedef struct svn_client_info2_t +{ + /** Where the item lives in the repository. */ + const char *URL; + + /** The revision of the object. If the target is a working-copy + * path, then this is its current working revnum. If the target + * is a URL, then this is the repos revision that it lives in. */ + svn_revnum_t rev; + + /** The root URL of the repository. */ + const char *repos_root_URL; + + /** The repository's UUID. */ + const char *repos_UUID; + + /** The node's kind. */ + svn_node_kind_t kind; + + /** The size of the file in the repository (untranslated, + * e.g. without adjustment of line endings and keyword + * expansion). Only applicable for file -- not directory -- URLs. + * For working copy paths, @a size will be #SVN_INVALID_FILESIZE. */ + svn_filesize_t size; + + /** The last revision in which this object changed. */ + svn_revnum_t last_changed_rev; + + /** The date of the last_changed_rev. */ + apr_time_t last_changed_date; + + /** The author of the last_changed_rev. */ + const char *last_changed_author; + + /** An exclusive lock, if present. Could be either local or remote. */ + const svn_lock_t *lock; + + /** Possible information about the working copy, NULL if not valid. */ + const svn_wc_info_t *wc_info; + +} svn_client_info2_t; + +/** + * Return a duplicate of @a info, allocated in @a pool. No part of the new + * structure will be shared with @a info. + * + * @since New in 1.7. + */ +svn_client_info2_t * +svn_client_info2_dup(const svn_client_info2_t *info, + apr_pool_t *pool); + +/** + * The callback invoked by info retrievers. Each invocation + * describes @a abspath_or_url with the information present in @a info. + * Use @a scratch_pool for all temporary allocation. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_client_info_receiver2_t)( + void *baton, + const char *abspath_or_url, + const svn_client_info2_t *info, + apr_pool_t *scratch_pool); + +/** + * Invoke @a receiver with @a receiver_baton to return information + * about @a abspath_or_url in @a revision. The information returned is + * system-generated metadata, not the sort of "property" metadata + * created by users. See #svn_client_info2_t. + * + * If both revision arguments are either #svn_opt_revision_unspecified + * or @c NULL, then information will be pulled solely from the working copy; + * no network connections will be made. + * + * Otherwise, information will be pulled from a repository. The + * actual node revision selected is determined by the @a abspath_or_url + * as it exists in @a peg_revision. If @a peg_revision->kind is + * #svn_opt_revision_unspecified, then it defaults to + * #svn_opt_revision_head for URLs or #svn_opt_revision_working for + * WC targets. + * + * If @a abspath_or_url is not a local path, then if @a revision is of + * kind #svn_opt_revision_previous (or some other kind that requires + * a local path), an error will be returned, because the desired + * revision cannot be determined. + * + * Use the authentication baton cached in @a ctx to authenticate + * against the repository. + * + * If @a abspath_or_url is a file, just invoke @a receiver on it. If it + * is a directory, then descend according to @a depth. If @a depth is + * #svn_depth_empty, invoke @a receiver on @a abspath_or_url and + * nothing else; if #svn_depth_files, on @a abspath_or_url and its + * immediate file children; if #svn_depth_immediates, the preceding + * plus on each immediate subdirectory; if #svn_depth_infinity, then + * recurse fully, invoking @a receiver on @a abspath_or_url and + * everything beneath it. + * + * If @a fetch_excluded is TRUE, also also send excluded nodes in the working + * copy to @a receiver, otherwise these are skipped. If @a fetch_actual_only + * is TRUE also send nodes that don't exist as versioned but are still + * tree conflicted. + * + * @a changelists is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose info is + * reported; that is, don't report info about any item unless + * it's a member of one of those changelists. If @a changelists is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_info3(const char *abspath_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_depth_t depth, + svn_boolean_t fetch_excluded, + svn_boolean_t fetch_actual_only, + const apr_array_header_t *changelists, + svn_client_info_receiver2_t receiver, + void *receiver_baton, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** Similar to svn_client_info3, but uses an svn_info_receiver_t instead of + * a #svn_client_info_receiver2_t, and @a path_or_url may be a relative path. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_info2(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_info_receiver_t receiver, + void *receiver_baton, + svn_depth_t depth, + const apr_array_header_t *changelists, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Similar to svn_client_info2() but with @a changelists passed as @c + * NULL, and @a depth set according to @a recurse: if @a recurse is + * TRUE, @a depth is #svn_depth_infinity, else #svn_depth_empty. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_info(const char *path_or_url, + const svn_opt_revision_t *peg_revision, + const svn_opt_revision_t *revision, + svn_info_receiver_t receiver, + void *receiver_baton, + svn_boolean_t recurse, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** + * Set @a *wcroot_abspath to the local abspath of the root of the + * working copy in which @a local_abspath resides. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_get_wc_root(const char **wcroot_abspath, + const char *local_abspath, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Set @a *min_revision and @a *max_revision to the lowest and highest + * revision numbers found within @a local_abspath. If @a committed is + * TRUE, set @a *min_revision and @a *max_revision to the lowest and + * highest comitted (i.e. "last changed") revision numbers, + * respectively. NULL may be passed for either of @a min_revision and + * @a max_revision to indicate the caller's lack of interest in the + * value. Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_min_max_revisions(svn_revnum_t *min_revision, + svn_revnum_t *max_revision, + const char *local_abspath, + svn_boolean_t committed, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** @} */ + + +/** + * @defgroup Patch Apply a patch to the working copy + * + * @{ + */ + +/** + * The callback invoked by svn_client_patch() before attempting to patch + * the target file at @a canon_path_from_patchfile (the path as parsed from + * the patch file, but in canonicalized form). The callback can set + * @a *filtered to @c TRUE to prevent the file from being patched, or else + * must set it to @c FALSE. + * + * The callback is also provided with @a patch_abspath, the path of a + * temporary file containing the patched result, and with @a reject_abspath, + * the path to a temporary file containing the diff text of any hunks + * which were rejected during patching. + * + * Because the callback is invoked before the patching attempt is made, + * there is no guarantee that the target file will actually be patched + * successfully. Client implementations must pay attention to notification + * feedback provided by svn_client_patch() to find out which paths were + * patched successfully. + * + * Note also that the files at @a patch_abspath and @a reject_abspath are + * guaranteed to remain on disk after patching only if the + * @a remove_tempfiles parameter for svn_client_patch() is @c FALSE. + * + * The const char * parameters may be allocated in @a scratch_pool which + * will be cleared after each invocation. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_client_patch_func_t)( + void *baton, + svn_boolean_t *filtered, + const char *canon_path_from_patchfile, + const char *patch_abspath, + const char *reject_abspath, + apr_pool_t *scratch_pool); + +/** + * Apply a unidiff patch that's located at absolute path + * @a patch_abspath to the working copy directory at @a wc_dir_abspath. + * + * This function makes a best-effort attempt at applying the patch. + * It might skip patch targets which cannot be patched (e.g. targets + * that are outside of the working copy). It will also reject hunks + * which cannot be applied to a target in case the hunk's context + * does not match anywhere in the patch target. + * + * If @a dry_run is TRUE, the patching process is carried out, and full + * notification feedback is provided, but the working copy is not modified. + * + * @a strip_count specifies how many leading path components should be + * stripped from paths obtained from the patch. It is an error if a + * negative strip count is passed. + * + * If @a reverse is @c TRUE, apply patches in reverse, deleting lines + * the patch would add and adding lines the patch would delete. + * + * If @a ignore_whitespace is TRUE, allow patches to be applied if they + * only differ from the target by whitespace. + * + * If @a remove_tempfiles is TRUE, lifetimes of temporary files created + * during patching will be managed internally. Otherwise, the caller should + * take ownership of these files, the names of which can be obtained by + * passing a @a patch_func callback. + * + * If @a patch_func is non-NULL, invoke @a patch_func with @a patch_baton + * for each patch target processed. + * + * If @a ctx->notify_func2 is non-NULL, invoke @a ctx->notify_func2 with + * @a ctx->notify_baton2 as patching progresses. + * + * If @a ctx->cancel_func is non-NULL, invoke it passing @a + * ctx->cancel_baton at various places during the operation. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_patch(const char *patch_abspath, + const char *wc_dir_abspath, + svn_boolean_t dry_run, + int strip_count, + svn_boolean_t reverse, + svn_boolean_t ignore_whitespace, + svn_boolean_t remove_tempfiles, + svn_client_patch_func_t patch_func, + void *patch_baton, + svn_client_ctx_t *ctx, + apr_pool_t *scratch_pool); + +/** @} */ + +/** @} end group: Client working copy management */ + +/** + * + * @defgroup clnt_sessions Client session related functions + * + * @{ + * + */ + + +/* Converting paths to URLs. */ + +/** Set @a *url to the URL for @a path_or_url allocated in result_pool. + * + * If @a path_or_url is already a URL, set @a *url to @a path_or_url. + * + * If @a path_or_url is a versioned item, set @a *url to @a + * path_or_url's entry URL. If @a path_or_url is unversioned (has + * no entry), set @a *url to NULL. + * + * Use @a ctx->wc_ctx to retrieve the information. Use + ** @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_client_url_from_path2(const char **url, + const char *path_or_url, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_client_url_from_path2(), but without a context argument. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_url_from_path(const char **url, + const char *path_or_url, + apr_pool_t *pool); + + + +/* Fetching a repository's root URL and UUID. */ + +/** Set @a *repos_root_url and @a *repos_uuid, to the root URL and UUID of + * the repository in which @a abspath_or_url is versioned. Use the + * authentication baton and working copy context cached in @a ctx as + * necessary. @a repos_root_url and/or @a repos_uuid may be NULL if not + * wanted. + * + * This function will open a temporary RA session to the repository if + * necessary to get the information. + * + * Allocate @a *repos_root_url and @a *repos_uuid in @a result_pool. + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_client_get_repos_root(const char **repos_root_url, + const char **repos_uuid, + const char *abspath_or_url, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Set @a *url to the repository root URL of the repository in which + * @a path_or_url is versioned (or scheduled to be versioned), + * allocated in @a pool. @a ctx is required for possible repository + * authentication. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.7 API. Use + * svn_client_get_repos_root() instead, with an absolute path. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_root_url_from_path(const char **url, + const char *path_or_url, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + +/** Get repository @a uuid for @a url. + * + * Use a @a pool to open a temporary RA session to @a url, discover the + * repository uuid, and free the session. Return the uuid in @a uuid, + * allocated in @a pool. @a ctx is required for possible repository + * authentication. + * + * @deprecated Provided for backward compatibility with the 1.7 API. Use + * svn_client_get_repos_root() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_uuid_from_url(const char **uuid, + const char *url, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** Return the repository @a uuid for working-copy @a local_abspath, + * allocated in @a result_pool. Use @a ctx->wc_ctx to retrieve the + * information. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. Use + * svn_client_get_repos_root() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_uuid_from_path2(const char **uuid, + const char *local_abspath, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_client_uuid_from_path2(), but with a relative path and + * an access baton. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_uuid_from_path(const char **uuid, + const char *path, + svn_wc_adm_access_t *adm_access, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/* Opening RA sessions. */ + +/** Open an RA session rooted at @a url, and return it in @a *session. + * + * Use the authentication baton stored in @a ctx for authentication. + * @a *session is allocated in @a result_pool. + * + * If @a wri_abspath is not NULL, use the working copy identified by @a + * wri_abspath to potentially avoid transferring unneeded data. + * + * @note This function is similar to svn_ra_open4(), but the caller avoids + * having to providing its own callback functions. + * @since New in 1.8. + */ +svn_error_t * +svn_client_open_ra_session2(svn_ra_session_t **session, + const char *url, + const char *wri_abspath, + svn_client_ctx_t *ctx, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_client_open_ra_session(), but with @ wri_abspath + * always passed as NULL, and with the same pool used as both @a + * result_pool and @a scratch_pool. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_client_open_ra_session(svn_ra_session_t **session, + const char *url, + svn_client_ctx_t *ctx, + apr_pool_t *pool); + + +/** @} end group: Client session related functions */ + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CLIENT_H */ diff --git a/subversion/include/svn_cmdline.h b/subversion/include/svn_cmdline.h new file mode 100644 index 0000000..80442e4 --- /dev/null +++ b/subversion/include/svn_cmdline.h @@ -0,0 +1,376 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_cmdline.h + * @brief Support functions for command line programs + */ + + + + +#ifndef SVN_CMDLINE_H +#define SVN_CMDLINE_H + +#include <apr_pools.h> +#include <apr_getopt.h> + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +#define APR_WANT_STDIO +#endif +#include <apr_want.h> + +#include "svn_types.h" +#include "svn_auth.h" +#include "svn_config.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Set up the locale for character conversion, and initialize APR. + * If @a error_stream is non-NULL, print error messages to the stream, + * using @a progname as the program name. Attempt to set @c stdout to + * line-buffered mode, and @a error_stream to unbuffered mode. Return + * @c EXIT_SUCCESS if successful, otherwise @c EXIT_FAILURE. + * + * @note This function should be called exactly once at program startup, + * before calling any other APR or Subversion functions. + */ +int +svn_cmdline_init(const char *progname, + FILE *error_stream); + + +/** Set @a *dest to an output-encoded C string from UTF-8 C string @a + * src; allocate @a *dest in @a pool. + */ +svn_error_t * +svn_cmdline_cstring_from_utf8(const char **dest, + const char *src, + apr_pool_t *pool); + +/** Like svn_utf_cstring_from_utf8_fuzzy(), but converts to an + * output-encoded C string. */ +const char * +svn_cmdline_cstring_from_utf8_fuzzy(const char *src, + apr_pool_t *pool); + +/** Set @a *dest to a UTF-8-encoded C string from input-encoded C + * string @a src; allocate @a *dest in @a pool. + */ +svn_error_t * +svn_cmdline_cstring_to_utf8(const char **dest, + const char *src, + apr_pool_t *pool); + +/** Set @a *dest to an output-encoded natively-formatted path string + * from canonical path @a src; allocate @a *dest in @a pool. + */ +svn_error_t * +svn_cmdline_path_local_style_from_utf8(const char **dest, + const char *src, + apr_pool_t *pool); + +/** Write to stdout, using a printf-like format string @a fmt, passed + * through apr_pvsprintf(). All string arguments are in UTF-8; the output + * is converted to the output encoding. Use @a pool for temporary + * allocation. + * + * @since New in 1.1. + */ +svn_error_t * +svn_cmdline_printf(apr_pool_t *pool, + const char *fmt, + ...) + __attribute__((format(printf, 2, 3))); + +/** Write to the stdio @a stream, using a printf-like format string @a fmt, + * passed through apr_pvsprintf(). All string arguments are in UTF-8; + * the output is converted to the output encoding. Use @a pool for + * temporary allocation. + * + * @since New in 1.1. + */ +svn_error_t * +svn_cmdline_fprintf(FILE *stream, + apr_pool_t *pool, + const char *fmt, + ...) + __attribute__((format(printf, 3, 4))); + +/** Output the @a string to the stdio @a stream, converting from UTF-8 + * to the output encoding. Use @a pool for temporary allocation. + * + * @since New in 1.1. + */ +svn_error_t * +svn_cmdline_fputs(const char *string, + FILE *stream, + apr_pool_t *pool); + +/** Flush output buffers of the stdio @a stream, returning an error if that + * fails. This is just a wrapper for the standard fflush() function for + * consistent error handling. + * + * @since New in 1.1. + */ +svn_error_t * +svn_cmdline_fflush(FILE *stream); + +/** Return the name of the output encoding allocated in @a pool, or @c + * APR_LOCALE_CHARSET if the output encoding is the same as the locale + * encoding. + * + * @since New in 1.3. + */ +const char * +svn_cmdline_output_encoding(apr_pool_t *pool); + +/** Handle @a error in preparation for immediate exit from a + * command-line client. Specifically: + * + * Call svn_handle_error2(@a error, stderr, FALSE, @a prefix), clear + * @a error, destroy @a pool iff it is non-NULL, and return EXIT_FAILURE. + * + * @since New in 1.3. + */ +int +svn_cmdline_handle_exit_error(svn_error_t *error, + apr_pool_t *pool, + const char *prefix); + +/** A prompt function/baton pair, and the path to the configuration + * directory. To be passed as the baton argument to the + * @c svn_cmdline_*_prompt functions. + * + * @since New in 1.6. + */ +typedef struct svn_cmdline_prompt_baton2_t { + svn_cancel_func_t cancel_func; + void *cancel_baton; + const char *config_dir; +} svn_cmdline_prompt_baton2_t; + +/** Like svn_cmdline_prompt_baton2_t, but without the path to the + * configuration directory. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +typedef struct svn_cmdline_prompt_baton_t { + svn_cancel_func_t cancel_func; + void *cancel_baton; +} svn_cmdline_prompt_baton_t; + +/** Prompt the user for input, using @a prompt_str for the prompt and + * @a baton (which may be @c NULL) for cancellation, and returning the + * user's response in @a result, allocated in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_cmdline_prompt_user2(const char **result, + const char *prompt_str, + svn_cmdline_prompt_baton_t *baton, + apr_pool_t *pool); + +/** Similar to svn_cmdline_prompt_user2, but without cancellation + * support. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_cmdline_prompt_user(const char **result, + const char *prompt_str, + apr_pool_t *pool); + +/** An implementation of @c svn_auth_simple_prompt_func_t that prompts + * the user for keyboard input on the command line. + * + * @since New in 1.4. + * + * Expects a @c svn_cmdline_prompt_baton_t to be passed as @a baton. + */ +svn_error_t * +svn_cmdline_auth_simple_prompt(svn_auth_cred_simple_t **cred_p, + void *baton, + const char *realm, + const char *username, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** An implementation of @c svn_auth_username_prompt_func_t that prompts + * the user for their username via the command line. + * + * @since New in 1.4. + * + * Expects a @c svn_cmdline_prompt_baton_t to be passed as @a baton. + */ +svn_error_t * +svn_cmdline_auth_username_prompt(svn_auth_cred_username_t **cred_p, + void *baton, + const char *realm, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** An implementation of @c svn_auth_ssl_server_trust_prompt_func_t that + * asks the user if they trust a specific ssl server via the command line. + * + * @since New in 1.4. + * + * Expects a @c svn_cmdline_prompt_baton_t to be passed as @a baton. + */ +svn_error_t * +svn_cmdline_auth_ssl_server_trust_prompt( + svn_auth_cred_ssl_server_trust_t **cred_p, + void *baton, + const char *realm, + apr_uint32_t failures, + const svn_auth_ssl_server_cert_info_t *cert_info, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** An implementation of @c svn_auth_ssl_client_cert_prompt_func_t that + * prompts the user for the filename of their SSL client certificate via + * the command line. + * + * Records absolute path of the SSL client certificate file. + * + * @since New in 1.4. + * + * Expects a @c svn_cmdline_prompt_baton_t to be passed as @a baton. + */ +svn_error_t * +svn_cmdline_auth_ssl_client_cert_prompt( + svn_auth_cred_ssl_client_cert_t **cred_p, + void *baton, + const char *realm, + svn_boolean_t may_save, + apr_pool_t *pool); + + +/** An implementation of @c svn_auth_ssl_client_cert_pw_prompt_func_t that + * prompts the user for their SSL certificate password via the command line. + * + * @since New in 1.4. + * + * Expects a @c svn_cmdline_prompt_baton_t to be passed as @a baton. + */ +svn_error_t * +svn_cmdline_auth_ssl_client_cert_pw_prompt( + svn_auth_cred_ssl_client_cert_pw_t **cred_p, + void *baton, + const char *realm, + svn_boolean_t may_save, + apr_pool_t *pool); + +/** An implementation of @c svn_auth_plaintext_prompt_func_t that + * prompts the user whether storing unencrypted passwords to disk is OK. + * + * Expects a @c svn_cmdline_prompt_baton2_t to be passed as @a baton. + * + * @since New in 1.6. + */ +svn_error_t * +svn_cmdline_auth_plaintext_prompt(svn_boolean_t *may_save_plaintext, + const char *realmstring, + void *baton, + apr_pool_t *pool); + +/** An implementation of @c svn_auth_plaintext_passphrase_prompt_func_t that + * prompts the user whether storing unencrypted passphrase to disk is OK. + * + * Expects a @c svn_cmdline_prompt_baton2_t to be passed as @a baton. + * + * @since New in 1.6. + */ +svn_error_t * +svn_cmdline_auth_plaintext_passphrase_prompt(svn_boolean_t *may_save_plaintext, + const char *realmstring, + void *baton, + apr_pool_t *pool); + + +/** Set @a *ab to an authentication baton allocated from @a pool and + * initialized with the standard set of authentication providers used + * by the command line client. + * + * @a non_interactive, @a username, @a password, @a config_dir, + * @a no_auth_cache, and @a trust_server_cert are the values of the + * command line options of the corresponding names. + * + * @a cfg is the @c SVN_CONFIG_CATEGORY_CONFIG configuration, and + * @a cancel_func and @a cancel_baton control the cancellation of the + * prompting providers that are initialized. + * + * Use @a pool for all allocations. + * + * @since New in 1.6. + */ +svn_error_t * +svn_cmdline_create_auth_baton(svn_auth_baton_t **ab, + svn_boolean_t non_interactive, + const char *username, + const char *password, + const char *config_dir, + svn_boolean_t no_auth_cache, + svn_boolean_t trust_server_cert, + svn_config_t *cfg, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Similar to svn_cmdline_create_auth_baton(), but with + * @a trust_server_cert always set to false. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.5 API. + * Use svn_cmdline_create_auth_baton() instead. + * + * @note This deprecation does not follow the usual pattern of putting + * a new number on end of the function's name. Instead, the new + * function name is distinguished from the old by a grammatical + * improvement: the verb "create" instead of the noun "setup". + */ +SVN_DEPRECATED +svn_error_t * +svn_cmdline_setup_auth_baton(svn_auth_baton_t **ab, + svn_boolean_t non_interactive, + const char *username, + const char *password, + const char *config_dir, + svn_boolean_t no_auth_cache, + svn_config_t *cfg, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CMDLINE_H */ diff --git a/subversion/include/svn_compat.h b/subversion/include/svn_compat.h new file mode 100644 index 0000000..a127125 --- /dev/null +++ b/subversion/include/svn_compat.h @@ -0,0 +1,104 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_compat.h + * @brief Utilities to help applications provide backwards-compatibility + */ + +#ifndef SVN_COMPAT_H +#define SVN_COMPAT_H + +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Return, in @a *callback2 and @a *callback2_baton a function/baton that + * will call @a callback/@a callback_baton, allocating the @a *callback2_baton + * in @a pool. + * + * @note This is used by compatibility wrappers, which exist in more than + * Subversion core library. + * + * @since New in 1.4. + */ +void +svn_compat_wrap_commit_callback(svn_commit_callback2_t *callback2, + void **callback2_baton, + svn_commit_callback_t callback, + void *callback_baton, + apr_pool_t *pool); + +/** Clear svn:author, svn:date, and svn:log from @a revprops if not NULL. + * Use this if you must handle these three properties separately for + * compatibility reasons. + * + * @since New in 1.5. + */ +void +svn_compat_log_revprops_clear(apr_hash_t *revprops); + +/** Return a list to pass to post-1.5 log-retrieval functions in order to + * retrieve the pre-1.5 set of revprops: svn:author, svn:date, and svn:log. + * + * @since New in 1.5. + */ +apr_array_header_t * +svn_compat_log_revprops_in(apr_pool_t *pool); + +/** Return, in @a **author, @a **date, and @a **message, the values of the + * svn:author, svn:date, and svn:log revprops from @a revprops. If @a + * revprops is NULL, all return values are NULL. Any return value may be + * NULL if the corresponding property is not set in @a revprops. + * + * @since New in 1.5. + */ +void +svn_compat_log_revprops_out(const char **author, const char **date, + const char **message, apr_hash_t *revprops); + +/** Return, in @a *receiver2 and @a *receiver2_baton a function/baton that + * will call @a receiver/@a receiver_baton, allocating the @a *receiver2_baton + * in @a pool. + * + * @note This is used by compatibility wrappers, which exist in more than + * Subversion core library. + * + * @since New in 1.5. + */ +void +svn_compat_wrap_log_receiver(svn_log_entry_receiver_t *receiver2, + void **receiver2_baton, + svn_log_message_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_COMPAT_H */ diff --git a/subversion/include/svn_config.h b/subversion/include/svn_config.h new file mode 100644 index 0000000..c5d6976 --- /dev/null +++ b/subversion/include/svn_config.h @@ -0,0 +1,808 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_config.h + * @brief Accessing SVN configuration files. + */ + + + +#ifndef SVN_CONFIG_H +#define SVN_CONFIG_H + +#include <apr.h> /* for apr_int64_t */ +#include <apr_pools.h> /* for apr_pool_t */ +#include <apr_hash.h> /* for apr_hash_t */ + +#include "svn_types.h" +#include "svn_io.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/************************************************************************** + *** *** + *** For a description of the SVN configuration file syntax, see *** + *** your ~/.subversion/README, which is written out automatically by *** + *** svn_config_ensure(). *** + *** *** + **************************************************************************/ + + +/** Opaque structure describing a set of configuration options. */ +typedef struct svn_config_t svn_config_t; + + +/*** Configuration Defines ***/ + +/** + * @name Client configuration files strings + * Strings for the names of files, sections, and options in the + * client configuration files. + * @{ + */ + + /* This list of #defines is intentionally presented as a nested list + that matches the in-config hierarchy. */ + +#define SVN_CONFIG_CATEGORY_SERVERS "servers" +#define SVN_CONFIG_SECTION_GROUPS "groups" +#define SVN_CONFIG_SECTION_GLOBAL "global" +#define SVN_CONFIG_OPTION_HTTP_PROXY_HOST "http-proxy-host" +#define SVN_CONFIG_OPTION_HTTP_PROXY_PORT "http-proxy-port" +#define SVN_CONFIG_OPTION_HTTP_PROXY_USERNAME "http-proxy-username" +#define SVN_CONFIG_OPTION_HTTP_PROXY_PASSWORD "http-proxy-password" +#define SVN_CONFIG_OPTION_HTTP_PROXY_EXCEPTIONS "http-proxy-exceptions" +#define SVN_CONFIG_OPTION_HTTP_TIMEOUT "http-timeout" +#define SVN_CONFIG_OPTION_HTTP_COMPRESSION "http-compression" +#define SVN_CONFIG_OPTION_NEON_DEBUG_MASK "neon-debug-mask" +#define SVN_CONFIG_OPTION_HTTP_AUTH_TYPES "http-auth-types" +#define SVN_CONFIG_OPTION_SSL_AUTHORITY_FILES "ssl-authority-files" +#define SVN_CONFIG_OPTION_SSL_TRUST_DEFAULT_CA "ssl-trust-default-ca" +#define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE "ssl-client-cert-file" +#define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_PASSWORD "ssl-client-cert-password" +#define SVN_CONFIG_OPTION_SSL_PKCS11_PROVIDER "ssl-pkcs11-provider" +#define SVN_CONFIG_OPTION_HTTP_LIBRARY "http-library" +#define SVN_CONFIG_OPTION_STORE_PASSWORDS "store-passwords" +#define SVN_CONFIG_OPTION_STORE_PLAINTEXT_PASSWORDS "store-plaintext-passwords" +#define SVN_CONFIG_OPTION_STORE_AUTH_CREDS "store-auth-creds" +#define SVN_CONFIG_OPTION_STORE_SSL_CLIENT_CERT_PP "store-ssl-client-cert-pp" +#define SVN_CONFIG_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ + "store-ssl-client-cert-pp-plaintext" +#define SVN_CONFIG_OPTION_USERNAME "username" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_HTTP_BULK_UPDATES "http-bulk-updates" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_HTTP_MAX_CONNECTIONS "http-max-connections" + +#define SVN_CONFIG_CATEGORY_CONFIG "config" +#define SVN_CONFIG_SECTION_AUTH "auth" +#define SVN_CONFIG_OPTION_PASSWORD_STORES "password-stores" +#define SVN_CONFIG_OPTION_KWALLET_WALLET "kwallet-wallet" +#define SVN_CONFIG_OPTION_KWALLET_SVN_APPLICATION_NAME_WITH_PID "kwallet-svn-application-name-with-pid" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE_PROMPT "ssl-client-cert-file-prompt" +/* The majority of options of the "auth" section + * has been moved to SVN_CONFIG_CATEGORY_SERVERS. */ +#define SVN_CONFIG_SECTION_HELPERS "helpers" +#define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd" +#define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd" +/** @since New in 1.7. */ +#define SVN_CONFIG_OPTION_DIFF_EXTENSIONS "diff-extensions" +#define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd" +#define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg" +#define SVN_CONFIG_OPTION_MERGE_TOOL_CMD "merge-tool-cmd" +#define SVN_CONFIG_SECTION_MISCELLANY "miscellany" +#define SVN_CONFIG_OPTION_GLOBAL_IGNORES "global-ignores" +#define SVN_CONFIG_OPTION_LOG_ENCODING "log-encoding" +#define SVN_CONFIG_OPTION_USE_COMMIT_TIMES "use-commit-times" +/** @deprecated Not used by Subversion since 2003/r847039 (well before 1.0) */ +#define SVN_CONFIG_OPTION_TEMPLATE_ROOT "template-root" +#define SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS "enable-auto-props" +#define SVN_CONFIG_OPTION_NO_UNLOCK "no-unlock" +#define SVN_CONFIG_OPTION_MIMETYPES_FILE "mime-types-file" +#define SVN_CONFIG_OPTION_PRESERVED_CF_EXTS "preserved-conflict-file-exts" +#define SVN_CONFIG_OPTION_INTERACTIVE_CONFLICTS "interactive-conflicts" +#define SVN_CONFIG_OPTION_MEMORY_CACHE_SIZE "memory-cache-size" +#define SVN_CONFIG_SECTION_TUNNELS "tunnels" +#define SVN_CONFIG_SECTION_AUTO_PROPS "auto-props" +/** @since New in 1.8. */ +#define SVN_CONFIG_SECTION_WORKING_COPY "working-copy" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE "exclusive-locking" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_SQLITE_EXCLUSIVE_CLIENTS "exclusive-locking-clients" +/** @} */ + +/** @name Repository conf directory configuration files strings + * Strings for the names of sections and options in the + * repository conf directory configuration files. + * @{ + */ +/* For repository svnserve.conf files */ +#define SVN_CONFIG_SECTION_GENERAL "general" +#define SVN_CONFIG_OPTION_ANON_ACCESS "anon-access" +#define SVN_CONFIG_OPTION_AUTH_ACCESS "auth-access" +#define SVN_CONFIG_OPTION_PASSWORD_DB "password-db" +#define SVN_CONFIG_OPTION_REALM "realm" +#define SVN_CONFIG_OPTION_AUTHZ_DB "authz-db" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_GROUPS_DB "groups-db" +/** @since New in 1.7. */ +#define SVN_CONFIG_OPTION_FORCE_USERNAME_CASE "force-username-case" +/** @since New in 1.8. */ +#define SVN_CONFIG_OPTION_HOOKS_ENV "hooks-env" +#define SVN_CONFIG_SECTION_SASL "sasl" +#define SVN_CONFIG_OPTION_USE_SASL "use-sasl" +#define SVN_CONFIG_OPTION_MIN_SSF "min-encryption" +#define SVN_CONFIG_OPTION_MAX_SSF "max-encryption" + +/* For repository password database */ +#define SVN_CONFIG_SECTION_USERS "users" +/** @} */ + +/*** Configuration Default Values ***/ + +/* '*' matches leading dots, e.g. '*.rej' matches '.foo.rej'. */ +/* We want this to be printed on two lines in the generated config file, + * but we don't want the # character to end up in the variable. + */ +#define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 \ + "*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo __pycache__" +#define SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2 \ + "*.rej *~ #*# .#* .*.swp .DS_Store" + +#define SVN_CONFIG_DEFAULT_GLOBAL_IGNORES \ + SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_1 " " \ + SVN_CONFIG__DEFAULT_GLOBAL_IGNORES_LINE_2 + +#define SVN_CONFIG_TRUE "TRUE" +#define SVN_CONFIG_FALSE "FALSE" +#define SVN_CONFIG_ASK "ASK" + +/* Default values for some options. Should be passed as default values + * to svn_config_get and friends, instead of hard-coding the defaults in + * multiple places. */ +#define SVN_CONFIG_DEFAULT_OPTION_STORE_PASSWORDS TRUE +#define SVN_CONFIG_DEFAULT_OPTION_STORE_PLAINTEXT_PASSWORDS SVN_CONFIG_ASK +#define SVN_CONFIG_DEFAULT_OPTION_STORE_AUTH_CREDS TRUE +#define SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP TRUE +#define SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT \ + SVN_CONFIG_ASK +#define SVN_CONFIG_DEFAULT_OPTION_HTTP_MAX_CONNECTIONS 4 + +/** Read configuration information from the standard sources and merge it + * into the hash @a *cfg_hash. If @a config_dir is not NULL it specifies a + * directory from which to read the configuration files, overriding all + * other sources. Otherwise, first read any system-wide configurations + * (from a file or from the registry), then merge in personal + * configurations (again from file or registry). The hash and all its data + * are allocated in @a pool. + * + * @a *cfg_hash is a hash whose keys are @c const char * configuration + * categories (@c SVN_CONFIG_CATEGORY_SERVERS, + * @c SVN_CONFIG_CATEGORY_CONFIG, etc.) and whose values are the @c + * svn_config_t * items representing the configuration values for that + * category. + */ +svn_error_t * +svn_config_get_config(apr_hash_t **cfg_hash, + const char *config_dir, + apr_pool_t *pool); + +/** Set @a *cfgp to an empty @c svn_config_t structure, + * allocated in @a result_pool. + * + * Pass TRUE to @a section_names_case_sensitive if + * section names are to be populated case sensitively. + * + * Pass TRUE to @a option_names_case_sensitive if + * option names are to be populated case sensitively. + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_create2(svn_config_t **cfgp, + svn_boolean_t section_names_case_sensitive, + svn_boolean_t option_names_case_sensitive, + apr_pool_t *result_pool); + +/** Similar to svn_config_create2, but always passes @c FALSE to + * @a option_names_case_sensitive. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_config_create(svn_config_t **cfgp, + svn_boolean_t section_names_case_sensitive, + apr_pool_t *result_pool); + +/** Read configuration data from @a file (a file or registry path) into + * @a *cfgp, allocated in @a pool. + * + * If @a file does not exist, then if @a must_exist, return an error, + * otherwise return an empty @c svn_config_t. + * + * If @a section_names_case_sensitive is @c TRUE, populate section name hashes + * case sensitively, except for the @c "DEFAULT" section. + * + * If @a option_names_case_sensitive is @c TRUE, populate option name hashes + * case sensitively. + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_read3(svn_config_t **cfgp, + const char *file, + svn_boolean_t must_exist, + svn_boolean_t section_names_case_sensitive, + svn_boolean_t option_names_case_sensitive, + apr_pool_t *result_pool); + +/** Similar to svn_config_read3, but always passes @c FALSE to + * @a option_names_case_sensitive. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_config_read2(svn_config_t **cfgp, + const char *file, + svn_boolean_t must_exist, + svn_boolean_t section_names_case_sensitive, + apr_pool_t *result_pool); + +/** Similar to svn_config_read2, but always passes @c FALSE to + * @a section_names_case_sensitive. + * + * @deprecated Provided for backward compatibility with 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_config_read(svn_config_t **cfgp, + const char *file, + svn_boolean_t must_exist, + apr_pool_t *result_pool); + +/** Read configuration data from @a stream into @a *cfgp, allocated in + * @a result_pool. + * + * If @a section_names_case_sensitive is @c TRUE, populate section name hashes + * case sensitively, except for the @c "DEFAULT" section. + * + * If @a option_names_case_sensitive is @c TRUE, populate option name hashes + * case sensitively. + * + * @since New in 1.8. + */ + +svn_error_t * +svn_config_parse(svn_config_t **cfgp, + svn_stream_t *stream, + svn_boolean_t section_names_case_sensitive, + svn_boolean_t option_names_case_sensitive, + apr_pool_t *result_pool); + +/** Like svn_config_read(), but merges the configuration data from @a file + * (a file or registry path) into @a *cfg, which was previously returned + * from svn_config_read(). This function invalidates all value + * expansions in @a cfg, so that the next svn_config_get() takes the + * modifications into account. + */ +svn_error_t * +svn_config_merge(svn_config_t *cfg, + const char *file, + svn_boolean_t must_exist); + + +/** Find the value of a (@a section, @a option) pair in @a cfg, set @a + * *valuep to the value. + * + * If @a cfg is @c NULL, just sets @a *valuep to @a default_value. If + * the value does not exist, expand and return @a default_value. @a + * default_value can be NULL. + * + * The returned value will be valid at least until the next call to + * svn_config_get(), or for the lifetime of @a default_value. It is + * safest to consume the returned value immediately. + * + * This function may change @a cfg by expanding option values. + */ +void +svn_config_get(svn_config_t *cfg, + const char **valuep, + const char *section, + const char *option, + const char *default_value); + +/** Add or replace the value of a (@a section, @a option) pair in @a cfg with + * @a value. + * + * This function invalidates all value expansions in @a cfg. + * + * To remove an option, pass NULL for the @a value. + */ +void +svn_config_set(svn_config_t *cfg, + const char *section, + const char *option, + const char *value); + +/** Like svn_config_get(), but for boolean values. + * + * Parses the option as a boolean value. The recognized representations + * are 'TRUE'/'FALSE', 'yes'/'no', 'on'/'off', '1'/'0'; case does not + * matter. Returns an error if the option doesn't contain a known string. + */ +svn_error_t * +svn_config_get_bool(svn_config_t *cfg, + svn_boolean_t *valuep, + const char *section, + const char *option, + svn_boolean_t default_value); + +/** Like svn_config_set(), but for boolean values. + * + * Sets the option to 'TRUE'/'FALSE', depending on @a value. + */ +void +svn_config_set_bool(svn_config_t *cfg, + const char *section, + const char *option, + svn_boolean_t value); + +/** Like svn_config_get(), but for 64-bit signed integers. + * + * Parses the @a option in @a section of @a cfg as an integer value, + * setting @a *valuep to the result. If the option is not found, sets + * @a *valuep to @a default_value. If the option is found but cannot + * be converted to an integer, returns an error. + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_get_int64(svn_config_t *cfg, + apr_int64_t *valuep, + const char *section, + const char *option, + apr_int64_t default_value); + +/** Like svn_config_set(), but for 64-bit signed integers. + * + * Sets the value of @a option in @a section of @a cfg to the signed + * decimal @a value. + * + * @since New in 1.8. + */ +void +svn_config_set_int64(svn_config_t *cfg, + const char *section, + const char *option, + apr_int64_t value); + +/** Like svn_config_get(), but only for yes/no/ask values. + * + * Parse @a option in @a section and set @a *valuep to one of + * SVN_CONFIG_TRUE, SVN_CONFIG_FALSE, or SVN_CONFIG_ASK. If there is + * no setting for @a option, then parse @a default_value and set + * @a *valuep accordingly. If @a default_value is NULL, the result is + * undefined, and may be an error; we recommend that you pass one of + * SVN_CONFIG_TRUE, SVN_CONFIG_FALSE, or SVN_CONFIG_ASK for @a default value. + * + * Valid representations are (at least) "true"/"false", "yes"/"no", + * "on"/"off", "1"/"0", and "ask"; they are case-insensitive. Return + * an SVN_ERR_BAD_CONFIG_VALUE error if either @a default_value or + * @a option's value is not a valid representation. + * + * @since New in 1.6. + */ +svn_error_t * +svn_config_get_yes_no_ask(svn_config_t *cfg, + const char **valuep, + const char *section, + const char *option, + const char* default_value); + +/** Like svn_config_get_bool(), but for tristate values. + * + * Set @a *valuep to #svn_tristate_true, #svn_tristate_false, or + * #svn_tristate_unknown, depending on the value of @a option in @a + * section of @a cfg. True and false values are the same as for + * svn_config_get_bool(); @a unknown_value specifies the option value + * allowed for third state (#svn_tristate_unknown). + * + * Use @a default_value as the default value if @a option cannot be + * found. + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_get_tristate(svn_config_t *cfg, + svn_tristate_t *valuep, + const char *section, + const char *option, + const char *unknown_value, + svn_tristate_t default_value); + +/** Similar to @c svn_config_section_enumerator2_t, but is not + * provided with a memory pool argument. + * + * See svn_config_enumerate_sections() for the details of this type. + * + * @deprecated Provided for backwards compatibility with the 1.2 API. + */ +typedef svn_boolean_t (*svn_config_section_enumerator_t)(const char *name, + void *baton); + +/** Similar to svn_config_enumerate_sections2(), but uses a memory pool of + * @a cfg instead of one that is explicitly provided. + * + * @deprecated Provided for backwards compatibility with the 1.2 API. + */ +SVN_DEPRECATED +int +svn_config_enumerate_sections(svn_config_t *cfg, + svn_config_section_enumerator_t callback, + void *baton); + +/** A callback function used in enumerating config sections. + * + * See svn_config_enumerate_sections2() for the details of this type. + * + * @since New in 1.3. + */ +typedef svn_boolean_t (*svn_config_section_enumerator2_t)(const char *name, + void *baton, + apr_pool_t *pool); + +/** Enumerate the sections, passing @a baton and the current section's name + * to @a callback. Continue the enumeration if @a callback returns @c TRUE. + * Return the number of times @a callback was called. + * + * ### See kff's comment to svn_config_enumerate2(). It applies to this + * function, too. ### + * + * @a callback's @a name parameter is only valid for the duration of the call. + * + * @since New in 1.3. + */ +int +svn_config_enumerate_sections2(svn_config_t *cfg, + svn_config_section_enumerator2_t callback, + void *baton, apr_pool_t *pool); + +/** Similar to @c svn_config_enumerator2_t, but is not + * provided with a memory pool argument. + * See svn_config_enumerate() for the details of this type. + * + * @deprecated Provided for backwards compatibility with the 1.2 API. + */ +typedef svn_boolean_t (*svn_config_enumerator_t)(const char *name, + const char *value, + void *baton); + +/** Similar to svn_config_enumerate2(), but uses a memory pool of + * @a cfg instead of one that is explicitly provided. + * + * @deprecated Provided for backwards compatibility with the 1.2 API. + */ +SVN_DEPRECATED +int +svn_config_enumerate(svn_config_t *cfg, + const char *section, + svn_config_enumerator_t callback, + void *baton); + + +/** A callback function used in enumerating config options. + * + * See svn_config_enumerate2() for the details of this type. + * + * @since New in 1.3. + */ +typedef svn_boolean_t (*svn_config_enumerator2_t)(const char *name, + const char *value, + void *baton, + apr_pool_t *pool); + +/** Enumerate the options in @a section, passing @a baton and the current + * option's name and value to @a callback. Continue the enumeration if + * @a callback returns @c TRUE. Return the number of times @a callback + * was called. + * + * ### kff asks: A more usual interface is to continue enumerating + * while @a callback does not return error, and if @a callback does + * return error, to return the same error (or a wrapping of it) + * from svn_config_enumerate(). What's the use case for + * svn_config_enumerate()? Is it more likely to need to break out + * of an enumeration early, with no error, than an invocation of + * @a callback is likely to need to return an error? ### + * + * @a callback's @a name and @a value parameters are only valid for the + * duration of the call. + * + * @since New in 1.3. + */ +int +svn_config_enumerate2(svn_config_t *cfg, + const char *section, + svn_config_enumerator2_t callback, + void *baton, + apr_pool_t *pool); + +/** + * Return @c TRUE if @a section exists in @a cfg, @c FALSE otherwise. + * + * @since New in 1.4. + */ +svn_boolean_t +svn_config_has_section(svn_config_t *cfg, + const char *section); + +/** Enumerate the group @a master_section in @a cfg. Each variable + * value is interpreted as a list of glob patterns (separated by comma + * and optional whitespace). Return the name of the first variable + * whose value matches @a key, or @c NULL if no variable matches. + */ +const char * +svn_config_find_group(svn_config_t *cfg, + const char *key, + const char *master_section, + apr_pool_t *pool); + +/** Retrieve value corresponding to @a option_name in @a cfg, or + * return @a default_value if none is found. + * + * The config will first be checked for a default. + * If @a server_group is not @c NULL, the config will also be checked + * for an override in a server group, + * + */ +const char * +svn_config_get_server_setting(svn_config_t *cfg, + const char* server_group, + const char* option_name, + const char* default_value); + +/** Retrieve value into @a result_value corresponding to @a option_name for a + * given @a server_group in @a cfg, or return @a default_value if none is + * found. + * + * The config will first be checked for a default, then will be checked for + * an override in a server group. If the value found is not a valid integer, + * a @c svn_error_t* will be returned. + */ +svn_error_t * +svn_config_get_server_setting_int(svn_config_t *cfg, + const char *server_group, + const char *option_name, + apr_int64_t default_value, + apr_int64_t *result_value, + apr_pool_t *pool); + + +/** Set @a *valuep according to @a option_name for a given + * @a server_group in @a cfg, or set to @a default_value if no value is + * specified. + * + * Check first a default, then for an override in a server group. If + * a value is found but is not a valid boolean, return an + * SVN_ERR_BAD_CONFIG_VALUE error. + * + * @since New in 1.6. + */ +svn_error_t * +svn_config_get_server_setting_bool(svn_config_t *cfg, + svn_boolean_t *valuep, + const char *server_group, + const char *option_name, + svn_boolean_t default_value); + + + +/** Try to ensure that the user's ~/.subversion/ area exists, and create + * no-op template files for any absent config files. Use @a pool for any + * temporary allocation. If @a config_dir is not @c NULL it specifies a + * directory from which to read the config overriding all other sources. + * + * Don't error if something exists but is the wrong kind (for example, + * ~/.subversion exists but is a file, or ~/.subversion/servers exists + * but is a directory). + * + * Also don't error if trying to create something and failing -- it's + * okay for the config area or its contents not to be created. + * However, if creating a config template file succeeds, return an + * error if unable to initialize its contents. + */ +svn_error_t * +svn_config_ensure(const char *config_dir, + apr_pool_t *pool); + + + + +/** Accessing cached authentication data in the user config area. + * + * @defgroup cached_authentication_data Cached authentication data + * @{ + */ + + +/** A hash-key pointing to a realmstring. Every file containing + * authentication data should have this key. + */ +#define SVN_CONFIG_REALMSTRING_KEY "svn:realmstring" + +/** Use @a cred_kind and @a realmstring to locate a file within the + * ~/.subversion/auth/ area. If the file exists, initialize @a *hash + * and load the file contents into the hash, using @a pool. If the + * file doesn't exist, set @a *hash to NULL. + * + * If @a config_dir is not NULL it specifies a directory from which to + * read the config overriding all other sources. + * + * Besides containing the original credential fields, the hash will + * also contain @c SVN_CONFIG_REALMSTRING_KEY. The caller can examine + * this value as a sanity-check that the correct file was loaded. + * + * The hashtable will contain <tt>const char *</tt> keys and + * <tt>svn_string_t *</tt> values. + */ +svn_error_t * +svn_config_read_auth_data(apr_hash_t **hash, + const char *cred_kind, + const char *realmstring, + const char *config_dir, + apr_pool_t *pool); + +/** Use @a cred_kind and @a realmstring to create or overwrite a file + * within the ~/.subversion/auth/ area. Write the contents of @a hash into + * the file. If @a config_dir is not NULL it specifies a directory to read + * the config overriding all other sources. + * + * Also, add @a realmstring to the file, with key @c + * SVN_CONFIG_REALMSTRING_KEY. This allows programs (or users) to + * verify exactly which set credentials live within the file. + * + * The hashtable must contain <tt>const char *</tt> keys and + * <tt>svn_string_t *</tt> values. + */ +svn_error_t * +svn_config_write_auth_data(apr_hash_t *hash, + const char *cred_kind, + const char *realmstring, + const char *config_dir, + apr_pool_t *pool); + + +/** Callback for svn_config_walk_auth_data(). + * + * Called for each credential walked by that function (and able to be + * fully purged) to allow perusal and selective removal of credentials. + * + * @a cred_kind and @a realmstring specify the key of the credential. + * @a hash contains the hash data associated with the record. + * + * Before returning set @a *delete_cred to TRUE to remove the credential from + * the cache; leave @a *delete_cred unchanged or set it to FALSE to keep the + * credential. + * + * Implementations may return #SVN_ERR_CEASE_INVOCATION to indicate + * that the callback should not be called again. Note that when that + * error is returned, the value of @a delete_cred will still be + * honored and action taken if necessary. (For other returned errors, + * @a delete_cred is ignored by svn_config_walk_auth_data().) + * + * @since New in 1.8. + */ +typedef svn_error_t * +(*svn_config_auth_walk_func_t)(svn_boolean_t *delete_cred, + void *cleanup_baton, + const char *cred_kind, + const char *realmstring, + apr_hash_t *hash, + apr_pool_t *scratch_pool); + +/** Call @a walk_func with @a walk_baton and information describing + * each credential cached within the Subversion auth store located + * under @a config_dir. If the callback sets its delete_cred return + * flag, delete the associated credential. + * + * @note Removing credentials from the config-based disk store will + * not purge them from any open svn_auth_baton_t instance. Consider + * using svn_auth_forget_credentials() -- from the @a cleanup_func, + * even -- for this purpose. + * + * @note Removing credentials from the config-based disk store will + * not also remove any related credentials from third-party password + * stores. (Implementations of @a walk_func which delete credentials + * may wish to consult the "passtype" element of @a hash, if any, to + * see if a third-party store -- such as "gnome-keyring" or "kwallet" + * is being used to hold the most sensitive portion of the credentials + * for this @a cred_kind and @a realmstring.) + * + * @see svn_auth_forget_credentials() + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_walk_auth_data(const char *config_dir, + svn_config_auth_walk_func_t walk_func, + void *walk_baton, + apr_pool_t *scratch_pool); + +/** Put the absolute path to the user's configuration directory, + * or to a file within that directory, into @a *path. + * + * If @a config_dir is not NULL, it must point to an alternative + * config directory location. If it is NULL, the default location + * is used. If @a fname is not NULL, it must specify the last + * component of the path to be returned. This can be used to create + * a path to any file in the configuration directory. + * + * Do all allocations in @a pool. + * + * Hint: + * To get the user configuration file, pass @c SVN_CONFIG_CATEGORY_CONFIG + * for @a fname. To get the servers configuration file, pass + * @c SVN_CONFIG_CATEGORY_SERVERS for @a fname. + * + * @since New in 1.6. + */ +svn_error_t * +svn_config_get_user_config_path(const char **path, + const char *config_dir, + const char *fname, + apr_pool_t *pool); + +/** Create a deep copy of the config object @a src and return + * it in @a cfgp, allocating the memory in @a pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_dup(svn_config_t **cfgp, + svn_config_t *src, + apr_pool_t *pool); + +/** Create a deep copy of the config hash @a src_hash and return + * it in @a cfg_hash, allocating the memory in @a pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_config_copy_config(apr_hash_t **cfg_hash, + apr_hash_t *src_hash, + apr_pool_t *pool); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CONFIG_H */ diff --git a/subversion/include/svn_ctype.h b/subversion/include/svn_ctype.h new file mode 100644 index 0000000..1263552 --- /dev/null +++ b/subversion/include/svn_ctype.h @@ -0,0 +1,196 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_ctype.h + * @brief Character classification routines + * @since New in 1.2. + */ + + +#ifndef SVN_CTYPE_H +#define SVN_CTYPE_H + +#include <apr.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Table of flags for character classification. */ +extern const apr_uint32_t *const svn_ctype_table; + + +/** Check if @a c is in the character class described by @a flags. + * The @a flags is a bitwise-or combination of @c SVN_CTYPE_* + * constants. Uses #svn_ctype_table. + */ +#define svn_ctype_test(c, flags) \ + (0 != (svn_ctype_table[(unsigned char)(c)] & (flags))) + + +/** + * @defgroup ctype_basic Basic character classification - 7-bit ASCII only + * @{ + */ + +/* Basic character classes */ +#define SVN_CTYPE_CNTRL 0x0001 /**< Control character */ +#define SVN_CTYPE_SPACE 0x0002 /**< Whitespace */ +#define SVN_CTYPE_DIGIT 0x0004 /**< Decimal digit */ +#define SVN_CTYPE_UPPER 0x0008 /**< Uppercase letter */ +#define SVN_CTYPE_LOWER 0x0010 /**< Lowercase letter */ +#define SVN_CTYPE_PUNCT 0x0020 /**< Punctuation mark */ +#define SVN_CTYPE_XALPHA 0x0040 /**< Hexadecimal digits A to F */ +#define SVN_CTYPE_ASCII 0x0080 /**< ASCII subset*/ + +/* Derived character classes */ +/** ASCII letter */ +#define SVN_CTYPE_ALPHA (SVN_CTYPE_LOWER | SVN_CTYPE_UPPER) +/** ASCII letter or decimal digit */ +#define SVN_CTYPE_ALNUM (SVN_CTYPE_ALPHA | SVN_CTYPE_DIGIT) +/** ASCII hexadecimal digit */ +#define SVN_CTYPE_XDIGIT (SVN_CTYPE_DIGIT | SVN_CTYPE_XALPHA) +/** Printable ASCII except space */ +#define SVN_CTYPE_GRAPH (SVN_CTYPE_PUNCT | SVN_CTYPE_ALNUM) +/** All printable ASCII */ +#define SVN_CTYPE_PRINT (SVN_CTYPE_GRAPH | SVN_CTYPE_SPACE) + + +/** Check if @a c is an ASCII control character. */ +#define svn_ctype_iscntrl(c) svn_ctype_test((c), SVN_CTYPE_CNTRL) + +/** Check if @a c is an ASCII whitespace character. */ +#define svn_ctype_isspace(c) svn_ctype_test((c), SVN_CTYPE_SPACE) + +/** Check if @a c is an ASCII digit. */ +#define svn_ctype_isdigit(c) svn_ctype_test((c), SVN_CTYPE_DIGIT) + +/** Check if @a c is an ASCII uppercase letter. */ +#define svn_ctype_isupper(c) svn_ctype_test((c), SVN_CTYPE_UPPER) + +/** Check if @a c is an ASCII lowercase letter. */ +#define svn_ctype_islower(c) svn_ctype_test((c), SVN_CTYPE_LOWER) + +/** Check if @a c is an ASCII punctuation mark. */ +#define svn_ctype_ispunct(c) svn_ctype_test((c), SVN_CTYPE_PUNCT) + +/** Check if @a c is an ASCII character. */ +#define svn_ctype_isascii(c) svn_ctype_test((c), SVN_CTYPE_ASCII) + +/** Check if @a c is an ASCII letter. */ +#define svn_ctype_isalpha(c) svn_ctype_test((c), SVN_CTYPE_ALPHA) + +/** Check if @a c is an ASCII letter or decimal digit. */ +#define svn_ctype_isalnum(c) svn_ctype_test((c), SVN_CTYPE_ALNUM) + +/** Check if @a c is an ASCII hexadecimal digit. */ +#define svn_ctype_isxdigit(c) svn_ctype_test((c), SVN_CTYPE_XDIGIT) + +/** Check if @a c is an ASCII graphical (visible printable) character. */ +#define svn_ctype_isgraph(c) svn_ctype_test((c), SVN_CTYPE_GRAPH) + +/** Check if @a c is an ASCII printable character. */ +#define svn_ctype_isprint(c) svn_ctype_test((c), SVN_CTYPE_PRINT) + +/** @} */ + +/** + * @defgroup ctype_extra Extended character classification + * @{ + */ + +/* Basic extended character classes */ +#define SVN_CTYPE_UTF8LEAD 0x0100 /**< UTF-8 multibyte lead byte */ +#define SVN_CTYPE_UTF8CONT 0x0200 /**< UTF-8 multibyte non-lead byte */ +/* ### TBD +#define SVN_CTYPE_XMLNAME 0x0400 +#define SVN_CTYPE_URISAFE 0x0800 +*/ + +/* Derived extended character classes */ +/** Part of a UTF-8 multibyte character. */ +#define SVN_CTYPE_UTF8MBC (SVN_CTYPE_UTF8LEAD | SVN_CTYPE_UTF8CONT) +/** All valid UTF-8 bytes. */ +#define SVN_CTYPE_UTF8 (SVN_CTYPE_ASCII | SVN_CTYPE_UTF8MBC) + +/** Check if @a c is a UTF-8 multibyte lead byte. */ +#define svn_ctype_isutf8lead(c) svn_ctype_test((c), SVN_CTYPE_UTF8LEAD) + +/** Check if @a c is a UTF-8 multibyte continuation (non-lead) byte. */ +#define svn_ctype_isutf8cont(c) svn_ctype_test((c), SVN_CTYLE_UTF8CONT) + +/** Check if @a c is part of a UTF-8 multibyte character. */ +#define svn_ctype_isutf8mbc(c) svn_ctype_test((c), SVN_CTYPE_UTF8MBC) + +/** Check if @a c is valid in UTF-8. */ +#define svn_ctype_isutf8(c) svn_ctype_test((c), SVN_CTYPE_UTF8) + +/** @} */ + +/** + * @defgroup ctype_ascii ASCII character value constants + * @{ + */ + +#define SVN_CTYPE_ASCII_MINUS 45 /**< ASCII value of '-' */ +#define SVN_CTYPE_ASCII_DOT 46 /**< ASCII value of '.' */ +#define SVN_CTYPE_ASCII_COLON 58 /**< ASCII value of ':' */ +#define SVN_CTYPE_ASCII_UNDERSCORE 95 /**< ASCII value of '_' */ +#define SVN_CTYPE_ASCII_TAB 9 /**< ASCII value of a tab */ +#define SVN_CTYPE_ASCII_LINEFEED 10 /**< ASCII value of a line feed */ +#define SVN_CTYPE_ASCII_CARRIAGERETURN 13 + /**< ASCII value of a carriage return */ +#define SVN_CTYPE_ASCII_DELETE 127 + /**< ASCII value of a delete character */ + + +/** @} */ + +/** + * @defgroup ctype_case ASCII-subset case folding + * @{ + */ + +/** + * Compare two characters @a a and @a b, treating case-equivalent + * unaccented Latin (ASCII subset) letters as equal. + * + * Returns in integer greater than, equal to, or less than 0, + * according to whether @a a is considered greater than, equal to, + * or less than @a b. + * + * @since New in 1.5. + */ +int +svn_ctype_casecmp(int a, + int b); + + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_CTYPE_H */ diff --git a/subversion/include/svn_dav.h b/subversion/include/svn_dav.h new file mode 100644 index 0000000..e9092d5 --- /dev/null +++ b/subversion/include/svn_dav.h @@ -0,0 +1,398 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_dav.h + * @brief Code related to WebDAV/DeltaV usage in Subversion. + */ + + + + +#ifndef SVN_DAV_H +#define SVN_DAV_H + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** This is the MIME type that Subversion uses for its "svndiff" format. + * + * This is an application type, for the "svn" vendor. The specific subtype + * is "svndiff". + */ +#define SVN_SVNDIFF_MIME_TYPE "application/vnd.svn-svndiff" + +/** This is the MIME type that Subversion users for its "skel" format. + * + * This is an application type, for the "svn" vendor. The specific subtype + * is "skel". + * @since New in 1.7. + */ +#define SVN_SKEL_MIME_TYPE "application/vnd.svn-skel" + +/** This header is *TEMPORARILY* used to transmit the delta base to the + * server. It contains a version resource URL for what is on the client. + * + * @note The HTTP delta draft recommends an If-None-Match header + * holding an entity tag corresponding to the base copy that the + * client has. In Subversion, it is much more natural to use a version + * URL to specify that base. We'd like, then, to use the If: header + * to specify the URL. Unfortunately, mod_dav sees all "State-token" + * items as lock tokens. So we'll use this custom header until mod_dav + * and other backend APIs are taught to be less rigid, at which time + * we can switch to using an If: header to report our base version. + */ +#define SVN_DAV_DELTA_BASE_HEADER "X-SVN-VR-Base" + +/** This header is used when an svn client wants to trigger specific + * svn server behaviors. Normal WebDAV or DeltaV clients won't use it. + */ +#define SVN_DAV_OPTIONS_HEADER "X-SVN-Options" + +/** + * @name options-header defines + * Specific options that can appear in the options-header: + * @{ + */ +#define SVN_DAV_OPTION_NO_MERGE_RESPONSE "no-merge-response" +#define SVN_DAV_OPTION_LOCK_BREAK "lock-break" +#define SVN_DAV_OPTION_LOCK_STEAL "lock-steal" +#define SVN_DAV_OPTION_RELEASE_LOCKS "release-locks" +#define SVN_DAV_OPTION_KEEP_LOCKS "keep-locks" +/** @} */ + +/** This header is used when an svn client wants to tell mod_dav_svn + * exactly what revision of a resource it thinks it's operating on. + * (For example, an svn server can use it to validate a DELETE request.) + * Normal WebDAV or DeltaV clients won't use it. + */ +#define SVN_DAV_VERSION_NAME_HEADER "X-SVN-Version-Name" + +/** A header generated by mod_dav_svn whenever it responds + successfully to a LOCK request. Only svn clients will notice it, + and use it to fill in svn_lock_t->creation_date. */ +#define SVN_DAV_CREATIONDATE_HEADER "X-SVN-Creation-Date" + +/** A header generated by mod_dav_svn whenever it responds + successfully to a PROPFIND for the 'DAV:lockdiscovery' property. + Only svn clients will notice it, and use it to fill in + svn_lock_t->owner. (Remember that the DAV:owner field maps to + svn_lock_t->comment, and that there is no analogue in the DAV + universe of svn_lock_t->owner.) */ +#define SVN_DAV_LOCK_OWNER_HEADER "X-SVN-Lock-Owner" + +/** Assuming the OPTIONS was performed against a resource within a + * Subversion repository, then this header indicates the youngest + * revision in the repository. + * @since New in 1.7. */ +#define SVN_DAV_YOUNGEST_REV_HEADER "SVN-Youngest-Rev" + +/** Assuming the OPTIONS was performed against a resource within a + * Subversion repository, then this header indicates the UUID of the + * repository. + * @since New in 1.7. */ +#define SVN_DAV_REPOS_UUID_HEADER "SVN-Repository-UUID" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the server speaks HTTP protocol v2. This header provides an + * opaque URI that the client should send all custom REPORT requests + * against. + * @since New in 1.7. */ +#define SVN_DAV_ME_RESOURCE_HEADER "SVN-Me-Resource" + +/** This header provides the repository root URI, suitable for use in + * calculating the relative paths of other public URIs for this + * repository into . (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_ROOT_URI_HEADER "SVN-Repository-Root" + +/** This header provides an opaque URI that the client can append a + * revision to, to construct a 'revision URL'. This allows direct + * read/write access to revprops via PROPFIND or PROPPATCH, and is + * similar to libsvn_fs's revision objects (as distinct from "revision + * roots"). (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_REV_STUB_HEADER "SVN-Rev-Stub" + +/** This header provides an opaque URI that the client can append + * PEGREV/PATH to, in order to construct URIs of pegged objects in the + * repository, similar to the use of a "revision root" in the + * libsvn_fs API. (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_REV_ROOT_STUB_HEADER "SVN-Rev-Root-Stub" + +/** This header provides an opaque URI which represents a Subversion + * transaction (revision-in-progress) object. It is suitable for use + * in fetching and modifying transaction properties as part of a + * commit process, similar to the svn_fs_txn_t object (as distinct + * from a "txn root"). (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_TXN_STUB_HEADER "SVN-Txn-Stub" + +/** Companion to @c SVN_DAV_TXN_STUB_HEADER, used when a POST request + * returns @c SVN_DAV_VTXN_NAME_HEADER in response to a client + * supplied name. (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_VTXN_STUB_HEADER "SVN-VTxn-Stub" + +/** This header provides an opaque URI which represents the root + * directory of a Subversion transaction (revision-in-progress), + * similar to the concept of a "txn root" in the libsvn_fs API. The + * client can append additional path segments to it to access items + * deeper in the transaction tree as part of a commit process. (HTTP + * protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_TXN_ROOT_STUB_HEADER "SVN-Txn-Root-Stub" + +/** Companion to @c SVN_DAV_TXN_ROOT_STUB_HEADER, used when a POST + * request returns @c SVN_DAV_VTXN_NAME_HEADER in response to a + * client supplied name. (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_VTXN_ROOT_STUB_HEADER "SVN-VTxn-Root-Stub" + +/** This header is used in the POST response to tell the client the + * name of the Subversion transaction created by the request. It can + * then be appended to the transaction stub and transaction root stub + * for access to the properties and paths, respectively, of the named + * transaction. (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_TXN_NAME_HEADER "SVN-Txn-Name" + +/** This header is used in the POST request, to pass a client supplied + * alternative transaction name to the server, and in the POST + * response, to tell the client that the alternative transaction + * resource names should be used. (HTTP protocol v2 only) + * @since New in 1.7. */ +#define SVN_DAV_VTXN_NAME_HEADER "SVN-VTxn-Name" + +/** This header is used in the OPTIONS response to identify named + * skel-based POST request types which the server is prepared to + * handle. (HTTP protocol v2 only) + * @since New in 1.8. */ +#define SVN_DAV_SUPPORTED_POSTS_HEADER "SVN-Supported-Posts" + +/** This header is used in the OPTIONS response to indicate if the server + * wants bulk update requests (Prefer) or only accepts skelta requests (Off). + * If this value is On both options are allowed. + * @since New in 1.8. */ +#define SVN_DAV_ALLOW_BULK_UPDATES "SVN-Allow-Bulk-Updates" + +/** Assuming the request target is a Subversion repository resource, + * this header is returned in the OPTIONS response to indicate whether + * the repository supports the merge tracking feature ("yes") or not + * ("no"). + * @since New in 1.8. */ +#define SVN_DAV_REPOSITORY_MERGEINFO "SVN-Repository-MergeInfo" + +/** + * @name Fulltext MD5 headers + * + * These headers are for client and server to verify that the base + * and the result of a change transmission are the same on both + * sides, regardless of what transformations (svndiff deltification, + * gzipping, etc) the data may have gone through in between. + * + * The result md5 is always used whenever file contents are + * transferred, because every transmission has a resulting text. + * + * The base md5 is used to verify the base text against which svndiff + * data is being applied. Note that even for svndiff transmissions, + * base verification is not strictly necessary (and may therefore be + * unimplemented), as any error will be caught by the verification of + * the final result. However, if the problem is that the base text is + * corrupt, the error will be caught earlier if the base md5 is used. + * + * Normal WebDAV or DeltaV clients don't use these. + * @{ + */ +#define SVN_DAV_BASE_FULLTEXT_MD5_HEADER "X-SVN-Base-Fulltext-MD5" +#define SVN_DAV_RESULT_FULLTEXT_MD5_HEADER "X-SVN-Result-Fulltext-MD5" +/** @} */ + +/* ### should add strings for the various XML elements in the reports + ### and things. also the custom prop names. etc. +*/ + +/** The svn-specific object that is placed within a <D:error> response. + * + * @defgroup svn_dav_error Errors in svn_dav + * @{ */ + +/** The error object's namespace */ +#define SVN_DAV_ERROR_NAMESPACE "svn:" + +/** The error object's tag */ +#define SVN_DAV_ERROR_TAG "error" + +/** @} */ + + +/** General property (xml) namespaces that will be used by both ra_dav + * and mod_dav_svn for marshalling properties. + * + * @defgroup svn_dav_property_xml_namespaces DAV property namespaces + * @{ + */ + +/** A property stored in the fs and wc, begins with 'svn:', and is + * interpreted either by client or server. + */ +#define SVN_DAV_PROP_NS_SVN "http://subversion.tigris.org/xmlns/svn/" + +/** A property stored in the fs and wc, but totally ignored by svn + * client and server. + * + * A property simply invented by the users. + */ +#define SVN_DAV_PROP_NS_CUSTOM "http://subversion.tigris.org/xmlns/custom/" + +/** A property purely generated and consumed by the network layer, not + * seen by either fs or wc. + */ +#define SVN_DAV_PROP_NS_DAV "http://subversion.tigris.org/xmlns/dav/" + + +/** + * @name Custom (extension) values for the DAV header. + * Note that although these share the SVN_DAV_PROP_NS_DAV namespace + * prefix, they are not properties; they are header values. + * @{ + */ + +/* ################################################################## + * + * WARNING: At least some versions of Microsoft's Web Folders + * WebDAV client implementation are unable to handle + * DAV: headers with values longer than 63 characters, + * so please keep these strings within that limit. + * + * ################################################################## + */ + + +/** Presence of this in a DAV header in an OPTIONS request or response + * indicates that the transmitter supports @c svn_depth_t. + * + * @since New in 1.5. + */ +#define SVN_DAV_NS_DAV_SVN_DEPTH\ + SVN_DAV_PROP_NS_DAV "svn/depth" + +/** Presence of this in a DAV header in an OPTIONS request or response + * indicates that the server knows how to handle merge-tracking + * information. + * + * Note that this says nothing about whether the repository can handle + * mergeinfo, only whether the server does. For more information, see + * mod_dav_svn/version.c:get_vsn_options(). + * + * @since New in 1.5. + */ +#define SVN_DAV_NS_DAV_SVN_MERGEINFO\ + SVN_DAV_PROP_NS_DAV "svn/mergeinfo" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to send + * custom revprops in log responses. + * + * @since New in 1.5. + */ +#define SVN_DAV_NS_DAV_SVN_LOG_REVPROPS\ + SVN_DAV_PROP_NS_DAV "svn/log-revprops" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to handle + * a replay of a directory in the repository (not root). + * + * @since New in 1.5. + */ +#define SVN_DAV_NS_DAV_SVN_PARTIAL_REPLAY\ + SVN_DAV_PROP_NS_DAV "svn/partial-replay" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to enforce + * old-value atomicity in PROPPATCH (for editing revprops). + * + * @since New in 1.7. + */ +#define SVN_DAV_NS_DAV_SVN_ATOMIC_REVPROPS\ + SVN_DAV_PROP_NS_DAV "svn/atomic-revprops" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to get + * inherited properties. + * + * @since New in 1.8. + */ +#define SVN_DAV_NS_DAV_SVN_INHERITED_PROPS\ + SVN_DAV_PROP_NS_DAV "svn/inherited-props" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to + * properly handle ephemeral (that is, deleted-just-before-commit) FS + * transaction properties. + * + * @since New in 1.8. + */ +#define SVN_DAV_NS_DAV_SVN_EPHEMERAL_TXNPROPS\ + SVN_DAV_PROP_NS_DAV "svn/ephemeral-txnprops" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) supports serving + * properties inline in update editor when 'send-all' is 'false'. + * + * @since New in 1.8. + */ +#define SVN_DAV_NS_DAV_SVN_INLINE_PROPS\ + SVN_DAV_PROP_NS_DAV "svn/inline-props" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to handle + * a replay of a revision resource. Transmitters must be + * HTTP-v2-enabled to support this feature. + * + * @since New in 1.8. + */ +#define SVN_DAV_NS_DAV_SVN_REPLAY_REV_RESOURCE\ + SVN_DAV_PROP_NS_DAV "svn/replay-rev-resource" + +/** Presence of this in a DAV header in an OPTIONS response indicates + * that the transmitter (in this case, the server) knows how to handle + * a reversed fetch of file versions. + * + * @since New in 1.8. + */ +#define SVN_DAV_NS_DAV_SVN_REVERSE_FILE_REVS\ + SVN_DAV_PROP_NS_DAV "svn/reverse-file-revs" + + +/** @} */ + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DAV_H */ diff --git a/subversion/include/svn_delta.h b/subversion/include/svn_delta.h new file mode 100644 index 0000000..7df7f3f --- /dev/null +++ b/subversion/include/svn_delta.h @@ -0,0 +1,1367 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_delta.h + * @brief Delta-parsing + */ + +/* ==================================================================== */ + + + +#ifndef SVN_DELTA_H +#define SVN_DELTA_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_file_io.h> /* for apr_file_t */ + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_io.h" +#include "svn_checksum.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** This compression level effectively disables data compression. + * However, the data pre-processing costs may still not be zero. + * + * @since New in 1.7. + */ +#define SVN_DELTA_COMPRESSION_LEVEL_NONE 0 + +/** This is the maximum compression level we can pass to zlib. + * + * @since New in 1.7. + */ +#define SVN_DELTA_COMPRESSION_LEVEL_MAX 9 + +/** This is the default compression level we pass to zlib. It + * should be between 0 and 9, with higher numbers resulting in + * better compression rates but slower operation. + * + * @since New in 1.7. + */ +#define SVN_DELTA_COMPRESSION_LEVEL_DEFAULT 5 + +/** + * Get libsvn_delta version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_delta_version(void); + +/** + * @defgroup delta_support Delta generation and handling + * + * @{ + */ + +/** Text deltas. + * + * A text delta represents the difference between two strings of + * bytes, the `source' string and the `target' string. Given a source + * string and a target string, we can compute a text delta; given a + * source string and a delta, we can reconstruct the target string. + * However, note that deltas are not reversible: you cannot always + * reconstruct the source string given the target string and delta. + * + * Since text deltas can be very large, the interface here allows us + * to produce and consume them in pieces. Each piece, represented by + * an #svn_txdelta_window_t structure, describes how to produce the + * next section of the target string. + * + * To compute a new text delta: + * + * - We call svn_txdelta() on the streams we want to compare. That + * returns us an #svn_txdelta_stream_t object. + * + * - We then call svn_txdelta_next_window() on the stream object + * repeatedly. Each call returns a new #svn_txdelta_window_t + * object, which describes the next portion of the target string. + * When svn_txdelta_next_window() returns zero, we are done building + * the target string. + * + * @defgroup svn_delta_txt_delta Text deltas + * @{ + */ + +/** Action codes for text delta instructions. */ +enum svn_delta_action { + /* Note: The svndiff implementation relies on the values assigned in + * this enumeration matching the instruction encoding values. */ + + /** Append the @a length bytes at @a offset in the source view to the + * target. + * + * It must be the case that 0 <= @a offset < @a offset + + * @a length <= size of source view. + */ + svn_txdelta_source, + + /** Append the @a length bytes at @a offset in the target view, to the + * target. + * + * It must be the case that 0 <= @a offset < current position in the + * target view. + * + * However! @a offset + @a length may be *beyond* the end of the existing + * target data. "Where the heck does the text come from, then?" + * If you start at @a offset, and append @a length bytes one at a time, + * it'll work out --- you're adding new bytes to the end at the + * same rate you're reading them from the middle. Thus, if your + * current target text is "abcdefgh", and you get an #svn_txdelta_target + * instruction whose @a offset is 6 and whose @a length is 7, + * the resulting string is "abcdefghghghghg". This trick is actually + * useful in encoding long runs of consecutive characters, long runs + * of CR/LF pairs, etc. + */ + svn_txdelta_target, + + /** Append the @a length bytes at @a offset in the window's @a new string + * to the target. + * + * It must be the case that 0 <= @a offset < @a offset + + * @a length <= length of @a new. Windows MUST use new data in ascending + * order with no overlap at the moment; svn_txdelta_to_svndiff() + * depends on this. + */ + svn_txdelta_new +}; + +/** A single text delta instruction. */ +typedef struct svn_txdelta_op_t +{ + /** Action code of delta instruction */ + enum svn_delta_action action_code; + /** Offset of delta, see #svn_delta_action for more details. */ + apr_size_t offset; + /** Number of bytes of delta, see #svn_delta_action for more details. */ + apr_size_t length; +} svn_txdelta_op_t; + + +/** An #svn_txdelta_window_t object describes how to reconstruct a + * contiguous section of the target string (the "target view") using a + * specified contiguous region of the source string (the "source + * view"). It contains a series of instructions which assemble the + * new target string text by pulling together substrings from: + * + * - the source view, + * + * - the previously constructed portion of the target view, + * + * - a string of new data contained within the window structure + * + * The source view must always slide forward from one window to the + * next; that is, neither the beginning nor the end of the source view + * may move to the left as we read from a window stream. This + * property allows us to apply deltas to non-seekable source streams + * without making a full copy of the source stream. + */ +typedef struct svn_txdelta_window_t +{ + + /** The offset of the source view for this window. */ + svn_filesize_t sview_offset; + + /** The length of the source view for this window. */ + apr_size_t sview_len; + + /** The length of the target view for this window, i.e. the number of + * bytes which will be reconstructed by the instruction stream. */ + apr_size_t tview_len; + + /** The number of instructions in this window. */ + int num_ops; + + /** The number of svn_txdelta_source instructions in this window. If + * this number is 0, we don't need to read the source in order to + * reconstruct the target view. + */ + int src_ops; + + /** The instructions for this window. */ + const svn_txdelta_op_t *ops; + + /** New data, for use by any `svn_txdelta_new' instructions. */ + const svn_string_t *new_data; + +} svn_txdelta_window_t; + +/** + * Return a deep copy of @a window, allocated in @a pool. + * + * @since New in 1.3. + */ +svn_txdelta_window_t * +svn_txdelta_window_dup(const svn_txdelta_window_t *window, + apr_pool_t *pool); + +/** + * Compose two delta windows, yielding a third, allocated in @a pool. + * + * @since New in 1.4 + * + */ +svn_txdelta_window_t * +svn_txdelta_compose_windows(const svn_txdelta_window_t *window_A, + const svn_txdelta_window_t *window_B, + apr_pool_t *pool); + +/** + * Apply the instructions from @a window to a source view @a sbuf to + * produce a target view @a tbuf. + * + * @a sbuf is assumed to have @a window->sview_len bytes of data and + * @a tbuf is assumed to have room for @a tlen bytes of output. @a + * tlen may be more than @a window->tview_len, so return the actual + * number of bytes written. @a sbuf is not touched and may be NULL if + * @a window contains no source-copy operations. This is purely a + * memory operation; nothing can go wrong as long as we have a valid + * window. + * + * @since New in 1.4 + * + */ +void +svn_txdelta_apply_instructions(svn_txdelta_window_t *window, + const char *sbuf, char *tbuf, + apr_size_t *tlen); + +/** A typedef for functions that consume a series of delta windows, for + * use in caller-pushes interfaces. Such functions will typically + * apply the delta windows to produce some file, or save the windows + * somewhere. At the end of the delta window stream, you must call + * this function passing zero for the @a window argument. + */ +typedef svn_error_t *(*svn_txdelta_window_handler_t)( + svn_txdelta_window_t *window, void *baton); + + +/** This function will generate delta windows that turn @a source into + * @a target, and pushing these windows into the @a handler window handler + * callback (passing @a handler_baton to each invocation). + * + * If @a checksum is not NULL, then a checksum (of kind @a checksum_kind) + * will be computed for the target stream, and placed into *checksum. + * + * If @a cancel_func is not NULL, then it should refer to a cancellation + * function (along with @a cancel_baton). + * + * Results (the checksum) will be allocated from @a result_pool, and all + * temporary allocations will be performed in @a scratch_pool. + * + * Note: this function replaces the combination of svn_txdelta() and + * svn_txdelta_send_txstream(). + * + * @since New in 1.6. + */ +svn_error_t * +svn_txdelta_run(svn_stream_t *source, + svn_stream_t *target, + svn_txdelta_window_handler_t handler, + void *handler_baton, + svn_checksum_kind_t checksum_kind, + svn_checksum_t **checksum, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** A delta stream --- this is the hat from which we pull a series of + * svn_txdelta_window_t objects, which, taken in order, describe the + * entire target string. This type is defined within libsvn_delta, and + * opaque outside that library. + */ +typedef struct svn_txdelta_stream_t svn_txdelta_stream_t; + + +/** A typedef for a function that will set @a *window to the next + * window from a #svn_txdelta_stream_t object. If there are no more + * delta windows, NULL will be used. The returned window, if any, + * will be allocated in @a pool. @a baton is the baton specified + * when the stream was created. + * + * @since New in 1.4. + */ +typedef svn_error_t * +(*svn_txdelta_next_window_fn_t)(svn_txdelta_window_t **window, + void *baton, + apr_pool_t *pool); + +/** A typedef for a function that will return the md5 checksum of the + * fulltext deltified by a #svn_txdelta_stream_t object. Will + * return NULL if the final null window hasn't yet been returned by + * the stream. The returned value will be allocated in the same pool + * as the stream. @a baton is the baton specified when the stream was + * created. + * + * @since New in 1.4. + */ +typedef const unsigned char * +(*svn_txdelta_md5_digest_fn_t)(void *baton); + +/** Create and return a generic text delta stream with @a baton, @a + * next_window and @a md5_digest. Allocate the new stream in @a + * pool. + * + * @since New in 1.4. + */ +svn_txdelta_stream_t * +svn_txdelta_stream_create(void *baton, + svn_txdelta_next_window_fn_t next_window, + svn_txdelta_md5_digest_fn_t md5_digest, + apr_pool_t *pool); + +/** Set @a *window to a pointer to the next window from the delta stream + * @a stream. When we have completely reconstructed the target string, + * set @a *window to zero. + * + * The window will be allocated in @a pool. + */ +svn_error_t * +svn_txdelta_next_window(svn_txdelta_window_t **window, + svn_txdelta_stream_t *stream, + apr_pool_t *pool); + + +/** Return the md5 digest for the complete fulltext deltified by + * @a stream, or @c NULL if @a stream has not yet returned its final + * @c NULL window. The digest is allocated in the same memory as @a + * STREAM. + */ +const unsigned char * +svn_txdelta_md5_digest(svn_txdelta_stream_t *stream); + +/** Set @a *stream to a pointer to a delta stream that will turn the byte + * string from @a source into the byte stream from @a target. + * + * @a source and @a target are both readable generic streams. When we call + * svn_txdelta_next_window() on @a *stream, it will read from @a source and + * @a target to gather as much data as it needs. If @a calculate_checksum + * is set, you may call svn_txdelta_md5_digest() to get an MD5 checksum + * for @a target. + * + * Do any necessary allocation in a sub-pool of @a pool. + * + * @since New in 1.8. + */ +void +svn_txdelta2(svn_txdelta_stream_t **stream, + svn_stream_t *source, + svn_stream_t *target, + svn_boolean_t calculate_checksum, + apr_pool_t *pool); + +/** Similar to svn_txdelta2 but always calculating the target checksum. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +void +svn_txdelta(svn_txdelta_stream_t **stream, + svn_stream_t *source, + svn_stream_t *target, + apr_pool_t *pool); + + +/** + * Return a writable stream which, when fed target data, will send + * delta windows to @a handler/@a handler_baton which transform the + * data in @a source to the target data. As usual, the window handler + * will receive a NULL window to signify the end of the window stream. + * The stream handler functions will read data from @a source as + * necessary. + * + * @since New in 1.1. + */ +svn_stream_t * +svn_txdelta_target_push(svn_txdelta_window_handler_t handler, + void *handler_baton, + svn_stream_t *source, + apr_pool_t *pool); + + +/** Send the contents of @a string to window-handler @a handler/@a baton. + * This is effectively a 'copy' operation, resulting in delta windows that + * make the target equivalent to the value of @a string. + * + * All temporary allocation is performed in @a pool. + */ +svn_error_t * +svn_txdelta_send_string(const svn_string_t *string, + svn_txdelta_window_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + +/** Send the contents of @a stream to window-handler @a handler/@a baton. + * This is effectively a 'copy' operation, resulting in delta windows that + * make the target equivalent to the stream. + * + * If @a digest is non-NULL, populate it with the md5 checksum for the + * fulltext that was deltified (@a digest must be at least + * @c APR_MD5_DIGESTSIZE bytes long). + * + * All temporary allocation is performed in @a pool. + */ +svn_error_t * +svn_txdelta_send_stream(svn_stream_t *stream, + svn_txdelta_window_handler_t handler, + void *handler_baton, + unsigned char *digest, + apr_pool_t *pool); + +/** Send the contents of @a txstream to window-handler @a handler/@a baton. + * Windows will be extracted from the stream and delivered to the handler. + * + * All temporary allocation is performed in @a pool. + */ +svn_error_t * +svn_txdelta_send_txstream(svn_txdelta_stream_t *txstream, + svn_txdelta_window_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + + +/** Send the @a contents of length @a len as a txdelta against an empty + * source directly to window-handler @a handler/@a handler_baton. + * + * All temporary allocation is performed in @a pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_txdelta_send_contents(const unsigned char *contents, + apr_size_t len, + svn_txdelta_window_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + +/** Prepare to apply a text delta. @a source is a readable generic stream + * yielding the source data, @a target is a writable generic stream to + * write target data to, and allocation takes place in a sub-pool of + * @a pool. On return, @a *handler is set to a window handler function and + * @a *handler_baton is set to the value to pass as the @a baton argument to + * @a *handler. + * + * If @a result_digest is non-NULL, it points to APR_MD5_DIGESTSIZE bytes + * of storage, and the final call to @a handler populates it with the + * MD5 digest of the resulting fulltext. + * + * If @a error_info is non-NULL, it is inserted parenthetically into + * the error string for any error returned by svn_txdelta_apply() or + * @a *handler. (It is normally used to provide path information, + * since there's nothing else in the delta application's context to + * supply a path for error messages.) + * + * @note To avoid lifetime issues, @a error_info is copied into + * @a pool or a subpool thereof. + */ +void +svn_txdelta_apply(svn_stream_t *source, + svn_stream_t *target, + unsigned char *result_digest, + const char *error_info, + apr_pool_t *pool, + svn_txdelta_window_handler_t *handler, + void **handler_baton); + + + + +/*** Producing and consuming svndiff-format text deltas. ***/ + +/** Prepare to produce an svndiff-format diff from text delta windows. + * @a output is a writable generic stream to write the svndiff data to. + * Allocation takes place in a sub-pool of @a pool. On return, @a *handler + * is set to a window handler function and @a *handler_baton is set to + * the value to pass as the @a baton argument to @a *handler. The svndiff + * version is @a svndiff_version. @a compression_level is the zlib + * compression level from 0 (no compression) and 9 (maximum compression). + * + * @since New in 1.7. + */ +void +svn_txdelta_to_svndiff3(svn_txdelta_window_handler_t *handler, + void **handler_baton, + svn_stream_t *output, + int svndiff_version, + int compression_level, + apr_pool_t *pool); + +/** Similar to svn_txdelta_to_svndiff3(), but always using the SVN default + * compression level (#SVN_DELTA_COMPRESSION_LEVEL_DEFAULT). + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +void +svn_txdelta_to_svndiff2(svn_txdelta_window_handler_t *handler, + void **handler_baton, + svn_stream_t *output, + int svndiff_version, + apr_pool_t *pool); + +/** Similar to svn_txdelta_to_svndiff2, but always using svndiff + * version 0. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +void +svn_txdelta_to_svndiff(svn_stream_t *output, + apr_pool_t *pool, + svn_txdelta_window_handler_t *handler, + void **handler_baton); + +/** Return a writable generic stream which will parse svndiff-format + * data into a text delta, invoking @a handler with @a handler_baton + * whenever a new window is ready. If @a error_on_early_close is @c + * TRUE, attempting to close this stream before it has handled the entire + * svndiff data set will result in #SVN_ERR_SVNDIFF_UNEXPECTED_END, + * else this error condition will be ignored. + */ +svn_stream_t * +svn_txdelta_parse_svndiff(svn_txdelta_window_handler_t handler, + void *handler_baton, + svn_boolean_t error_on_early_close, + apr_pool_t *pool); + +/** + * Read and parse one delta window in svndiff format from the + * readable stream @a stream and place it in @a *window, allocating + * the result in @a pool. The caller must take responsibility for + * stripping off the four-byte 'SVN@<ver@>' header at the beginning of + * the svndiff document before reading the first window, and must + * provide the version number (the value of the fourth byte) to each + * invocation of this routine with the @a svndiff_version argument. + * + * @since New in 1.1. + */ +svn_error_t * +svn_txdelta_read_svndiff_window(svn_txdelta_window_t **window, + svn_stream_t *stream, + int svndiff_version, + apr_pool_t *pool); + +/** + * Read and skip one delta window in svndiff format from the + * file @a file. @a pool is used for temporary allocations. The + * caller must take responsibility for stripping off the four-byte + * 'SVN@<ver@>' header at the beginning of the svndiff document before + * reading or skipping the first window, and must provide the version + * number (the value of the fourth byte) to each invocation of this + * routine with the @a svndiff_version argument. + * + * @since New in 1.1. + */ +svn_error_t * +svn_txdelta_skip_svndiff_window(apr_file_t *file, + int svndiff_version, + apr_pool_t *pool); + +/** @} */ + + +/** Traversing tree deltas. + * + * In Subversion, we've got various producers and consumers of tree + * deltas. + * + * In processing a `commit' command: + * - The client examines its working copy data, and produces a tree + * delta describing the changes to be committed. + * - The client networking library consumes that delta, and sends them + * across the wire as an equivalent series of network requests (for + * example, to svnserve as an ra_svn protocol stream, or to an + * Apache httpd server as WebDAV commands) + * - The server receives those requests and produces a tree delta --- + * hopefully equivalent to the one the client produced above. + * - The Subversion server module consumes that delta and commits an + * appropriate transaction to the filesystem. + * + * In processing an `update' command, the process is reversed: + * - The Subversion server module talks to the filesystem and produces + * a tree delta describing the changes necessary to bring the + * client's working copy up to date. + * - The server consumes this delta, and assembles a reply + * representing the appropriate changes. + * - The client networking library receives that reply, and produces a + * tree delta --- hopefully equivalent to the one the Subversion + * server produced above. + * - The working copy library consumes that delta, and makes the + * appropriate changes to the working copy. + * + * The simplest approach would be to represent tree deltas using the + * obvious data structure. To do an update, the server would + * construct a delta structure, and the working copy library would + * apply that structure to the working copy; the network layer's job + * would simply be to get the structure across the net intact. + * + * However, we expect that these deltas will occasionally be too large + * to fit in a typical workstation's swap area. For example, in + * checking out a 200Mb source tree, the entire source tree is + * represented by a single tree delta. So it's important to handle + * deltas that are too large to fit in swap all at once. + * + * So instead of representing the tree delta explicitly, we define a + * standard way for a consumer to process each piece of a tree delta + * as soon as the producer creates it. The #svn_delta_editor_t + * structure is a set of callback functions to be defined by a delta + * consumer, and invoked by a delta producer. Each invocation of a + * callback function describes a piece of the delta --- a file's + * contents changing, something being renamed, etc. + * + * @defgroup svn_delta_tree_deltas Tree deltas + * @{ + */ + +/** A structure full of callback functions the delta source will invoke + * as it produces the delta. + * + * @note Don't try to allocate one of these yourself. Instead, always + * use svn_delta_default_editor() or some other constructor, to ensure + * that unused slots are filled in with no-op functions. + * + * <h3>Function Usage</h3> + * + * Here's how to use these functions to express a tree delta. + * + * The delta consumer implements the callback functions described in + * this structure, and the delta producer invokes them. So the + * caller (producer) is pushing tree delta data at the callee + * (consumer). + * + * At the start of traversal, the consumer provides @a edit_baton, a + * baton global to the entire delta edit. If there is a target + * revision that needs to be set for this operation, the producer + * should call the @c set_target_revision function at this point. + * + * Next, if there are any tree deltas to express, the producer should + * pass the @a edit_baton to the @c open_root function, to get a baton + * representing root of the tree being edited. + * + * Most of the callbacks work in the obvious way: + * + * @c delete_entry + * @c add_file + * @c add_directory + * @c open_file + * @c open_directory + * + * Each of these takes a directory baton, indicating the directory + * in which the change takes place, and a @a path argument, giving the + * path of the file, subdirectory, or directory entry to change. + * + * The @a path argument to each of the callbacks is relative to the + * root of the edit. Editors will usually want to join this relative + * path with some base stored in the edit baton (e.g. a URL, or a + * location in the OS filesystem). + * + * Since every call requires a parent directory baton, including + * @c add_directory and @c open_directory, where do we ever get our + * initial directory baton, to get things started? The @c open_root + * function returns a baton for the top directory of the change. In + * general, the producer needs to invoke the editor's @c open_root + * function before it can get anything of interest done. + * + * While @c open_root provides a directory baton for the root of + * the tree being changed, the @c add_directory and @c open_directory + * callbacks provide batons for other directories. Like the + * callbacks above, they take a @a parent_baton and a relative path + * @a path, and then return a new baton for the subdirectory being + * created / modified --- @a child_baton. The producer can then use + * @a child_baton to make further changes in that subdirectory. + * + * So, if we already have subdirectories named `foo' and `foo/bar', + * then the producer can create a new file named `foo/bar/baz.c' by + * calling: + * + * - @c open_root () --- yielding a baton @a root for the top directory + * + * - @c open_directory (@a root, "foo") --- yielding a baton @a f for `foo' + * + * - @c open_directory (@a f, "foo/bar") --- yielding a baton @a b for + * `foo/bar' + * + * - @c add_file (@a b, "foo/bar/baz.c") + * + * When the producer is finished making changes to a directory, it + * should call @c close_directory. This lets the consumer do any + * necessary cleanup, and free the baton's storage. + * + * The @c add_file and @c open_file callbacks each return a baton + * for the file being created or changed. This baton can then be + * passed to @c apply_textdelta to change the file's contents, or + * @c change_file_prop to change the file's properties. When the + * producer is finished making changes to a file, it should call + * @c close_file, to let the consumer clean up and free the baton. + * + * The @c add_file and @c add_directory functions each take arguments + * @a copyfrom_path and @a copyfrom_revision. If @a copyfrom_path is + * non-@c NULL, then @a copyfrom_path and @a copyfrom_revision indicate where + * the file or directory should be copied from (to create the file + * or directory being added). In that case, @a copyfrom_path must be + * either a path relative to the root of the edit, or a URI from the + * repository being edited. If @a copyfrom_path is @c NULL, then @a + * copyfrom_revision must be #SVN_INVALID_REVNUM; it is invalid to + * pass a mix of valid and invalid copyfrom arguments. + * + * + * <h3>Function Call Ordering</h3> + * + * There are six restrictions on the order in which the producer + * may use the batons: + * + * 1. The producer may call @c open_directory, @c add_directory, + * @c open_file, @c add_file at most once on any given directory + * entry. @c delete_entry may be called at most once on any given + * directory entry and may later be followed by @c add_directory or + * @c add_file on the same directory entry. @c delete_entry may + * not be called on any directory entry after @c open_directory, + * @c add_directory, @c open_file or @c add_file has been called on + * that directory entry. + * + * 2. The producer may not close a directory baton until it has + * closed all batons for its subdirectories. + * + * 3. When a producer calls @c open_directory or @c add_directory, + * it must specify the most recently opened of the currently open + * directory batons. Put another way, the producer cannot have + * two sibling directory batons open at the same time. + * + * 4. A producer must call @c change_dir_prop on a directory either + * before opening any of the directory's subdirs or after closing + * them, but not in the middle. + * + * 5. When the producer calls @c open_file or @c add_file, either: + * + * (a) The producer must follow with any changes to the file + * (@c change_file_prop and/or @c apply_textdelta, as applicable), + * followed by a @c close_file call, before issuing any other file + * or directory calls, or + * + * (b) The producer must follow with a @c change_file_prop call if + * it is applicable, before issuing any other file or directory + * calls; later, after all directory batons including the root + * have been closed, the producer must issue @c apply_textdelta + * and @c close_file calls. + * + * 6. When the producer calls @c apply_textdelta, it must make all of + * the window handler calls (including the @c NULL window at the + * end) before issuing any other #svn_delta_editor_t calls. + * + * So, the producer needs to use directory and file batons as if it + * is doing a single depth-first traversal of the tree, with the + * exception that the producer may keep file batons open in order to + * make @c apply_textdelta calls at the end. + * + * + * <h3>Pool Usage</h3> + * + * Many editor functions are invoked multiple times, in a sequence + * determined by the editor "driver". The driver is responsible for + * creating a pool for use on each iteration of the editor function, + * and clearing that pool between each iteration. The driver passes + * the appropriate pool on each function invocation. + * + * Based on the requirement of calling the editor functions in a + * depth-first style, it is usually customary for the driver to similarly + * nest the pools. However, this is only a safety feature to ensure + * that pools associated with deeper items are always cleared when the + * top-level items are also cleared. The interface does not assume, nor + * require, any particular organization of the pools passed to these + * functions. In fact, if "postfix deltas" are used for files, the file + * pools definitely need to live outside the scope of their parent + * directories' pools. + * + * Note that close_directory can be called *before* a file in that + * directory has been closed. That is, the directory's baton is + * closed before the file's baton. The implication is that + * @c apply_textdelta and @c close_file should not refer to a parent + * directory baton UNLESS the editor has taken precautions to + * allocate it in a pool of the appropriate lifetime (the @a dir_pool + * passed to @c open_directory and @c add_directory definitely does not + * have the proper lifetime). In general, it is recommended to simply + * avoid keeping a parent directory baton in a file baton. + * + * + * <h3>Errors</h3> + * + * At least one implementation of the editor interface is + * asynchronous; an error from one operation may be detected some + * number of operations later. As a result, an editor driver must not + * assume that an error from an editing function resulted from the + * particular operation being detected. Moreover, once an editing + * function (including @c close_edit) returns an error, the edit is + * dead; the only further operation which may be called on the editor + * is @c abort_edit. + */ +typedef struct svn_delta_editor_t +{ + /** Set the target revision for this edit to @a target_revision. This + * call, if used, should precede all other editor calls. + * + * @note This is typically used only for server->client update-type + * operations. It doesn't really make much sense for commit-type + * operations, because the revision of a commit isn't known until + * the commit is finalized. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*set_target_revision)(void *edit_baton, + svn_revnum_t target_revision, + apr_pool_t *scratch_pool); + + /** Set @a *root_baton to a baton for the top directory of the change. + * (This is the top of the subtree being changed, not necessarily + * the root of the filesystem.) As with any other directory baton, the + * producer should call @c close_directory on @a root_baton when done. + * And as with other @c open_* calls, the @a base_revision here is the + * current revision of the directory (before getting bumped up to the + * new target revision set with @c set_target_revision). + * + * Allocations for the returned @a root_baton should be performed in + * @a result_pool. It is also typical to (possibly) save this pool for + * later usage by @c close_directory. + */ + svn_error_t *(*open_root)(void *edit_baton, + svn_revnum_t base_revision, + apr_pool_t *result_pool, + void **root_baton); + + + /** Remove the directory entry at @a path, a child of the directory + * represented by @a parent_baton. If @a revision is a valid + * revision number, it is used as a sanity check to ensure that you + * are really removing the revision of @a path that you think you are. + * + * Any temporary allocations may be performed in @a scratch_pool. + * + * @note The @a revision parameter is typically used only for + * client->server commit-type operations, allowing the server to + * verify that it is deleting what the client thinks it should be + * deleting. It only really makes sense in the opposite direction + * (during server->client update-type operations) when the trees + * whose delta is being described are ancestrally related (that is, + * one tree is an ancestor of the other). + */ + svn_error_t *(*delete_entry)(const char *path, + svn_revnum_t revision, + void *parent_baton, + apr_pool_t *scratch_pool); + + + /** We are going to add a new subdirectory at @a path, a child of + * the directory represented by @a parent_baton. We will use + * the value this callback stores in @a *child_baton as the + * parent baton for further changes in the new subdirectory. + * + * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a + * copy), and the origin of the copy may be recorded as + * @a copyfrom_path under @a copyfrom_revision. + * + * Allocations for the returned @a child_baton should be performed in + * @a result_pool. It is also typical to (possibly) save this pool for + * later usage by @c close_directory. + */ + svn_error_t *(*add_directory)(const char *path, + void *parent_baton, + const char *copyfrom_path, + svn_revnum_t copyfrom_revision, + apr_pool_t *result_pool, + void **child_baton); + + /** We are going to make changes in the subdirectory at @a path, a + * child of the directory represented by @a parent_baton. + * The callback must store a value in @a *child_baton that + * should be used as the parent baton for subsequent changes in this + * subdirectory. If a valid revnum, @a base_revision is the current + * revision of the subdirectory. + * + * Allocations for the returned @a child_baton should be performed in + * @a result_pool. It is also typical to (possibly) save this pool for + * later usage by @c close_directory. + */ + svn_error_t *(*open_directory)(const char *path, + void *parent_baton, + svn_revnum_t base_revision, + apr_pool_t *result_pool, + void **child_baton); + + /** Change the value of a directory's property. + * - @a dir_baton specifies the directory whose property should change. + * - @a name is the name of the property to change. + * - @a value is the new (final) value of the property, or @c NULL if the + * property should be removed altogether. + * + * The callback is guaranteed to be called exactly once for each property + * whose value differs between the start and the end of the edit. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*change_dir_prop)(void *dir_baton, + const char *name, + const svn_string_t *value, + apr_pool_t *scratch_pool); + + /** We are done processing a subdirectory, whose baton is @a dir_baton + * (set by @c add_directory or @c open_directory). We won't be using + * the baton any more, so whatever resources it refers to may now be + * freed. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*close_directory)(void *dir_baton, + apr_pool_t *scratch_pool); + + + /** In the directory represented by @a parent_baton, indicate that + * @a path is present as a subdirectory in the edit source, but + * cannot be conveyed to the edit consumer. Currently, this would + * only occur because of authorization restrictions, but may change + * in the future. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*absent_directory)(const char *path, + void *parent_baton, + apr_pool_t *scratch_pool); + + /** We are going to add a new file at @a path, a child of the + * directory represented by @a parent_baton. The callback can + * store a baton for this new file in @a **file_baton; whatever value + * it stores there should be passed through to @c apply_textdelta. + * + * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a + * copy), and the origin of the copy may be recorded as + * @a copyfrom_path under @a copyfrom_revision. + * + * Allocations for the returned @a file_baton should be performed in + * @a result_pool. It is also typical to save this pool for later usage + * by @c apply_textdelta and possibly @c close_file. + * + * @note Because the editor driver could be employing the "postfix + * deltas" paradigm, @a result_pool could potentially be relatively + * long-lived. Every file baton created by the editor for a given + * editor drive might be resident in memory similtaneously. Editor + * implementations should ideally keep their file batons as + * conservative (memory-usage-wise) as possible, and use @a result_pool + * only for those batons. (Consider using a subpool of @a result_pool + * for scratch work, destroying the subpool before exiting this + * function's implementation.) + */ + svn_error_t *(*add_file)(const char *path, + void *parent_baton, + const char *copyfrom_path, + svn_revnum_t copyfrom_revision, + apr_pool_t *result_pool, + void **file_baton); + + /** We are going to make changes to a file at @a path, a child of the + * directory represented by @a parent_baton. + * + * The callback can store a baton for this new file in @a **file_baton; + * whatever value it stores there should be passed through to + * @c apply_textdelta. If a valid revnum, @a base_revision is the + * current revision of the file. + * + * Allocations for the returned @a file_baton should be performed in + * @a result_pool. It is also typical to save this pool for later usage + * by @c apply_textdelta and possibly @c close_file. + * + * @note See note about memory usage on @a add_file, which also + * applies here. + */ + svn_error_t *(*open_file)(const char *path, + void *parent_baton, + svn_revnum_t base_revision, + apr_pool_t *result_pool, + void **file_baton); + + /** Apply a text delta, yielding the new revision of a file. + * + * @a file_baton indicates the file we're creating or updating, and the + * ancestor file on which it is based; it is the baton set by some + * prior @c add_file or @c open_file callback. + * + * The callback should set @a *handler to a text delta window + * handler; we will then call @a *handler on successive text + * delta windows as we receive them. The callback should set + * @a *handler_baton to the value we should pass as the @a baton + * argument to @a *handler. These values should be allocated within + * @a result_pool. + * + * @a base_checksum is the hex MD5 digest for the base text against + * which the delta is being applied; it is ignored if NULL, and may + * be ignored even if not NULL. If it is not ignored, it must match + * the checksum of the base text against which svndiff data is being + * applied; if it does not, @c apply_textdelta or the @a *handler call + * which detects the mismatch will return the error + * SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may + * still be an error if @a base_checksum is neither NULL nor the hex + * MD5 checksum of the empty string). + */ + svn_error_t *(*apply_textdelta)(void *file_baton, + const char *base_checksum, + apr_pool_t *result_pool, + svn_txdelta_window_handler_t *handler, + void **handler_baton); + + /** Change the value of a file's property. + * - @a file_baton specifies the file whose property should change. + * - @a name is the name of the property to change. + * - @a value is the new (final) value of the property, or @c NULL if the + * property should be removed altogether. + * + * The callback is guaranteed to be called exactly once for each property + * whose value differs between the start and the end of the edit. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*change_file_prop)(void *file_baton, + const char *name, + const svn_string_t *value, + apr_pool_t *scratch_pool); + + /** We are done processing a file, whose baton is @a file_baton (set by + * @c add_file or @c open_file). We won't be using the baton any + * more, so whatever resources it refers to may now be freed. + * + * @a text_checksum is the hex MD5 digest for the fulltext that + * resulted from a delta application, see @c apply_textdelta. The + * checksum is ignored if NULL. If not null, it is compared to the + * checksum of the new fulltext, and the error + * SVN_ERR_CHECKSUM_MISMATCH is returned if they do not match. If + * there is no new fulltext, @a text_checksum is ignored. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*close_file)(void *file_baton, + const char *text_checksum, + apr_pool_t *scratch_pool); + + /** In the directory represented by @a parent_baton, indicate that + * @a path is present as a file in the edit source, but cannot be + * cannot be conveyed to the edit consumer. Currently, this would + * only occur because of authorization restrictions, but may change + * in the future. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*absent_file)(const char *path, + void *parent_baton, + apr_pool_t *scratch_pool); + + /** All delta processing is done. Call this, with the @a edit_baton for + * the entire edit. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*close_edit)(void *edit_baton, + apr_pool_t *scratch_pool); + + /** The editor-driver has decided to bail out. Allow the editor to + * gracefully clean up things if it needs to. + * + * Any temporary allocations may be performed in @a scratch_pool. + */ + svn_error_t *(*abort_edit)(void *edit_baton, + apr_pool_t *scratch_pool); + + /* Be sure to update svn_delta_get_cancellation_editor() and + * svn_delta_default_editor() if you add a new callback here. */ +} svn_delta_editor_t; + + +/** Return a default delta editor template, allocated in @a pool. + * + * The editor functions in the template do only the most basic + * baton-swapping: each editor function that produces a baton does so + * by copying its incoming baton into the outgoing baton reference. + * + * This editor is not intended to be useful by itself, but is meant to + * be the basis for a useful editor. After getting a default editor, + * you substitute in your own implementations for the editor functions + * you care about. The ones you don't care about, you don't have to + * implement -- you can rely on the template's implementation to + * safely do nothing of consequence. + */ +svn_delta_editor_t * +svn_delta_default_editor(apr_pool_t *pool); + +/** A text-delta window handler which does nothing. + * + * Editors can return this handler from @c apply_textdelta if they don't + * care about text delta windows. + */ +svn_error_t * +svn_delta_noop_window_handler(svn_txdelta_window_t *window, + void *baton); + +/** Set @a *editor and @a *edit_baton to a cancellation editor that + * wraps @a wrapped_editor and @a wrapped_baton. + * + * The @a editor will call @a cancel_func with @a cancel_baton when each of + * its functions is called, continuing on to call the corresponding wrapped + * function if @a cancel_func returns #SVN_NO_ERROR. + * + * If @a cancel_func is @c NULL, set @a *editor to @a wrapped_editor and + * @a *edit_baton to @a wrapped_baton. + */ +svn_error_t * +svn_delta_get_cancellation_editor(svn_cancel_func_t cancel_func, + void *cancel_baton, + const svn_delta_editor_t *wrapped_editor, + void *wrapped_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_pool_t *pool); + +/** Set @a *editor and @a *edit_baton to an depth-based filtering + * editor that wraps @a wrapped_editor and @a wrapped_baton. + * + * The @a editor will track the depth of this drive against the @a + * requested_depth, taking into account whether not the edit drive is + * making use of a target (via @a has_target), and forward editor + * calls which operate "within" the request depth range through to @a + * wrapped_editor. + * + * @a requested_depth must be one of the following depth values: + * #svn_depth_infinity, #svn_depth_empty, #svn_depth_files, + * #svn_depth_immediates, or #svn_depth_unknown. + * + * If filtering is deemed unnecessary (or if @a requested_depth is + * #svn_depth_unknown), @a *editor and @a *edit_baton will be set to @a + * wrapped_editor and @a wrapped_baton, respectively; otherwise, + * they'll be set to new objects allocated from @a pool. + * + * @note Because the svn_delta_editor_t interface's @c delete_entry() + * function doesn't carry node kind information, a depth-based + * filtering editor being asked to filter for #svn_depth_files but + * receiving a @c delete_entry() call on an immediate child of the + * editor's target is unable to know if that deletion should be + * allowed or filtered out -- a delete of a top-level file is okay in + * this case, a delete of a top-level subdirectory is not. As such, + * this filtering editor takes a conservative approach, and ignores + * top-level deletion requests when filtering for #svn_depth_files. + * Fortunately, most non-depth-aware (pre-1.5) Subversion editor + * drivers can be told to drive non-recursively (where non-recursive + * means essentially #svn_depth_files), which means they won't + * transmit out-of-scope editor commands anyway. + * + * @since New in 1.5. + */ +svn_error_t * +svn_delta_depth_filter_editor(const svn_delta_editor_t **editor, + void **edit_baton, + const svn_delta_editor_t *wrapped_editor, + void *wrapped_edit_baton, + svn_depth_t requested_depth, + svn_boolean_t has_target, + apr_pool_t *pool); + +/** @} */ + + +/** Path-based editor drives. + * + * @defgroup svn_delta_path_delta_drivers Path-based delta drivers + * @{ + */ + +/** Callback function type for svn_delta_path_driver(). + * + * The handler of this callback is given the callback baton @a + * callback_baton, @a path which is a relpath relative to the + * root of the edit, and the @a parent_baton which represents + * path's parent directory as created by the editor passed to + * svn_delta_path_driver(). + * + * If @a path represents a directory, the handler must return a @a + * *dir_baton for @a path, generated from the same editor (so that the + * driver can later close that directory). + * + * If, however, @a path represents a file, the handler should NOT + * return any file batons. It can close any opened or added files + * immediately, or delay that close until the end of the edit when + * svn_delta_path_driver() returns. + * + * Finally, if @a parent_baton is @c NULL, then the root of the edit + * is also one of the paths passed to svn_delta_path_driver(). The + * handler of this callback must call the editor's open_root() + * function and return the top-level root dir baton in @a *dir_baton. + */ +typedef svn_error_t *(*svn_delta_path_driver_cb_func_t)( + void **dir_baton, + void *parent_baton, + void *callback_baton, + const char *path, + apr_pool_t *pool); + + +/** Drive @a editor (with its @a edit_baton) to visit each path in @a paths. + * As each path is hit as part of the editor drive, use + * @a callback_func and @a callback_baton to allow the caller to handle + * the portion of the editor drive related to that path. + * + * Each path in @a paths is a (const char *) relpath, relative + * to the root path of the @a edit. The editor drive will be + * performed in the same order as @a paths. The paths should be sorted + * using something like svn_sort_compare_paths to ensure that a depth-first + * pattern is observed for directory/file baton creation. If @a sort_paths + * is set, the function will sort the paths for you. Some callers may need + * further customization of the order (ie. libsvn_delta/compat.c). + * + * Use @a scratch_pool for all necessary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_delta_path_driver2(const svn_delta_editor_t *editor, + void *edit_baton, + const apr_array_header_t *paths, + svn_boolean_t sort_paths, + svn_delta_path_driver_cb_func_t callback_func, + void *callback_baton, + apr_pool_t *scratch_pool); + + +/** Similar to svn_delta_path_driver2, but takes an (unused) revision, + * and will sort the provided @a paths using svn_sort_compare_paths. + * + * @note In versions prior to 1.8, this function would modify the order + * of elements in @a paths, despite the 'const' marker on the parameter. + * This has been fixed in 1.8. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_delta_path_driver(const svn_delta_editor_t *editor, + void *edit_baton, + svn_revnum_t revision, + const apr_array_header_t *paths, + svn_delta_path_driver_cb_func_t callback_func, + void *callback_baton, + apr_pool_t *scratch_pool); + +/** @} */ + + +/*** File revision iterator types ***/ + +/** + * The callback invoked by file rev loopers, such as + * svn_ra_plugin_t.get_file_revs2() and svn_repos_get_file_revs2(). + * + * @a baton is provided by the caller, @a path is the pathname of the file + * in revision @a rev and @a rev_props are the revision properties. + * + * If @a delta_handler and @a delta_baton are non-NULL, they may be set to a + * handler/baton which will be called with the delta between the previous + * revision and this one after the return of this callback. They may be + * left as NULL/NULL. + * + * @a result_of_merge will be @c TRUE if the revision being returned was + * included as the result of a merge. + * + * @a prop_diffs is an array of svn_prop_t elements indicating the property + * delta for this and the previous revision. + * + * @a pool may be used for temporary allocations, but you can't rely + * on objects allocated to live outside of this particular call and + * the immediately following calls to @a *delta_handler if any. (Pass + * in a pool via @a baton if need be.) + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_file_rev_handler_t)( + void *baton, + const char *path, + svn_revnum_t rev, + apr_hash_t *rev_props, + svn_boolean_t result_of_merge, + svn_txdelta_window_handler_t *delta_handler, + void **delta_baton, + apr_array_header_t *prop_diffs, + apr_pool_t *pool); + +/** + * The old file rev handler interface. + * + * @note #svn_file_rev_handler_old_t is a placeholder type for both + * #svn_repos_file_rev_handler_t and #svn_ra_file_rev_handler_t. It is + * reproduced here for dependency reasons. + * + * @deprecated This type is provided for the svn_compat_wrap_file_rev_handler() + * compatibility wrapper, and should not be used for new development. + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_file_rev_handler_old_t)( + void *baton, + const char *path, + svn_revnum_t rev, + apr_hash_t *rev_props, + svn_txdelta_window_handler_t *delta_handler, + void **delta_baton, + apr_array_header_t *prop_diffs, + apr_pool_t *pool); + +/** Return, in @a *handler2 and @a *handler2_baton a function/baton that + * will call @a handler/@a handler_baton, allocating the @a *handler2_baton + * in @a pool. + * + * @note This is used by compatibility wrappers, which exist in more than + * Subversion core library. + * + * @note #svn_file_rev_handler_old_t is a placeholder type for both + * #svn_repos_file_rev_handler_t and #svn_ra_file_rev_handler_t. It is + * reproduced here for dependency reasons. + * + * @since New in 1.5. + */ +void +svn_compat_wrap_file_rev_handler(svn_file_rev_handler_t *handler2, + void **handler2_baton, + svn_file_rev_handler_old_t handler, + void *handler_baton, + apr_pool_t *pool); + +/** @} end group: delta_support */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DELTA_H */ diff --git a/subversion/include/svn_diff.h b/subversion/include/svn_diff.h new file mode 100644 index 0000000..23b8970 --- /dev/null +++ b/subversion/include/svn_diff.h @@ -0,0 +1,1118 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_diff.h + * @brief Contextual diffing. + * + * This is an internalized library for performing contextual diffs + * between sources of data. + * + * @note This is different than Subversion's binary-diffing engine. + * That API lives in @c svn_delta.h -- see the "text deltas" section. A + * "text delta" is way of representing precise binary diffs between + * strings of data. The Subversion client and server send text deltas + * to one another during updates and commits. + * + * This API, however, is (or will be) used for performing *contextual* + * merges between files in the working copy. During an update or + * merge, 3-way file merging is needed. And 'svn diff' needs to show + * the differences between 2 files. + * + * The nice thing about this API is that it's very general. It + * operates on any source of data (a "datasource") and calculates + * contextual differences on "tokens" within the data. In our + * particular usage, the datasources are files and the tokens are + * lines. But the possibilities are endless. + */ + + +#ifndef SVN_DIFF_H +#define SVN_DIFF_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_tables.h> /* for apr_array_header_t */ + +#include "svn_types.h" +#include "svn_io.h" /* for svn_stream_t */ +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** + * Get libsvn_diff version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_diff_version(void); + + +/* Diffs. */ + +/** An opaque type that represents a difference between either two or + * three datasources. This object is returned by svn_diff_diff(), + * svn_diff_diff3() and svn_diff_diff4(), and consumed by a number of + * other routines. + */ +typedef struct svn_diff_t svn_diff_t; + +/** + * There are four types of datasources. In GNU diff3 terminology, + * the first three types correspond to the phrases "older", "mine", + * and "yours". + */ +typedef enum svn_diff_datasource_e +{ + /** The oldest form of the data. */ + svn_diff_datasource_original, + + /** The same data, but potentially changed by the user. */ + svn_diff_datasource_modified, + + /** The latest version of the data, possibly different than the + * user's modified version. + */ + svn_diff_datasource_latest, + + /** The common ancestor of original and modified. */ + svn_diff_datasource_ancestor + +} svn_diff_datasource_e; + + +/** A vtable for reading data from the three datasources. + * @since New in 1.7. */ +typedef struct svn_diff_fns2_t +{ + /** Open the datasources of type @a datasources. */ + svn_error_t *(*datasources_open)(void *diff_baton, + apr_off_t *prefix_lines, + apr_off_t *suffix_lines, + const svn_diff_datasource_e *datasources, + apr_size_t datasources_len); + + /** Close the datasource of type @a datasource. */ + svn_error_t *(*datasource_close)(void *diff_baton, + svn_diff_datasource_e datasource); + + /** Get the next "token" from the datasource of type @a datasource. + * Return a "token" in @a *token. Return a hash of "token" in @a *hash. + * Leave @a token and @a hash untouched when the datasource is exhausted. + */ + svn_error_t *(*datasource_get_next_token)(apr_uint32_t *hash, void **token, + void *diff_baton, + svn_diff_datasource_e datasource); + + /** A function for ordering the tokens, resembling 'strcmp' in functionality. + * @a compare should contain the return value of the comparison: + * If @a ltoken and @a rtoken are "equal", return 0. If @a ltoken is + * "less than" @a rtoken, return a number < 0. If @a ltoken is + * "greater than" @a rtoken, return a number > 0. + */ + svn_error_t *(*token_compare)(void *diff_baton, + void *ltoken, + void *rtoken, + int *compare); + + /** Free @a token from memory, the diff algorithm is done with it. */ + void (*token_discard)(void *diff_baton, + void *token); + + /** Free *all* tokens from memory, they're no longer needed. */ + void (*token_discard_all)(void *diff_baton); +} svn_diff_fns2_t; + + +/** Like #svn_diff_fns2_t except with datasource_open() instead of + * datasources_open(). + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef struct svn_diff_fns_t +{ + svn_error_t *(*datasource_open)(void *diff_baton, + svn_diff_datasource_e datasource); + + svn_error_t *(*datasource_close)(void *diff_baton, + svn_diff_datasource_e datasource); + + svn_error_t *(*datasource_get_next_token)(apr_uint32_t *hash, void **token, + void *diff_baton, + svn_diff_datasource_e datasource); + + svn_error_t *(*token_compare)(void *diff_baton, + void *ltoken, + void *rtoken, + int *compare); + + void (*token_discard)(void *diff_baton, + void *token); + + void (*token_discard_all)(void *diff_baton); +} svn_diff_fns_t; + + +/* The Main Events */ + +/** Given a vtable of @a diff_fns/@a diff_baton for reading datasources, + * return a diff object in @a *diff that represents a difference between + * an "original" and "modified" datasource. Do all allocation in @a pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_diff_diff_2(svn_diff_t **diff, + void *diff_baton, + const svn_diff_fns2_t *diff_fns, + apr_pool_t *pool); + +/** Like svn_diff_diff_2() but using #svn_diff_fns_t instead of + * #svn_diff_fns2_t. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_diff(svn_diff_t **diff, + void *diff_baton, + const svn_diff_fns_t *diff_fns, + apr_pool_t *pool); + +/** Given a vtable of @a diff_fns/@a diff_baton for reading datasources, + * return a diff object in @a *diff that represents a difference between + * three datasources: "original", "modified", and "latest". Do all + * allocation in @a pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_diff_diff3_2(svn_diff_t **diff, + void *diff_baton, + const svn_diff_fns2_t *diff_fns, + apr_pool_t *pool); + +/** Like svn_diff_diff3_2() but using #svn_diff_fns_t instead of + * #svn_diff_fns2_t. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_diff3(svn_diff_t **diff, + void *diff_baton, + const svn_diff_fns_t *diff_fns, + apr_pool_t *pool); + +/** Given a vtable of @a diff_fns/@a diff_baton for reading datasources, + * return a diff object in @a *diff that represents a difference between + * two datasources: "original" and "latest", adjusted to become a full + * difference between "original", "modified" and "latest" using "ancestor". + * Do all allocation in @a pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_diff_diff4_2(svn_diff_t **diff, + void *diff_baton, + const svn_diff_fns2_t *diff_fns, + apr_pool_t *pool); + +/** Like svn_diff_diff4_2() but using #svn_diff_fns_t instead of + * #svn_diff_fns2_t. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_diff4(svn_diff_t **diff, + void *diff_baton, + const svn_diff_fns_t *diff_fns, + apr_pool_t *pool); + + +/* Utility functions */ + +/** Determine if a diff object contains conflicts. If it does, return + * @c TRUE, else return @c FALSE. + */ +svn_boolean_t +svn_diff_contains_conflicts(svn_diff_t *diff); + + +/** Determine if a diff object contains actual differences between the + * datasources. If so, return @c TRUE, else return @c FALSE. + */ +svn_boolean_t +svn_diff_contains_diffs(svn_diff_t *diff); + + + + +/* Displaying Diffs */ + +/** A vtable for displaying (or consuming) differences between datasources. + * + * Differences, similarities, and conflicts are described by lining up + * "ranges" of data. + * + * Any of the function pointers in this vtable may be NULL to ignore the + * corresponding kinds of output. + * + * @note These callbacks describe data ranges in units of "tokens". + * A "token" is whatever you've defined it to be in your datasource + * @c svn_diff_fns_t vtable. + */ +typedef struct svn_diff_output_fns_t +{ + /* Two-way and three-way diffs both call the first two output functions: */ + + /** + * If doing a two-way diff, then an *identical* data range was found + * between the "original" and "modified" datasources. Specifically, + * the match starts at @a original_start and goes for @a original_length + * tokens in the original data, and at @a modified_start for + * @a modified_length tokens in the modified data. + * + * If doing a three-way diff, then all three datasources have + * matching data ranges. The range @a latest_start, @a latest_length in + * the "latest" datasource is identical to the range @a original_start, + * @a original_length in the original data, and is also identical to + * the range @a modified_start, @a modified_length in the modified data. + */ + svn_error_t *(*output_common)(void *output_baton, + apr_off_t original_start, + apr_off_t original_length, + apr_off_t modified_start, + apr_off_t modified_length, + apr_off_t latest_start, + apr_off_t latest_length); + + /** + * If doing a two-way diff, then an *conflicting* data range was found + * between the "original" and "modified" datasources. Specifically, + * the conflict starts at @a original_start and goes for @a original_length + * tokens in the original data, and at @a modified_start for + * @a modified_length tokens in the modified data. + * + * If doing a three-way diff, then an identical data range was discovered + * between the "original" and "latest" datasources, but this conflicts with + * a range in the "modified" datasource. + */ + svn_error_t *(*output_diff_modified)(void *output_baton, + apr_off_t original_start, + apr_off_t original_length, + apr_off_t modified_start, + apr_off_t modified_length, + apr_off_t latest_start, + apr_off_t latest_length); + + /* ------ The following callbacks are used by three-way diffs only --- */ + + /** An identical data range was discovered between the "original" and + * "modified" datasources, but this conflicts with a range in the + * "latest" datasource. + */ + svn_error_t *(*output_diff_latest)(void *output_baton, + apr_off_t original_start, + apr_off_t original_length, + apr_off_t modified_start, + apr_off_t modified_length, + apr_off_t latest_start, + apr_off_t latest_length); + + /** An identical data range was discovered between the "modified" and + * "latest" datasources, but this conflicts with a range in the + * "original" datasource. + */ + svn_error_t *(*output_diff_common)(void *output_baton, + apr_off_t original_start, + apr_off_t original_length, + apr_off_t modified_start, + apr_off_t modified_length, + apr_off_t latest_start, + apr_off_t latest_length); + + /** All three datasources have conflicting data ranges. The range + * @a latest_start, @a latest_length in the "latest" datasource conflicts + * with the range @a original_start, @a original_length in the "original" + * datasource, and also conflicts with the range @a modified_start, + * @a modified_length in the "modified" datasource. + * If there are common ranges in the "modified" and "latest" datasources + * in this conflicting range, @a resolved_diff will contain a diff + * which can be used to retrieve the common and conflicting ranges. + */ + svn_error_t *(*output_conflict)(void *output_baton, + apr_off_t original_start, + apr_off_t original_length, + apr_off_t modified_start, + apr_off_t modified_length, + apr_off_t latest_start, + apr_off_t latest_length, + svn_diff_t *resolved_diff); +} svn_diff_output_fns_t; + +/** Style for displaying conflicts during diff3 output. + * + * @since New in 1.6. + */ +typedef enum svn_diff_conflict_display_style_t +{ + /** Display modified and latest, with conflict markers. */ + svn_diff_conflict_display_modified_latest, + + /** Like svn_diff_conflict_display_modified_latest, but with an + extra effort to identify common sequences between modified and + latest. */ + svn_diff_conflict_display_resolved_modified_latest, + + /** Display modified, original, and latest, with conflict + markers. */ + svn_diff_conflict_display_modified_original_latest, + + /** Just display modified, with no markers. */ + svn_diff_conflict_display_modified, + + /** Just display latest, with no markers. */ + svn_diff_conflict_display_latest, + + /** Like svn_diff_conflict_display_modified_original_latest, but + *only* showing conflicts. */ + svn_diff_conflict_display_only_conflicts +} svn_diff_conflict_display_style_t; + + +/** Given a vtable of @a output_fns/@a output_baton for consuming + * differences, output the differences in @a diff. + */ +svn_error_t * +svn_diff_output(svn_diff_t *diff, + void *output_baton, + const svn_diff_output_fns_t *output_fns); + + + +/* Diffs on files */ + +/** To what extent whitespace should be ignored when comparing lines. + * + * @since New in 1.4. + */ +typedef enum svn_diff_file_ignore_space_t +{ + /** Ignore no whitespace. */ + svn_diff_file_ignore_space_none, + + /** Ignore changes in sequences of whitespace characters, treating each + * sequence of whitespace characters as a single space. */ + svn_diff_file_ignore_space_change, + + /** Ignore all whitespace characters. */ + svn_diff_file_ignore_space_all +} svn_diff_file_ignore_space_t; + +/** Options to control the behaviour of the file diff routines. + * + * @since New in 1.4. + * + * @note This structure may be extended in the future, so to preserve binary + * compatibility, users must not allocate structs of this type themselves. + * @see svn_diff_file_options_create(). + * + * @note Although its name suggests otherwise, this structure is used to + * pass options to file as well as in-memory diff functions. + */ +typedef struct svn_diff_file_options_t +{ + /** To what extent whitespace should be ignored when comparing lines. + * The default is @c svn_diff_file_ignore_space_none. */ + svn_diff_file_ignore_space_t ignore_space; + /** Whether to treat all end-of-line markers the same when comparing lines. + * The default is @c FALSE. */ + svn_boolean_t ignore_eol_style; + /** Whether the "@@" lines of the unified diff output should include a prefix + * of the nearest preceding line that starts with a character that might be + * the initial character of a C language identifier. The default is + * @c FALSE. + */ + svn_boolean_t show_c_function; +} svn_diff_file_options_t; + +/** Allocate a @c svn_diff_file_options_t structure in @a pool, initializing + * it with default values. + * + * @since New in 1.4. + */ +svn_diff_file_options_t * +svn_diff_file_options_create(apr_pool_t *pool); + +/** + * Parse @a args, an array of <tt>const char *</tt> command line switches + * and adjust @a options accordingly. @a options is assumed to be initialized + * with default values. @a pool is used for temporary allocation. + * + * @since New in 1.4. + * + * The following options are supported: + * - --ignore-space-change, -b + * - --ignore-all-space, -w + * - --ignore-eol-style + * - --show-c-function, -p @since New in 1.5. + * - --unified, -u (for compatibility, does nothing). + */ +svn_error_t * +svn_diff_file_options_parse(svn_diff_file_options_t *options, + const apr_array_header_t *args, + apr_pool_t *pool); + + +/** A convenience function to produce a diff between two files. + * + * @since New in 1.4. + * + * Return a diff object in @a *diff (allocated from @a pool) that represents + * the difference between an @a original file and @a modified file. + * (The file arguments must be full paths to the files.) + * + * Compare lines according to the relevant fields of @a options. + */ +svn_error_t * +svn_diff_file_diff_2(svn_diff_t **diff, + const char *original, + const char *modified, + const svn_diff_file_options_t *options, + apr_pool_t *pool); + +/** Similar to svn_file_diff_2(), but with @a options set to a struct with + * default options. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_file_diff(svn_diff_t **diff, + const char *original, + const char *modified, + apr_pool_t *pool); + +/** A convenience function to produce a diff between three files. + * + * @since New in 1.4. + * + * Return a diff object in @a *diff (allocated from @a pool) that represents + * the difference between an @a original file, @a modified file, and @a latest + * file. + * + * Compare lines according to the relevant fields of @a options. + */ +svn_error_t * +svn_diff_file_diff3_2(svn_diff_t **diff, + const char *original, + const char *modified, + const char *latest, + const svn_diff_file_options_t *options, + apr_pool_t *pool); + +/** Similar to svn_diff_file_diff3_2(), but with @a options set to a struct + * with default options. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_file_diff3(svn_diff_t **diff, + const char *original, + const char *modified, + const char *latest, + apr_pool_t *pool); + +/** A convenience function to produce a diff between four files. + * + * @since New in 1.4. + * + * Return a diff object in @a *diff (allocated from @a pool) that represents + * the difference between an @a original file, @a modified file, @a latest + * and @a ancestor file. (The file arguments must be full paths to the files.) + * + * Compare lines according to the relevant fields of @a options. + */ +svn_error_t * +svn_diff_file_diff4_2(svn_diff_t **diff, + const char *original, + const char *modified, + const char *latest, + const char *ancestor, + const svn_diff_file_options_t *options, + apr_pool_t *pool); + +/** Similar to svn_file_diff4_2(), but with @a options set to a struct with + * default options. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_file_diff4(svn_diff_t **diff, + const char *original, + const char *modified, + const char *latest, + const char *ancestor, + apr_pool_t *pool); + +/** A convenience function to produce unified diff output from the + * diff generated by svn_diff_file_diff(). + * + * @since New in 1.5. + * + * Output a @a diff between @a original_path and @a modified_path in unified + * context diff format to @a output_stream. Optionally supply + * @a original_header and/or @a modified_header to be displayed in the header + * of the output. If @a original_header or @a modified_header is @c NULL, a + * default header will be displayed, consisting of path and last modified time. + * Output all headers and markers in @a header_encoding. If @a relative_to_dir + * is not @c NULL, the @a original_path and @a modified_path will have the + * @a relative_to_dir stripped from the front of the respective paths. If + * @a relative_to_dir is @c NULL, paths will be not be modified. If + * @a relative_to_dir is not @c NULL but @a relative_to_dir is not a parent + * path of the target, an error is returned. Finally, if @a relative_to_dir + * is a URL, an error will be returned. + */ +svn_error_t * +svn_diff_file_output_unified3(svn_stream_t *output_stream, + svn_diff_t *diff, + const char *original_path, + const char *modified_path, + const char *original_header, + const char *modified_header, + const char *header_encoding, + const char *relative_to_dir, + svn_boolean_t show_c_function, + apr_pool_t *pool); + +/** Similar to svn_diff_file_output_unified3(), but with @a relative_to_dir + * set to NULL and @a show_c_function to false. + * + * @deprecated Provided for backwards compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_file_output_unified2(svn_stream_t *output_stream, + svn_diff_t *diff, + const char *original_path, + const char *modified_path, + const char *original_header, + const char *modified_header, + const char *header_encoding, + apr_pool_t *pool); + +/** Similar to svn_diff_file_output_unified2(), but with @a header_encoding + * set to @c APR_LOCALE_CHARSET. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_file_output_unified(svn_stream_t *output_stream, + svn_diff_t *diff, + const char *original_path, + const char *modified_path, + const char *original_header, + const char *modified_header, + apr_pool_t *pool); + + +/** A convenience function to produce diff3 output from the + * diff generated by svn_diff_file_diff3(). + * + * Output a @a diff between @a original_path, @a modified_path and + * @a latest_path in merged format to @a output_stream. Optionally supply + * @a conflict_modified, @a conflict_original, @a conflict_separator and/or + * @a conflict_latest to be displayed as conflict markers in the output. + * If @a conflict_original, @a conflict_modified, @a conflict_latest and/or + * @a conflict_separator is @c NULL, a default marker will be displayed. + * @a conflict_style dictates how conflicts are displayed. + * + * @since New in 1.6. + */ +svn_error_t * +svn_diff_file_output_merge2(svn_stream_t *output_stream, + svn_diff_t *diff, + const char *original_path, + const char *modified_path, + const char *latest_path, + const char *conflict_original, + const char *conflict_modified, + const char *conflict_latest, + const char *conflict_separator, + svn_diff_conflict_display_style_t conflict_style, + apr_pool_t *pool); + + +/** Similar to svn_diff_file_output_merge2, but with @a + * display_original_in_conflict and @a display_resolved_conflicts + * booleans instead of the @a conflict_style enum. + * + * If both booleans are false, acts like + * svn_diff_conflict_display_modified_latest; if @a + * display_original_in_conflict is true, acts like + * svn_diff_conflict_display_modified_original_latest; if @a + * display_resolved_conflicts is true, acts like + * svn_diff_conflict_display_resolved_modified_latest. The booleans + * may not both be true. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_file_output_merge(svn_stream_t *output_stream, + svn_diff_t *diff, + const char *original_path, + const char *modified_path, + const char *latest_path, + const char *conflict_original, + const char *conflict_modified, + const char *conflict_latest, + const char *conflict_separator, + svn_boolean_t display_original_in_conflict, + svn_boolean_t display_resolved_conflicts, + apr_pool_t *pool); + + + +/* Diffs on in-memory structures */ + +/** Generate @a diff output from the @a original and @a modified + * in-memory strings. @a diff will be allocated from @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_diff_mem_string_diff(svn_diff_t **diff, + const svn_string_t *original, + const svn_string_t *modified, + const svn_diff_file_options_t *options, + apr_pool_t *pool); + + +/** Generate @a diff output from the @a original, @a modified and @a latest + * in-memory strings. @a diff will be allocated in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_diff_mem_string_diff3(svn_diff_t **diff, + const svn_string_t *original, + const svn_string_t *modified, + const svn_string_t *latest, + const svn_diff_file_options_t *options, + apr_pool_t *pool); + + +/** Generate @a diff output from the @a original, @a modified and @a latest + * in-memory strings, using @a ancestor. @a diff will be allocated in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_diff_mem_string_diff4(svn_diff_t **diff, + const svn_string_t *original, + const svn_string_t *modified, + const svn_string_t *latest, + const svn_string_t *ancestor, + const svn_diff_file_options_t *options, + apr_pool_t *pool); + +/** Outputs the @a diff object generated by svn_diff_mem_string_diff() + * in unified diff format on @a output_stream, using @a original + * and @a modified for the text in the output. + * + * If @a with_diff_header is TRUE, write a diff header ("---" and "+++" + * lines), using @a original_header and @a modified_header to fill the field + * after the "---" and "+++" markers; otherwise @a original_header and + * @a modified_header are ignored and may be NULL. + * + * Outputs the header and hunk delimiters in @a header_encoding. + * A @a hunk_delimiter can optionally be specified. + * If @a hunk_delimiter is NULL, use the default hunk delimiter "@@". + * + * As a special case, if the hunk delimiter is "##", then for an incomplete + * final line use the text "\ No newline at end of property" instead of + * "\ No newline at end of file". + * + * @since New in 1.7. Hunk delimiter "##" has the special meaning since 1.8. + */ +svn_error_t * +svn_diff_mem_string_output_unified2(svn_stream_t *output_stream, + svn_diff_t *diff, + svn_boolean_t with_diff_header, + const char *hunk_delimiter, + const char *original_header, + const char *modified_header, + const char *header_encoding, + const svn_string_t *original, + const svn_string_t *modified, + apr_pool_t *pool); + +/** Similar to svn_diff_mem_string_output_unified2() but with + * @a with_diff_header always set to TRUE and @a hunk_delimiter always + * set to NULL. + * + * @since New in 1.5. + */ +svn_error_t * +svn_diff_mem_string_output_unified(svn_stream_t *output_stream, + svn_diff_t *diff, + const char *original_header, + const char *modified_header, + const char *header_encoding, + const svn_string_t *original, + const svn_string_t *modified, + apr_pool_t *pool); + +/** Output the @a diff generated by svn_diff_mem_string_diff3() in diff3 + * format on @a output_stream, using @a original, @a modified and @a latest + * for content changes. + * + * Use the conflict markers @a conflict_original, @a conflict_modified, + * @a conflict_latest and @a conflict_separator or the default one for + * each of these if @c NULL is passed. + * + * @a conflict_style dictates how conflicts are displayed. + * + * @since New in 1.6. + */ +svn_error_t * +svn_diff_mem_string_output_merge2(svn_stream_t *output_stream, + svn_diff_t *diff, + const svn_string_t *original, + const svn_string_t *modified, + const svn_string_t *latest, + const char *conflict_original, + const char *conflict_modified, + const char *conflict_latest, + const char *conflict_separator, + svn_diff_conflict_display_style_t style, + apr_pool_t *pool); + +/** Similar to svn_diff_mem_string_output_merge2, but with @a + * display_original_in_conflict and @a display_resolved_conflicts + * booleans instead of the @a conflict_style enum. + * + * If both booleans are false, acts like + * svn_diff_conflict_display_modified_latest; if @a + * display_original_in_conflict is true, acts like + * svn_diff_conflict_display_modified_original_latest; if @a + * display_resolved_conflicts is true, acts like + * svn_diff_conflict_display_resolved_modified_latest. The booleans + * may not both be true. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_diff_mem_string_output_merge(svn_stream_t *output_stream, + svn_diff_t *diff, + const svn_string_t *original, + const svn_string_t *modified, + const svn_string_t *latest, + const char *conflict_original, + const char *conflict_modified, + const char *conflict_latest, + const char *conflict_separator, + svn_boolean_t display_original_in_conflict, + svn_boolean_t display_resolved_conflicts, + apr_pool_t *pool); + + + +/* Diff parsing. If you want to apply a patch to a working copy + * rather than parse it, see svn_client_patch(). */ + +/** + * Describes what operation has been performed on a file. + * + * @since New in 1.7. + */ +typedef enum svn_diff_operation_kind_e +{ + svn_diff_op_unchanged, + svn_diff_op_added, + svn_diff_op_deleted, + svn_diff_op_copied, + svn_diff_op_moved, + /* There's no tree changes, just text modifications. */ + svn_diff_op_modified +} svn_diff_operation_kind_t; + +/** + * A single hunk inside a patch. + * + * The lines of text comprising the hunk can be interpreted in three ways: + * - diff text The hunk as it appears in the unidiff patch file, + * including the hunk header line ("@@ ... @@") + * - original text The text the patch was based on. + * - modified text The result of patching the original text. + * + * For example, consider a hunk with the following diff text: + * + * @verbatim + @@ -1,5 +1,5 @@ + #include <stdio.h> + int main(int argc, char *argv[]) { + - printf("Hello World!\n"); + + printf("I like Subversion!\n"); + } @endverbatim + * + * The original text of this hunk is: + * + * @verbatim + #include <stdio.h> + int main(int argc, char *argv[]) { + printf("Hello World!\n"); + } @endverbatim + * + * And the modified text is: + * + * @verbatim + #include <stdio.h> + int main(int argc, char *argv[]) { + printf("I like Subversion!\n"); + } @endverbatim + * + * @see svn_diff_hunk_readline_diff_text() + * @see svn_diff_hunk_readline_original_text() + * @see svn_diff_hunk_readline_modified_text() + * + * @since New in 1.7. */ +typedef struct svn_diff_hunk_t svn_diff_hunk_t; + +/** + * Allocate @a *stringbuf in @a result_pool, and read into it one line + * of the diff text of @a hunk. The first line returned is the hunk header. + * Any subsequent lines are unidiff data (starting with '+', '-', or ' '). + * If the @a hunk is being interpreted in reverse (i.e. the reverse + * parameter of svn_diff_parse_next_patch() was @c TRUE), the diff + * text will be returned in reversed form. + * The line-terminator is detected automatically and stored in @a *eol + * if @a eol is not NULL. + * If EOF is reached, set @a *eof to TRUE, and set @a *eol to NULL if the + * hunk does not end with a newline character and @a eol is not NULL. + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_diff_hunk_readline_diff_text(svn_diff_hunk_t *hunk, + svn_stringbuf_t **stringbuf, + const char **eol, + svn_boolean_t *eof, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Allocate @a *stringbuf in @a result_pool, and read into it one line + * of the original text of @a hunk. + * The line-terminator is detected automatically and stored in @a *eol + * if @a eol is not NULL. + * If EOF is reached, set @a *eof to TRUE, and set @a *eol to NULL if the + * hunk text does not end with a newline character and @a eol is not NULL. + * Temporary allocations will be performed in @a scratch_pool. + * + * @see svn_diff_hunk_t + * @since New in 1.7. + */ +svn_error_t * +svn_diff_hunk_readline_original_text(svn_diff_hunk_t *hunk, + svn_stringbuf_t **stringbuf, + const char **eol, + svn_boolean_t *eof, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Like svn_diff_hunk_readline_original_text(), but it returns lines from + * the modified text of the hunk. + * + * @see svn_diff_hunk_t + * @since New in 1.7. + */ +svn_error_t * +svn_diff_hunk_readline_modified_text(svn_diff_hunk_t *hunk, + svn_stringbuf_t **stringbuf, + const char **eol, + svn_boolean_t *eof, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Reset the diff text of @a hunk so it can be read again from the start. + * @since New in 1.7. */ +void +svn_diff_hunk_reset_diff_text(svn_diff_hunk_t *hunk); + +/** Reset the original text of @a hunk so it can be read again from the start. + * @since New in 1.7. */ +void +svn_diff_hunk_reset_original_text(svn_diff_hunk_t *hunk); + +/** Reset the modified text of @a hunk so it can be read again from the start. + * @since New in 1.7. */ +void +svn_diff_hunk_reset_modified_text(svn_diff_hunk_t *hunk); + +/** Return the line offset of the original hunk text, + * as parsed from the hunk header. + * @since New in 1.7. */ +svn_linenum_t +svn_diff_hunk_get_original_start(const svn_diff_hunk_t *hunk); + +/** Return the number of lines in the original @a hunk text, + * as parsed from the hunk header. + * @since New in 1.7. */ +svn_linenum_t +svn_diff_hunk_get_original_length(const svn_diff_hunk_t *hunk); + +/** Return the line offset of the modified @a hunk text, + * as parsed from the hunk header. + * @since New in 1.7. */ +svn_linenum_t +svn_diff_hunk_get_modified_start(const svn_diff_hunk_t *hunk); + +/** Return the number of lines in the modified @a hunk text, + * as parsed from the hunk header. + * @since New in 1.7. */ +svn_linenum_t +svn_diff_hunk_get_modified_length(const svn_diff_hunk_t *hunk); + +/** Return the number of lines of leading context of @a hunk, + * i.e. the number of lines starting with ' ' before the first line + * that starts with a '+' or '-'. + * @since New in 1.7. */ +svn_linenum_t +svn_diff_hunk_get_leading_context(const svn_diff_hunk_t *hunk); + +/** Return the number of lines of trailing context of @a hunk, + * i.e. the number of lines starting with ' ' after the last line + * that starts with a '+' or '-'. + * @since New in 1.7. */ +svn_linenum_t +svn_diff_hunk_get_trailing_context(const svn_diff_hunk_t *hunk); + +/** + * Data type to manage parsing of properties in patches. + * API users should not allocate structures of this type directly. + * + * @since New in 1.7. */ +typedef struct svn_prop_patch_t { + const char *name; + + /** Represents the operation performed on the property */ + svn_diff_operation_kind_t operation; + + /** + * An array containing an svn_diff_hunk_t object for each hunk parsed + * from the patch associated with our property name */ + apr_array_header_t *hunks; +} svn_prop_patch_t; + +/** + * Data type to manage parsing of patches. + * API users should not allocate structures of this type directly. + * + * @since New in 1.7. */ +typedef struct svn_patch_t { + /** + * The old and new file names as retrieved from the patch file. + * These paths are UTF-8 encoded and canonicalized, but otherwise + * left unchanged from how they appeared in the patch file. */ + const char *old_filename; + const char *new_filename; + + /** + * An array containing an svn_diff_hunk_t * for each hunk parsed + * from the patch. */ + apr_array_header_t *hunks; + + /** + * A hash table keyed by property names containing svn_prop_patch_t + * object for each property parsed from the patch. */ + apr_hash_t *prop_patches; + + /** + * Represents the operation performed on the file. */ + svn_diff_operation_kind_t operation; + + /** + * Indicates whether the patch is being interpreted in reverse. */ + svn_boolean_t reverse; +} svn_patch_t; + +/** An opaque type representing an open patch file. + * + * @since New in 1.7. */ +typedef struct svn_patch_file_t svn_patch_file_t; + +/** Open @a patch_file at @a local_abspath. + * Allocate @a patch_file in @a result_pool. + * + * @since New in 1.7. */ +svn_error_t * +svn_diff_open_patch_file(svn_patch_file_t **patch_file, + const char *local_abspath, + apr_pool_t *result_pool); + +/** + * Return the next @a *patch in @a patch_file. + * If no patch can be found, set @a *patch to NULL. + * If @a reverse is TRUE, invert the patch while parsing it. + * If @a ignore_whitespace is TRUE, allow patches with no leading + * whitespace to be parsed. + * Allocate results in @a result_pool. + * Use @a scratch_pool for all other allocations. + * + * @since New in 1.7. */ +svn_error_t * +svn_diff_parse_next_patch(svn_patch_t **patch, + svn_patch_file_t *patch_file, + svn_boolean_t reverse, + svn_boolean_t ignore_whitespace, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Dispose of @a patch_file. + * Use @a scratch_pool for all temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_diff_close_patch_file(svn_patch_file_t *patch_file, + apr_pool_t *scratch_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DIFF_H */ diff --git a/subversion/include/svn_dirent_uri.h b/subversion/include/svn_dirent_uri.h new file mode 100644 index 0000000..8fb449d --- /dev/null +++ b/subversion/include/svn_dirent_uri.h @@ -0,0 +1,805 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_dirent_uri.h + * @brief A library to manipulate URIs, relative paths and directory entries. + * + * This library makes a clear distinction between several path formats: + * + * - a dirent is a path on (local) disc or a UNC path (Windows) in + * either relative or absolute format. + * Examples: + * "/foo/bar", "X:/temp", "//server/share", "A:/" (Windows only), "" + * But not: + * "http://server" + * + * - a uri, for our purposes, is a percent-encoded, absolute path + * (URI) that starts with a schema definition. In practice, these + * tend to look like URLs, but never carry query strings. + * Examples: + * "http://server", "file:///path/to/repos", + * "svn+ssh://user@host:123/My%20Stuff/file.doc" + * But not: + * "file", "dir/file", "A:/dir", "/My%20Stuff/file.doc", "" + * + * - a relative path (relpath) is an unrooted path that can be joined + * to any other relative path, uri or dirent. A relative path is + * never rooted/prefixed by a '/'. + * Examples: + * "file", "dir/file", "dir/subdir/../file", "" + * But not: + * "/file", "http://server/file" + * + * This distinction is needed because on Windows we have to handle some + * dirents and URIs differently. Since it's not possible to determine from + * the path string if it's a dirent or a URI, it's up to the API user to + * make this choice. See also issue #2028. + * + * All incoming and outgoing paths are non-NULL unless otherwise documented. + * + * All of these functions expect paths passed into them to be in canonical + * form, except: + * + * - @c svn_dirent_canonicalize() + * - @c svn_dirent_is_canonical() + * - @c svn_dirent_internal_style() + * - @c svn_relpath_canonicalize() + * - @c svn_relpath_is_canonical() + * - @c svn_relpath__internal_style() + * - @c svn_uri_canonicalize() + * - @c svn_uri_is_canonical() + * + * The Subversion codebase also recognizes some other classes of path: + * + * - A Subversion filesystem path (fspath) -- otherwise known as a + * path within a repository -- is a path relative to the root of + * the repository filesystem, that starts with a slash ("/"). The + * rules for a fspath are the same as for a relpath except for the + * leading '/'. A fspath never ends with '/' except when the whole + * path is just '/'. The fspath API is private (see + * private/svn_fspath.h). + * + * - A URL path (urlpath) is just the path part of a URL (the part + * that follows the schema, username, hostname, and port). These + * are also like relpaths, except that they have a leading slash + * (like fspaths) and are URI-encoded. The urlpath API is also + * private (see private/svn_fspath.h) + * Example: + * "/svn/repos/trunk/README", + * "/svn/repos/!svn/bc/45/file%20with%20spaces.txt" + * + * So, which path API is appropriate for your use-case? + * + * - If your path refers to a local file, directory, symlink, etc. of + * the sort that you can examine and operate on with other software + * on your computer, it's a dirent. + * + * - If your path is a full URL -- with a schema, hostname (maybe), + * and path portion -- it's a uri. + * + * - If your path is relative, and is somewhat ambiguous unless it's + * joined to some other more explicit (possible absolute) base + * (such as a dirent or URL), it's a relpath. + * + * - If your path is the virtual path of a versioned object inside a + * Subversion repository, it could be one of two different types of + * paths. We'd prefer to use relpaths (relative to the root + * directory of the virtual repository filesystem) for that stuff, + * but some legacy code uses fspaths. You'll need to figure out if + * your code expects repository paths to have a leading '/' or not. + * If so, they are fspaths; otherwise they are relpaths. + * + * - If your path refers only to the path part of URL -- as if + * someone hacked off the initial schema and hostname portion -- + * it's a urlpath. To date, the ra_dav modules are the only ones + * within Subversion that make use of urlpaths, and this is because + * WebDAV makes heavy use of that form of path specification. + * + * When translating between local paths (dirents) and uris code should + * always go via the relative path format, perhaps by truncating a + * parent portion from a path with svn_*_skip_ancestor(), or by + * converting portions to basenames and then joining to existing + * paths. + * + * SECURITY WARNING: If a path that is received from an untrusted + * source -- such as from the network -- is converted to a dirent it + * should be tested with svn_dirent_is_under_root() before you can + * assume the path to be a safe local path. + * + * MEMORY ALLOCATION: A function documented as allocating the result + * in a pool may instead return a static string such as "." or "". If + * the result is equal to an input, it will duplicate the input. + */ + +#ifndef SVN_DIRENT_URI_H +#define SVN_DIRENT_URI_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_tables.h> + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Convert @a dirent from the local style to the canonical internal style. + * "Local style" means native path separators and "." for the empty path. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +const char * +svn_dirent_internal_style(const char *dirent, + apr_pool_t *result_pool); + +/** Convert @a dirent from the internal style to the local style. + * "Local style" means native path separators and "." for the empty path. + * If the input is not canonical, the output may not be canonical. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +const char * +svn_dirent_local_style(const char *dirent, + apr_pool_t *result_pool); + +/** Convert @a relpath from the local style to the canonical internal style. + * "Local style" means native path separators and "." for the empty path. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +const char * +svn_relpath__internal_style(const char *relpath, + apr_pool_t *result_pool); + + +/** Join a base dirent (@a base) with a component (@a component). + * + * If either @a base or @a component is the empty string, then the other + * argument will be copied and returned. If both are the empty string then + * empty string is returned. + * + * If the @a component is an absolute dirent, then it is copied and returned. + * The platform specific rules for joining paths are used to join the components. + * + * This function is NOT appropriate for native (local) file + * dirents. Only for "internal" canonicalized dirents, since it uses '/' + * for the separator. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +char * +svn_dirent_join(const char *base, + const char *component, + apr_pool_t *result_pool); + +/** Join multiple components onto a @a base dirent. The components are + * terminated by a @c NULL. + * + * If any component is the empty string, it will be ignored. + * + * If any component is an absolute dirent, then it resets the base and + * further components will be appended to it. + * + * See svn_dirent_join() for further notes about joining dirents. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +char * +svn_dirent_join_many(apr_pool_t *result_pool, + const char *base, + ...); + +/** Join a base relpath (@a base) with a component (@a component). + * @a component need not be a single component. + * + * If either @a base or @a component is the empty path, then the other + * argument will be copied and returned. If both are the empty path the + * empty path is returned. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +char * +svn_relpath_join(const char *base, + const char *component, + apr_pool_t *result_pool); + +/** Gets the name of the specified canonicalized @a dirent as it is known + * within its parent directory. If the @a dirent is root, return "". The + * returned value will not have slashes in it. + * + * Example: svn_dirent_basename("/foo/bar") -> "bar" + * + * If @a result_pool is NULL, return a pointer to the basename in @a dirent, + * otherwise allocate the result in @a result_pool. + * + * @note If an empty string is passed, then an empty string will be returned. + * + * @since New in 1.7. + */ +const char * +svn_dirent_basename(const char *dirent, + apr_pool_t *result_pool); + +/** Get the dirname of the specified canonicalized @a dirent, defined as + * the dirent with its basename removed. + * + * If @a dirent is root ("/", "X:/", "//server/share/") or "", it is returned + * unchanged. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +char * +svn_dirent_dirname(const char *dirent, + apr_pool_t *result_pool); + +/** Divide the canonicalized @a dirent into @a *dirpath and @a *base_name. + * + * If @a dirpath or @a base_name is NULL, then don't set that one. + * + * Either @a dirpath or @a base_name may be @a dirent's own address, but they + * may not both be the same address, or the results are undefined. + * + * If @a dirent has two or more components, the separator between @a dirpath + * and @a base_name is not included in either of the new names. + * + * Examples: + * - <pre>"/foo/bar/baz" ==> "/foo/bar" and "baz"</pre> + * - <pre>"/bar" ==> "/" and "bar"</pre> + * - <pre>"/" ==> "/" and ""</pre> + * - <pre>"bar" ==> "" and "bar"</pre> + * - <pre>"" ==> "" and ""</pre> + * Windows: - <pre>"X:/" ==> "X:/" and ""</pre> + * - <pre>"X:/foo" ==> "X:/" and "foo"</pre> + * - <pre>"X:foo" ==> "X:" and "foo"</pre> + * Posix: - <pre>"X:foo" ==> "" and "X:foo"</pre> + * + * Allocate the results in @a result_pool. + * + * @since New in 1.7. + */ +void +svn_dirent_split(const char **dirpath, + const char **base_name, + const char *dirent, + apr_pool_t *result_pool); + +/** Divide the canonicalized @a relpath into @a *dirpath and @a *base_name. + * + * If @a dirpath or @a base_name is NULL, then don't set that one. + * + * Either @a dirpath or @a base_name may be @a relpaths's own address, but + * they may not both be the same address, or the results are undefined. + * + * If @a relpath has two or more components, the separator between @a dirpath + * and @a base_name is not included in either of the new names. + * + * examples: + * - <pre>"foo/bar/baz" ==> "foo/bar" and "baz"</pre> + * - <pre>"bar" ==> "" and "bar"</pre> + * - <pre>"" ==> "" and ""</pre> + * + * Allocate the results in @a result_pool. + * + * @since New in 1.7. + */ +void +svn_relpath_split(const char **dirpath, + const char **base_name, + const char *relpath, + apr_pool_t *result_pool); + +/** Get the basename of the specified canonicalized @a relpath. The + * basename is defined as the last component of the relpath. If the @a + * relpath has only one component then that is returned. The returned + * value will have no slashes in it. + * + * Example: svn_relpath_basename("/trunk/foo/bar") -> "bar" + * + * If @a result_pool is NULL, return a pointer to the basename in @a relpath, + * otherwise allocate the result in @a result_pool. + * + * @note If an empty string is passed, then an empty string will be returned. + * + * @since New in 1.7. + */ +const char * +svn_relpath_basename(const char *relpath, + apr_pool_t *result_pool); + +/** Get the dirname of the specified canonicalized @a relpath, defined as + * the relpath with its basename removed. + * + * If @a relpath is empty, "" is returned. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +char * +svn_relpath_dirname(const char *relpath, + apr_pool_t *result_pool); + + +/** Divide the canonicalized @a uri into a uri @a *dirpath and a + * (URI-decoded) relpath @a *base_name. + * + * If @a dirpath or @a base_name is NULL, then don't set that one. + * + * Either @a dirpath or @a base_name may be @a uri's own address, but they + * may not both be the same address, or the results are undefined. + * + * If @a uri has two or more components, the separator between @a dirpath + * and @a base_name is not included in either of the new names. + * + * Examples: + * - <pre>"http://server/foo/bar" ==> "http://server/foo" and "bar"</pre> + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +void +svn_uri_split(const char **dirpath, + const char **base_name, + const char *uri, + apr_pool_t *result_pool); + +/** Get the (URI-decoded) basename of the specified canonicalized @a + * uri. The basename is defined as the last component of the uri. If + * the @a uri is root, return "". The returned value will have no + * slashes in it. + * + * Example: svn_uri_basename("http://server/foo/bar") -> "bar" + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +const char * +svn_uri_basename(const char *uri, + apr_pool_t *result_pool); + +/** Get the dirname of the specified canonicalized @a uri, defined as + * the uri with its basename removed. + * + * If @a uri is root (e.g. "http://server"), it is returned + * unchanged. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +char * +svn_uri_dirname(const char *uri, + apr_pool_t *result_pool); + +/** Return TRUE if @a dirent is considered absolute on the platform at + * hand. E.g. '/foo' on Posix platforms or 'X:/foo', '//server/share/foo' + * on Windows. + * + * @since New in 1.6. + */ +svn_boolean_t +svn_dirent_is_absolute(const char *dirent); + +/** Return TRUE if @a dirent is considered a root directory on the platform + * at hand. + * E.g.: + * On Posix: '/' + * On Windows: '/', 'X:/', '//server/share', 'X:' + * + * Note that on Windows '/' and 'X:' are roots, but paths starting with this + * root are not absolute. + * + * @since New in 1.5. + */ +svn_boolean_t +svn_dirent_is_root(const char *dirent, + apr_size_t len); + +/** Return TRUE if @a uri is a root URL (e.g., "http://server"). + * + * @since New in 1.7 + */ +svn_boolean_t +svn_uri_is_root(const char *uri, + apr_size_t len); + +/** Return a new dirent like @a dirent, but transformed such that some types + * of dirent specification redundancies are removed. + * + * This involves: + * - collapsing redundant "/./" elements + * - removing multiple adjacent separator characters + * - removing trailing separator characters + * - converting the server name of a UNC path to lower case (on Windows) + * - converting a drive letter to upper case (on Windows) + * + * and possibly other semantically inoperative transformations. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +const char * +svn_dirent_canonicalize(const char *dirent, + apr_pool_t *result_pool); + + +/** Return a new relpath like @a relpath, but transformed such that some types + * of relpath specification redundancies are removed. + * + * This involves: + * - collapsing redundant "/./" elements + * - removing multiple adjacent separator characters + * - removing trailing separator characters + * + * and possibly other semantically inoperative transformations. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +const char * +svn_relpath_canonicalize(const char *relpath, + apr_pool_t *result_pool); + + +/** Return a new uri like @a uri, but transformed such that some types + * of uri specification redundancies are removed. + * + * This involves: + * - collapsing redundant "/./" elements + * - removing multiple adjacent separator characters + * - removing trailing separator characters + * - normalizing the escaping of the path component by unescaping + * characters that don't need escaping and escaping characters that do + * need escaping but weren't + * - removing the port number if it is the default port number (80 for + * http, 443 for https, 3690 for svn) + * + * and possibly other semantically inoperative transformations. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +const char * +svn_uri_canonicalize(const char *uri, + apr_pool_t *result_pool); + +/** Return @c TRUE iff @a dirent is canonical. + * + * Use @a scratch_pool for temporary allocations. + * + * @note The test for canonicalization is currently defined as + * "looks exactly the same as @c svn_dirent_canonicalize() would make + * it look". + * + * @see svn_dirent_canonicalize() + * @since New in 1.6. + */ +svn_boolean_t +svn_dirent_is_canonical(const char *dirent, + apr_pool_t *scratch_pool); + +/** Return @c TRUE iff @a relpath is canonical. + * + * @see svn_relpath_canonicalize() + * @since New in 1.7. + */ +svn_boolean_t +svn_relpath_is_canonical(const char *relpath); + +/** Return @c TRUE iff @a uri is canonical. + * + * Use @a scratch_pool for temporary allocations. + * + * @see svn_uri_canonicalize() + * @since New in 1.7. + */ +svn_boolean_t +svn_uri_is_canonical(const char *uri, + apr_pool_t *scratch_pool); + +/** Return the longest common dirent shared by two canonicalized dirents, + * @a dirent1 and @a dirent2. If there's no common ancestor, return the + * empty path. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +char * +svn_dirent_get_longest_ancestor(const char *dirent1, + const char *dirent2, + apr_pool_t *result_pool); + +/** Return the longest common path shared by two relative paths, + * @a relpath1 and @a relpath2. If there's no common ancestor, return the + * empty path. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +char * +svn_relpath_get_longest_ancestor(const char *relpath1, + const char *relpath2, + apr_pool_t *result_pool); + +/** Return the longest common path shared by two canonicalized uris, + * @a uri1 and @a uri2. If there's no common ancestor, return the + * empty path. In order for two URLs to have a common ancestor, they + * must (a) have the same protocol (since two URLs with the same path + * but different protocols may point at completely different + * resources), and (b) share a common ancestor in their path + * component, i.e. 'protocol://' is not a sufficient ancestor. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +char * +svn_uri_get_longest_ancestor(const char *uri1, + const char *uri2, + apr_pool_t *result_pool); + +/** Convert @a relative canonicalized dirent to an absolute dirent and + * return the results in @a *pabsolute. + * Raise SVN_ERR_BAD_FILENAME if the absolute dirent cannot be determined. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.6. + */ +svn_error_t * +svn_dirent_get_absolute(const char **pabsolute, + const char *relative, + apr_pool_t *result_pool); + +/** Similar to svn_dirent_skip_ancestor(), except that if @a child_dirent is + * the same as @a parent_dirent, it is not considered a child, so the result + * is @c NULL; an empty string is never returned. + * + * If @a result_pool is NULL, return a pointer into @a child_dirent, otherwise + * allocate the result in @a result_pool. + * + * ### TODO: Deprecate, as the semantics are trivially + * obtainable from *_skip_ancestor(). + * + * @since New in 1.6. + */ +const char * +svn_dirent_is_child(const char *parent_dirent, + const char *child_dirent, + apr_pool_t *result_pool); + +/** Return TRUE if @a parent_dirent is an ancestor of @a child_dirent or + * the dirents are equal, and FALSE otherwise. + * + * ### TODO: Deprecate, as the semantics are trivially + * obtainable from *_skip_ancestor(). + * + * @since New in 1.6. + */ +svn_boolean_t +svn_dirent_is_ancestor(const char *parent_dirent, + const char *child_dirent); + +/** Return TRUE if @a parent_uri is an ancestor of @a child_uri or + * the uris are equal, and FALSE otherwise. + */ +svn_boolean_t +svn_uri__is_ancestor(const char *parent_uri, + const char *child_uri); + + +/** Return the relative path part of @a child_dirent that is below + * @a parent_dirent, or just "" if @a parent_dirent is equal to + * @a child_dirent. If @a child_dirent is not below or equal to + * @a parent_dirent, return NULL. + * + * If one of @a parent_dirent and @a child_dirent is absolute and + * the other relative, return NULL. + * + * @since New in 1.7. + */ +const char * +svn_dirent_skip_ancestor(const char *parent_dirent, + const char *child_dirent); + +/** Return the relative path part of @a child_relpath that is below + * @a parent_relpath, or just "" if @a parent_relpath is equal to + * @a child_relpath. If @a child_relpath is not below or equal to + * @a parent_relpath, return NULL. + * + * @since New in 1.7. + */ +const char * +svn_relpath_skip_ancestor(const char *parent_relpath, + const char *child_relpath); + +/** Return the URI-decoded relative path of @a child_uri that is below + * @a parent_uri, or just "" if @a parent_uri is equal to @a child_uri. If + * @a child_uri is not below or equal to @a parent_uri, return NULL. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +const char * +svn_uri_skip_ancestor(const char *parent_uri, + const char *child_uri, + apr_pool_t *result_pool); + +/** Find the common prefix of the canonicalized dirents in @a targets + * (an array of <tt>const char *</tt>'s), and remove redundant dirents if @a + * remove_redundancies is TRUE. + * + * - Set @a *pcommon to the absolute dirent of the dirent common to + * all of the targets. If the targets have no common prefix (e.g. + * "C:/file" and "D:/file" on Windows), set @a *pcommon to the empty + * string. + * + * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets + * to an array of targets relative to @a *pcommon, and if + * @a remove_redundancies is TRUE, omit any dirents that are + * descendants of another dirent in @a targets. If *pcommon + * is empty, @a *pcondensed_targets will contain absolute dirents; + * redundancies can still be removed. If @a pcondensed_targets is NULL, + * leave it alone. + * + * Else if there is exactly one target, then + * + * - Set @a *pcommon to that target, and + * + * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets + * to an array containing zero elements. Else if + * @a pcondensed_targets is NULL, leave it alone. + * + * If there are no items in @a targets, set @a *pcommon and (if + * applicable) @a *pcondensed_targets to @c NULL. + * + * Allocate the results in @a result_pool. Use @a scratch_pool for + * temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_dirent_condense_targets(const char **pcommon, + apr_array_header_t **pcondensed_targets, + const apr_array_header_t *targets, + svn_boolean_t remove_redundancies, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Find the common prefix of the canonicalized uris in @a targets + * (an array of <tt>const char *</tt>'s), and remove redundant uris if @a + * remove_redundancies is TRUE. + * + * - Set @a *pcommon to the common base uri of all of the targets. + * If the targets have no common prefix (e.g. "http://srv1/file" + * and "http://srv2/file"), set @a *pcommon to the empty + * string. + * + * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets + * to an array of URI-decoded targets relative to @a *pcommon, and + * if @a remove_redundancies is TRUE, omit any uris that are + * descendants of another uri in @a targets. If *pcommon is + * empty, @a *pcondensed_targets will contain absolute uris; + * redundancies can still be removed. If @a pcondensed_targets is + * NULL, leave it alone. + * + * Else if there is exactly one target, then + * + * - Set @a *pcommon to that target, and + * + * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets + * to an array containing zero elements. Else if + * @a pcondensed_targets is NULL, leave it alone. + * + * If there are no items in @a targets, set @a *pcommon and (if + * applicable) @a *pcondensed_targets to @c NULL. + * + * Allocate the results in @a result_pool. Use @a scratch_pool for + * temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_uri_condense_targets(const char **pcommon, + apr_array_header_t **pcondensed_targets, + const apr_array_header_t *targets, + svn_boolean_t remove_redundancies, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Join @a path onto @a base_path, checking that @a path does not attempt + * to traverse above @a base_path. If @a path or any ".." component within + * it resolves to a path above @a base_path, or if @a path is an absolute + * path, then set @a *under_root to @c FALSE. Otherwise, set @a *under_root + * to @c TRUE and, if @a result_path is not @c NULL, set @a *result_path to + * the resulting path. + * + * @a path need not be canonical. @a base_path must be canonical and + * @a *result_path will be canonical. + * + * Allocate the result in @a result_pool. + * + * @note Use of this function is strongly encouraged. Do not roll your own. + * (http://cve.mitre.org/cgi-bin/cvename.cgi?name=2007-3846) + * + * @since New in 1.7. + */ +svn_error_t * +svn_dirent_is_under_root(svn_boolean_t *under_root, + const char **result_path, + const char *base_path, + const char *path, + apr_pool_t *result_pool); + +/** Set @a *dirent to the path corresponding to the file:// URL @a url, using + * the platform-specific file:// rules. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_uri_get_dirent_from_file_url(const char **dirent, + const char *url, + apr_pool_t *result_pool); + +/** Set @a *url to a file:// URL, corresponding to @a dirent using the + * platform specific dirent and file:// rules. + * + * Allocate the result in @a result_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_uri_get_file_url_from_dirent(const char **url, + const char *dirent, + apr_pool_t *result_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DIRENT_URI_H */ diff --git a/subversion/include/svn_dso.h b/subversion/include/svn_dso.h new file mode 100644 index 0000000..f5cfa10 --- /dev/null +++ b/subversion/include/svn_dso.h @@ -0,0 +1,99 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_dso.h + * @brief DSO loading routines + */ + + + +#ifndef SVN_DSO_H +#define SVN_DSO_H + +#include <apr_dso.h> + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Initialize the DSO loading routines. + * + * @note This should be called prior to the creation of any pool that + * is passed to a function that comes from a DSO, otherwise you + * risk having the DSO unloaded before all pool cleanup callbacks + * that live in the DSO have been executed. If it is not called + * prior to @c svn_dso_load being used for the first time there + * will be a best effort attempt made to initialize the subsystem, + * but it will not be entirely thread safe and it risks running + * into the previously mentioned problems with DSO unloading and + * pool cleanup callbacks. + * + * Returns svn_error_t object with corresponding apr_err returned by + * underlying calls. In case of no error returns @c SVN_NO_ERROR. + * + * @since New in 1.6. + */ +svn_error_t * +svn_dso_initialize2(void); + +/** The same as svn_dso_initialize2(), except that if there is an error this + * calls abort() instead of returning the error. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. + * + * @since New in 1.4. + */ +SVN_DEPRECATED +void +svn_dso_initialize(void); + + +#if APR_HAS_DSO + +/** + * Attempt to load @a libname, returning it in @a *dso. + * + * If @a libname cannot be loaded set @a *dso to NULL and return + * @c SVN_NO_ERROR. + * + * @note Due to pool lifetime issues DSOs are all loaded into a global + * pool, so you must be certain that there is a bounded number of + * them that will ever be loaded by the system, otherwise you will + * leak memory. + * + * @since New in 1.4. + */ +svn_error_t * +svn_dso_load(apr_dso_handle_t **dso, + const char *libname); + +#endif /* APR_HAS_DSO */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_DSO_H */ diff --git a/subversion/include/svn_error.h b/subversion/include/svn_error.h new file mode 100644 index 0000000..3a6e4c5 --- /dev/null +++ b/subversion/include/svn_error.h @@ -0,0 +1,662 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_error.h + * @brief Common exception handling for Subversion. + */ + +#ifndef SVN_ERROR_H +#define SVN_ERROR_H + +#include <apr.h> /* for apr_size_t */ +#include <apr_errno.h> /* APR's error system */ +#include <apr_pools.h> /* for apr_pool_t */ + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +#define APR_WANT_STDIO +#endif +#include <apr_want.h> /* for FILE* */ + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* For the Subversion developers, this #define turns on extended "stack + traces" of any errors that get thrown. See the SVN_ERR() macro. */ +#ifdef SVN_DEBUG +#define SVN_ERR__TRACING +#endif + + +/** the best kind of (@c svn_error_t *) ! */ +#define SVN_NO_ERROR 0 + +/* The actual error codes are kept in a separate file; see comments + there for the reasons why. */ +#include "svn_error_codes.h" + +/** Put an English description of @a statcode into @a buf and return @a buf, + * NULL-terminated. @a statcode is either an svn error or apr error. + */ +char * +svn_strerror(apr_status_t statcode, + char *buf, + apr_size_t bufsize); + + +/** + * Return the symbolic name of an error code. If the error code + * is in svn_error_codes.h, return the name of the macro as a string. + * If the error number is not recognised, return @c NULL. + * + * An error number may not be recognised because it was defined in a future + * version of Subversion (e.g., a 1.9.x server may transmit a defined-in-1.9.0 + * error number to a 1.8.x client). + * + * An error number may be recognised @em incorrectly if the @c apr_status_t + * value originates in another library (such as libserf) which also uses APR. + * (This is a theoretical concern only: the @c apr_err member of #svn_error_t + * should never contain a "foreign" @c apr_status_t value, and + * in any case Subversion and Serf use non-overlapping subsets of the + * @c APR_OS_START_USERERR range.) + * + * Support for error codes returned by APR itself (i.e., not in the + * @c APR_OS_START_USERERR range, as defined in apr_errno.h) may be implemented + * in the future. + * + * @note In rare cases, a single numeric code has more than one symbolic name. + * (For example, #SVN_ERR_WC_NOT_DIRECTORY and #SVN_ERR_WC_NOT_WORKING_COPY). + * In those cases, it is not guaranteed which symbolic name is returned. + * + * @since New in 1.8. + */ +const char * +svn_error_symbolic_name(apr_status_t statcode); + + +/** If @a err has a custom error message, return that, otherwise + * store the generic error string associated with @a err->apr_err into + * @a buf (terminating with NULL) and return @a buf. + * + * @since New in 1.4. + * + * @note @a buf and @a bufsize are provided in the interface so that + * this function is thread-safe and yet does no allocation. + */ +const char *svn_err_best_message(svn_error_t *err, + char *buf, + apr_size_t bufsize); + + + +/** SVN error creation and destruction. + * + * @defgroup svn_error_error_creation_destroy Error creation and destruction + * @{ + */ + +/** Create a nested exception structure. + * + * Input: an APR or SVN custom error code, + * a "child" error to wrap, + * a specific message + * + * Returns: a new error structure (containing the old one). + * + * @note Errors are always allocated in a subpool of the global pool, + * since an error's lifetime is generally not related to the + * lifetime of any convenient pool. Errors must be freed + * with svn_error_clear(). The specific message should be @c NULL + * if there is nothing to add to the general message associated + * with the error code. + * + * If creating the "bottommost" error in a chain, pass @c NULL for + * the child argument. + */ +svn_error_t * +svn_error_create(apr_status_t apr_err, + svn_error_t *child, + const char *message); + +/** Create an error structure with the given @a apr_err and @a child, + * with a printf-style error message produced by passing @a fmt, using + * apr_psprintf(). + */ +svn_error_t * +svn_error_createf(apr_status_t apr_err, + svn_error_t *child, + const char *fmt, + ...) + __attribute__ ((format(printf, 3, 4))); + +/** Wrap a @a status from an APR function. If @a fmt is NULL, this is + * equivalent to svn_error_create(status,NULL,NULL). Otherwise, + * the error message is constructed by formatting @a fmt and the + * following arguments according to apr_psprintf(), and then + * appending ": " and the error message corresponding to @a status. + * (If UTF-8 translation of the APR error message fails, the ": " and + * APR error are not appended to the error message.) + */ +svn_error_t * +svn_error_wrap_apr(apr_status_t status, + const char *fmt, + ...) + __attribute__((format(printf, 2, 3))); + +/** A quick n' easy way to create a wrapped exception with your own + * message, before throwing it up the stack. (It uses all of the + * @a child's fields.) + */ +svn_error_t * +svn_error_quick_wrap(svn_error_t *child, + const char *new_msg); + +/** Compose two errors, returning the composition as a brand new error + * and consuming the original errors. Either or both of @a err1 and + * @a err2 may be @c SVN_NO_ERROR. If both are not @c SVN_NO_ERROR, + * @a err2 will follow @a err1 in the chain of the returned error. + * + * Either @a err1 or @a err2 can be functions that return svn_error_t* + * but if both are functions they can be evaluated in either order as + * per the C language rules. + * + * @since New in 1.6. + */ +svn_error_t * +svn_error_compose_create(svn_error_t *err1, + svn_error_t *err2); + +/** Add @a new_err to the end of @a chain's chain of errors. The @a new_err + * chain will be copied into @a chain's pool and destroyed, so @a new_err + * itself becomes invalid after this function. + * + * Either @a chain or @a new_err can be functions that return svn_error_t* + * but if both are functions they can be evaluated in either order as + * per the C language rules. + */ +void +svn_error_compose(svn_error_t *chain, + svn_error_t *new_err); + +/** Return the root cause of @a err by finding the last error in its + * chain (e.g. it or its children). @a err may be @c SVN_NO_ERROR, in + * which case @c SVN_NO_ERROR is returned. + * + * @since New in 1.5. + */ +svn_error_t * +svn_error_root_cause(svn_error_t *err); + +/** Return the first error in @a err's chain that has an error code @a + * apr_err or #SVN_NO_ERROR if there is no error with that code. The + * returned error should @em not be cleared as it shares memory with @a err. + * + * If @a err is #SVN_NO_ERROR, return #SVN_NO_ERROR. + * + * @since New in 1.7. + */ +svn_error_t * +svn_error_find_cause(svn_error_t *err, apr_status_t apr_err); + +/** Create a new error that is a deep copy of @a err and return it. + * + * @since New in 1.2. + */ +svn_error_t * +svn_error_dup(svn_error_t *err); + +/** Free the memory used by @a error, as well as all ancestors and + * descendants of @a error. + * + * Unlike other Subversion objects, errors are managed explicitly; you + * MUST clear an error if you are ignoring it, or you are leaking memory. + * For convenience, @a error may be @c NULL, in which case this function does + * nothing; thus, svn_error_clear(svn_foo(...)) works as an idiom to + * ignore errors. + */ +void +svn_error_clear(svn_error_t *error); + + +#if defined(SVN_ERR__TRACING) +/** Set the error location for debug mode. */ +void +svn_error__locate(const char *file, + long line); + +/* Wrapper macros to collect file and line information */ +#define svn_error_create \ + (svn_error__locate(__FILE__,__LINE__), (svn_error_create)) +#define svn_error_createf \ + (svn_error__locate(__FILE__,__LINE__), (svn_error_createf)) +#define svn_error_wrap_apr \ + (svn_error__locate(__FILE__,__LINE__), (svn_error_wrap_apr)) +#define svn_error_quick_wrap \ + (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrap)) +#endif + + +/** + * Very basic default error handler: print out error stack @a error to the + * stdio stream @a stream, with each error prefixed by @a prefix; quit and + * clear @a error iff the @a fatal flag is set. Allocations are performed + * in the @a error's pool. + * + * If you're not sure what prefix to pass, just pass "svn: ". That's + * what code that used to call svn_handle_error() and now calls + * svn_handle_error2() does. + * + * @since New in 1.2. + */ +void +svn_handle_error2(svn_error_t *error, + FILE *stream, + svn_boolean_t fatal, + const char *prefix); + +/** Like svn_handle_error2() but with @c prefix set to "svn: " + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +void +svn_handle_error(svn_error_t *error, + FILE *stream, + svn_boolean_t fatal); + +/** + * Very basic default warning handler: print out the error @a error to the + * stdio stream @a stream, prefixed by @a prefix. Allocations are + * performed in the error's pool. + * + * @a error may not be @c NULL. + * + * @since New in 1.2. + */ +void +svn_handle_warning2(FILE *stream, + svn_error_t *error, + const char *prefix); + +/** Like svn_handle_warning2() but with @c prefix set to "svn: " + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +void +svn_handle_warning(FILE *stream, + svn_error_t *error); + + +/** A statement macro for checking error values. + * + * Evaluate @a expr. If it yields an error, return that error from the + * current function. Otherwise, continue. + * + * The <tt>do { ... } while (0)</tt> wrapper has no semantic effect, + * but it makes this macro syntactically equivalent to the expression + * statement it resembles. Without it, statements like + * + * @code + * if (a) + * SVN_ERR(some operation); + * else + * foo; + * @endcode + * + * would not mean what they appear to. + */ +#define SVN_ERR(expr) \ + do { \ + svn_error_t *svn_err__temp = (expr); \ + if (svn_err__temp) \ + return svn_error_trace(svn_err__temp); \ + } while (0) + +/** + * A macro for wrapping an error in a source-location trace message. + * + * This macro can be used when directly returning an already created + * error (when not using SVN_ERR, svn_error_create(), etc.) to ensure + * that the call stack is recorded correctly. + * + * @since New in 1.7. + */ +#ifdef SVN_ERR__TRACING +svn_error_t * +svn_error__trace(const char *file, long line, svn_error_t *err); + +#define svn_error_trace(expr) svn_error__trace(__FILE__, __LINE__, (expr)) +#else +#define svn_error_trace(expr) (expr) +#endif + +/** + * Returns an error chain that is based on @a err's error chain but + * does not include any error tracing placeholders. @a err is not + * modified, except for any allocations using its pool. + * + * The returned error chain is allocated from @a err's pool and shares + * its message and source filename character arrays. The returned + * error chain should *not* be cleared because it is not a fully + * fledged error chain, only clearing @a err should be done to clear + * the returned error chain. If @a err is cleared, then the returned + * error chain is unusable. + * + * @a err can be #SVN_NO_ERROR. If @a err is not #SVN_NO_ERROR, then + * the last link in the error chain must be a non-tracing error, i.e, + * a real error. + * + * @since New in 1.7. + */ +svn_error_t *svn_error_purge_tracing(svn_error_t *err); + + +/** A statement macro, very similar to @c SVN_ERR. + * + * This macro will wrap the error with the specified text before + * returning the error. + */ +#define SVN_ERR_W(expr, wrap_msg) \ + do { \ + svn_error_t *svn_err__temp = (expr); \ + if (svn_err__temp) \ + return svn_error_quick_wrap(svn_err__temp, wrap_msg); \ + } while (0) + + +/** A statement macro, similar to @c SVN_ERR, but returns an integer. + * + * Evaluate @a expr. If it yields an error, handle that error and + * return @c EXIT_FAILURE. + */ +#define SVN_INT_ERR(expr) \ + do { \ + svn_error_t *svn_err__temp = (expr); \ + if (svn_err__temp) { \ + svn_handle_error2(svn_err__temp, stderr, FALSE, "svn: "); \ + svn_error_clear(svn_err__temp); \ + return EXIT_FAILURE; } \ + } while (0) + +/** @} */ + + +/** Error groups + * + * @defgroup svn_error_error_groups Error groups + * @{ + */ + +/** + * Return TRUE if @a err is an error specifically related to locking a + * path in the repository, FALSE otherwise. + * + * SVN_ERR_FS_OUT_OF_DATE and SVN_ERR_FS_NOT_FOUND are in here because it's a + * non-fatal error that can be thrown when attempting to lock an item. + * + * @since New in 1.2. + */ +#define SVN_ERR_IS_LOCK_ERROR(err) \ + (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED || \ + err->apr_err == SVN_ERR_FS_NOT_FOUND || \ + err->apr_err == SVN_ERR_FS_OUT_OF_DATE || \ + err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN) + +/** + * Return TRUE if @a err is an error specifically related to unlocking + * a path in the repository, FALSE otherwise. + * + * @since New in 1.2. + */ +#define SVN_ERR_IS_UNLOCK_ERROR(err) \ + (err->apr_err == SVN_ERR_FS_PATH_NOT_LOCKED || \ + err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN || \ + err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH || \ + err->apr_err == SVN_ERR_FS_NO_SUCH_LOCK || \ + err->apr_err == SVN_ERR_RA_NOT_LOCKED || \ + err->apr_err == SVN_ERR_FS_LOCK_EXPIRED) + +/** Evaluates to @c TRUE iff @a apr_err (of type apr_status_t) is in the given + * @a category, which should be one of the @c SVN_ERR_*_CATEGORY_START + * constants. + * + * @since New in 1.7. + */ +#define SVN_ERROR_IN_CATEGORY(apr_err, category) \ + ((category) == ((apr_err) / SVN_ERR_CATEGORY_SIZE) * SVN_ERR_CATEGORY_SIZE) + + +/** @} */ + + +/** Internal malfunctions and assertions + * + * @defgroup svn_error_malfunction_assertion Malfunctions and assertions + * @{ + */ + +/** Report that an internal malfunction has occurred, and possibly terminate + * the program. + * + * Act as determined by the current "malfunction handler" which may have + * been specified by a call to svn_error_set_malfunction_handler() or else + * is the default handler as specified in that function's documentation. If + * the malfunction handler returns, then cause the function using this macro + * to return the error object that it generated. + * + * @note The intended use of this macro is where execution reaches a point + * that cannot possibly be reached unless there is a bug in the program. + * + * @since New in 1.6. + */ +#define SVN_ERR_MALFUNCTION() \ + do { \ + return svn_error_trace(svn_error__malfunction( \ + TRUE, __FILE__, __LINE__, NULL)); \ + } while (0) + +/** Similar to SVN_ERR_MALFUNCTION(), but without the option of returning + * an error to the calling function. + * + * If possible you should use SVN_ERR_MALFUNCTION() instead. + * + * @since New in 1.6. + */ +#define SVN_ERR_MALFUNCTION_NO_RETURN() \ + do { \ + svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \ + abort(); \ + } while (1) + +/** Like SVN_ERR_ASSERT(), but append ERR to the returned error chain. + * + * If EXPR is false, return a malfunction error whose chain includes ERR. + * If EXPR is true, do nothing. (In particular, this does not clear ERR.) + * + * Types: (svn_boolean_t expr, svn_error_t *err) + * + * @since New in 1.8. + */ +#ifdef __clang_analyzer__ +#include <assert.h> +/* Just ignore ERR. If the assert triggers, it'll be our least concern. */ +#define SVN_ERR_ASSERT_E(expr, err) assert((expr)) +#else +#define SVN_ERR_ASSERT_E(expr, err) \ + do { \ + if (!(expr)) { \ + return svn_error_compose_create( \ + svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \ + (err)); \ + } \ + } while (0) +#endif + + +/** Check that a condition is true: if not, report an error and possibly + * terminate the program. + * + * If the Boolean expression @a expr is true, do nothing. Otherwise, + * act as determined by the current "malfunction handler" which may have + * been specified by a call to svn_error_set_malfunction_handler() or else + * is the default handler as specified in that function's documentation. If + * the malfunction handler returns, then cause the function using this macro + * to return the error object that it generated. + * + * @note The intended use of this macro is to check a condition that cannot + * possibly be false unless there is a bug in the program. + * + * @note The condition to be checked should not be computationally expensive + * if it is reached often, as, unlike traditional "assert" statements, the + * evaluation of this expression is not compiled out in release-mode builds. + * + * @since New in 1.6. + * + * @see SVN_ERR_ASSERT_E() + */ +#ifdef __clang_analyzer__ +#include <assert.h> +#define SVN_ERR_ASSERT(expr) assert((expr)) +#else +#define SVN_ERR_ASSERT(expr) \ + do { \ + if (!(expr)) \ + SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \ + } while (0) +#endif + +/** Similar to SVN_ERR_ASSERT(), but without the option of returning + * an error to the calling function. + * + * If possible you should use SVN_ERR_ASSERT() instead. + * + * @since New in 1.6. + */ +#define SVN_ERR_ASSERT_NO_RETURN(expr) \ + do { \ + if (!(expr)) { \ + svn_error__malfunction(FALSE, __FILE__, __LINE__, #expr); \ + abort(); \ + } \ + } while (0) + +/** Report a "Not implemented" malfunction. Internal use only. */ +#define SVN__NOT_IMPLEMENTED() \ + return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.") + +/** A helper function for the macros that report malfunctions. Handle a + * malfunction by calling the current "malfunction handler" which may have + * been specified by a call to svn_error_set_malfunction_handler() or else + * is the default handler as specified in that function's documentation. + * + * Pass all of the parameters to the handler. The error occurred in the + * source file @a file at line @a line, and was an assertion failure of the + * expression @a expr, or, if @a expr is null, an unconditional error. + * + * If @a can_return is true, the handler can return an error object + * that is returned by the caller. If @a can_return is false the + * method should never return. (The caller will call abort()) + * + * @since New in 1.6. + */ +svn_error_t * +svn_error__malfunction(svn_boolean_t can_return, + const char *file, + int line, + const char *expr); + +/** A type of function that handles an assertion failure or other internal + * malfunction detected within the Subversion libraries. + * + * The error occurred in the source file @a file at line @a line, and was an + * assertion failure of the expression @a expr, or, if @a expr is null, an + * unconditional error. + * + * If @a can_return is false a function of this type must never return. + * + * If @a can_return is true a function of this type must do one of: + * - Return an error object describing the error, using an error code in + * the category SVN_ERR_MALFUNC_CATEGORY_START. + * - Never return. + * + * The function may alter its behaviour according to compile-time + * and run-time and even interactive conditions. + * + * @see SVN_ERROR_IN_CATEGORY() + * + * @since New in 1.6. + */ +typedef svn_error_t *(*svn_error_malfunction_handler_t) + (svn_boolean_t can_return, const char *file, int line, const char *expr); + +/** Cause subsequent malfunctions to be handled by @a func. + * Return the handler that was previously in effect. + * + * @a func may not be null. + * + * @note The default handler is svn_error_abort_on_malfunction(). + * + * @note This function must be called in a single-threaded context. + * + * @since New in 1.6. + */ +svn_error_malfunction_handler_t +svn_error_set_malfunction_handler(svn_error_malfunction_handler_t func); + +/** Handle a malfunction by returning an error object that describes it. + * + * When @a can_return is false, abort() + * + * This function implements @c svn_error_malfunction_handler_t. + * + * @since New in 1.6. + */ +svn_error_t * +svn_error_raise_on_malfunction(svn_boolean_t can_return, + const char *file, + int line, + const char *expr); + +/** Handle a malfunction by printing a message to stderr and aborting. + * + * This function implements @c svn_error_malfunction_handler_t. + * + * @since New in 1.6. + */ +svn_error_t * +svn_error_abort_on_malfunction(svn_boolean_t can_return, + const char *file, + int line, + const char *expr); + +/** @} */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_ERROR_H */ diff --git a/subversion/include/svn_error_codes.h b/subversion/include/svn_error_codes.h new file mode 100644 index 0000000..222bc2b --- /dev/null +++ b/subversion/include/svn_error_codes.h @@ -0,0 +1,1521 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_error_codes.h + * @brief Subversion error codes. + */ + +/* What's going on here? + + In order to define error codes and their associated description + strings in the same place, we overload the SVN_ERRDEF() macro with + two definitions below. Both take two arguments, an error code name + and a description string. One definition of the macro just throws + away the string and defines enumeration constants using the error + code names -- that definition is used by the header file that + exports error codes to the rest of Subversion. The other + definition creates a static table mapping the enum codes to their + corresponding strings -- that definition is used by the C file that + implements svn_strerror(). + + The header and C files both include this file, using #defines to + control which version of the macro they get. +*/ + + +/* Process this file if we're building an error array, or if we have + not defined the enumerated constants yet. */ +#if defined(SVN_ERROR_BUILD_ARRAY) || !defined(SVN_ERROR_ENUM_DEFINED) + +/* Note: despite lacking double underscores in its name, the macro + SVN_ERROR_BUILD_ARRAY is an implementation detail of Subversion and not + a public API. */ + + +#include <apr_errno.h> /* APR's error system */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#if defined(SVN_ERROR_BUILD_ARRAY) + +#define SVN_ERROR_START \ + static const err_defn error_table[] = { \ + { SVN_WARNING, "SVN_WARNING", "Warning" }, +#define SVN_ERRDEF(num, offset, str) { num, #num, str }, +#define SVN_ERROR_END { 0, NULL, NULL } }; + +#elif !defined(SVN_ERROR_ENUM_DEFINED) + +#define SVN_ERROR_START \ + typedef enum svn_errno_t { \ + SVN_WARNING = APR_OS_START_USERERR + 1, +#define SVN_ERRDEF(num, offset, str) /** str */ num = offset, +#define SVN_ERROR_END SVN_ERR_LAST } svn_errno_t; + +#define SVN_ERROR_ENUM_DEFINED + +#endif + +/* Define custom Subversion error numbers, in the range reserved for + that in APR: from APR_OS_START_USERERR to APR_OS_START_SYSERR (see + apr_errno.h). + + Error numbers are divided into categories of up to 5000 errors + each. Since we're dividing up the APR user error space, which has + room for 500,000 errors, we can have up to 100 categories. + Categories are fixed-size; if a category has fewer than 5000 + errors, then it just ends with a range of unused numbers. + + To maintain binary compatibility, please observe these guidelines: + + - When adding a new error, always add on the end of the + appropriate category, so that the real values of existing + errors are not changed. + + - When deleting an error, leave a placeholder comment indicating + the offset, again so that the values of other errors are not + perturbed. +*/ + +#define SVN_ERR_CATEGORY_SIZE 5000 + +/* Leave one category of room at the beginning, for SVN_WARNING and + any other such beasts we might create in the future. */ +#define SVN_ERR_BAD_CATEGORY_START (APR_OS_START_USERERR \ + + ( 1 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_XML_CATEGORY_START (APR_OS_START_USERERR \ + + ( 2 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_IO_CATEGORY_START (APR_OS_START_USERERR \ + + ( 3 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_STREAM_CATEGORY_START (APR_OS_START_USERERR \ + + ( 4 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_NODE_CATEGORY_START (APR_OS_START_USERERR \ + + ( 5 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_ENTRY_CATEGORY_START (APR_OS_START_USERERR \ + + ( 6 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_WC_CATEGORY_START (APR_OS_START_USERERR \ + + ( 7 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_FS_CATEGORY_START (APR_OS_START_USERERR \ + + ( 8 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_REPOS_CATEGORY_START (APR_OS_START_USERERR \ + + ( 9 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_RA_CATEGORY_START (APR_OS_START_USERERR \ + + (10 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_RA_DAV_CATEGORY_START (APR_OS_START_USERERR \ + + (11 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_RA_LOCAL_CATEGORY_START (APR_OS_START_USERERR \ + + (12 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_SVNDIFF_CATEGORY_START (APR_OS_START_USERERR \ + + (13 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_APMOD_CATEGORY_START (APR_OS_START_USERERR \ + + (14 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_CLIENT_CATEGORY_START (APR_OS_START_USERERR \ + + (15 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_MISC_CATEGORY_START (APR_OS_START_USERERR \ + + (16 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_CL_CATEGORY_START (APR_OS_START_USERERR \ + + (17 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_RA_SVN_CATEGORY_START (APR_OS_START_USERERR \ + + (18 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_AUTHN_CATEGORY_START (APR_OS_START_USERERR \ + + (19 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_AUTHZ_CATEGORY_START (APR_OS_START_USERERR \ + + (20 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_DIFF_CATEGORY_START (APR_OS_START_USERERR \ + + (21 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_RA_SERF_CATEGORY_START (APR_OS_START_USERERR \ + + (22 * SVN_ERR_CATEGORY_SIZE)) +#define SVN_ERR_MALFUNC_CATEGORY_START (APR_OS_START_USERERR \ + + (23 * SVN_ERR_CATEGORY_SIZE)) + +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ + +/** Collection of Subversion error code values, located within the + * APR user error space. */ +SVN_ERROR_START + + /* validation ("BAD_FOO") errors */ + + SVN_ERRDEF(SVN_ERR_BAD_CONTAINING_POOL, + SVN_ERR_BAD_CATEGORY_START + 0, + "Bad parent pool passed to svn_make_pool()") + + SVN_ERRDEF(SVN_ERR_BAD_FILENAME, + SVN_ERR_BAD_CATEGORY_START + 1, + "Bogus filename") + + SVN_ERRDEF(SVN_ERR_BAD_URL, + SVN_ERR_BAD_CATEGORY_START + 2, + "Bogus URL") + + SVN_ERRDEF(SVN_ERR_BAD_DATE, + SVN_ERR_BAD_CATEGORY_START + 3, + "Bogus date") + + SVN_ERRDEF(SVN_ERR_BAD_MIME_TYPE, + SVN_ERR_BAD_CATEGORY_START + 4, + "Bogus mime-type") + + /** @since New in 1.5. + * + * Note that there was an unused slot sitting here at + * SVN_ERR_BAD_CATEGORY_START + 5, so error codes after this aren't + * necessarily "New in 1.5" just because they come later. + */ + SVN_ERRDEF(SVN_ERR_BAD_PROPERTY_VALUE, + SVN_ERR_BAD_CATEGORY_START + 5, + "Wrong or unexpected property value") + + SVN_ERRDEF(SVN_ERR_BAD_VERSION_FILE_FORMAT, + SVN_ERR_BAD_CATEGORY_START + 6, + "Version file format not correct") + + SVN_ERRDEF(SVN_ERR_BAD_RELATIVE_PATH, + SVN_ERR_BAD_CATEGORY_START + 7, + "Path is not an immediate child of the specified directory") + + SVN_ERRDEF(SVN_ERR_BAD_UUID, + SVN_ERR_BAD_CATEGORY_START + 8, + "Bogus UUID") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_BAD_CONFIG_VALUE, + SVN_ERR_BAD_CATEGORY_START + 9, + "Invalid configuration value") + + SVN_ERRDEF(SVN_ERR_BAD_SERVER_SPECIFICATION, + SVN_ERR_BAD_CATEGORY_START + 10, + "Bogus server specification") + + SVN_ERRDEF(SVN_ERR_BAD_CHECKSUM_KIND, + SVN_ERR_BAD_CATEGORY_START + 11, + "Unsupported checksum type") + + SVN_ERRDEF(SVN_ERR_BAD_CHECKSUM_PARSE, + SVN_ERR_BAD_CATEGORY_START + 12, + "Invalid character in hex checksum") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_BAD_TOKEN, + SVN_ERR_BAD_CATEGORY_START + 13, + "Unknown string value of token") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_BAD_CHANGELIST_NAME, + SVN_ERR_BAD_CATEGORY_START + 14, + "Invalid changelist name") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_BAD_ATOMIC, + SVN_ERR_BAD_CATEGORY_START + 15, + "Invalid atomic") + + /* xml errors */ + + SVN_ERRDEF(SVN_ERR_XML_ATTRIB_NOT_FOUND, + SVN_ERR_XML_CATEGORY_START + 0, + "No such XML tag attribute") + + SVN_ERRDEF(SVN_ERR_XML_MISSING_ANCESTRY, + SVN_ERR_XML_CATEGORY_START + 1, + "<delta-pkg> is missing ancestry") + + SVN_ERRDEF(SVN_ERR_XML_UNKNOWN_ENCODING, + SVN_ERR_XML_CATEGORY_START + 2, + "Unrecognized binary data encoding; can't decode") + + SVN_ERRDEF(SVN_ERR_XML_MALFORMED, + SVN_ERR_XML_CATEGORY_START + 3, + "XML data was not well-formed") + + SVN_ERRDEF(SVN_ERR_XML_UNESCAPABLE_DATA, + SVN_ERR_XML_CATEGORY_START + 4, + "Data cannot be safely XML-escaped") + + /* io errors */ + + SVN_ERRDEF(SVN_ERR_IO_INCONSISTENT_EOL, + SVN_ERR_IO_CATEGORY_START + 0, + "Inconsistent line ending style") + + SVN_ERRDEF(SVN_ERR_IO_UNKNOWN_EOL, + SVN_ERR_IO_CATEGORY_START + 1, + "Unrecognized line ending style") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_IO_CORRUPT_EOL, + SVN_ERR_IO_CATEGORY_START + 2, + "Line endings other than expected") + + SVN_ERRDEF(SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED, + SVN_ERR_IO_CATEGORY_START + 3, + "Ran out of unique names") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_IO_PIPE_FRAME_ERROR, + SVN_ERR_IO_CATEGORY_START + 4, + "Framing error in pipe protocol") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_IO_PIPE_READ_ERROR, + SVN_ERR_IO_CATEGORY_START + 5, + "Read error in pipe") + + SVN_ERRDEF(SVN_ERR_IO_WRITE_ERROR, + SVN_ERR_IO_CATEGORY_START + 6, + "Write error") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_IO_PIPE_WRITE_ERROR, + SVN_ERR_IO_CATEGORY_START + 7, + "Write error in pipe") + + /* stream errors */ + + SVN_ERRDEF(SVN_ERR_STREAM_UNEXPECTED_EOF, + SVN_ERR_STREAM_CATEGORY_START + 0, + "Unexpected EOF on stream") + + SVN_ERRDEF(SVN_ERR_STREAM_MALFORMED_DATA, + SVN_ERR_STREAM_CATEGORY_START + 1, + "Malformed stream data") + + SVN_ERRDEF(SVN_ERR_STREAM_UNRECOGNIZED_DATA, + SVN_ERR_STREAM_CATEGORY_START + 2, + "Unrecognized stream data") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_STREAM_SEEK_NOT_SUPPORTED, + SVN_ERR_STREAM_CATEGORY_START + 3, + "Stream doesn't support seeking") + + /* node errors */ + + SVN_ERRDEF(SVN_ERR_NODE_UNKNOWN_KIND, + SVN_ERR_NODE_CATEGORY_START + 0, + "Unknown svn_node_kind") + + SVN_ERRDEF(SVN_ERR_NODE_UNEXPECTED_KIND, + SVN_ERR_NODE_CATEGORY_START + 1, + "Unexpected node kind found") + + /* entry errors */ + + SVN_ERRDEF(SVN_ERR_ENTRY_NOT_FOUND, + SVN_ERR_ENTRY_CATEGORY_START + 0, + "Can't find an entry") + + /* UNUSED error slot: + 1 */ + + SVN_ERRDEF(SVN_ERR_ENTRY_EXISTS, + SVN_ERR_ENTRY_CATEGORY_START + 2, + "Entry already exists") + + SVN_ERRDEF(SVN_ERR_ENTRY_MISSING_REVISION, + SVN_ERR_ENTRY_CATEGORY_START + 3, + "Entry has no revision") + + SVN_ERRDEF(SVN_ERR_ENTRY_MISSING_URL, + SVN_ERR_ENTRY_CATEGORY_START + 4, + "Entry has no URL") + + SVN_ERRDEF(SVN_ERR_ENTRY_ATTRIBUTE_INVALID, + SVN_ERR_ENTRY_CATEGORY_START + 5, + "Entry has an invalid attribute") + + SVN_ERRDEF(SVN_ERR_ENTRY_FORBIDDEN, + SVN_ERR_ENTRY_CATEGORY_START + 6, + "Can't create an entry for a forbidden name") + + /* wc errors */ + + SVN_ERRDEF(SVN_ERR_WC_OBSTRUCTED_UPDATE, + SVN_ERR_WC_CATEGORY_START + 0, + "Obstructed update") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_WC_UNWIND_MISMATCH, + SVN_ERR_WC_CATEGORY_START + 1, + "Mismatch popping the WC unwind stack") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_WC_UNWIND_EMPTY, + SVN_ERR_WC_CATEGORY_START + 2, + "Attempt to pop empty WC unwind stack") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_WC_UNWIND_NOT_EMPTY, + SVN_ERR_WC_CATEGORY_START + 3, + "Attempt to unlock with non-empty unwind stack") + + SVN_ERRDEF(SVN_ERR_WC_LOCKED, + SVN_ERR_WC_CATEGORY_START + 4, + "Attempted to lock an already-locked dir") + + SVN_ERRDEF(SVN_ERR_WC_NOT_LOCKED, + SVN_ERR_WC_CATEGORY_START + 5, + "Working copy not locked; this is probably a bug, please report") + + /** @deprecated Unused, slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_WC_INVALID_LOCK, + SVN_ERR_WC_CATEGORY_START + 6, + "Invalid lock") + + /** @since New in 1.7. Previously this error number was used by + * #SVN_ERR_WC_NOT_DIRECTORY, which is now an alias for this error. */ + SVN_ERRDEF(SVN_ERR_WC_NOT_WORKING_COPY, + SVN_ERR_WC_CATEGORY_START + 7, + "Path is not a working copy directory") + + /** @deprecated Provided for backward compatibility with the 1.6 API. + * Use #SVN_ERR_WC_NOT_WORKING_COPY. */ + SVN_ERRDEF(SVN_ERR_WC_NOT_DIRECTORY, + SVN_ERR_WC_NOT_WORKING_COPY, + "Path is not a working copy directory") + + SVN_ERRDEF(SVN_ERR_WC_NOT_FILE, + SVN_ERR_WC_CATEGORY_START + 8, + "Path is not a working copy file") + + SVN_ERRDEF(SVN_ERR_WC_BAD_ADM_LOG, + SVN_ERR_WC_CATEGORY_START + 9, + "Problem running log") + + SVN_ERRDEF(SVN_ERR_WC_PATH_NOT_FOUND, + SVN_ERR_WC_CATEGORY_START + 10, + "Can't find a working copy path") + + SVN_ERRDEF(SVN_ERR_WC_NOT_UP_TO_DATE, + SVN_ERR_WC_CATEGORY_START + 11, + "Working copy is not up-to-date") + + SVN_ERRDEF(SVN_ERR_WC_LEFT_LOCAL_MOD, + SVN_ERR_WC_CATEGORY_START + 12, + "Left locally modified or unversioned files") + + SVN_ERRDEF(SVN_ERR_WC_SCHEDULE_CONFLICT, + SVN_ERR_WC_CATEGORY_START + 13, + "Unmergeable scheduling requested on an entry") + + SVN_ERRDEF(SVN_ERR_WC_PATH_FOUND, + SVN_ERR_WC_CATEGORY_START + 14, + "Found a working copy path") + + SVN_ERRDEF(SVN_ERR_WC_FOUND_CONFLICT, + SVN_ERR_WC_CATEGORY_START + 15, + "A conflict in the working copy obstructs the current operation") + + SVN_ERRDEF(SVN_ERR_WC_CORRUPT, + SVN_ERR_WC_CATEGORY_START + 16, + "Working copy is corrupt") + + SVN_ERRDEF(SVN_ERR_WC_CORRUPT_TEXT_BASE, + SVN_ERR_WC_CATEGORY_START + 17, + "Working copy text base is corrupt") + + SVN_ERRDEF(SVN_ERR_WC_NODE_KIND_CHANGE, + SVN_ERR_WC_CATEGORY_START + 18, + "Cannot change node kind") + + SVN_ERRDEF(SVN_ERR_WC_INVALID_OP_ON_CWD, + SVN_ERR_WC_CATEGORY_START + 19, + "Invalid operation on the current working directory") + + SVN_ERRDEF(SVN_ERR_WC_BAD_ADM_LOG_START, + SVN_ERR_WC_CATEGORY_START + 20, + "Problem on first log entry in a working copy") + + SVN_ERRDEF(SVN_ERR_WC_UNSUPPORTED_FORMAT, + SVN_ERR_WC_CATEGORY_START + 21, + "Unsupported working copy format") + + SVN_ERRDEF(SVN_ERR_WC_BAD_PATH, + SVN_ERR_WC_CATEGORY_START + 22, + "Path syntax not supported in this context") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_WC_INVALID_SCHEDULE, + SVN_ERR_WC_CATEGORY_START + 23, + "Invalid schedule") + + /** @since New in 1.3. */ + SVN_ERRDEF(SVN_ERR_WC_INVALID_RELOCATION, + SVN_ERR_WC_CATEGORY_START + 24, + "Invalid relocation") + + /** @since New in 1.3. */ + SVN_ERRDEF(SVN_ERR_WC_INVALID_SWITCH, + SVN_ERR_WC_CATEGORY_START + 25, + "Invalid switch") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_WC_MISMATCHED_CHANGELIST, + SVN_ERR_WC_CATEGORY_START + 26, + "Changelist doesn't match") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, + SVN_ERR_WC_CATEGORY_START + 27, + "Conflict resolution failed") + + SVN_ERRDEF(SVN_ERR_WC_COPYFROM_PATH_NOT_FOUND, + SVN_ERR_WC_CATEGORY_START + 28, + "Failed to locate 'copyfrom' path in working copy") + + /** @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + * This event is not an error, and is now reported + * via the standard notification mechanism instead. */ + SVN_ERRDEF(SVN_ERR_WC_CHANGELIST_MOVE, + SVN_ERR_WC_CATEGORY_START + 29, + "Moving a path from one changelist to another") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_WC_CANNOT_DELETE_FILE_EXTERNAL, + SVN_ERR_WC_CATEGORY_START + 30, + "Cannot delete a file external") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_WC_CANNOT_MOVE_FILE_EXTERNAL, + SVN_ERR_WC_CATEGORY_START + 31, + "Cannot move a file external") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_DB_ERROR, + SVN_ERR_WC_CATEGORY_START + 32, + "Something's amiss with the wc sqlite database") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_MISSING, + SVN_ERR_WC_CATEGORY_START + 33, + "The working copy is missing") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_NOT_SYMLINK, + SVN_ERR_WC_CATEGORY_START + 34, + "The specified node is not a symlink") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, + SVN_ERR_WC_CATEGORY_START + 35, + "The specified path has an unexpected status") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_UPGRADE_REQUIRED, + SVN_ERR_WC_CATEGORY_START + 36, + "The working copy needs to be upgraded") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_CLEANUP_REQUIRED, + SVN_ERR_WC_CATEGORY_START + 37, + "Previous operation has not finished; " + "run 'cleanup' if it was interrupted") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_INVALID_OPERATION_DEPTH, + SVN_ERR_WC_CATEGORY_START + 38, + "The operation cannot be performed with the specified depth") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_WC_PATH_ACCESS_DENIED, + SVN_ERR_WC_CATEGORY_START + 39, + "Couldn't open a working copy file because access was denied") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_WC_MIXED_REVISIONS, + SVN_ERR_WC_CATEGORY_START + 40, + "Mixed-revision working copy was found but not expected") + + /** @since New in 1.8 */ + SVN_ERRDEF(SVN_ERR_WC_DUPLICATE_EXTERNALS_TARGET, + SVN_ERR_WC_CATEGORY_START + 41, + "Duplicate targets in svn:externals property") + + /* fs errors */ + + SVN_ERRDEF(SVN_ERR_FS_GENERAL, + SVN_ERR_FS_CATEGORY_START + 0, + "General filesystem error") + + SVN_ERRDEF(SVN_ERR_FS_CLEANUP, + SVN_ERR_FS_CATEGORY_START + 1, + "Error closing filesystem") + + SVN_ERRDEF(SVN_ERR_FS_ALREADY_OPEN, + SVN_ERR_FS_CATEGORY_START + 2, + "Filesystem is already open") + + SVN_ERRDEF(SVN_ERR_FS_NOT_OPEN, + SVN_ERR_FS_CATEGORY_START + 3, + "Filesystem is not open") + + SVN_ERRDEF(SVN_ERR_FS_CORRUPT, + SVN_ERR_FS_CATEGORY_START + 4, + "Filesystem is corrupt") + + SVN_ERRDEF(SVN_ERR_FS_PATH_SYNTAX, + SVN_ERR_FS_CATEGORY_START + 5, + "Invalid filesystem path syntax") + + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_REVISION, + SVN_ERR_FS_CATEGORY_START + 6, + "Invalid filesystem revision number") + + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_TRANSACTION, + SVN_ERR_FS_CATEGORY_START + 7, + "Invalid filesystem transaction name") + + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_ENTRY, + SVN_ERR_FS_CATEGORY_START + 8, + "Filesystem directory has no such entry") + + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_REPRESENTATION, + SVN_ERR_FS_CATEGORY_START + 9, + "Filesystem has no such representation") + + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_STRING, + SVN_ERR_FS_CATEGORY_START + 10, + "Filesystem has no such string") + + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_COPY, + SVN_ERR_FS_CATEGORY_START + 11, + "Filesystem has no such copy") + + SVN_ERRDEF(SVN_ERR_FS_TRANSACTION_NOT_MUTABLE, + SVN_ERR_FS_CATEGORY_START + 12, + "The specified transaction is not mutable") + + SVN_ERRDEF(SVN_ERR_FS_NOT_FOUND, + SVN_ERR_FS_CATEGORY_START + 13, + "Filesystem has no item") + + SVN_ERRDEF(SVN_ERR_FS_ID_NOT_FOUND, + SVN_ERR_FS_CATEGORY_START + 14, + "Filesystem has no such node-rev-id") + + SVN_ERRDEF(SVN_ERR_FS_NOT_ID, + SVN_ERR_FS_CATEGORY_START + 15, + "String does not represent a node or node-rev-id") + + SVN_ERRDEF(SVN_ERR_FS_NOT_DIRECTORY, + SVN_ERR_FS_CATEGORY_START + 16, + "Name does not refer to a filesystem directory") + + SVN_ERRDEF(SVN_ERR_FS_NOT_FILE, + SVN_ERR_FS_CATEGORY_START + 17, + "Name does not refer to a filesystem file") + + SVN_ERRDEF(SVN_ERR_FS_NOT_SINGLE_PATH_COMPONENT, + SVN_ERR_FS_CATEGORY_START + 18, + "Name is not a single path component") + + SVN_ERRDEF(SVN_ERR_FS_NOT_MUTABLE, + SVN_ERR_FS_CATEGORY_START + 19, + "Attempt to change immutable filesystem node") + + SVN_ERRDEF(SVN_ERR_FS_ALREADY_EXISTS, + SVN_ERR_FS_CATEGORY_START + 20, + "Item already exists in filesystem") + + SVN_ERRDEF(SVN_ERR_FS_ROOT_DIR, + SVN_ERR_FS_CATEGORY_START + 21, + "Attempt to remove or recreate fs root dir") + + SVN_ERRDEF(SVN_ERR_FS_NOT_TXN_ROOT, + SVN_ERR_FS_CATEGORY_START + 22, + "Object is not a transaction root") + + SVN_ERRDEF(SVN_ERR_FS_NOT_REVISION_ROOT, + SVN_ERR_FS_CATEGORY_START + 23, + "Object is not a revision root") + + SVN_ERRDEF(SVN_ERR_FS_CONFLICT, + SVN_ERR_FS_CATEGORY_START + 24, + "Merge conflict during commit") + + SVN_ERRDEF(SVN_ERR_FS_REP_CHANGED, + SVN_ERR_FS_CATEGORY_START + 25, + "A representation vanished or changed between reads") + + SVN_ERRDEF(SVN_ERR_FS_REP_NOT_MUTABLE, + SVN_ERR_FS_CATEGORY_START + 26, + "Tried to change an immutable representation") + + SVN_ERRDEF(SVN_ERR_FS_MALFORMED_SKEL, + SVN_ERR_FS_CATEGORY_START + 27, + "Malformed skeleton data") + + SVN_ERRDEF(SVN_ERR_FS_TXN_OUT_OF_DATE, + SVN_ERR_FS_CATEGORY_START + 28, + "Transaction is out of date") + + SVN_ERRDEF(SVN_ERR_FS_BERKELEY_DB, + SVN_ERR_FS_CATEGORY_START + 29, + "Berkeley DB error") + + SVN_ERRDEF(SVN_ERR_FS_BERKELEY_DB_DEADLOCK, + SVN_ERR_FS_CATEGORY_START + 30, + "Berkeley DB deadlock error") + + SVN_ERRDEF(SVN_ERR_FS_TRANSACTION_DEAD, + SVN_ERR_FS_CATEGORY_START + 31, + "Transaction is dead") + + SVN_ERRDEF(SVN_ERR_FS_TRANSACTION_NOT_DEAD, + SVN_ERR_FS_CATEGORY_START + 32, + "Transaction is not dead") + + /** @since New in 1.1. */ + SVN_ERRDEF(SVN_ERR_FS_UNKNOWN_FS_TYPE, + SVN_ERR_FS_CATEGORY_START + 33, + "Unknown FS type") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_NO_USER, + SVN_ERR_FS_CATEGORY_START + 34, + "No user associated with filesystem") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_PATH_ALREADY_LOCKED, + SVN_ERR_FS_CATEGORY_START + 35, + "Path is already locked") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_PATH_NOT_LOCKED, + SVN_ERR_FS_CATEGORY_START + 36, + "Path is not locked") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_BAD_LOCK_TOKEN, + SVN_ERR_FS_CATEGORY_START + 37, + "Lock token is incorrect") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_NO_LOCK_TOKEN, + SVN_ERR_FS_CATEGORY_START + 38, + "No lock token provided") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_LOCK_OWNER_MISMATCH, + SVN_ERR_FS_CATEGORY_START + 39, + "Username does not match lock owner") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_LOCK, + SVN_ERR_FS_CATEGORY_START + 40, + "Filesystem has no such lock") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_LOCK_EXPIRED, + SVN_ERR_FS_CATEGORY_START + 41, + "Lock has expired") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_FS_OUT_OF_DATE, + SVN_ERR_FS_CATEGORY_START + 42, + "Item is out of date") + + /**@since New in 1.2. + * + * This is analogous to SVN_ERR_REPOS_UNSUPPORTED_VERSION. To avoid + * confusion with "versions" (i.e., releases) of Subversion, we've + * started calling this the "format" number instead. The old + * SVN_ERR_REPOS_UNSUPPORTED_VERSION error predates this and so + * retains its name. + */ + SVN_ERRDEF(SVN_ERR_FS_UNSUPPORTED_FORMAT, + SVN_ERR_FS_CATEGORY_START + 43, + "Unsupported FS format") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_FS_REP_BEING_WRITTEN, + SVN_ERR_FS_CATEGORY_START + 44, + "Representation is being written") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_FS_TXN_NAME_TOO_LONG, + SVN_ERR_FS_CATEGORY_START + 45, + "The generated transaction name is too long") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_NODE_ORIGIN, + SVN_ERR_FS_CATEGORY_START + 46, + "Filesystem has no such node origin record") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_FS_UNSUPPORTED_UPGRADE, + SVN_ERR_FS_CATEGORY_START + 47, + "Filesystem upgrade is not supported") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_FS_NO_SUCH_CHECKSUM_REP, + SVN_ERR_FS_CATEGORY_START + 48, + "Filesystem has no such checksum-representation index record") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_FS_PROP_BASEVALUE_MISMATCH, + SVN_ERR_FS_CATEGORY_START + 49, + "Property value in filesystem differs from the provided " + "base value") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_FS_INCORRECT_EDITOR_COMPLETION, + SVN_ERR_FS_CATEGORY_START + 50, + "The filesystem editor completion process was not followed") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_FS_PACKED_REVPROP_READ_FAILURE, + SVN_ERR_FS_CATEGORY_START + 51, + "A packed revprop could not be read") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_FS_REVPROP_CACHE_INIT_FAILURE, + SVN_ERR_FS_CATEGORY_START + 52, + "Could not initialize the revprop caching infrastructure.") + + /* repos errors */ + + SVN_ERRDEF(SVN_ERR_REPOS_LOCKED, + SVN_ERR_REPOS_CATEGORY_START + 0, + "The repository is locked, perhaps for db recovery") + + SVN_ERRDEF(SVN_ERR_REPOS_HOOK_FAILURE, + SVN_ERR_REPOS_CATEGORY_START + 1, + "A repository hook failed") + + SVN_ERRDEF(SVN_ERR_REPOS_BAD_ARGS, + SVN_ERR_REPOS_CATEGORY_START + 2, + "Incorrect arguments supplied") + + SVN_ERRDEF(SVN_ERR_REPOS_NO_DATA_FOR_REPORT, + SVN_ERR_REPOS_CATEGORY_START + 3, + "A report cannot be generated because no data was supplied") + + SVN_ERRDEF(SVN_ERR_REPOS_BAD_REVISION_REPORT, + SVN_ERR_REPOS_CATEGORY_START + 4, + "Bogus revision report") + + /* This is analogous to SVN_ERR_FS_UNSUPPORTED_FORMAT. To avoid + * confusion with "versions" (i.e., releases) of Subversion, we + * started using the word "format" instead of "version". However, + * this error code's name predates that decision. + */ + SVN_ERRDEF(SVN_ERR_REPOS_UNSUPPORTED_VERSION, + SVN_ERR_REPOS_CATEGORY_START + 5, + "Unsupported repository version") + + SVN_ERRDEF(SVN_ERR_REPOS_DISABLED_FEATURE, + SVN_ERR_REPOS_CATEGORY_START + 6, + "Disabled repository feature") + + SVN_ERRDEF(SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED, + SVN_ERR_REPOS_CATEGORY_START + 7, + "Error running post-commit hook") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_REPOS_POST_LOCK_HOOK_FAILED, + SVN_ERR_REPOS_CATEGORY_START + 8, + "Error running post-lock hook") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_REPOS_POST_UNLOCK_HOOK_FAILED, + SVN_ERR_REPOS_CATEGORY_START + 9, + "Error running post-unlock hook") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_REPOS_UNSUPPORTED_UPGRADE, + SVN_ERR_REPOS_CATEGORY_START + 10, + "Repository upgrade is not supported") + + /* generic RA errors */ + + SVN_ERRDEF(SVN_ERR_RA_ILLEGAL_URL, + SVN_ERR_RA_CATEGORY_START + 0, + "Bad URL passed to RA layer") + + SVN_ERRDEF(SVN_ERR_RA_NOT_AUTHORIZED, + SVN_ERR_RA_CATEGORY_START + 1, + "Authorization failed") + + SVN_ERRDEF(SVN_ERR_RA_UNKNOWN_AUTH, + SVN_ERR_RA_CATEGORY_START + 2, + "Unknown authorization method") + + SVN_ERRDEF(SVN_ERR_RA_NOT_IMPLEMENTED, + SVN_ERR_RA_CATEGORY_START + 3, + "Repository access method not implemented") + + SVN_ERRDEF(SVN_ERR_RA_OUT_OF_DATE, + SVN_ERR_RA_CATEGORY_START + 4, + "Item is out of date") + + SVN_ERRDEF(SVN_ERR_RA_NO_REPOS_UUID, + SVN_ERR_RA_CATEGORY_START + 5, + "Repository has no UUID") + + SVN_ERRDEF(SVN_ERR_RA_UNSUPPORTED_ABI_VERSION, + SVN_ERR_RA_CATEGORY_START + 6, + "Unsupported RA plugin ABI version") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_RA_NOT_LOCKED, + SVN_ERR_RA_CATEGORY_START + 7, + "Path is not locked") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_RA_PARTIAL_REPLAY_NOT_SUPPORTED, + SVN_ERR_RA_CATEGORY_START + 8, + "Server can only replay from the root of a repository") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_RA_UUID_MISMATCH, + SVN_ERR_RA_CATEGORY_START + 9, + "Repository UUID does not match expected UUID") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_RA_REPOS_ROOT_URL_MISMATCH, + SVN_ERR_RA_CATEGORY_START + 10, + "Repository root URL does not match expected root URL") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_RA_SESSION_URL_MISMATCH, + SVN_ERR_RA_CATEGORY_START + 11, + "Session URL does not match expected session URL") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_RA_CANNOT_CREATE_TUNNEL, + SVN_ERR_RA_CATEGORY_START + 12, + "Can't create tunnel") + + /* ra_dav errors */ + + SVN_ERRDEF(SVN_ERR_RA_DAV_SOCK_INIT, + SVN_ERR_RA_DAV_CATEGORY_START + 0, + "RA layer failed to init socket layer") + + SVN_ERRDEF(SVN_ERR_RA_DAV_CREATING_REQUEST, + SVN_ERR_RA_DAV_CATEGORY_START + 1, + "RA layer failed to create HTTP request") + + SVN_ERRDEF(SVN_ERR_RA_DAV_REQUEST_FAILED, + SVN_ERR_RA_DAV_CATEGORY_START + 2, + "RA layer request failed") + + SVN_ERRDEF(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, + SVN_ERR_RA_DAV_CATEGORY_START + 3, + "RA layer didn't receive requested OPTIONS info") + + SVN_ERRDEF(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, + SVN_ERR_RA_DAV_CATEGORY_START + 4, + "RA layer failed to fetch properties") + + SVN_ERRDEF(SVN_ERR_RA_DAV_ALREADY_EXISTS, + SVN_ERR_RA_DAV_CATEGORY_START + 5, + "RA layer file already exists") + + /** @deprecated To improve consistency between ra layers, this error code + is replaced by SVN_ERR_BAD_CONFIG_VALUE. + Slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_RA_DAV_INVALID_CONFIG_VALUE, + SVN_ERR_RA_DAV_CATEGORY_START + 6, + "Invalid configuration value") + + /** @deprecated To improve consistency between ra layers, this error code + is replaced in ra_serf by SVN_ERR_FS_NOT_FOUND. + Slated for removal in the next major release. */ + SVN_ERRDEF(SVN_ERR_RA_DAV_PATH_NOT_FOUND, + SVN_ERR_RA_DAV_CATEGORY_START + 7, + "HTTP Path Not Found") + + SVN_ERRDEF(SVN_ERR_RA_DAV_PROPPATCH_FAILED, + SVN_ERR_RA_DAV_CATEGORY_START + 8, + "Failed to execute WebDAV PROPPATCH") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_RA_DAV_MALFORMED_DATA, + SVN_ERR_RA_DAV_CATEGORY_START + 9, + "Malformed network data") + + /** @since New in 1.3 */ + SVN_ERRDEF(SVN_ERR_RA_DAV_RESPONSE_HEADER_BADNESS, + SVN_ERR_RA_DAV_CATEGORY_START + 10, + "Unable to extract data from response header") + + /** @since New in 1.5 */ + SVN_ERRDEF(SVN_ERR_RA_DAV_RELOCATED, + SVN_ERR_RA_DAV_CATEGORY_START + 11, + "Repository has been moved") + + /** @since New in 1.7 */ + SVN_ERRDEF(SVN_ERR_RA_DAV_CONN_TIMEOUT, + SVN_ERR_RA_DAV_CATEGORY_START + 12, + "Connection timed out") + + /** @since New in 1.6 */ + SVN_ERRDEF(SVN_ERR_RA_DAV_FORBIDDEN, + SVN_ERR_RA_DAV_CATEGORY_START + 13, + "URL access forbidden for unknown reason") + + /* ra_local errors */ + + SVN_ERRDEF(SVN_ERR_RA_LOCAL_REPOS_NOT_FOUND, + SVN_ERR_RA_LOCAL_CATEGORY_START + 0, + "Couldn't find a repository") + + SVN_ERRDEF(SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, + SVN_ERR_RA_LOCAL_CATEGORY_START + 1, + "Couldn't open a repository") + + /* svndiff errors */ + + SVN_ERRDEF(SVN_ERR_SVNDIFF_INVALID_HEADER, + SVN_ERR_SVNDIFF_CATEGORY_START + 0, + "Svndiff data has invalid header") + + SVN_ERRDEF(SVN_ERR_SVNDIFF_CORRUPT_WINDOW, + SVN_ERR_SVNDIFF_CATEGORY_START + 1, + "Svndiff data contains corrupt window") + + SVN_ERRDEF(SVN_ERR_SVNDIFF_BACKWARD_VIEW, + SVN_ERR_SVNDIFF_CATEGORY_START + 2, + "Svndiff data contains backward-sliding source view") + + SVN_ERRDEF(SVN_ERR_SVNDIFF_INVALID_OPS, + SVN_ERR_SVNDIFF_CATEGORY_START + 3, + "Svndiff data contains invalid instruction") + + SVN_ERRDEF(SVN_ERR_SVNDIFF_UNEXPECTED_END, + SVN_ERR_SVNDIFF_CATEGORY_START + 4, + "Svndiff data ends unexpectedly") + + SVN_ERRDEF(SVN_ERR_SVNDIFF_INVALID_COMPRESSED_DATA, + SVN_ERR_SVNDIFF_CATEGORY_START + 5, + "Svndiff compressed data is invalid") + + /* mod_dav_svn errors */ + + SVN_ERRDEF(SVN_ERR_APMOD_MISSING_PATH_TO_FS, + SVN_ERR_APMOD_CATEGORY_START + 0, + "Apache has no path to an SVN filesystem") + + SVN_ERRDEF(SVN_ERR_APMOD_MALFORMED_URI, + SVN_ERR_APMOD_CATEGORY_START + 1, + "Apache got a malformed URI") + + SVN_ERRDEF(SVN_ERR_APMOD_ACTIVITY_NOT_FOUND, + SVN_ERR_APMOD_CATEGORY_START + 2, + "Activity not found") + + SVN_ERRDEF(SVN_ERR_APMOD_BAD_BASELINE, + SVN_ERR_APMOD_CATEGORY_START + 3, + "Baseline incorrect") + + SVN_ERRDEF(SVN_ERR_APMOD_CONNECTION_ABORTED, + SVN_ERR_APMOD_CATEGORY_START + 4, + "Input/output error") + + /* libsvn_client errors */ + + SVN_ERRDEF(SVN_ERR_CLIENT_VERSIONED_PATH_REQUIRED, + SVN_ERR_CLIENT_CATEGORY_START + 0, + "A path under version control is needed for this operation") + + SVN_ERRDEF(SVN_ERR_CLIENT_RA_ACCESS_REQUIRED, + SVN_ERR_CLIENT_CATEGORY_START + 1, + "Repository access is needed for this operation") + + SVN_ERRDEF(SVN_ERR_CLIENT_BAD_REVISION, + SVN_ERR_CLIENT_CATEGORY_START + 2, + "Bogus revision information given") + + SVN_ERRDEF(SVN_ERR_CLIENT_DUPLICATE_COMMIT_URL, + SVN_ERR_CLIENT_CATEGORY_START + 3, + "Attempting to commit to a URL more than once") + + SVN_ERRDEF(SVN_ERR_CLIENT_IS_BINARY_FILE, + SVN_ERR_CLIENT_CATEGORY_START + 4, + "Operation does not apply to binary file") + + /*### SVN_PROP_EXTERNALS needed to be replaced with "svn:externals" + in order to get gettext translatable strings */ + SVN_ERRDEF(SVN_ERR_CLIENT_INVALID_EXTERNALS_DESCRIPTION, + SVN_ERR_CLIENT_CATEGORY_START + 5, + "Format of an svn:externals property was invalid") + + SVN_ERRDEF(SVN_ERR_CLIENT_MODIFIED, + SVN_ERR_CLIENT_CATEGORY_START + 6, + "Attempting restricted operation for modified resource") + + SVN_ERRDEF(SVN_ERR_CLIENT_IS_DIRECTORY, + SVN_ERR_CLIENT_CATEGORY_START + 7, + "Operation does not apply to directory") + + SVN_ERRDEF(SVN_ERR_CLIENT_REVISION_RANGE, + SVN_ERR_CLIENT_CATEGORY_START + 8, + "Revision range is not allowed") + + SVN_ERRDEF(SVN_ERR_CLIENT_INVALID_RELOCATION, + SVN_ERR_CLIENT_CATEGORY_START + 9, + "Inter-repository relocation not allowed") + + SVN_ERRDEF(SVN_ERR_CLIENT_REVISION_AUTHOR_CONTAINS_NEWLINE, + SVN_ERR_CLIENT_CATEGORY_START + 10, + "Author name cannot contain a newline") + + SVN_ERRDEF(SVN_ERR_CLIENT_PROPERTY_NAME, + SVN_ERR_CLIENT_CATEGORY_START + 11, + "Bad property name") + + /** @since New in 1.1. */ + SVN_ERRDEF(SVN_ERR_CLIENT_UNRELATED_RESOURCES, + SVN_ERR_CLIENT_CATEGORY_START + 12, + "Two versioned resources are unrelated") + + /** @since New in 1.2. */ + SVN_ERRDEF(SVN_ERR_CLIENT_MISSING_LOCK_TOKEN, + SVN_ERR_CLIENT_CATEGORY_START + 13, + "Path has no lock token") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_CLIENT_MULTIPLE_SOURCES_DISALLOWED, + SVN_ERR_CLIENT_CATEGORY_START + 14, + "Operation does not support multiple sources") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_CLIENT_NO_VERSIONED_PARENT, + SVN_ERR_CLIENT_CATEGORY_START + 15, + "No versioned parent directories") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_CLIENT_NOT_READY_TO_MERGE, + SVN_ERR_CLIENT_CATEGORY_START + 16, + "Working copy and merge source not ready for reintegration") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_CLIENT_FILE_EXTERNAL_OVERWRITE_VERSIONED, + SVN_ERR_CLIENT_CATEGORY_START + 17, + "A file external cannot overwrite an existing versioned item") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_CLIENT_PATCH_BAD_STRIP_COUNT, + SVN_ERR_CLIENT_CATEGORY_START + 18, + "Invalid path component strip count specified") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_CLIENT_CYCLE_DETECTED, + SVN_ERR_CLIENT_CATEGORY_START + 19, + "Detected a cycle while processing the operation") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_CLIENT_MERGE_UPDATE_REQUIRED, + SVN_ERR_CLIENT_CATEGORY_START + 20, + "Working copy and merge source not ready for reintegration") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_CLIENT_INVALID_MERGEINFO_NO_MERGETRACKING, + SVN_ERR_CLIENT_CATEGORY_START + 21, + "Invalid mergeinfo detected in merge target") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_CLIENT_NO_LOCK_TOKEN, + SVN_ERR_CLIENT_CATEGORY_START + 22, + "Can't perform this operation without a valid lock token") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_CLIENT_FORBIDDEN_BY_SERVER, + SVN_ERR_CLIENT_CATEGORY_START + 23, + "The operation is forbidden by the server") + + /* misc errors */ + + SVN_ERRDEF(SVN_ERR_BASE, + SVN_ERR_MISC_CATEGORY_START + 0, + "A problem occurred; see other errors for details") + + SVN_ERRDEF(SVN_ERR_PLUGIN_LOAD_FAILURE, + SVN_ERR_MISC_CATEGORY_START + 1, + "Failure loading plugin") + + SVN_ERRDEF(SVN_ERR_MALFORMED_FILE, + SVN_ERR_MISC_CATEGORY_START + 2, + "Malformed file") + + SVN_ERRDEF(SVN_ERR_INCOMPLETE_DATA, + SVN_ERR_MISC_CATEGORY_START + 3, + "Incomplete data") + + SVN_ERRDEF(SVN_ERR_INCORRECT_PARAMS, + SVN_ERR_MISC_CATEGORY_START + 4, + "Incorrect parameters given") + + SVN_ERRDEF(SVN_ERR_UNVERSIONED_RESOURCE, + SVN_ERR_MISC_CATEGORY_START + 5, + "Tried a versioning operation on an unversioned resource") + + SVN_ERRDEF(SVN_ERR_TEST_FAILED, + SVN_ERR_MISC_CATEGORY_START + 6, + "Test failed") + + SVN_ERRDEF(SVN_ERR_UNSUPPORTED_FEATURE, + SVN_ERR_MISC_CATEGORY_START + 7, + "Trying to use an unsupported feature") + + SVN_ERRDEF(SVN_ERR_BAD_PROP_KIND, + SVN_ERR_MISC_CATEGORY_START + 8, + "Unexpected or unknown property kind") + + SVN_ERRDEF(SVN_ERR_ILLEGAL_TARGET, + SVN_ERR_MISC_CATEGORY_START + 9, + "Illegal target for the requested operation") + + SVN_ERRDEF(SVN_ERR_DELTA_MD5_CHECKSUM_ABSENT, + SVN_ERR_MISC_CATEGORY_START + 10, + "MD5 checksum is missing") + + SVN_ERRDEF(SVN_ERR_DIR_NOT_EMPTY, + SVN_ERR_MISC_CATEGORY_START + 11, + "Directory needs to be empty but is not") + + SVN_ERRDEF(SVN_ERR_EXTERNAL_PROGRAM, + SVN_ERR_MISC_CATEGORY_START + 12, + "Error calling external program") + + SVN_ERRDEF(SVN_ERR_SWIG_PY_EXCEPTION_SET, + SVN_ERR_MISC_CATEGORY_START + 13, + "Python exception has been set with the error") + + SVN_ERRDEF(SVN_ERR_CHECKSUM_MISMATCH, + SVN_ERR_MISC_CATEGORY_START + 14, + "A checksum mismatch occurred") + + SVN_ERRDEF(SVN_ERR_CANCELLED, + SVN_ERR_MISC_CATEGORY_START + 15, + "The operation was interrupted") + + SVN_ERRDEF(SVN_ERR_INVALID_DIFF_OPTION, + SVN_ERR_MISC_CATEGORY_START + 16, + "The specified diff option is not supported") + + SVN_ERRDEF(SVN_ERR_PROPERTY_NOT_FOUND, + SVN_ERR_MISC_CATEGORY_START + 17, + "Property not found") + + SVN_ERRDEF(SVN_ERR_NO_AUTH_FILE_PATH, + SVN_ERR_MISC_CATEGORY_START + 18, + "No auth file path available") + + /** @since New in 1.1. */ + SVN_ERRDEF(SVN_ERR_VERSION_MISMATCH, + SVN_ERR_MISC_CATEGORY_START + 19, + "Incompatible library version") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_MERGEINFO_PARSE_ERROR, + SVN_ERR_MISC_CATEGORY_START + 20, + "Mergeinfo parse error") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_CEASE_INVOCATION, + SVN_ERR_MISC_CATEGORY_START + 21, + "Cease invocation of this API") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_REVNUM_PARSE_FAILURE, + SVN_ERR_MISC_CATEGORY_START + 22, + "Error parsing revision number") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_ITER_BREAK, + SVN_ERR_MISC_CATEGORY_START + 23, + "Iteration terminated before completion") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_UNKNOWN_CHANGELIST, + SVN_ERR_MISC_CATEGORY_START + 24, + "Unknown changelist") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_RESERVED_FILENAME_SPECIFIED, + SVN_ERR_MISC_CATEGORY_START + 25, + "Reserved directory name in command line arguments") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_UNKNOWN_CAPABILITY, + SVN_ERR_MISC_CATEGORY_START + 26, + "Inquiry about unknown capability") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_TEST_SKIPPED, + SVN_ERR_MISC_CATEGORY_START + 27, + "Test skipped") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_NO_APR_MEMCACHE, + SVN_ERR_MISC_CATEGORY_START + 28, + "APR memcache library not available") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_ATOMIC_INIT_FAILURE, + SVN_ERR_MISC_CATEGORY_START + 29, + "Couldn't perform atomic initialization") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_SQLITE_ERROR, + SVN_ERR_MISC_CATEGORY_START + 30, + "SQLite error") + + /** @since New in 1.6. */ + SVN_ERRDEF(SVN_ERR_SQLITE_READONLY, + SVN_ERR_MISC_CATEGORY_START + 31, + "Attempted to write to readonly SQLite db") + + /** @since New in 1.6. + * @deprecated the internal sqlite support code does not manage schemas + * any longer. */ + SVN_ERRDEF(SVN_ERR_SQLITE_UNSUPPORTED_SCHEMA, + SVN_ERR_MISC_CATEGORY_START + 32, + "Unsupported schema found in SQLite db") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_SQLITE_BUSY, + SVN_ERR_MISC_CATEGORY_START + 33, + "The SQLite db is busy") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_SQLITE_RESETTING_FOR_ROLLBACK, + SVN_ERR_MISC_CATEGORY_START + 34, + "SQLite busy at transaction rollback; " + "resetting all busy SQLite statements to allow rollback") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_SQLITE_CONSTRAINT, + SVN_ERR_MISC_CATEGORY_START + 35, + "Constraint error in SQLite db") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_TOO_MANY_MEMCACHED_SERVERS, + SVN_ERR_MISC_CATEGORY_START + 36, + "Too many memcached servers configured") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_MALFORMED_VERSION_STRING, + SVN_ERR_MISC_CATEGORY_START + 37, + "Failed to parse version number string") + + /** @since New in 1.8. */ + SVN_ERRDEF(SVN_ERR_CORRUPTED_ATOMIC_STORAGE, + SVN_ERR_MISC_CATEGORY_START + 38, + "Atomic data storage is corrupt") + + /* command-line client errors */ + + SVN_ERRDEF(SVN_ERR_CL_ARG_PARSING_ERROR, + SVN_ERR_CL_CATEGORY_START + 0, + "Error parsing arguments") + + SVN_ERRDEF(SVN_ERR_CL_INSUFFICIENT_ARGS, + SVN_ERR_CL_CATEGORY_START + 1, + "Not enough arguments provided") + + SVN_ERRDEF(SVN_ERR_CL_MUTUALLY_EXCLUSIVE_ARGS, + SVN_ERR_CL_CATEGORY_START + 2, + "Mutually exclusive arguments specified") + + SVN_ERRDEF(SVN_ERR_CL_ADM_DIR_RESERVED, + SVN_ERR_CL_CATEGORY_START + 3, + "Attempted command in administrative dir") + + SVN_ERRDEF(SVN_ERR_CL_LOG_MESSAGE_IS_VERSIONED_FILE, + SVN_ERR_CL_CATEGORY_START + 4, + "The log message file is under version control") + + SVN_ERRDEF(SVN_ERR_CL_LOG_MESSAGE_IS_PATHNAME, + SVN_ERR_CL_CATEGORY_START + 5, + "The log message is a pathname") + + SVN_ERRDEF(SVN_ERR_CL_COMMIT_IN_ADDED_DIR, + SVN_ERR_CL_CATEGORY_START + 6, + "Committing in directory scheduled for addition") + + SVN_ERRDEF(SVN_ERR_CL_NO_EXTERNAL_EDITOR, + SVN_ERR_CL_CATEGORY_START + 7, + "No external editor available") + + SVN_ERRDEF(SVN_ERR_CL_BAD_LOG_MESSAGE, + SVN_ERR_CL_CATEGORY_START + 8, + "Something is wrong with the log message's contents") + + SVN_ERRDEF(SVN_ERR_CL_UNNECESSARY_LOG_MESSAGE, + SVN_ERR_CL_CATEGORY_START + 9, + "A log message was given where none was necessary") + + SVN_ERRDEF(SVN_ERR_CL_NO_EXTERNAL_MERGE_TOOL, + SVN_ERR_CL_CATEGORY_START + 10, + "No external merge tool available") + + SVN_ERRDEF(SVN_ERR_CL_ERROR_PROCESSING_EXTERNALS, + SVN_ERR_CL_CATEGORY_START + 11, + "Failed processing one or more externals definitions") + + /* ra_svn errors */ + + SVN_ERRDEF(SVN_ERR_RA_SVN_CMD_ERR, + SVN_ERR_RA_SVN_CATEGORY_START + 0, + "Special code for wrapping server errors to report to client") + + SVN_ERRDEF(SVN_ERR_RA_SVN_UNKNOWN_CMD, + SVN_ERR_RA_SVN_CATEGORY_START + 1, + "Unknown svn protocol command") + + SVN_ERRDEF(SVN_ERR_RA_SVN_CONNECTION_CLOSED, + SVN_ERR_RA_SVN_CATEGORY_START + 2, + "Network connection closed unexpectedly") + + SVN_ERRDEF(SVN_ERR_RA_SVN_IO_ERROR, + SVN_ERR_RA_SVN_CATEGORY_START + 3, + "Network read/write error") + + SVN_ERRDEF(SVN_ERR_RA_SVN_MALFORMED_DATA, + SVN_ERR_RA_SVN_CATEGORY_START + 4, + "Malformed network data") + + SVN_ERRDEF(SVN_ERR_RA_SVN_REPOS_NOT_FOUND, + SVN_ERR_RA_SVN_CATEGORY_START + 5, + "Couldn't find a repository") + + SVN_ERRDEF(SVN_ERR_RA_SVN_BAD_VERSION, + SVN_ERR_RA_SVN_CATEGORY_START + 6, + "Client/server version mismatch") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_RA_SVN_NO_MECHANISMS, + SVN_ERR_RA_SVN_CATEGORY_START + 7, + "Cannot negotiate authentication mechanism") + + /** @since New in 1.7 */ + SVN_ERRDEF(SVN_ERR_RA_SVN_EDIT_ABORTED, + SVN_ERR_RA_SVN_CATEGORY_START + 8, + "Editor drive was aborted") + + /* libsvn_auth errors */ + + /* this error can be used when an auth provider doesn't have + the creds, but no other "real" error occurred. */ + SVN_ERRDEF(SVN_ERR_AUTHN_CREDS_UNAVAILABLE, + SVN_ERR_AUTHN_CATEGORY_START + 0, + "Credential data unavailable") + + SVN_ERRDEF(SVN_ERR_AUTHN_NO_PROVIDER, + SVN_ERR_AUTHN_CATEGORY_START + 1, + "No authentication provider available") + + SVN_ERRDEF(SVN_ERR_AUTHN_PROVIDERS_EXHAUSTED, + SVN_ERR_AUTHN_CATEGORY_START + 2, + "All authentication providers exhausted") + + SVN_ERRDEF(SVN_ERR_AUTHN_CREDS_NOT_SAVED, + SVN_ERR_AUTHN_CATEGORY_START + 3, + "Credentials not saved") + + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_AUTHN_FAILED, + SVN_ERR_AUTHN_CATEGORY_START + 4, + "Authentication failed") + + /* authorization errors */ + + SVN_ERRDEF(SVN_ERR_AUTHZ_ROOT_UNREADABLE, + SVN_ERR_AUTHZ_CATEGORY_START + 0, + "Read access denied for root of edit") + + /** @since New in 1.1. */ + SVN_ERRDEF(SVN_ERR_AUTHZ_UNREADABLE, + SVN_ERR_AUTHZ_CATEGORY_START + 1, + "Item is not readable") + + /** @since New in 1.1. */ + SVN_ERRDEF(SVN_ERR_AUTHZ_PARTIALLY_READABLE, + SVN_ERR_AUTHZ_CATEGORY_START + 2, + "Item is partially readable") + + SVN_ERRDEF(SVN_ERR_AUTHZ_INVALID_CONFIG, + SVN_ERR_AUTHZ_CATEGORY_START + 3, + "Invalid authz configuration") + + /** @since New in 1.3 */ + SVN_ERRDEF(SVN_ERR_AUTHZ_UNWRITABLE, + SVN_ERR_AUTHZ_CATEGORY_START + 4, + "Item is not writable") + + + /* libsvn_diff errors */ + + SVN_ERRDEF(SVN_ERR_DIFF_DATASOURCE_MODIFIED, + SVN_ERR_DIFF_CATEGORY_START + 0, + "Diff data source modified unexpectedly") + + /* libsvn_ra_serf errors */ + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_RA_SERF_SSPI_INITIALISATION_FAILED, + SVN_ERR_RA_SERF_CATEGORY_START + 0, + "Initialization of SSPI library failed") + /** @since New in 1.5. */ + SVN_ERRDEF(SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED, + SVN_ERR_RA_SERF_CATEGORY_START + 1, + "Server SSL certificate untrusted") + /** @since New in 1.7. + @deprecated GSSAPI now handled by serf rather than libsvn_ra_serf. */ + SVN_ERRDEF(SVN_ERR_RA_SERF_GSSAPI_INITIALISATION_FAILED, + SVN_ERR_RA_SERF_CATEGORY_START + 2, + "Initialization of the GSSAPI context failed") + + /** @since New in 1.7. */ + SVN_ERRDEF(SVN_ERR_RA_SERF_WRAPPED_ERROR, + SVN_ERR_RA_SERF_CATEGORY_START + 3, + "While handling serf response:") + + /* malfunctions such as assertion failures */ + + SVN_ERRDEF(SVN_ERR_ASSERTION_FAIL, + SVN_ERR_MALFUNC_CATEGORY_START + 0, + "Assertion failure") + + SVN_ERRDEF(SVN_ERR_ASSERTION_ONLY_TRACING_LINKS, + SVN_ERR_MALFUNC_CATEGORY_START + 1, + "No non-tracing links found in the error chain") + +SVN_ERROR_END + + +#undef SVN_ERROR_START +#undef SVN_ERRDEF +#undef SVN_ERROR_END + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* defined(SVN_ERROR_BUILD_ARRAY) || !defined(SVN_ERROR_ENUM_DEFINED) */ diff --git a/subversion/include/svn_fs.h b/subversion/include/svn_fs.h new file mode 100644 index 0000000..8cef9a3 --- /dev/null +++ b/subversion/include/svn_fs.h @@ -0,0 +1,2530 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_fs.h + * @brief Interface to the Subversion filesystem. + */ + +#ifndef SVN_FS_H +#define SVN_FS_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_time.h> /* for apr_time_t */ + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_delta.h" +#include "svn_io.h" +#include "svn_mergeinfo.h" +#include "svn_checksum.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * Get libsvn_fs version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_fs_version(void); + +/** + * @defgroup fs_handling Filesystem interaction subsystem + * @{ + */ + +/* Opening and creating filesystems. */ + + +/** An object representing a Subversion filesystem. */ +typedef struct svn_fs_t svn_fs_t; + + +/** + * @name Filesystem configuration options + * @{ + */ +#define SVN_FS_CONFIG_BDB_TXN_NOSYNC "bdb-txn-nosync" +#define SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE "bdb-log-autoremove" + +/** Enable / disable text delta caching for a FSFS repository. + * + * @since New in 1.7. + */ +#define SVN_FS_CONFIG_FSFS_CACHE_DELTAS "fsfs-cache-deltas" + +/** Enable / disable full-text caching for a FSFS repository. + * + * @since New in 1.7. + */ +#define SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS "fsfs-cache-fulltexts" + +/** Enable / disable revprop caching for a FSFS repository. + * + * "2" is allowed, too and means "enable if efficient", + * i.e. this will not create warning at runtime if there + * if no efficient support for revprop caching. + * + * @since New in 1.8. + */ +#define SVN_FS_CONFIG_FSFS_CACHE_REVPROPS "fsfs-cache-revprops" + +/** Select the cache namespace. If you potentially share the cache with + * another FS object for the same repository, objects read through one FS + * will not need to be read again for the other. In most cases, that is + * a very desirable behavior and the default is, therefore, an empty + * namespace. + * + * If you want to be sure that your FS instance will actually read all + * requested data at least once, you need to specify a separate namespace + * for it. All repository verification code, for instance, should use + * some GUID here that is different each time you open an FS instance. + * + * @since New in 1.8. + */ +#define SVN_FS_CONFIG_FSFS_CACHE_NS "fsfs-cache-namespace" + +/* Note to maintainers: if you add further SVN_FS_CONFIG_FSFS_CACHE_* knobs, + update fs_fs.c:verify_as_revision_before_current_plus_plus(). */ + +/* See also svn_fs_type(). */ +/** @since New in 1.1. */ +#define SVN_FS_CONFIG_FS_TYPE "fs-type" +/** @since New in 1.1. */ +#define SVN_FS_TYPE_BDB "bdb" +/** @since New in 1.1. */ +#define SVN_FS_TYPE_FSFS "fsfs" + +/** Create repository format compatible with Subversion versions + * earlier than 1.4. + * + * @since New in 1.4. + */ +#define SVN_FS_CONFIG_PRE_1_4_COMPATIBLE "pre-1.4-compatible" + +/** Create repository format compatible with Subversion versions + * earlier than 1.5. + * + * @since New in 1.5. + */ +#define SVN_FS_CONFIG_PRE_1_5_COMPATIBLE "pre-1.5-compatible" + +/** Create repository format compatible with Subversion versions + * earlier than 1.6. + * + * @since New in 1.6. + */ +#define SVN_FS_CONFIG_PRE_1_6_COMPATIBLE "pre-1.6-compatible" + +/** Create repository format compatible with Subversion versions + * earlier than 1.8. + * + * @since New in 1.8. + */ +#define SVN_FS_CONFIG_PRE_1_8_COMPATIBLE "pre-1.8-compatible" +/** @} */ + + +/** + * Callers should invoke this function to initialize global state in + * the FS library before creating FS objects. If this function is + * invoked, no FS objects may be created in another thread at the same + * time as this invocation, and the provided @a pool must last longer + * than any FS object created subsequently. + * + * If this function is not called, the FS library will make a best + * effort to bootstrap a mutex for protecting data common to FS + * objects; however, there is a small window of failure. Also, a + * small amount of data will be leaked if the Subversion FS library is + * dynamically unloaded, and using the bdb FS can potentially segfault + * or invoke other undefined behavior if this function is not called + * with an appropriate pool (such as the pool the module was loaded into) + * when loaded dynamically. + * + * If this function is called multiple times before the pool passed to + * the first call is destroyed or cleared, the later calls will have + * no effect. + * + * @since New in 1.2. + */ +svn_error_t * +svn_fs_initialize(apr_pool_t *pool); + + +/** The type of a warning callback function. @a baton is the value specified + * in the call to svn_fs_set_warning_func(); the filesystem passes it through + * to the callback. @a err contains the warning message. + * + * The callback function should not clear the error that is passed to it; + * its caller should do that. + */ +typedef void (*svn_fs_warning_callback_t)(void *baton, svn_error_t *err); + + +/** Provide a callback function, @a warning, that @a fs should use to + * report (non-fatal) errors. To print an error, the filesystem will call + * @a warning, passing it @a warning_baton and the error. + * + * By default, this is set to a function that will crash the process. + * Dumping to @c stderr or <tt>/dev/tty</tt> is not acceptable default + * behavior for server processes, since those may both be equivalent to + * <tt>/dev/null</tt>. + */ +void +svn_fs_set_warning_func(svn_fs_t *fs, + svn_fs_warning_callback_t warning, + void *warning_baton); + + + +/** + * Create a new, empty Subversion filesystem, stored in the directory + * @a path, and return a pointer to it in @a *fs_p. @a path must not + * currently exist, but its parent must exist. If @a fs_config is not + * @c NULL, the options it contains modify the behavior of the + * filesystem. The interpretation of @a fs_config is specific to the + * filesystem back-end. The new filesystem may be closed by + * destroying @a pool. + * + * @note The lifetime of @a fs_config must not be shorter than @a + * pool's. It's a good idea to allocate @a fs_config from @a pool or + * one of its ancestors. + * + * If @a fs_config contains a value for #SVN_FS_CONFIG_FS_TYPE, that + * value determines the filesystem type for the new filesystem. + * Currently defined values are: + * + * SVN_FS_TYPE_BDB Berkeley-DB implementation + * SVN_FS_TYPE_FSFS Native-filesystem implementation + * + * If @a fs_config is @c NULL or does not contain a value for + * #SVN_FS_CONFIG_FS_TYPE then the default filesystem type will be used. + * This will typically be BDB for version 1.1 and FSFS for later versions, + * though the caller should not rely upon any particular default if they + * wish to ensure that a filesystem of a specific type is created. + * + * @since New in 1.1. + */ +svn_error_t * +svn_fs_create(svn_fs_t **fs_p, + const char *path, + apr_hash_t *fs_config, + apr_pool_t *pool); + +/** + * Open a Subversion filesystem located in the directory @a path, and + * return a pointer to it in @a *fs_p. If @a fs_config is not @c + * NULL, the options it contains modify the behavior of the + * filesystem. The interpretation of @a fs_config is specific to the + * filesystem back-end. The opened filesystem may be closed by + * destroying @a pool. + * + * @note The lifetime of @a fs_config must not be shorter than @a + * pool's. It's a good idea to allocate @a fs_config from @a pool or + * one of its ancestors. + * + * Only one thread may operate on any given filesystem object at once. + * Two threads may access the same filesystem simultaneously only if + * they open separate filesystem objects. + * + * @note You probably don't want to use this directly. Take a look at + * svn_repos_open2() instead. + * + * @since New in 1.1. + */ +svn_error_t * +svn_fs_open(svn_fs_t **fs_p, + const char *path, + apr_hash_t *fs_config, + apr_pool_t *pool); + +/** + * Upgrade the Subversion filesystem located in the directory @a path + * to the latest version supported by this library. Return + * #SVN_ERR_FS_UNSUPPORTED_UPGRADE and make no changes to the + * filesystem if the requested upgrade is not supported. Use @a pool + * for necessary allocations. + * + * @note You probably don't want to use this directly. Take a look at + * svn_repos_upgrade() instead. + * + * @since New in 1.5. + */ +svn_error_t * +svn_fs_upgrade(const char *path, + apr_pool_t *pool); + +/** + * Callback function type for progress notification. + * + * @a revision is the number of the revision currently begin processed, + * #SVN_INVALID_REVNUM if the current stage is not linked to any specific + * revision. @a baton is the callback baton. + * + * @since New in 1.8. + */ +typedef void (*svn_fs_progress_notify_func_t)(svn_revnum_t revision, + void *baton, + apr_pool_t *pool); + +/** + * Return, in @a *fs_type, a string identifying the back-end type of + * the Subversion filesystem located in @a path. Allocate @a *fs_type + * in @a pool. + * + * The string should be equal to one of the @c SVN_FS_TYPE_* defined + * constants, unless the filesystem is a new back-end type added in + * a later version of Subversion. + * + * In general, the type should make no difference in the filesystem's + * semantics, but there are a few situations (such as backups) where + * it might matter. + * + * @since New in 1.3. + */ +svn_error_t * +svn_fs_type(const char **fs_type, + const char *path, + apr_pool_t *pool); + +/** + * Return the path to @a fs's repository, allocated in @a pool. + * @note This is just what was passed to svn_fs_create() or + * svn_fs_open() -- might be absolute, might not. + * + * @since New in 1.1. + */ +const char * +svn_fs_path(svn_fs_t *fs, + apr_pool_t *pool); + +/** + * Return a shallow copy of the configuration parameters used to open + * @a fs, allocated in @a pool. It may be @c NULL. The contents of the + * hash contents remains valid only for @a fs's lifetime. + * + * @note This is just what was passed to svn_fs_create() or svn_fs_open(). + * You may not modify it. + * + * @since New in 1.8. + */ +apr_hash_t * +svn_fs_config(svn_fs_t *fs, + apr_pool_t *pool); + +/** + * Delete the filesystem at @a path. + * + * @note: Deleting a filesystem that has an open svn_fs_t is not + * supported. Clear/destroy all pools used to create/open @a path. + * See issue 4264. + * + * @since New in 1.1. + */ +svn_error_t * +svn_fs_delete_fs(const char *path, + apr_pool_t *pool); + +/** + * Copy a possibly live Subversion filesystem from @a src_path to + * @a dest_path. If @a clean is @c TRUE, perform cleanup on the + * source filesystem as part of the copy operation; currently, this + * means deleting copied, unused logfiles for a Berkeley DB source + * filesystem. + * + * If @a incremental is TRUE, make an effort to avoid re-copying + * information already present in the destination where possible. If + * incremental hotcopy is not implemented, raise + * #SVN_ERR_UNSUPPORTED_FEATURE. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs_hotcopy2(const char *src_path, + const char *dest_path, + svn_boolean_t clean, + svn_boolean_t incremental, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Like svn_fs_hotcopy2(), but with @a incremental always passed as @c + * TRUE and without cancellation support. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.1. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_hotcopy(const char *src_path, + const char *dest_path, + svn_boolean_t clean, + apr_pool_t *pool); + +/** Perform any necessary non-catastrophic recovery on the Subversion + * filesystem located at @a path. + * + * If @a cancel_func is not @c NULL, it is called periodically with + * @a cancel_baton as argument to see if the client wishes to cancel + * recovery. BDB filesystems do not currently support cancellation. + * + * Do any necessary allocation within @a pool. + * + * For FSFS filesystems, recovery is currently limited to recreating + * the db/current file, and does not require exclusive access. + * + * For BDB filesystems, recovery requires exclusive access, and is + * described in detail below. + * + * After an unexpected server exit, due to a server crash or a system + * crash, a Subversion filesystem based on Berkeley DB needs to run + * recovery procedures to bring the database back into a consistent + * state and release any locks that were held by the deceased process. + * The recovery procedures require exclusive access to the database + * --- while they execute, no other process or thread may access the + * database. + * + * In a server with multiple worker processes, like Apache, if a + * worker process accessing the filesystem dies, you must stop the + * other worker processes, and run recovery. Then, the other worker + * processes can re-open the database and resume work. + * + * If the server exited cleanly, there is no need to run recovery, but + * there is no harm in it, either, and it take very little time. So + * it's a fine idea to run recovery when the server process starts, + * before it begins handling any requests. + * + * @since New in 1.5. + */ +svn_error_t * +svn_fs_recover(const char *path, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Callback for svn_fs_freeze(). + * + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_fs_freeze_func_t)(void *baton, apr_pool_t *pool); + +/** + * Take an exclusive lock on @a fs to prevent commits and then invoke + * @a freeze_func passing @a freeze_baton. + * + * @note The BDB backend doesn't implement this feature so most + * callers should not call this function directly but should use the + * higher level svn_repos_freeze() instead. + * + * @see svn_repos_freeze() + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs_freeze(svn_fs_t *fs, + svn_fs_freeze_func_t freeze_func, + void *freeze_baton, + apr_pool_t *pool); + + +/** Subversion filesystems based on Berkeley DB. + * + * The following functions are specific to Berkeley DB filesystems. + * + * @defgroup svn_fs_bdb Berkeley DB filesystems + * @{ + */ + +/** Register an error handling function for Berkeley DB error messages. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * + * Despite being first declared deprecated in Subversion 1.3, this API + * is redundant in versions 1.1 and 1.2 as well. + * + * Berkeley DB's error codes are seldom sufficiently informative to allow + * adequate troubleshooting. Berkeley DB provides extra messages through + * a callback function - if an error occurs, the @a handler will be called + * with two strings: an error message prefix, which will be zero, and + * an error message. @a handler might print it out, log it somewhere, + * etc. + * + * Subversion 1.1 and later install their own handler internally, and + * wrap the messages from Berkeley DB into the standard svn_error_t object, + * making any information gained through this interface redundant. + * + * It is only worth using this function if your program will be used + * with Subversion 1.0. + * + * This function connects to the Berkeley DB @c DBENV->set_errcall interface. + * Since that interface supports only a single callback, Subversion's internal + * callback is registered with Berkeley DB, and will forward notifications to + * a user provided callback after performing its own processing. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_set_berkeley_errcall(svn_fs_t *fs, + void (*handler)(const char *errpfx, + char *msg)); + +/** Set @a *logfiles to an array of <tt>const char *</tt> log file names + * of Berkeley DB-based Subversion filesystem. + * + * If @a only_unused is @c TRUE, set @a *logfiles to an array which + * contains only the names of Berkeley DB log files no longer in use + * by the filesystem. Otherwise, all log files (used and unused) are + * returned. + + * This function wraps the Berkeley DB 'log_archive' function + * called by the db_archive binary. Repository administrators may + * want to run this function periodically and delete the unused log + * files, as a way of reclaiming disk space. + */ +svn_error_t * +svn_fs_berkeley_logfiles(apr_array_header_t **logfiles, + const char *path, + svn_boolean_t only_unused, + apr_pool_t *pool); + + +/** + * The following functions are similar to their generic counterparts. + * + * In Subversion 1.2 and earlier, they only work on Berkeley DB filesystems. + * In Subversion 1.3 and later, they perform largely as aliases for their + * generic counterparts (with the exception of recover, which only gained + * a generic counterpart in 1.5). + * + * @defgroup svn_fs_bdb_deprecated Berkeley DB filesystem compatibility + * @{ + */ + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +SVN_DEPRECATED +svn_fs_t * +svn_fs_new(apr_hash_t *fs_config, + apr_pool_t *pool); + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +SVN_DEPRECATED +svn_error_t * +svn_fs_create_berkeley(svn_fs_t *fs, + const char *path); + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +SVN_DEPRECATED +svn_error_t * +svn_fs_open_berkeley(svn_fs_t *fs, + const char *path); + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +SVN_DEPRECATED +const char * +svn_fs_berkeley_path(svn_fs_t *fs, + apr_pool_t *pool); + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +SVN_DEPRECATED +svn_error_t * +svn_fs_delete_berkeley(const char *path, + apr_pool_t *pool); + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +SVN_DEPRECATED +svn_error_t * +svn_fs_hotcopy_berkeley(const char *src_path, + const char *dest_path, + svn_boolean_t clean_logs, + apr_pool_t *pool); + +/** @deprecated Provided for backward compatibility with the 1.4 API. */ +SVN_DEPRECATED +svn_error_t * +svn_fs_berkeley_recover(const char *path, + apr_pool_t *pool); +/** @} */ + +/** @} */ + + +/** Filesystem Access Contexts. + * + * @since New in 1.2. + * + * At certain times, filesystem functions need access to temporary + * user data. For example, which user is changing a file? If the + * file is locked, has an appropriate lock-token been supplied? + * + * This temporary user data is stored in an "access context" object, + * and the access context is then connected to the filesystem object. + * Whenever a filesystem function requires information, it can pull + * things out of the context as needed. + * + * @defgroup svn_fs_access_ctx Filesystem access contexts + * @{ + */ + +/** An opaque object representing temporary user data. */ +typedef struct svn_fs_access_t svn_fs_access_t; + + +/** Set @a *access_ctx to a new #svn_fs_access_t object representing + * @a username, allocated in @a pool. @a username is presumed to + * have been authenticated by the caller. + * + * Make a deep copy of @a username. + */ +svn_error_t * +svn_fs_create_access(svn_fs_access_t **access_ctx, + const char *username, + apr_pool_t *pool); + + +/** Associate @a access_ctx with an open @a fs. + * + * This function can be run multiple times on the same open + * filesystem, in order to change the filesystem access context for + * different filesystem operations. Pass a NULL value for @a + * access_ctx to disassociate the current access context from the + * filesystem. + */ +svn_error_t * +svn_fs_set_access(svn_fs_t *fs, + svn_fs_access_t *access_ctx); + + +/** Set @a *access_ctx to the current @a fs access context, or NULL if + * there is no current fs access context. + */ +svn_error_t * +svn_fs_get_access(svn_fs_access_t **access_ctx, + svn_fs_t *fs); + + +/** Accessors for the access context: */ + +/** Set @a *username to the name represented by @a access_ctx. */ +svn_error_t * +svn_fs_access_get_username(const char **username, + svn_fs_access_t *access_ctx); + + +/** Push a lock-token @a token associated with path @a path into the + * context @a access_ctx. The context remembers all tokens it + * receives, and makes them available to fs functions. The token and + * path are not duplicated into @a access_ctx's pool; make sure the + * token's lifetime is at least as long as @a access_ctx. + * + * @since New in 1.6. */ +svn_error_t * +svn_fs_access_add_lock_token2(svn_fs_access_t *access_ctx, + const char *path, + const char *token); + +/** + * Same as svn_fs_access_add_lock_token2(), but with @a path set to value 1. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_access_add_lock_token(svn_fs_access_t *access_ctx, + const char *token); + +/** @} */ + + +/** Filesystem Nodes and Node-Revisions. + * + * In a Subversion filesystem, a `node' corresponds roughly to an + * `inode' in a Unix filesystem: + * - A node is either a file or a directory. + * - A node's contents change over time. + * - When you change a node's contents, it's still the same node; it's + * just been changed. So a node's identity isn't bound to a specific + * set of contents. + * - If you rename a node, it's still the same node, just under a + * different name. So a node's identity isn't bound to a particular + * filename. + * + * A `node revision' refers to one particular version of a node's contents, + * that existed over a specific period of time (one or more repository + * revisions). Changing a node's contents always creates a new revision of + * that node, which is to say creates a new `node revision'. Once created, + * a node revision's contents never change. + * + * When we create a node, its initial contents are the initial revision of + * the node. As users make changes to the node over time, we create new + * revisions of that same node. When a user commits a change that deletes + * a file from the filesystem, we don't delete the node, or any revision + * of it --- those stick around to allow us to recreate prior revisions of + * the filesystem. Instead, we just remove the reference to the node + * from the directory. + * + * Each node revision is a part of exactly one node, and appears only once + * in the history of that node. It is uniquely identified by a node + * revision id, #svn_fs_id_t. Its node revision id also identifies which + * node it is a part of. + * + * @note: Often when we talk about `the node' within the context of a single + * revision (or transaction), we implicitly mean `the node as it appears in + * this revision (or transaction)', or in other words `the node revision'. + * + * @note: Commonly, a node revision will have the same content as some other + * node revisions in the same node and in different nodes. The FS libraries + * allow different node revisions to share the same data without storing a + * separate copy of the data. + * + * @defgroup svn_fs_nodes Filesystem nodes + * @{ + */ + +/** An object representing a node-revision id. */ +typedef struct svn_fs_id_t svn_fs_id_t; + + +/** Return -1, 0, or 1 if node revisions @a a and @a b are respectively + * unrelated, equivalent, or otherwise related (part of the same node). + */ +int +svn_fs_compare_ids(const svn_fs_id_t *a, + const svn_fs_id_t *b); + + + +/** Return TRUE if node revisions @a id1 and @a id2 are related (part of the + * same node), else return FALSE. + */ +svn_boolean_t +svn_fs_check_related(const svn_fs_id_t *id1, + const svn_fs_id_t *id2); + + +/** + * @note This function is not guaranteed to work with all filesystem + * types. There is currently no un-deprecated equivalent; contact the + * Subversion developers if you have a need for it. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_fs_id_t * +svn_fs_parse_id(const char *data, + apr_size_t len, + apr_pool_t *pool); + + +/** Return a Subversion string containing the unparsed form of the + * node revision id @a id. Allocate the string containing the + * unparsed form in @a pool. + */ +svn_string_t * +svn_fs_unparse_id(const svn_fs_id_t *id, + apr_pool_t *pool); + +/** @} */ + + +/** Filesystem Transactions. + * + * To make a change to a Subversion filesystem: + * - Create a transaction object, using svn_fs_begin_txn(). + * - Call svn_fs_txn_root(), to get the transaction's root directory. + * - Make whatever changes you like in that tree. + * - Commit the transaction, using svn_fs_commit_txn(). + * + * The filesystem implementation guarantees that your commit will + * either: + * - succeed completely, so that all of the changes are committed to + * create a new revision of the filesystem, or + * - fail completely, leaving the filesystem unchanged. + * + * Until you commit the transaction, any changes you make are + * invisible. Only when your commit succeeds do they become visible + * to the outside world, as a new revision of the filesystem. + * + * If you begin a transaction, and then decide you don't want to make + * the change after all (say, because your net connection with the + * client disappeared before the change was complete), you can call + * svn_fs_abort_txn(), to cancel the entire transaction; this + * leaves the filesystem unchanged. + * + * The only way to change the contents of files or directories, or + * their properties, is by making a transaction and creating a new + * revision, as described above. Once a revision has been committed, it + * never changes again; the filesystem interface provides no means to + * go back and edit the contents of an old revision. Once history has + * been recorded, it is set in stone. Clients depend on this property + * to do updates and commits reliably; proxies depend on this property + * to cache changes accurately; and so on. + * + * There are two kinds of nodes in the filesystem: mutable, and + * immutable. Revisions in the filesystem consist entirely of + * immutable nodes, whose contents never change. A transaction in + * progress, which the user is still constructing, uses mutable nodes + * for those nodes which have been changed so far, and refers to + * immutable nodes from existing revisions for portions of the tree + * which haven't been changed yet in that transaction. + * + * Immutable nodes, as part of revisions, never refer to mutable + * nodes, which are part of uncommitted transactions. Mutable nodes + * may refer to immutable nodes, or other mutable nodes. + * + * Note that the terms "immutable" and "mutable" describe whether or + * not the nodes have been changed as part of a transaction --- not + * the permissions on the nodes they refer to. Even if you aren't + * authorized to modify the filesystem's root directory, you might be + * authorized to change some descendant of the root; doing so would + * create a new mutable copy of the root directory. Mutability refers + * to the role of the node: part of an existing revision, or part of a + * new one. This is independent of your authorization to make changes + * to a given node. + * + * Transactions are actually persistent objects, stored in the + * database. You can open a filesystem, begin a transaction, and + * close the filesystem, and then a separate process could open the + * filesystem, pick up the same transaction, and continue work on it. + * When a transaction is successfully committed, it is removed from + * the database. + * + * Every transaction is assigned a name. You can open a transaction + * by name, and resume work on it, or find out the name of a + * transaction you already have open. You can also list all the + * transactions currently present in the database. + * + * You may assign properties to transactions; these are name/value + * pairs. When you commit a transaction, all of its properties become + * unversioned revision properties of the new revision. (There is one + * exception: the svn:date property will be automatically set on new + * transactions to the date that the transaction was created, and will + * be overwritten when the transaction is committed by the current + * time; changes to a transaction's svn:date property will not affect + * its committed value.) + * + * Transaction names are guaranteed to contain only letters (upper- + * and lower-case), digits, `-', and `.', from the ASCII character + * set. + * + * The Subversion filesystem will make a best effort to not reuse + * transaction names. The Berkeley DB backend generates transaction + * names using a sequence, or a counter, which is stored in the BDB + * database. Each new transaction increments the counter. The + * current value of the counter is not serialized into a filesystem + * dump file, so dumping and restoring the repository will reset the + * sequence and reuse transaction names. The FSFS backend generates a + * transaction name using the hostname, process ID and current time in + * microseconds since 00:00:00 January 1, 1970 UTC. So it is + * extremely unlikely that a transaction name will be reused. + * + * @defgroup svn_fs_txns Filesystem transactions + * @{ + */ + +/** The type of a Subversion transaction object. */ +typedef struct svn_fs_txn_t svn_fs_txn_t; + + +/** @defgroup svn_fs_begin_txn2_flags Bitmask flags for svn_fs_begin_txn2() + * @since New in 1.2. + * @{ */ + +/** Do on-the-fly out-of-dateness checks. That is, an fs routine may + * throw error if a caller tries to edit an out-of-date item in the + * transaction. + * + * @warning ### Not yet implemented. + */ +#define SVN_FS_TXN_CHECK_OOD 0x00001 + +/** Do on-the-fly lock checks. That is, an fs routine may throw error + * if a caller tries to edit a locked item without having rights to the lock. + */ +#define SVN_FS_TXN_CHECK_LOCKS 0x00002 + +/** @} */ + +/** + * Begin a new transaction on the filesystem @a fs, based on existing + * revision @a rev. Set @a *txn_p to a pointer to the new transaction. + * When committed, this transaction will create a new revision. + * + * Allocate the new transaction in @a pool; when @a pool is freed, the new + * transaction will be closed (neither committed nor aborted). + * + * @a flags determines transaction enforcement behaviors, and is composed + * from the constants SVN_FS_TXN_* (#SVN_FS_TXN_CHECK_OOD etc.). + * + * @note If you're building a txn for committing, you probably + * don't want to call this directly. Instead, call + * svn_repos_fs_begin_txn_for_commit(), which honors the + * repository's hook configurations. + * + * @since New in 1.2. + */ +svn_error_t * +svn_fs_begin_txn2(svn_fs_txn_t **txn_p, + svn_fs_t *fs, + svn_revnum_t rev, + apr_uint32_t flags, + apr_pool_t *pool); + + +/** + * Same as svn_fs_begin_txn2(), but with @a flags set to 0. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_begin_txn(svn_fs_txn_t **txn_p, + svn_fs_t *fs, + svn_revnum_t rev, + apr_pool_t *pool); + + + +/** Commit @a txn. + * + * @note You usually don't want to call this directly. + * Instead, call svn_repos_fs_commit_txn(), which honors the + * repository's hook configurations. + * + * If the transaction conflicts with other changes committed to the + * repository, return an #SVN_ERR_FS_CONFLICT error. Otherwise, create + * a new filesystem revision containing the changes made in @a txn, + * storing that new revision number in @a *new_rev, and return zero. + * + * If @a conflict_p is non-zero, use it to provide details on any + * conflicts encountered merging @a txn with the most recent committed + * revisions. If a conflict occurs, set @a *conflict_p to the path of + * the conflict in @a txn, allocated within @a pool; + * otherwise, set @a *conflict_p to NULL. + * + * If the commit succeeds, @a txn is invalid. + * + * If the commit fails for any reason, @a *new_rev is an invalid + * revision number, an error other than #SVN_NO_ERROR is returned and + * @a txn is still valid; you can make more operations to resolve the + * conflict, or call svn_fs_abort_txn() to abort the transaction. + * + * @note Success or failure of the commit of @a txn is determined by + * examining the value of @a *new_rev upon this function's return. If + * the value is a valid revision number, the commit was successful, + * even though a non-@c NULL function return value may indicate that + * something else went wrong in post commit FS processing. + * + * @note See api-errata/1.8/fs001.txt for information on how this + * function was documented in versions prior to 1.8. + * + * ### need to document this better. there are four combinations of + * ### return values: + * ### 1) err=NULL. conflict=NULL. new_rev is valid + * ### 2) err=SVN_ERR_FS_CONFLICT. conflict is set. new_rev=SVN_INVALID_REVNUM + * ### 3) err=!NULL. conflict=NULL. new_rev is valid + * ### 4) err=!NULL. conflict=NULL. new_rev=SVN_INVALID_REVNUM + * ### + * ### some invariants: + * ### *conflict_p will be non-NULL IFF SVN_ERR_FS_CONFLICT + * ### if *conflict_p is set (and SVN_ERR_FS_CONFLICT), then new_rev + * ### will always be SVN_INVALID_REVNUM + * ### *conflict_p will always be initialized to NULL, or to a valid + * ### conflict string + * ### *new_rev will always be initialized to SVN_INVALID_REVNUM, or + * ### to a valid, committed revision number + */ +svn_error_t * +svn_fs_commit_txn(const char **conflict_p, + svn_revnum_t *new_rev, + svn_fs_txn_t *txn, + apr_pool_t *pool); + + +/** Abort the transaction @a txn. Any changes made in @a txn are + * discarded, and the filesystem is left unchanged. Use @a pool for + * any necessary allocations. + * + * @note This function first sets the state of @a txn to "dead", and + * then attempts to purge it and any related data from the filesystem. + * If some part of the cleanup process fails, @a txn and some portion + * of its data may remain in the database after this function returns. + * Use svn_fs_purge_txn() to retry the transaction cleanup. + */ +svn_error_t * +svn_fs_abort_txn(svn_fs_txn_t *txn, + apr_pool_t *pool); + + +/** Cleanup the dead transaction in @a fs whose ID is @a txn_id. Use + * @a pool for all allocations. If the transaction is not yet dead, + * the error #SVN_ERR_FS_TRANSACTION_NOT_DEAD is returned. (The + * caller probably forgot to abort the transaction, or the cleanup + * step of that abort failed for some reason.) + */ +svn_error_t * +svn_fs_purge_txn(svn_fs_t *fs, + const char *txn_id, + apr_pool_t *pool); + + +/** Set @a *name_p to the name of the transaction @a txn, as a + * NULL-terminated string. Allocate the name in @a pool. + */ +svn_error_t * +svn_fs_txn_name(const char **name_p, + svn_fs_txn_t *txn, + apr_pool_t *pool); + +/** Return @a txn's base revision. */ +svn_revnum_t +svn_fs_txn_base_revision(svn_fs_txn_t *txn); + + + +/** Open the transaction named @a name in the filesystem @a fs. Set @a *txn + * to the transaction. + * + * If there is no such transaction, #SVN_ERR_FS_NO_SUCH_TRANSACTION is + * the error returned. + * + * Allocate the new transaction in @a pool; when @a pool is freed, the new + * transaction will be closed (neither committed nor aborted). + */ +svn_error_t * +svn_fs_open_txn(svn_fs_txn_t **txn, + svn_fs_t *fs, + const char *name, + apr_pool_t *pool); + + +/** Set @a *names_p to an array of <tt>const char *</tt> ids which are the + * names of all the currently active transactions in the filesystem @a fs. + * Allocate the array in @a pool. + */ +svn_error_t * +svn_fs_list_transactions(apr_array_header_t **names_p, + svn_fs_t *fs, + apr_pool_t *pool); + +/* Transaction properties */ + +/** Set @a *value_p to the value of the property named @a propname on + * transaction @a txn. If @a txn has no property by that name, set + * @a *value_p to zero. Allocate the result in @a pool. + */ +svn_error_t * +svn_fs_txn_prop(svn_string_t **value_p, + svn_fs_txn_t *txn, + const char *propname, + apr_pool_t *pool); + + +/** Set @a *table_p to the entire property list of transaction @a txn, as + * an APR hash table allocated in @a pool. The resulting table maps property + * names to pointers to #svn_string_t objects containing the property value. + */ +svn_error_t * +svn_fs_txn_proplist(apr_hash_t **table_p, + svn_fs_txn_t *txn, + apr_pool_t *pool); + + +/** Change a transactions @a txn's property's value, or add/delete a + * property. @a name is the name of the property to change, and @a value + * is the new value of the property, or zero if the property should be + * removed altogether. Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_change_txn_prop(svn_fs_txn_t *txn, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + + +/** Change, add, and/or delete transaction property values in + * transaction @a txn. @a props is an array of <tt>svn_prop_t</tt> + * elements. This is equivalent to calling svn_fs_change_txn_prop() + * multiple times with the @c name and @c value fields of each + * successive <tt>svn_prop_t</tt>, but may be more efficient. + * (Properties not mentioned are left alone.) Do any necessary + * temporary allocation in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_fs_change_txn_props(svn_fs_txn_t *txn, + const apr_array_header_t *props, + apr_pool_t *pool); + +/** @} */ + + +/** Roots. + * + * An #svn_fs_root_t object represents the root directory of some + * revision or transaction in a filesystem. To refer to particular + * node or node revision, you provide a root, and a directory path + * relative to that root. + * + * @defgroup svn_fs_roots Filesystem roots + * @{ + */ + +/** The Filesystem Root object. */ +typedef struct svn_fs_root_t svn_fs_root_t; + + +/** Set @a *root_p to the root directory of revision @a rev in filesystem @a fs. + * Allocate @a *root_p in a private subpool of @a pool; the root can be + * destroyed earlier than @a pool by calling #svn_fs_close_root. + */ +svn_error_t * +svn_fs_revision_root(svn_fs_root_t **root_p, + svn_fs_t *fs, + svn_revnum_t rev, + apr_pool_t *pool); + + +/** Set @a *root_p to the root directory of @a txn. Allocate @a *root_p in a + * private subpool of @a pool; the root can be destroyed earlier than @a pool by + * calling #svn_fs_close_root. + */ +svn_error_t * +svn_fs_txn_root(svn_fs_root_t **root_p, + svn_fs_txn_t *txn, + apr_pool_t *pool); + + +/** Free the root directory @a root; this only needs to be used if you want to + * free the memory associated with @a root earlier than the time you destroy + * the pool passed to the function that created it (svn_fs_revision_root() or + * svn_fs_txn_root()). + */ +void +svn_fs_close_root(svn_fs_root_t *root); + + +/** Return the filesystem to which @a root belongs. */ +svn_fs_t * +svn_fs_root_fs(svn_fs_root_t *root); + + +/** Return @c TRUE iff @a root is a transaction root. */ +svn_boolean_t +svn_fs_is_txn_root(svn_fs_root_t *root); + +/** Return @c TRUE iff @a root is a revision root. */ +svn_boolean_t +svn_fs_is_revision_root(svn_fs_root_t *root); + + +/** If @a root is the root of a transaction, return the name of the + * transaction, allocated in @a pool; otherwise, return NULL. + */ +const char * +svn_fs_txn_root_name(svn_fs_root_t *root, + apr_pool_t *pool); + +/** If @a root is the root of a transaction, return the number of the + * revision on which is was based when created. Otherwise, return + * #SVN_INVALID_REVNUM. + * + * @since New in 1.5. + */ +svn_revnum_t +svn_fs_txn_root_base_revision(svn_fs_root_t *root); + +/** If @a root is the root of a revision, return the revision number. + * Otherwise, return #SVN_INVALID_REVNUM. + */ +svn_revnum_t +svn_fs_revision_root_revision(svn_fs_root_t *root); + +/** @} */ + + +/** Directory entry names and directory paths. + * + * Here are the rules for directory entry names, and directory paths: + * + * A directory entry name is a Unicode string encoded in UTF-8, and + * may not contain the NULL character (U+0000). The name should be in + * Unicode canonical decomposition and ordering. No directory entry + * may be named '.', '..', or the empty string. Given a directory + * entry name which fails to meet these requirements, a filesystem + * function returns an SVN_ERR_FS_PATH_SYNTAX error. + * + * A directory path is a sequence of zero or more directory entry + * names, separated by slash characters (U+002f), and possibly ending + * with slash characters. Sequences of two or more consecutive slash + * characters are treated as if they were a single slash. If a path + * ends with a slash, it refers to the same node it would without the + * slash, but that node must be a directory, or else the function + * returns an SVN_ERR_FS_NOT_DIRECTORY error. + * + * A path consisting of the empty string, or a string containing only + * slashes, refers to the root directory. + * + * @defgroup svn_fs_directories Filesystem directories + * @{ + */ + + + +/** The kind of change that occurred on the path. */ +typedef enum svn_fs_path_change_kind_t +{ + /** path modified in txn */ + svn_fs_path_change_modify = 0, + + /** path added in txn */ + svn_fs_path_change_add, + + /** path removed in txn */ + svn_fs_path_change_delete, + + /** path removed and re-added in txn */ + svn_fs_path_change_replace, + + /** ignore all previous change items for path (internal-use only) */ + svn_fs_path_change_reset + +} svn_fs_path_change_kind_t; + +/** Change descriptor. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type. + * + * @since New in 1.6. */ +typedef struct svn_fs_path_change2_t +{ + /** node revision id of changed path */ + const svn_fs_id_t *node_rev_id; + + /** kind of change */ + svn_fs_path_change_kind_t change_kind; + + /** were there text mods? */ + svn_boolean_t text_mod; + + /** were there property mods? */ + svn_boolean_t prop_mod; + + /** what node kind is the path? + (Note: it is legal for this to be #svn_node_unknown.) */ + svn_node_kind_t node_kind; + + /** Copyfrom revision and path; this is only valid if copyfrom_known + * is true. */ + svn_boolean_t copyfrom_known; + svn_revnum_t copyfrom_rev; + const char *copyfrom_path; + + /* NOTE! Please update svn_fs_path_change2_create() when adding new + fields here. */ +} svn_fs_path_change2_t; + + +/** Similar to #svn_fs_path_change2_t, but without kind and copyfrom + * information. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. + */ + +typedef struct svn_fs_path_change_t +{ + /** node revision id of changed path */ + const svn_fs_id_t *node_rev_id; + + /** kind of change */ + svn_fs_path_change_kind_t change_kind; + + /** were there text mods? */ + svn_boolean_t text_mod; + + /** were there property mods? */ + svn_boolean_t prop_mod; + +} svn_fs_path_change_t; + +/** + * Allocate an #svn_fs_path_change2_t structure in @a pool, initialize and + * return it. + * + * Set the @c node_rev_id field of the created struct to @a node_rev_id, and + * @c change_kind to @a change_kind. Set all other fields to their + * @c _unknown, @c NULL or invalid value, respectively. + * + * @since New in 1.6. + */ +svn_fs_path_change2_t * +svn_fs_path_change2_create(const svn_fs_id_t *node_rev_id, + svn_fs_path_change_kind_t change_kind, + apr_pool_t *pool); + +/** Determine what has changed under a @a root. + * + * Allocate and return a hash @a *changed_paths2_p containing descriptions + * of the paths changed under @a root. The hash is keyed with + * <tt>const char *</tt> paths, and has #svn_fs_path_change2_t * values. + * + * Callers can assume that this function takes time proportional to + * the amount of data output, and does not need to do tree crawls; + * however, it is possible that some of the @c node_kind fields in the + * #svn_fs_path_change2_t * values will be #svn_node_unknown or + * that and some of the @c copyfrom_known fields will be FALSE. + * + * Use @a pool for all allocations, including the hash and its values. + * + * @since New in 1.6. + */ +svn_error_t * +svn_fs_paths_changed2(apr_hash_t **changed_paths2_p, + svn_fs_root_t *root, + apr_pool_t *pool); + + +/** Same as svn_fs_paths_changed2(), only with #svn_fs_path_change_t * values + * in the hash (and thus no kind or copyfrom data). + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_paths_changed(apr_hash_t **changed_paths_p, + svn_fs_root_t *root, + apr_pool_t *pool); + +/** @} */ + + +/* Operations appropriate to all kinds of nodes. */ + +/** Set @a *kind_p to the type of node present at @a path under @a + * root. If @a path does not exist under @a root, set @a *kind_p to + * #svn_node_none. Use @a pool for temporary allocation. + */ +svn_error_t * +svn_fs_check_path(svn_node_kind_t *kind_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** An opaque node history object. */ +typedef struct svn_fs_history_t svn_fs_history_t; + + +/** Set @a *history_p to an opaque node history object which + * represents @a path under @a root. @a root must be a revision root. + * Use @a pool for all allocations. + */ +svn_error_t * +svn_fs_node_history(svn_fs_history_t **history_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Set @a *prev_history_p to an opaque node history object which + * represents the previous (or "next oldest") interesting history + * location for the filesystem node represented by @a history, or @c + * NULL if no such previous history exists. If @a cross_copies is @c + * FALSE, also return @c NULL if stepping backwards in history to @a + * *prev_history_p would cross a filesystem copy operation. + * + * @note If this is the first call to svn_fs_history_prev() for the @a + * history object, it could return a history object whose location is + * the same as the original. This will happen if the original + * location was an interesting one (where the node was modified, or + * took place in a copy event). This behavior allows looping callers + * to avoid the calling svn_fs_history_location() on the object + * returned by svn_fs_node_history(), and instead go ahead and begin + * calling svn_fs_history_prev(). + * + * @note This function uses node-id ancestry alone to determine + * modifiedness, and therefore does NOT claim that in any of the + * returned revisions file contents changed, properties changed, + * directory entries lists changed, etc. + * + * @note The revisions returned for @a path will be older than or + * the same age as the revision of that path in @a root. That is, if + * @a root is a revision root based on revision X, and @a path was + * modified in some revision(s) younger than X, those revisions + * younger than X will not be included for @a path. */ +svn_error_t * +svn_fs_history_prev(svn_fs_history_t **prev_history_p, + svn_fs_history_t *history, + svn_boolean_t cross_copies, + apr_pool_t *pool); + + +/** Set @a *path and @a *revision to the path and revision, + * respectively, of the @a history object. Use @a pool for all + * allocations. + */ +svn_error_t * +svn_fs_history_location(const char **path, + svn_revnum_t *revision, + svn_fs_history_t *history, + apr_pool_t *pool); + + +/** Set @a *is_dir to @c TRUE iff @a path in @a root is a directory. + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_is_dir(svn_boolean_t *is_dir, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Set @a *is_file to @c TRUE iff @a path in @a root is a file. + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_is_file(svn_boolean_t *is_file, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Get the id of a node. + * + * Set @a *id_p to the node revision ID of @a path in @a root, allocated in + * @a pool. + * + * If @a root is the root of a transaction, keep in mind that other + * changes to the transaction can change which node @a path refers to, + * and even whether the path exists at all. + */ +svn_error_t * +svn_fs_node_id(const svn_fs_id_t **id_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + +/** Set @a *revision to the revision in which @a path under @a root was + * created. Use @a pool for any temporary allocations. @a *revision will + * be set to #SVN_INVALID_REVNUM for uncommitted nodes (i.e. modified nodes + * under a transaction root). Note that the root of an unmodified transaction + * is not itself considered to be modified; in that case, return the revision + * upon which the transaction was based. + */ +svn_error_t * +svn_fs_node_created_rev(svn_revnum_t *revision, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + +/** Set @a *revision to the revision in which the line of history + * represented by @a path under @a root originated. Use @a pool for + * any temporary allocations. If @a root is a transaction root, @a + * *revision will be set to #SVN_INVALID_REVNUM for any nodes newly + * added in that transaction (brand new files or directories created + * using #svn_fs_make_dir or #svn_fs_make_file). + * + * @since New in 1.5. + */ +svn_error_t * +svn_fs_node_origin_rev(svn_revnum_t *revision, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + +/** Set @a *created_path to the path at which @a path under @a root was + * created. Use @a pool for all allocations. Callers may use this + * function in conjunction with svn_fs_node_created_rev() to perform a + * reverse lookup of the mapping of (path, revision) -> node-id that + * svn_fs_node_id() performs. + */ +svn_error_t * +svn_fs_node_created_path(const char **created_path, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Set @a *value_p to the value of the property named @a propname of + * @a path in @a root. If the node has no property by that name, set + * @a *value_p to zero. Allocate the result in @a pool. + */ +svn_error_t * +svn_fs_node_prop(svn_string_t **value_p, + svn_fs_root_t *root, + const char *path, + const char *propname, + apr_pool_t *pool); + + +/** Set @a *table_p to the entire property list of @a path in @a root, + * as an APR hash table allocated in @a pool. The resulting table maps + * property names to pointers to #svn_string_t objects containing the + * property value. + */ +svn_error_t * +svn_fs_node_proplist(apr_hash_t **table_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Change a node's property's value, or add/delete a property. + * + * - @a root and @a path indicate the node whose property should change. + * @a root must be the root of a transaction, not the root of a revision. + * - @a name is the name of the property to change. + * - @a value is the new value of the property, or zero if the property should + * be removed altogether. + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_change_node_prop(svn_fs_root_t *root, + const char *path, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + + +/** Determine if the properties of two path/root combinations are different. + * + * Set @a *changed_p to 1 if the properties at @a path1 under @a root1 differ + * from those at @a path2 under @a root2, or set it to 0 if they are the + * same. Both paths must exist under their respective roots, and both + * roots must be in the same filesystem. + */ +svn_error_t * +svn_fs_props_changed(svn_boolean_t *changed_p, + svn_fs_root_t *root1, + const char *path1, + svn_fs_root_t *root2, + const char *path2, + apr_pool_t *pool); + + +/** Discover a node's copy ancestry, if any. + * + * If the node at @a path in @a root was copied from some other node, set + * @a *rev_p and @a *path_p to the revision and path (expressed as an + * absolute filesystem path) of the other node, allocating @a *path_p + * in @a pool. + * + * Else if there is no copy ancestry for the node, set @a *rev_p to + * #SVN_INVALID_REVNUM and @a *path_p to NULL. + * + * If an error is returned, the values of @a *rev_p and @a *path_p are + * undefined, but otherwise, if one of them is set as described above, + * you may assume the other is set correspondingly. + * + * @a root may be a revision root or a transaction root. + * + * Notes: + * - Copy ancestry does not descend. After copying directory D to + * E, E will have copy ancestry referring to D, but E's children + * may not. See also svn_fs_copy(). + * + * - Copy ancestry *under* a copy is preserved. That is, if you + * copy /A/D/G/pi to /A/D/G/pi2, and then copy /A/D/G to /G, then + * /G/pi2 will still have copy ancestry pointing to /A/D/G/pi. + * We don't know if this is a feature or a bug yet; if it turns + * out to be a bug, then the fix is to make svn_fs_copied_from() + * observe the following logic, which currently callers may + * choose to follow themselves: if node X has copy history, but + * its ancestor A also has copy history, then you may ignore X's + * history if X's revision-of-origin is earlier than A's -- + * because that would mean that X's copy history was preserved in + * a copy-under-a-copy scenario. If X's revision-of-origin is + * the same as A's, then it was copied under A during the same + * transaction that created A. (X's revision-of-origin cannot be + * greater than A's, if X has copy history.) @todo See how + * people like this, it can always be hidden behind the curtain + * if necessary. + * + * - Copy ancestry is not stored as a regular subversion property + * because it is not inherited. Copying foo to bar results in a + * revision of bar with copy ancestry; but committing a text + * change to bar right after that results in a new revision of + * bar without copy ancestry. + */ +svn_error_t * +svn_fs_copied_from(svn_revnum_t *rev_p, + const char **path_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Set @a *root_p and @a *path_p to the revision root and path of the + * destination of the most recent copy event that caused @a path to + * exist where it does in @a root, or to NULL if no such copy exists. + * + * @a *path_p might be a parent of @a path, rather than @a path + * itself. However, it will always be the deepest relevant path. + * That is, if a copy occurs underneath another copy in the same txn, + * this function makes sure to set @a *path_p to the longest copy + * destination path that is still a parent of or equal to @a path. + * + * Values returned in @a *root_p and @a *path_p will be allocated + * from @a pool. + * + * @since New in 1.3. + */ +svn_error_t * +svn_fs_closest_copy(svn_fs_root_t **root_p, + const char **path_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Retrieve mergeinfo for multiple nodes. + * + * @a *catalog is a catalog for @a paths. It will never be @c NULL, + * but may be empty. + * + * @a root is revision root to use when looking up paths. + * + * @a paths are the paths you are requesting information for. + * + * @a inherit indicates whether to retrieve explicit, + * explicit-or-inherited, or only inherited mergeinfo. + * + * If @a adjust_inherited_mergeinfo is @c TRUE, then any inherited + * mergeinfo returned in @a *catalog is normalized to represent the + * inherited mergeinfo on the path which inherits it. If + * @a adjust_inherited_mergeinfo is @c FALSE, then any inherited + * mergeinfo is the raw explicit mergeinfo from the nearest parent + * of the path with explicit mergeinfo, unadjusted for the path-wise + * difference between the path and its parent. This may include + * non-inheritable mergeinfo. + * + * If @a include_descendants is TRUE, then additionally return the + * mergeinfo for any descendant of any element of @a paths which has + * the #SVN_PROP_MERGEINFO property explicitly set on it. (Note + * that inheritance is only taken into account for the elements in @a + * paths; descendants of the elements in @a paths which get their + * mergeinfo via inheritance are not included in @a *catalog.) + * + * Allocate @a *catalog in result_pool. Do any necessary temporary + * allocations in @a scratch_pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs_get_mergeinfo2(svn_mergeinfo_catalog_t *catalog, + svn_fs_root_t *root, + const apr_array_header_t *paths, + svn_mergeinfo_inheritance_t inherit, + svn_boolean_t include_descendants, + svn_boolean_t adjust_inherited_mergeinfo, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Same as svn_fs_get_mergeinfo2(), but with @a adjust_inherited_mergeinfo + * set always set to @c TRUE and with only one pool. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_get_mergeinfo(svn_mergeinfo_catalog_t *catalog, + svn_fs_root_t *root, + const apr_array_header_t *paths, + svn_mergeinfo_inheritance_t inherit, + svn_boolean_t include_descendants, + apr_pool_t *pool); + +/** Merge changes between two nodes into a third node. + * + * Given nodes @a source and @a target, and a common ancestor @a ancestor, + * modify @a target to contain all the changes made between @a ancestor and + * @a source, as well as the changes made between @a ancestor and @a target. + * @a target_root must be the root of a transaction, not a revision. + * + * @a source, @a target, and @a ancestor are generally directories; this + * function recursively merges the directories' contents. If they are + * files, this function simply returns an error whenever @a source, + * @a target, and @a ancestor are all distinct node revisions. + * + * If there are differences between @a ancestor and @a source that conflict + * with changes between @a ancestor and @a target, this function returns an + * #SVN_ERR_FS_CONFLICT error. + * + * If the merge is successful, @a target is left in the merged state, and + * the base root of @a target's txn is set to the root node of @a source. + * If an error is returned (whether for conflict or otherwise), @a target + * is left unaffected. + * + * If @a conflict_p is non-NULL, then: a conflict error sets @a *conflict_p + * to the name of the node in @a target which couldn't be merged, + * otherwise, success sets @a *conflict_p to NULL. + * + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_merge(const char **conflict_p, + svn_fs_root_t *source_root, + const char *source_path, + svn_fs_root_t *target_root, + const char *target_path, + svn_fs_root_t *ancestor_root, + const char *ancestor_path, + apr_pool_t *pool); + + + +/* Directories. */ + + +/** The type of a Subversion directory entry. */ +typedef struct svn_fs_dirent_t +{ + + /** The name of this directory entry. */ + const char *name; + + /** The node revision ID it names. */ + const svn_fs_id_t *id; + + /** The node kind. */ + svn_node_kind_t kind; + +} svn_fs_dirent_t; + + +/** Set @a *entries_p to a newly allocated APR hash table containing the + * entries of the directory at @a path in @a root. The keys of the table + * are entry names, as byte strings, excluding the final NULL + * character; the table's values are pointers to #svn_fs_dirent_t + * structures. Allocate the table and its contents in @a pool. + */ +svn_error_t * +svn_fs_dir_entries(apr_hash_t **entries_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Create a new directory named @a path in @a root. The new directory has + * no entries, and no properties. @a root must be the root of a transaction, + * not a revision. + * + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_make_dir(svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Delete the node named @a path in @a root. If the node being deleted is + * a directory, its contents will be deleted recursively. @a root must be + * the root of a transaction, not of a revision. Use @a pool for + * temporary allocation. + * + * If return #SVN_ERR_FS_NO_SUCH_ENTRY, then the basename of @a path is + * missing from its parent, that is, the final target of the deletion + * is missing. + * + * Attempting to remove the root dir also results in an error, + * #SVN_ERR_FS_ROOT_DIR, even if the dir is empty. + */ +svn_error_t * +svn_fs_delete(svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Create a copy of @a from_path in @a from_root named @a to_path in + * @a to_root. If @a from_path in @a from_root is a directory, copy the + * tree it refers to recursively. + * + * The copy will remember its source; use svn_fs_copied_from() to + * access this information. + * + * @a to_root must be the root of a transaction; @a from_root must be the + * root of a revision. (Requiring @a from_root to be the root of a + * revision makes the implementation trivial: there is no detectable + * difference (modulo node revision ID's) between copying @a from and + * simply adding a reference to it. So the operation takes place in + * constant time. However, there's no reason not to extend this to + * mutable nodes --- it's just more code.) Further, @a to_root and @a + * from_root must represent the same filesystem. + * + * @note To do a copy without preserving copy history, use + * svn_fs_revision_link(). + * + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_copy(svn_fs_root_t *from_root, + const char *from_path, + svn_fs_root_t *to_root, + const char *to_path, + apr_pool_t *pool); + + +/** Like svn_fs_copy(), but doesn't record copy history, and preserves + * the PATH. You cannot use svn_fs_copied_from() later to find out + * where this copy came from. + * + * Use svn_fs_revision_link() in situations where you don't care + * about the copy history, and where @a to_path and @a from_path are + * the same, because it is cheaper than svn_fs_copy(). + */ +svn_error_t * +svn_fs_revision_link(svn_fs_root_t *from_root, + svn_fs_root_t *to_root, + const char *path, + apr_pool_t *pool); + +/* Files. */ + +/** Set @a *length_p to the length of the file @a path in @a root, in bytes. + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_file_length(svn_filesize_t *length_p, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Set @a *checksum to the checksum of type @a kind for the file @a path. + * @a *checksum will be allocated out of @a pool, which will also be used + * for temporary allocations. + * + * If the filesystem does not have a prerecorded checksum of @a kind for + * @a path, and @a force is not TRUE, do not calculate a checksum + * dynamically, just put NULL into @a checksum. (By convention, the NULL + * checksum is considered to match any checksum.) + * + * Notes: + * + * You might wonder, why do we only provide this interface for file + * contents, and not for properties or directories? + * + * The answer is that property lists and directory entry lists are + * essentially data structures, not text. We serialize them for + * transmission, but there is no guarantee that the consumer will + * parse them into the same form, or even the same order, as the + * producer. It's difficult to find a checksumming method that + * reaches the same result given such variation in input. (I suppose + * we could calculate an independent MD5 sum for each propname and + * value, and XOR them together; same with directory entry names. + * Maybe that's the solution?) Anyway, for now we punt. The most + * important data, and the only data that goes through svndiff + * processing, is file contents, so that's what we provide + * checksumming for. + * + * Internally, of course, the filesystem checksums everything, because + * it has access to the lowest level storage forms: strings behind + * representations. + * + * @since New in 1.6. + */ +svn_error_t * +svn_fs_file_checksum(svn_checksum_t **checksum, + svn_checksum_kind_t kind, + svn_fs_root_t *root, + const char *path, + svn_boolean_t force, + apr_pool_t *pool); + +/** + * Same as svn_fs_file_checksum(), only always put the MD5 checksum of file + * @a path into @a digest, which should point to @c APR_MD5_DIGESTSIZE bytes + * of storage. If the checksum doesn't exist, put all 0's into @a digest. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_file_md5_checksum(unsigned char digest[], + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Set @a *contents to a readable generic stream that will yield the + * contents of the file @a path in @a root. Allocate the stream in + * @a pool. You can only use @a *contents for as long as the underlying + * filesystem is open. If @a path is not a file, return + * #SVN_ERR_FS_NOT_FILE. + * + * If @a root is the root of a transaction, it is possible that the + * contents of the file @a path will change between calls to + * svn_fs_file_contents(). In that case, the result of reading from + * @a *contents is undefined. + * + * ### @todo kff: I am worried about lifetime issues with this pool vs + * the trail created farther down the call stack. Trace this function + * to investigate... + */ +svn_error_t * +svn_fs_file_contents(svn_stream_t **contents, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + +/** + * Callback function type used with svn_fs_try_process_file_contents() + * that delivers the immutable, non-NULL @a contents of @a len bytes. + * @a baton is an implementation-specific closure. + * + * Use @a scratch_pool for allocations. + * + * @since New in 1.8. + */ +typedef svn_error_t * +(*svn_fs_process_contents_func_t)(const unsigned char *contents, + apr_size_t len, + void *baton, + apr_pool_t *scratch_pool); + +/** Efficiently deliver the contents of the file @a path in @a root + * via @a processor (with @a baton), setting @a *success to @c TRUE + * upon doing so. Use @a pool for allocations. + * + * This function is intended to support zero copy data processing. It may + * not be implemented for all data backends or not applicable for certain + * content. In that case, @a *success will always be @c FALSE. Also, this + * is a best-effort function which means that there is no guarantee that + * @a processor gets called at all for some content. + * + * @note @a processor is expected to be relatively short function with + * at most O(content size) runtime. + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs_try_process_file_contents(svn_boolean_t *success, + svn_fs_root_t *root, + const char *path, + svn_fs_process_contents_func_t processor, + void* baton, + apr_pool_t *pool); + +/** Create a new file named @a path in @a root. The file's initial contents + * are the empty string, and it has no properties. @a root must be the + * root of a transaction, not a revision. + * + * Do any necessary temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_make_file(svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** Apply a text delta to the file @a path in @a root. @a root must be the + * root of a transaction, not a revision. + * + * Set @a *contents_p to a function ready to receive text delta windows + * describing how to change the file's contents, relative to its + * current contents. Set @a *contents_baton_p to a baton to pass to + * @a *contents_p. + * + * If @a path does not exist in @a root, return an error. (You cannot use + * this routine to create new files; use svn_fs_make_file() to create + * an empty file first.) + * + * @a base_checksum is the hex MD5 digest for the base text against + * which the delta is to be applied; it is ignored if NULL, and may be + * ignored even if not NULL. If it is not ignored, it must match the + * checksum of the base text against which svndiff data is being + * applied; if not, svn_fs_apply_textdelta() or the @a *contents_p call + * which detects the mismatch will return the error + * #SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may + * still be an error if @a base_checksum is neither NULL nor the + * checksum of the empty string). + * + * @a result_checksum is the hex MD5 digest for the fulltext that + * results from this delta application. It is ignored if NULL, but if + * not NULL, it must match the checksum of the result; if it does not, + * then the @a *contents_p call which detects the mismatch will return + * the error #SVN_ERR_CHECKSUM_MISMATCH. + * + * The caller must send all delta windows including the terminating + * NULL window to @a *contents_p before making further changes to the + * transaction. + * + * Do temporary allocation in @a pool. + */ +svn_error_t * +svn_fs_apply_textdelta(svn_txdelta_window_handler_t *contents_p, + void **contents_baton_p, + svn_fs_root_t *root, + const char *path, + const char *base_checksum, + const char *result_checksum, + apr_pool_t *pool); + + +/** Write data directly to the file @a path in @a root. @a root must be the + * root of a transaction, not a revision. + * + * Set @a *contents_p to a stream ready to receive full textual data. + * When the caller closes this stream, the data replaces the previous + * contents of the file. The caller must write all file data and close + * the stream before making further changes to the transaction. + * + * If @a path does not exist in @a root, return an error. (You cannot use + * this routine to create new files; use svn_fs_make_file() to create + * an empty file first.) + * + * @a result_checksum is the hex MD5 digest for the final fulltext + * written to the stream. It is ignored if NULL, but if not null, it + * must match the checksum of the result; if it does not, then the @a + * *contents_p call which detects the mismatch will return the error + * #SVN_ERR_CHECKSUM_MISMATCH. + * + * Do any necessary temporary allocation in @a pool. + * + * ### This is like svn_fs_apply_textdelta(), but takes the text + * straight. It is currently used only by the loader, see + * libsvn_repos/load.c. It should accept a checksum, of course, which + * would come from an (optional) header in the dump file. See + * http://subversion.tigris.org/issues/show_bug.cgi?id=1102 for more. + */ +svn_error_t * +svn_fs_apply_text(svn_stream_t **contents_p, + svn_fs_root_t *root, + const char *path, + const char *result_checksum, + apr_pool_t *pool); + + +/** Check if the contents of two root/path combos have changed. + * + * Set @a *changed_p to 1 if the contents at @a path1 under @a root1 differ + * from those at @a path2 under @a root2, or set it to 0 if they are the + * same. Both paths must exist under their respective roots, and both + * roots must be in the same filesystem. + */ +svn_error_t * +svn_fs_contents_changed(svn_boolean_t *changed_p, + svn_fs_root_t *root1, + const char *path1, + svn_fs_root_t *root2, + const char *path2, + apr_pool_t *pool); + + + +/* Filesystem revisions. */ + + +/** Set @a *youngest_p to the number of the youngest revision in filesystem + * @a fs. Use @a pool for all temporary allocation. + * + * The oldest revision in any filesystem is numbered zero. + */ +svn_error_t * +svn_fs_youngest_rev(svn_revnum_t *youngest_p, + svn_fs_t *fs, + apr_pool_t *pool); + + +/** Provide filesystem @a fs the opportunity to compress storage relating to + * associated with @a revision in filesystem @a fs. Use @a pool for all + * allocations. + * + * @note This can be a time-consuming process, depending the breadth + * of the changes made in @a revision, and the depth of the history of + * those changed paths. This may also be a no op. + */ +svn_error_t * +svn_fs_deltify_revision(svn_fs_t *fs, + svn_revnum_t revision, + apr_pool_t *pool); + + +/** Set @a *value_p to the value of the property named @a propname on + * revision @a rev in the filesystem @a fs. If @a rev has no property by + * that name, set @a *value_p to zero. Allocate the result in @a pool. + */ +svn_error_t * +svn_fs_revision_prop(svn_string_t **value_p, + svn_fs_t *fs, + svn_revnum_t rev, + const char *propname, + apr_pool_t *pool); + + +/** Set @a *table_p to the entire property list of revision @a rev in + * filesystem @a fs, as an APR hash table allocated in @a pool. The table + * maps <tt>char *</tt> property names to #svn_string_t * values; the names + * and values are allocated in @a pool. + */ +svn_error_t * +svn_fs_revision_proplist(apr_hash_t **table_p, + svn_fs_t *fs, + svn_revnum_t rev, + apr_pool_t *pool); + + +/** Change a revision's property's value, or add/delete a property. + * + * - @a fs is a filesystem, and @a rev is the revision in that filesystem + * whose property should change. + * - @a name is the name of the property to change. + * - if @a old_value_p is not @c NULL, then changing the property will fail with + * error #SVN_ERR_FS_PROP_BASEVALUE_MISMATCH if the present value of the + * property is not @a *old_value_p. (This is an atomic test-and-set). + * @a *old_value_p may be @c NULL, representing that the property must be not + * already set. + * - @a value is the new value of the property, or zero if the property should + * be removed altogether. + * + * Note that revision properties are non-historied --- you can change + * them after the revision has been committed. They are not protected + * via transactions. + * + * Do any necessary temporary allocation in @a pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_fs_change_rev_prop2(svn_fs_t *fs, + svn_revnum_t rev, + const char *name, + const svn_string_t *const *old_value_p, + const svn_string_t *value, + apr_pool_t *pool); + + +/** + * Similar to svn_fs_change_rev_prop2(), but with @a old_value_p passed as + * @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_change_rev_prop(svn_fs_t *fs, + svn_revnum_t rev, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + + + +/* Computing deltas. */ + + +/** Set @a *stream_p to a pointer to a delta stream that will turn the + * contents of the file @a source into the contents of the file @a target. + * If @a source_root is zero, use a file with zero length as the source. + * + * This function does not compare the two files' properties. + * + * Allocate @a *stream_p, and do any necessary temporary allocation, in + * @a pool. + */ +svn_error_t * +svn_fs_get_file_delta_stream(svn_txdelta_stream_t **stream_p, + svn_fs_root_t *source_root, + const char *source_path, + svn_fs_root_t *target_root, + const char *target_path, + apr_pool_t *pool); + + + +/* UUID manipulation. */ + +/** Populate @a *uuid with the UUID associated with @a fs. Allocate + @a *uuid in @a pool. */ +svn_error_t * +svn_fs_get_uuid(svn_fs_t *fs, + const char **uuid, + apr_pool_t *pool); + + +/** If not @c NULL, associate @a *uuid with @a fs. Otherwise (if @a + * uuid is @c NULL), generate a new UUID for @a fs. Use @a pool for + * any scratch work. + */ +svn_error_t * +svn_fs_set_uuid(svn_fs_t *fs, + const char *uuid, + apr_pool_t *pool); + + +/* Non-historical properties. */ + +/* [[Yes, do tell.]] */ + + + +/** @defgroup svn_fs_locks Filesystem locks + * @{ + * @since New in 1.2. */ + +/** A lock represents one user's exclusive right to modify a path in a + * filesystem. In order to create or destroy a lock, a username must + * be associated with the filesystem's access context (see + * #svn_fs_access_t). + * + * When a lock is created, a 'lock-token' is returned. The lock-token + * is a unique URI that represents the lock (treated as an opaque + * string by the client), and is required to make further use of the + * lock (including removal of the lock.) A lock-token can also be + * queried to return a svn_lock_t structure that describes the details + * of the lock. lock-tokens must not contain any newline character, + * mainly due to the serialization for tokens for pre-commit hook. + * + * Locks are not secret; anyone can view existing locks in a + * filesystem. Locks are not omnipotent: they can broken and stolen + * by people who don't "own" the lock. (Though admins can tailor a + * custom break/steal policy via libsvn_repos pre-lock hook script.) + * + * Locks can be created with an optional expiration date. If a lock + * has an expiration date, then the act of fetching/reading it might + * cause it to automatically expire, returning either nothing or an + * expiration error (depending on the API). + */ + + +/** Lock @a path in @a fs, and set @a *lock to a lock + * representing the new lock, allocated in @a pool. + * + * @warning You may prefer to use svn_repos_fs_lock() instead, + * which see. + * + * @a fs must have a username associated with it (see + * #svn_fs_access_t), else return #SVN_ERR_FS_NO_USER. Set the + * 'owner' field in the new lock to the fs username. + * + * @a comment is optional: it's either an xml-escapable UTF8 string + * which describes the lock, or it is @c NULL. + * + * @a is_dav_comment describes whether the comment was created by a + * generic DAV client; only mod_dav_svn's autoversioning feature needs + * to use it. If in doubt, pass 0. + * + * If path is already locked, then return #SVN_ERR_FS_PATH_ALREADY_LOCKED, + * unless @a steal_lock is TRUE, in which case "steal" the existing + * lock, even if the FS access-context's username does not match the + * current lock's owner: delete the existing lock on @a path, and + * create a new one. + * + * @a token is a lock token such as can be generated using + * svn_fs_generate_lock_token() (indicating that the caller wants to + * dictate the lock token used), or it is @c NULL (indicating that the + * caller wishes to have a new token generated by this function). If + * @a token is not @c NULL, and represents an existing lock, then @a + * path must match the path associated with that existing lock. + * + * If @a expiration_date is zero, then create a non-expiring lock. + * Else, the lock will expire at @a expiration_date. + * + * If @a current_rev is a valid revnum, then do an out-of-dateness + * check. If the revnum is less than the last-changed-revision of @a + * path (or if @a path doesn't exist in HEAD), return + * #SVN_ERR_FS_OUT_OF_DATE. + * + * @note At this time, only files can be locked. + */ +svn_error_t * +svn_fs_lock(svn_lock_t **lock, + svn_fs_t *fs, + const char *path, + const char *token, + const char *comment, + svn_boolean_t is_dav_comment, + apr_time_t expiration_date, + svn_revnum_t current_rev, + svn_boolean_t steal_lock, + apr_pool_t *pool); + + +/** Generate a unique lock-token using @a fs. Return in @a *token, + * allocated in @a pool. + * + * This can be used in to populate lock->token before calling + * svn_fs_attach_lock(). + */ +svn_error_t * +svn_fs_generate_lock_token(const char **token, + svn_fs_t *fs, + apr_pool_t *pool); + + +/** Remove the lock on @a path represented by @a token in @a fs. + * + * If @a token doesn't point to a lock, return #SVN_ERR_FS_BAD_LOCK_TOKEN. + * If @a token points to an expired lock, return #SVN_ERR_FS_LOCK_EXPIRED. + * If @a fs has no username associated with it, return #SVN_ERR_FS_NO_USER + * unless @a break_lock is specified. + * + * If @a token points to a lock, but the username of @a fs's access + * context doesn't match the lock's owner, return + * #SVN_ERR_FS_LOCK_OWNER_MISMATCH. If @a break_lock is TRUE, however, don't + * return error; allow the lock to be "broken" in any case. In the latter + * case, @a token shall be @c NULL. + * + * Use @a pool for temporary allocations. + */ +svn_error_t * +svn_fs_unlock(svn_fs_t *fs, + const char *path, + const char *token, + svn_boolean_t break_lock, + apr_pool_t *pool); + + +/** If @a path is locked in @a fs, set @a *lock to an svn_lock_t which + * represents the lock, allocated in @a pool. + * + * If @a path is not locked, set @a *lock to NULL. + */ +svn_error_t * +svn_fs_get_lock(svn_lock_t **lock, + svn_fs_t *fs, + const char *path, + apr_pool_t *pool); + + +/** The type of a lock discovery callback function. @a baton is the + * value specified in the call to svn_fs_get_locks(); the filesystem + * passes it through to the callback. @a lock is a lock structure. + * @a pool is a temporary subpool for use by the callback + * implementation -- it is cleared after invocation of the callback. + */ +typedef svn_error_t *(*svn_fs_get_locks_callback_t)(void *baton, + svn_lock_t *lock, + apr_pool_t *pool); + + +/** Report locks on or below @a path in @a fs using the @a + * get_locks_func / @a get_locks_baton. Use @a pool for necessary + * allocations. + * + * @a depth limits the reported locks to those associated with paths + * within the specified depth of @a path, and must be one of the + * following values: #svn_depth_empty, #svn_depth_files, + * #svn_depth_immediates, or #svn_depth_infinity. + * + * If the @a get_locks_func callback implementation returns an error, + * lock iteration will terminate and that error will be returned by + * this function. + * + * @note Over the course of this function's invocation, locks might be + * added, removed, or modified by concurrent processes. Callers need + * to anticipate and gracefully handle the transience of this + * information. + * + * @since New in 1.7. + */ +svn_error_t * +svn_fs_get_locks2(svn_fs_t *fs, + const char *path, + svn_depth_t depth, + svn_fs_get_locks_callback_t get_locks_func, + void *get_locks_baton, + apr_pool_t *pool); + +/** Similar to svn_fs_get_locks2(), but with @a depth always passed as + * svn_depth_infinity, and with the following known problem (which is + * not present in svn_fs_get_locks2()): + * + * @note On Berkeley-DB-backed filesystems in Subversion 1.6 and + * prior, the @a get_locks_func callback will be invoked from within a + * Berkeley-DB transaction trail. Implementors of the callback are, + * as a result, forbidden from calling any svn_fs API functions which + * might themselves attempt to start a new Berkeley DB transaction + * (which is most of this svn_fs API). Yes, this is a nasty + * implementation detail to have to be aware of. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_fs_get_locks(svn_fs_t *fs, + const char *path, + svn_fs_get_locks_callback_t get_locks_func, + void *get_locks_baton, + apr_pool_t *pool); + +/** @} */ + +/** + * Append a textual list of all available FS modules to the stringbuf + * @a output. Third-party modules are only included if repository + * access has caused them to be loaded. + * + * @since New in 1.2. + */ +svn_error_t * +svn_fs_print_modules(svn_stringbuf_t *output, + apr_pool_t *pool); + + +/** The kind of action being taken by 'pack'. */ +typedef enum svn_fs_pack_notify_action_t +{ + /** packing of the shard has commenced */ + svn_fs_pack_notify_start = 0, + + /** packing of the shard is completed */ + svn_fs_pack_notify_end, + + /** packing of the shard revprops has commenced + @since New in 1.7. */ + svn_fs_pack_notify_start_revprop, + + /** packing of the shard revprops has completed + @since New in 1.7. */ + svn_fs_pack_notify_end_revprop + +} svn_fs_pack_notify_action_t; + +/** The type of a pack notification function. @a shard is the shard being + * acted upon; @a action is the type of action being performed. @a baton is + * the corresponding baton for the notification function, and @a pool can + * be used for temporary allocations, but will be cleared between invocations. + */ +typedef svn_error_t *(*svn_fs_pack_notify_t)(void *baton, + apr_int64_t shard, + svn_fs_pack_notify_action_t action, + apr_pool_t *pool); + +/** + * Possibly update the filesystem located in the directory @a path + * to use disk space more efficiently. + * + * @since New in 1.6. + */ +svn_error_t * +svn_fs_pack(const char *db_path, + svn_fs_pack_notify_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Perform backend-specific data consistency and correctness validations + * to the Subversion filesystem (mainly the meta-data) located in the + * directory @a path. Use the backend-specific configuration @a fs_config + * when opening the filesystem. @a NULL is valid for all backends. + * Use @a scratch_pool for temporary allocations. + * + * @a start and @a end define the (minimum) range of revisions to check. + * If @a start is #SVN_INVALID_REVNUM, it defaults to @c r0. Likewise, + * @a end will default to the current youngest repository revision when + * given as #SVN_INVALID_REVNUM. Since meta data checks may have to touch + * other revisions as well, you may receive notifications for revisions + * outside the specified range. In fact, it is perfectly legal for a FS + * implementation to always check all revisions. + * + * Global invariants are only guaranteed to get verified when @a r0 has + * been included in the range of revisions to check. + * + * The optional @a notify_func callback is only a general feedback that + * the operation is still in process but may be called in random revisions + * order and more than once for the same revision, i.e. r2, r1, r2 would + * be a valid sequence. + * + * The optional @a cancel_func callback will be invoked as usual to allow + * the user to preempt this potentially lengthy operation. + * + * @note You probably don't want to use this directly. Take a look at + * svn_repos_verify_fs2() instead, which does non-backend-specific + * verifications as well. + * + * @note To ensure a full verification using all tests and covering all + * revisions, you must call this function *and* #svn_fs_verify_root. + * + * @note Implementors, please do tests that can be done efficiently for + * a single revision in #svn_fs_verify_root. This function is meant for + * global checks or tests that require an expensive context setup. + * + * @see svn_repos_verify_fs2() + * @see svn_fs_verify_root() + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs_verify(const char *path, + apr_hash_t *fs_config, + svn_revnum_t start, + svn_revnum_t end, + svn_fs_progress_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Perform backend-specific data consistency and correctness validations + * of @a root in the Subversion filesystem @a fs. @a root is typically + * a revision root (see svn_fs_revision_root()), but may be a + * transaction root. Use @a scratch_pool for temporary allocations. + * + * @note You probably don't want to use this directly. Take a look at + * svn_repos_verify_fs2() instead, which does non-backend-specific + * verifications as well. + * + * @note To ensure a full verification using all available tests and + * covering all revisions, you must call both this function and + * #svn_fs_verify. + * + * @note Implementors, please perform tests that cannot be done + * efficiently for a single revision in #svn_fs_verify. This function + * is intended for local checks that don't require an expensive context + * setup. + * + * @see svn_repos_verify_fs2() + * @see svn_fs_verify() + * + * @since New in 1.8. + */ +svn_error_t * +svn_fs_verify_root(svn_fs_root_t *root, + apr_pool_t *scratch_pool); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_FS_H */ diff --git a/subversion/include/svn_hash.h b/subversion/include/svn_hash.h new file mode 100644 index 0000000..46b4760 --- /dev/null +++ b/subversion/include/svn_hash.h @@ -0,0 +1,265 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_hash.h + * @brief Dumping and reading hash tables to/from files. + */ + + +#ifndef SVN_HASH_H +#define SVN_HASH_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_file_io.h> /* for apr_file_t */ + +#include "svn_types.h" +#include "svn_io.h" /* for svn_stream_t */ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** The longest the "K <number>" line can be in one of our hashdump files. */ +#define SVN_KEYLINE_MAXLEN 100 + +/** + * @defgroup svn_hash_support Hash table serialization support + * @{ + */ + +/*----------------------------------------------------*/ + +/** Reading/writing hashtables to disk + * + * @defgroup svn_hash_read_write Reading and writing hashtables to disk + * @{ + */ + +/** + * The conventional terminator for hash dumps. + * + * @since New in 1.1. + */ +#define SVN_HASH_TERMINATOR "END" + +/** + * Read a hash table from @a stream, storing the resultants names and + * values in @a hash. Use a @a pool for all allocations. @a hash will + * have <tt>const char *</tt> keys and <tt>svn_string_t *</tt> values. + * If @a terminator is NULL, expect the hash to be terminated by the + * end of the stream; otherwise, expect the hash to be terminated by a + * line containing @a terminator. Pass @c SVN_HASH_TERMINATOR to use + * the conventional terminator "END". + * + * @since New in 1.1. + */ +svn_error_t * +svn_hash_read2(apr_hash_t *hash, + svn_stream_t *stream, + const char *terminator, + apr_pool_t *pool); + +/** + * Dump @a hash to @a stream. Use @a pool for all allocations. @a + * hash has <tt>const char *</tt> keys and <tt>svn_string_t *</tt> + * values. If @a terminator is not NULL, terminate the hash with a + * line containing @a terminator. + * + * @since New in 1.1. + */ +svn_error_t * +svn_hash_write2(apr_hash_t *hash, + svn_stream_t *stream, + const char *terminator, + apr_pool_t *pool); + +/** + * Similar to svn_hash_read2(), but allows @a stream to contain + * deletion lines which remove entries from @a hash as well as adding + * to it. + * + * @since New in 1.1. + */ +svn_error_t * +svn_hash_read_incremental(apr_hash_t *hash, + svn_stream_t *stream, + const char *terminator, + apr_pool_t *pool); + +/** + * Similar to svn_hash_write2(), but only writes out entries for + * keys which differ between @a hash and @a oldhash, and also writes + * out deletion lines for keys which are present in @a oldhash but not + * in @a hash. + * + * @since New in 1.1. + */ +svn_error_t * +svn_hash_write_incremental(apr_hash_t *hash, + apr_hash_t *oldhash, + svn_stream_t *stream, + const char *terminator, + apr_pool_t *pool); + +/** + * This function behaves like svn_hash_read2(), but it only works + * on an apr_file_t input, empty files are accepted, and the hash is + * expected to be terminated with a line containing "END" or + * "PROPS-END". + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_hash_read(apr_hash_t *hash, + apr_file_t *srcfile, + apr_pool_t *pool); + +/** + * This function behaves like svn_hash_write2(), but it only works + * on an apr_file_t output, and the terminator is always "END". + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_hash_write(apr_hash_t *hash, + apr_file_t *destfile, + apr_pool_t *pool); + +/** @} */ + + +/** Taking the "diff" of two hash tables. + * + * @defgroup svn_hash_diff Taking the diff of two hash tables. + * @{ + */ + +/** Hash key status indicator for svn_hash_diff_func_t. */ +enum svn_hash_diff_key_status + { + /* Key is present in both hashes. */ + svn_hash_diff_key_both, + + /* Key is present in first hash only. */ + svn_hash_diff_key_a, + + /* Key is present in second hash only. */ + svn_hash_diff_key_b + }; + + +/** Function type for expressing a key's status between two hash tables. */ +typedef svn_error_t *(*svn_hash_diff_func_t) + (const void *key, apr_ssize_t klen, + enum svn_hash_diff_key_status status, + void *baton); + + +/** Take the diff of two hashtables. + * + * For each key in the union of @a hash_a's and @a hash_b's keys, invoke + * @a diff_func exactly once, passing the key, the key's length, an enum + * @c svn_hash_diff_key_status indicating which table(s) the key appears + * in, and @a diff_func_baton. + * + * Process all keys of @a hash_a first, then all remaining keys of @a hash_b. + * + * If @a diff_func returns error, return that error immediately, without + * applying @a diff_func to anything else. + * + * @a hash_a or @a hash_b or both may be NULL; treat a null table as though + * empty. + * + * Use @a pool for temporary allocation. + */ +svn_error_t * +svn_hash_diff(apr_hash_t *hash_a, + apr_hash_t *hash_b, + svn_hash_diff_func_t diff_func, + void *diff_func_baton, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_hash_misc Miscellaneous hash APIs + * @{ + */ + +/** + * Return the keys to @a hash in @a *array. The keys are assumed to be + * (const char *). The keys are in no particular order. + * + * @a *array itself is allocated in @a pool; however, the keys are not + * copied from the hash. + * + * @since New in 1.5. + */ +svn_error_t * +svn_hash_keys(apr_array_header_t **array, + apr_hash_t *hash, + apr_pool_t *pool); + +/** + * Set @a *hash to a new hash whose keys come from the items in @a keys + * (an array of <tt>const char *</tt> items), and whose values are + * match their corresponding key. Use @a pool for all allocations + * (including @a *hash, its keys, and its values). + * + * @since New in 1.5. + */ +svn_error_t * +svn_hash_from_cstring_keys(apr_hash_t **hash, + const apr_array_header_t *keys, + apr_pool_t *pool); + +/** Shortcut for apr_hash_get() with a const char * key. + * + * @since New in 1.8. + */ +#define svn_hash_gets(ht, key) \ + apr_hash_get(ht, key, APR_HASH_KEY_STRING) + +/** Shortcut for apr_hash_set() with a const char * key. + * + * @since New in 1.8. + */ +#define svn_hash_sets(ht, key, val) \ + apr_hash_set(ht, key, APR_HASH_KEY_STRING, val) + +/** @} */ + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_HASH_H */ diff --git a/subversion/include/svn_io.h b/subversion/include/svn_io.h new file mode 100644 index 0000000..92874e1 --- /dev/null +++ b/subversion/include/svn_io.h @@ -0,0 +1,2282 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_io.h + * @brief General file I/O for Subversion + */ + +/* ==================================================================== */ + + +#ifndef SVN_IO_H +#define SVN_IO_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_time.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_file_io.h> +#include <apr_file_info.h> +#include <apr_thread_proc.h> /* for apr_proc_t, apr_exit_why_e */ + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_checksum.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** Used as an argument when creating temporary files to indicate + * when a file should be removed. + * + * @since New in 1.4. + * + * Not specifying any of these means no removal at all. */ +typedef enum svn_io_file_del_t +{ + /** No deletion ever */ + svn_io_file_del_none = 0, + /** Remove when the file is closed */ + svn_io_file_del_on_close, + /** Remove when the associated pool is cleared */ + svn_io_file_del_on_pool_cleanup +} svn_io_file_del_t; + +/** A set of directory entry data elements as returned by svn_io_get_dirents + * + * Note that the first two fields are exactly identical to svn_io_dirent_t + * to allow returning a svn_io_dirent2_t as a svn_io_dirent_t. + * + * Use svn_io_dirent2_create() to create new svn_dirent2_t instances or + * svn_io_dirent2_dup() to duplicate an existing instance. + * + * @since New in 1.7. + */ +typedef struct svn_io_dirent2_t { + /* New fields must be added at the end to preserve binary compatibility */ + + /** The kind of this entry. */ + svn_node_kind_t kind; + + /** If @c kind is #svn_node_file, whether this entry is a special file; + * else FALSE. + * + * @see svn_io_check_special_path(). + */ + svn_boolean_t special; + + /** The filesize of this entry or undefined for a directory */ + svn_filesize_t filesize; + + /** The time the file was last modified */ + apr_time_t mtime; + + /* Don't forget to update svn_io_dirent2_dup() when adding new fields */ +} svn_io_dirent2_t; + + +/** Creates a new #svn_io_dirent2_t structure + * + * @since New in 1.7. + */ +svn_io_dirent2_t * +svn_io_dirent2_create(apr_pool_t *result_pool); + +/** Duplicates a @c svn_io_dirent2_t structure into @a result_pool. + * + * @since New in 1.7. + */ +svn_io_dirent2_t * +svn_io_dirent2_dup(const svn_io_dirent2_t *item, + apr_pool_t *result_pool); + +/** Represents the kind and special status of a directory entry. + * + * Note that the first two fields are exactly identical to svn_io_dirent2_t + * to allow returning a svn_io_dirent2_t as a svn_io_dirent_t. + * + * @since New in 1.3. + */ +typedef struct svn_io_dirent_t { + /** The kind of this entry. */ + svn_node_kind_t kind; + /** If @c kind is #svn_node_file, whether this entry is a special file; + * else FALSE. + * + * @see svn_io_check_special_path(). + */ + svn_boolean_t special; +} svn_io_dirent_t; + +/** Determine the @a kind of @a path. @a path should be UTF-8 encoded. + * + * If @a path is a file, set @a *kind to #svn_node_file. + * + * If @a path is a directory, set @a *kind to #svn_node_dir. + * + * If @a path does not exist, set @a *kind to #svn_node_none. + * + * If @a path exists but is none of the above, set @a *kind to + * #svn_node_unknown. + * + * If @a path is not a valid pathname, set @a *kind to #svn_node_none. If + * unable to determine @a path's kind for any other reason, return an error, + * with @a *kind's value undefined. + * + * Use @a pool for temporary allocations. + * + * @see svn_node_kind_t + */ +svn_error_t * +svn_io_check_path(const char *path, + svn_node_kind_t *kind, + apr_pool_t *pool); + +/** + * Like svn_io_check_path(), but also set *is_special to @c TRUE if + * the path is not a normal file. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_check_special_path(const char *path, + svn_node_kind_t *kind, + svn_boolean_t *is_special, + apr_pool_t *pool); + +/** Like svn_io_check_path(), but resolve symlinks. This returns the + same varieties of @a kind as svn_io_check_path(). */ +svn_error_t * +svn_io_check_resolved_path(const char *path, + svn_node_kind_t *kind, + apr_pool_t *pool); + + +/** Open a new file (for reading and writing) with a unique name based on + * utf-8 encoded @a filename, in the directory @a dirpath. The file handle is + * returned in @a *file, and the name, which ends with @a suffix, is returned + * in @a *unique_name, also utf8-encoded. Either @a file or @a unique_name + * may be @c NULL. If @a file is @c NULL, the file will be created but not + * open. + * + * If @a delete_when is #svn_io_file_del_on_close, then the @c APR_DELONCLOSE + * flag will be used when opening the file. The @c APR_BUFFERED flag will + * always be used. + * + * The first attempt will just append @a suffix. If the result is not + * a unique name, then subsequent attempts will append a dot, + * followed by an iteration number ("2", then "3", and so on), + * followed by the suffix. For example, successive calls to + * + * svn_io_open_uniquely_named(&f, &u, "tests/t1/A/D/G", "pi", ".tmp", ...) + * + * will open + * + * tests/t1/A/D/G/pi.tmp + * tests/t1/A/D/G/pi.2.tmp + * tests/t1/A/D/G/pi.3.tmp + * tests/t1/A/D/G/pi.4.tmp + * tests/t1/A/D/G/pi.5.tmp + * ... + * + * Assuming @a suffix is non-empty, @a *unique_name will never be exactly + * the same as @a filename, even if @a filename does not exist. + * + * If @a dirpath is NULL, then the directory returned by svn_io_temp_dir() + * will be used. + * + * If @a filename is NULL, then "tempfile" will be used. + * + * If @a suffix is NULL, then ".tmp" will be used. + * + * Allocates @a *file and @a *unique_name in @a result_pool. All + * intermediate allocations will be performed in @a scratch_pool. + * + * If no unique name can be found, #SVN_ERR_IO_UNIQUE_NAMES_EXHAUSTED is + * the error returned. + * + * Claim of Historical Inevitability: this function was written + * because + * + * - tmpnam() is not thread-safe. + * - tempname() tries standard system tmp areas first. + * + * @since New in 1.6 + */ +svn_error_t * +svn_io_open_uniquely_named(apr_file_t **file, + const char **unique_name, + const char *dirpath, + const char *filename, + const char *suffix, + svn_io_file_del_t delete_when, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Create a writable file, with an arbitrary and unique name, in the + * directory @a dirpath. Set @a *temp_path to its full path, and set + * @a *file to the file handle, both allocated from @a result_pool. Either + * @a file or @a temp_path may be @c NULL. If @a file is @c NULL, the file + * will be created but not open. + * + * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir(). + * (Note that when using the system-provided temp directory, it may not + * be possible to atomically rename the resulting file due to cross-device + * issues.) + * + * The file will be deleted according to @a delete_when. If @a delete_when + * is @c svn_io_file_del_on_close and @a file is @c NULL, the file will be + * deleted before this function returns. + * + * When passing @c svn_io_file_del_none please don't forget to eventually + * remove the temporary file to avoid filling up the system temp directory. + * It is often appropriate to bind the lifetime of the temporary file to + * the lifetime of a pool by using @c svn_io_file_del_on_pool_cleanup. + * + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.6 + * @see svn_stream_open_unique() + */ +svn_error_t * +svn_io_open_unique_file3(apr_file_t **file, + const char **temp_path, + const char *dirpath, + svn_io_file_del_t delete_when, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Like svn_io_open_uniquely_named(), but takes a joined dirpath and + * filename, and a single pool. + * + * @since New in 1.4 + * + * @deprecated Provided for backward compatibility with the 1.5 API + */ +SVN_DEPRECATED +svn_error_t * +svn_io_open_unique_file2(apr_file_t **f, + const char **unique_name_p, + const char *path, + const char *suffix, + svn_io_file_del_t delete_when, + apr_pool_t *pool); + +/** Like svn_io_open_unique_file2, but can't delete on pool cleanup. + * + * @deprecated Provided for backward compatibility with the 1.3 API + * + * @note In 1.4 the API was extended to require either @a f or + * @a unique_name_p (the other can be NULL). Before that, both were + * required. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_open_unique_file(apr_file_t **f, + const char **unique_name_p, + const char *path, + const char *suffix, + svn_boolean_t delete_on_close, + apr_pool_t *pool); + + +/** + * Like svn_io_open_unique_file(), except that instead of creating a + * file, a symlink is generated that references the path @a dest. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_create_unique_link(const char **unique_name_p, + const char *path, + const char *dest, + const char *suffix, + apr_pool_t *pool); + + +/** + * Set @a *dest to the path that the symlink at @a path references. + * Allocate the string from @a pool. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_read_link(svn_string_t **dest, + const char *path, + apr_pool_t *pool); + + +/** Set @a *dir to a directory path (allocated in @a pool) deemed + * usable for the creation of temporary files and subdirectories. + */ +svn_error_t * +svn_io_temp_dir(const char **dir, + apr_pool_t *pool); + + +/** Copy @a src to @a dst atomically, in a "byte-for-byte" manner. + * Overwrite @a dst if it exists, else create it. Both @a src and @a dst + * are utf8-encoded filenames. If @a copy_perms is TRUE, set @a dst's + * permissions to match those of @a src. + */ +svn_error_t * +svn_io_copy_file(const char *src, + const char *dst, + svn_boolean_t copy_perms, + apr_pool_t *pool); + + +/** Copy permission flags from @a src onto the file at @a dst. Both + * filenames are utf8-encoded filenames. + * + * @since New in 1.6. + */ +svn_error_t * +svn_io_copy_perms(const char *src, + const char *dst, + apr_pool_t *pool); + + +/** + * Copy symbolic link @a src to @a dst atomically. Overwrite @a dst + * if it exists, else create it. Both @a src and @a dst are + * utf8-encoded filenames. After copying, the @a dst link will point + * to the same thing @a src does. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_copy_link(const char *src, + const char *dst, + apr_pool_t *pool); + + +/** Recursively copy directory @a src into @a dst_parent, as a new entry named + * @a dst_basename. If @a dst_basename already exists in @a dst_parent, + * return error. @a copy_perms will be passed through to svn_io_copy_file() + * when any files are copied. @a src, @a dst_parent, and @a dst_basename are + * all utf8-encoded. + * + * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at + * various points during the operation. If it returns any error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + */ +svn_error_t * +svn_io_copy_dir_recursively(const char *src, + const char *dst_parent, + const char *dst_basename, + svn_boolean_t copy_perms, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** Create directory @a path on the file system, creating intermediate + * directories as required, like <tt>mkdir -p</tt>. Report no error if @a + * path already exists. @a path is utf8-encoded. + * + * This is essentially a wrapper for apr_dir_make_recursive(), passing + * @c APR_OS_DEFAULT as the permissions. + */ +svn_error_t * +svn_io_make_dir_recursively(const char *path, + apr_pool_t *pool); + + +/** Set @a *is_empty_p to @c TRUE if directory @a path is empty, else to + * @c FALSE if it is not empty. @a path must be a directory, and is + * utf8-encoded. Use @a pool for temporary allocation. + */ +svn_error_t * +svn_io_dir_empty(svn_boolean_t *is_empty_p, + const char *path, + apr_pool_t *pool); + + +/** Append @a src to @a dst. @a dst will be appended to if it exists, else it + * will be created. Both @a src and @a dst are utf8-encoded. + */ +svn_error_t * +svn_io_append_file(const char *src, + const char *dst, + apr_pool_t *pool); + + +/** Make a file as read-only as the operating system allows. + * @a path is the utf8-encoded path to the file. If @a ignore_enoent is + * @c TRUE, don't fail if the target file doesn't exist. + * + * If @a path is a symlink, do nothing. + * + * @note If @a path is a directory, act on it as though it were a + * file, as described above, but note that you probably don't want to + * call this function on directories. We have left it effective on + * directories for compatibility reasons, but as its name implies, it + * should be used only for files. + */ +svn_error_t * +svn_io_set_file_read_only(const char *path, + svn_boolean_t ignore_enoent, + apr_pool_t *pool); + + +/** Make a file as writable as the operating system allows. + * @a path is the utf8-encoded path to the file. If @a ignore_enoent is + * @c TRUE, don't fail if the target file doesn't exist. + * @warning On Unix this function will do the equivalent of chmod a+w path. + * If this is not what you want you should not use this function, but rather + * use apr_file_perms_set(). + * + * If @a path is a symlink, do nothing. + * + * @note If @a path is a directory, act on it as though it were a + * file, as described above, but note that you probably don't want to + * call this function on directories. We have left it effective on + * directories for compatibility reasons, but as its name implies, it + * should be used only for files. + */ +svn_error_t * +svn_io_set_file_read_write(const char *path, + svn_boolean_t ignore_enoent, + apr_pool_t *pool); + + +/** Similar to svn_io_set_file_read_* functions. + * Change the read-write permissions of a file. + * @since New in 1.1. + * + * When making @a path read-write on operating systems with unix style + * permissions, set the permissions on @a path to the permissions that + * are set when a new file is created (effectively honoring the user's + * umask). + * + * When making the file read-only on operating systems with unix style + * permissions, remove all write permissions. + * + * On other operating systems, toggle the file's "writability" as much as + * the operating system allows. + * + * @a path is the utf8-encoded path to the file. If @a enable_write + * is @c TRUE, then make the file read-write. If @c FALSE, make it + * read-only. If @a ignore_enoent is @c TRUE, don't fail if the target + * file doesn't exist. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_set_file_read_write_carefully(const char *path, + svn_boolean_t enable_write, + svn_boolean_t ignore_enoent, + apr_pool_t *pool); + +/** Set @a path's "executability" (but do nothing if it is a symlink). + * + * @a path is the utf8-encoded path to the file. If @a executable + * is @c TRUE, then make the file executable. If @c FALSE, make it + * non-executable. If @a ignore_enoent is @c TRUE, don't fail if the target + * file doesn't exist. + * + * When making the file executable on operating systems with unix style + * permissions, never add an execute permission where there is not + * already a read permission: that is, only make the file executable + * for the user, group or world if the corresponding read permission + * is already set for user, group or world. + * + * When making the file non-executable on operating systems with unix style + * permissions, remove all execute permissions. + * + * On other operating systems, toggle the file's "executability" as much as + * the operating system allows. + * + * @note If @a path is a directory, act on it as though it were a + * file, as described above, but note that you probably don't want to + * call this function on directories. We have left it effective on + * directories for compatibility reasons, but as its name implies, it + * should be used only for files. + */ +svn_error_t * +svn_io_set_file_executable(const char *path, + svn_boolean_t executable, + svn_boolean_t ignore_enoent, + apr_pool_t *pool); + +/** Determine whether a file is executable by the current user. + * Set @a *executable to @c TRUE if the file @a path is executable by the + * current user, otherwise set it to @c FALSE. + * + * On Windows and on platforms without userids, always returns @c FALSE. + */ +svn_error_t * +svn_io_is_file_executable(svn_boolean_t *executable, + const char *path, + apr_pool_t *pool); + + +/** Read a line from @a file into @a buf, but not exceeding @a *limit bytes. + * Does not include newline, instead '\\0' is put there. + * Length (as in strlen) is returned in @a *limit. + * @a buf should be pre-allocated. + * @a file should be already opened. + * + * When the file is out of lines, @c APR_EOF will be returned. + */ +svn_error_t * +svn_io_read_length_line(apr_file_t *file, + char *buf, + apr_size_t *limit, + apr_pool_t *pool); + + +/** Set @a *apr_time to the time of last modification of the contents of the + * file @a path. @a path is utf8-encoded. + * + * @note This is the APR mtime which corresponds to the traditional mtime + * on Unix, and the last write time on Windows. + */ +svn_error_t * +svn_io_file_affected_time(apr_time_t *apr_time, + const char *path, + apr_pool_t *pool); + +/** Set the timestamp of file @a path to @a apr_time. @a path is + * utf8-encoded. + * + * @note This is the APR mtime which corresponds to the traditional mtime + * on Unix, and the last write time on Windows. + */ +svn_error_t * +svn_io_set_file_affected_time(apr_time_t apr_time, + const char *path, + apr_pool_t *pool); + +/** Sleep to ensure that any files modified after we exit have a different + * timestamp than the one we recorded. If @a path is not NULL, check if we + * can determine how long we should wait for a new timestamp on the filesystem + * containing @a path, an existing file or directory. If @a path is NULL or we + * can't determine the timestamp resolution, sleep until the next second. + * + * Use @a pool for any necessary allocations. @a pool can be null if @a path + * is NULL. + * + * Errors while retrieving the timestamp resolution will result in sleeping + * to the next second, to keep the working copy stable in error conditions. + * + * @since New in 1.6. + */ +void +svn_io_sleep_for_timestamps(const char *path, apr_pool_t *pool); + +/** Set @a *different_p to TRUE if @a file1 and @a file2 have different + * sizes, else set to FALSE. Both @a file1 and @a file2 are utf8-encoded. + * + * Setting @a *different_p to zero does not mean the files definitely + * have the same size, it merely means that the sizes are not + * definitely different. That is, if the size of one or both files + * cannot be determined, then the sizes are not known to be different, + * so @a *different_p is set to FALSE. + */ +svn_error_t * +svn_io_filesizes_different_p(svn_boolean_t *different_p, + const char *file1, + const char *file2, + apr_pool_t *pool); + +/** Set @a *different_p12 to non-zero if @a file1 and @a file2 have different + * sizes, else set to zero. Do the similar for @a *different_p23 with + * @a file2 and @a file3, and @a *different_p13 for @a file1 and @a file3. + * The filenames @a file1, @a file2 and @a file3 are utf8-encoded. + * + * Setting @a *different_p12 to zero does not mean the files definitely + * have the same size, it merely means that the sizes are not + * definitely different. That is, if the size of one or both files + * cannot be determined (due to stat() returning an error), then the sizes + * are not known to be different, so @a *different_p12 is set to 0. + * + * @since New in 1.8. + */ +svn_error_t * +svn_io_filesizes_three_different_p(svn_boolean_t *different_p12, + svn_boolean_t *different_p23, + svn_boolean_t *different_p13, + const char *file1, + const char *file2, + const char *file3, + apr_pool_t *scratch_pool); + +/** Return in @a *checksum the checksum of type @a kind of @a file + * Use @a pool for temporary allocations and to allocate @a *checksum. + * + * @since New in 1.6. + */ +svn_error_t * +svn_io_file_checksum2(svn_checksum_t **checksum, + const char *file, + svn_checksum_kind_t kind, + apr_pool_t *pool); + + +/** Put the md5 checksum of @a file into @a digest. + * @a digest points to @c APR_MD5_DIGESTSIZE bytes of storage. + * Use @a pool only for temporary allocations. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_file_checksum(unsigned char digest[], + const char *file, + apr_pool_t *pool); + + +/** Set @a *same to TRUE if @a file1 and @a file2 have the same + * contents, else set it to FALSE. Use @a pool for temporary allocations. + */ +svn_error_t * +svn_io_files_contents_same_p(svn_boolean_t *same, + const char *file1, + const char *file2, + apr_pool_t *pool); + +/** Set @a *same12 to TRUE if @a file1 and @a file2 have the same + * contents, else set it to FALSE. Do the similar for @a *same23 + * with @a file2 and @a file3, and @a *same13 for @a file1 and @a + * file3. The filenames @a file1, @a file2 and @a file3 are + * utf8-encoded. Use @a scratch_pool for temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_io_files_contents_three_same_p(svn_boolean_t *same12, + svn_boolean_t *same23, + svn_boolean_t *same13, + const char *file1, + const char *file2, + const char *file3, + apr_pool_t *scratch_pool); + +/** Create file at utf8-encoded @a file with contents @a contents. + * @a file must not already exist. + * Use @a pool for memory allocations. + */ +svn_error_t * +svn_io_file_create(const char *file, + const char *contents, + apr_pool_t *pool); + +/** + * Lock file at @a lock_file. If @a exclusive is TRUE, + * obtain exclusive lock, otherwise obtain shared lock. + * Lock will be automatically released when @a pool is cleared or destroyed. + * Use @a pool for memory allocations. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_file_lock(const char *lock_file, + svn_boolean_t exclusive, + apr_pool_t *pool); + +/** + * Lock file at @a lock_file. If @a exclusive is TRUE, + * obtain exclusive lock, otherwise obtain shared lock. + * + * If @a nonblocking is TRUE, do not wait for the lock if it + * is not available: throw an error instead. + * + * Lock will be automatically released when @a pool is cleared or destroyed. + * Use @a pool for memory allocations. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_file_lock2(const char *lock_file, + svn_boolean_t exclusive, + svn_boolean_t nonblocking, + apr_pool_t *pool); + +/** + * Lock the file @a lockfile_handle. If @a exclusive is TRUE, + * obtain exclusive lock, otherwise obtain shared lock. + * + * If @a nonblocking is TRUE, do not wait for the lock if it + * is not available: throw an error instead. + * + * Lock will be automatically released when @a pool is cleared or destroyed. + * You may also explicitly call svn_io_unlock_open_file(). + * Use @a pool for memory allocations. @a pool must be the pool that + * @a lockfile_handle has been created in or one of its sub-pools. + * + * @since New in 1.8. + */ +svn_error_t * +svn_io_lock_open_file(apr_file_t *lockfile_handle, + svn_boolean_t exclusive, + svn_boolean_t nonblocking, + apr_pool_t *pool); + +/** + * Unlock the file @a lockfile_handle. + * + * Use @a pool for memory allocations. @a pool must be the pool that + * was passed to svn_io_lock_open_file(). + * + * @since New in 1.8. + */ +svn_error_t * +svn_io_unlock_open_file(apr_file_t *lockfile_handle, + apr_pool_t *pool); + +/** + * Flush any unwritten data from @a file to disk. Use @a pool for + * memory allocations. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_file_flush_to_disk(apr_file_t *file, + apr_pool_t *pool); + +/** Copy the file whose basename (or relative path) is @a file within + * directory @a src_path to the same basename (or relative path) within + * directory @a dest_path. Overwrite the destination file if it already + * exists. The destination directory (including any directory + * components in @a name) must already exist. Set the destination + * file's permissions to match those of the source. Use @a pool for + * memory allocations. + */ +svn_error_t * +svn_io_dir_file_copy(const char *src_path, + const char *dest_path, + const char *file, + apr_pool_t *pool); + + +/** Generic byte-streams + * + * @defgroup svn_io_byte_streams Generic byte streams + * @{ + */ + +/** An abstract stream of bytes--either incoming or outgoing or both. + * + * The creator of a stream sets functions to handle read and write. + * Both of these handlers accept a baton whose value is determined at + * stream creation time; this baton can point to a structure + * containing data associated with the stream. If a caller attempts + * to invoke a handler which has not been set, it will generate a + * runtime assertion failure. The creator can also set a handler for + * close requests so that it can flush buffered data or whatever; + * if a close handler is not specified, a close request on the stream + * will simply be ignored. Note that svn_stream_close() does not + * deallocate the memory used to allocate the stream structure; free + * the pool you created the stream in to free that memory. + * + * The read and write handlers accept length arguments via pointer. + * On entry to the handler, the pointed-to value should be the amount + * of data which can be read or the amount of data to write. When the + * handler returns, the value is reset to the amount of data actually + * read or written. Handlers are obliged to complete a read or write + * to the maximum extent possible; thus, a short read with no + * associated error implies the end of the input stream, and a short + * write should never occur without an associated error. + * + * In Subversion 1.7 reset support was added as an optional feature of + * streams. If a stream implements resetting it allows reading the data + * again after a successful call to svn_stream_reset(). + */ +typedef struct svn_stream_t svn_stream_t; + + + +/** Read handler function for a generic stream. @see svn_stream_t. */ +typedef svn_error_t *(*svn_read_fn_t)(void *baton, + char *buffer, + apr_size_t *len); + +/** Skip data handler function for a generic stream. @see svn_stream_t + * and svn_stream_skip(). + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_stream_skip_fn_t)(void *baton, + apr_size_t len); + +/** Write handler function for a generic stream. @see svn_stream_t. */ +typedef svn_error_t *(*svn_write_fn_t)(void *baton, + const char *data, + apr_size_t *len); + +/** Close handler function for a generic stream. @see svn_stream_t. */ +typedef svn_error_t *(*svn_close_fn_t)(void *baton); + +/** An opaque type which represents a mark on a stream. There is no + * concrete definition of this type, it is a named type for stream + * implementation specific baton pointers. + * + * @see svn_stream_mark(). + * @since New in 1.7. + */ +typedef struct svn_stream_mark_t svn_stream_mark_t; + +/** Mark handler function for a generic stream. @see svn_stream_t and + * svn_stream_mark(). + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_stream_mark_fn_t)(void *baton, + svn_stream_mark_t **mark, + apr_pool_t *pool); + +/** Seek handler function for a generic stream. @see svn_stream_t and + * svn_stream_seek(). + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_stream_seek_fn_t)(void *baton, + const svn_stream_mark_t *mark); + +/** Create a generic stream. @see svn_stream_t. */ +svn_stream_t * +svn_stream_create(void *baton, + apr_pool_t *pool); + +/** Set @a stream's baton to @a baton */ +void +svn_stream_set_baton(svn_stream_t *stream, + void *baton); + +/** Set @a stream's read function to @a read_fn */ +void +svn_stream_set_read(svn_stream_t *stream, + svn_read_fn_t read_fn); + +/** Set @a stream's skip function to @a skip_fn + * + * @since New in 1.7 + */ +void +svn_stream_set_skip(svn_stream_t *stream, + svn_stream_skip_fn_t skip_fn); + +/** Set @a stream's write function to @a write_fn */ +void +svn_stream_set_write(svn_stream_t *stream, + svn_write_fn_t write_fn); + +/** Set @a stream's close function to @a close_fn */ +void +svn_stream_set_close(svn_stream_t *stream, + svn_close_fn_t close_fn); + +/** Set @a stream's mark function to @a mark_fn + * + * @since New in 1.7. + */ +void +svn_stream_set_mark(svn_stream_t *stream, + svn_stream_mark_fn_t mark_fn); + +/** Set @a stream's seek function to @a seek_fn + * + * @since New in 1.7. + */ +void +svn_stream_set_seek(svn_stream_t *stream, + svn_stream_seek_fn_t seek_fn); + +/** Create a stream that is empty for reading and infinite for writing. */ +svn_stream_t * +svn_stream_empty(apr_pool_t *pool); + +/** Return a stream allocated in @a pool which forwards all requests + * to @a stream. Destruction is explicitly excluded from forwarding. + * + * @see notes/destruction-of-stacked-resources + * + * @since New in 1.4. + */ +svn_stream_t * +svn_stream_disown(svn_stream_t *stream, + apr_pool_t *pool); + + +/** Create a stream to read the file at @a path. It will be opened using + * the APR_BUFFERED and APR_BINARY flag, and APR_OS_DEFAULT for the perms. + * If you'd like to use different values, then open the file yourself, and + * use the svn_stream_from_aprfile2() interface. + * + * The stream will be returned in @a stream, and allocated from @a result_pool. + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.6 + */ +svn_error_t * +svn_stream_open_readonly(svn_stream_t **stream, + const char *path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Create a stream to write a file at @a path. The file will be *created* + * using the APR_BUFFERED and APR_BINARY flag, and APR_OS_DEFAULT for the + * perms. The file will be created "exclusively", so if it already exists, + * then an error will be thrown. If you'd like to use different values, or + * open an existing file, then open the file yourself, and use the + * svn_stream_from_aprfile2() interface. + * + * The stream will be returned in @a stream, and allocated from @a result_pool. + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.6 + */ +svn_error_t * +svn_stream_open_writable(svn_stream_t **stream, + const char *path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Create a writable stream to a file in the directory @a dirpath. + * The file will have an arbitrary and unique name, and the full path + * will be returned in @a temp_path. The stream will be returned in + * @a stream. Both will be allocated from @a result_pool. + * + * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir(). + * (Note that when using the system-provided temp directory, it may not + * be possible to atomically rename the resulting file due to cross-device + * issues.) + * + * The file will be deleted according to @a delete_when. + * + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.6 + * @see svn_io_open_unique_file3() + */ +svn_error_t * +svn_stream_open_unique(svn_stream_t **stream, + const char **temp_path, + const char *dirpath, + svn_io_file_del_t delete_when, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Create a stream from an APR file. For convenience, if @a file is + * @c NULL, an empty stream created by svn_stream_empty() is returned. + * + * This function should normally be called with @a disown set to FALSE, + * in which case closing the stream will also close the underlying file. + * + * If @a disown is TRUE, the stream will disown the underlying file, + * meaning that svn_stream_close() will not close the file. + * + * @since New in 1.4. + */ +svn_stream_t * +svn_stream_from_aprfile2(apr_file_t *file, + svn_boolean_t disown, + apr_pool_t *pool); + +/** Similar to svn_stream_from_aprfile2(), except that the file will + * always be disowned. + * + * @note The stream returned is not considered to "own" the underlying + * file, meaning that svn_stream_close() on the stream will not + * close the file. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_stream_t * +svn_stream_from_aprfile(apr_file_t *file, + apr_pool_t *pool); + +/** Set @a *in to a generic stream connected to stdin, allocated in + * @a pool. The stream and its underlying APR handle will be closed + * when @a pool is cleared or destroyed. + * + * @since New in 1.7. + */ +svn_error_t * +svn_stream_for_stdin(svn_stream_t **in, + apr_pool_t *pool); + +/** Set @a *err to a generic stream connected to stderr, allocated in + * @a pool. The stream and its underlying APR handle will be closed + * when @a pool is cleared or destroyed. + * + * @since New in 1.7. + */ +svn_error_t * +svn_stream_for_stderr(svn_stream_t **err, + apr_pool_t *pool); + +/** Set @a *out to a generic stream connected to stdout, allocated in + * @a pool. The stream and its underlying APR handle will be closed + * when @a pool is cleared or destroyed. + */ +svn_error_t * +svn_stream_for_stdout(svn_stream_t **out, + apr_pool_t *pool); + +/** Return a generic stream connected to stringbuf @a str. Allocate the + * stream in @a pool. + */ +svn_stream_t * +svn_stream_from_stringbuf(svn_stringbuf_t *str, + apr_pool_t *pool); + +/** Return a generic read-only stream connected to string @a str. + * Allocate the stream in @a pool. + */ +svn_stream_t * +svn_stream_from_string(const svn_string_t *str, + apr_pool_t *pool); + +/** Return a generic stream which implements buffered reads and writes. + * The stream will preferentially store data in-memory, but may use + * disk storage as backup if the amount of data is large. + * Allocate the stream in @a result_pool + * + * @since New in 1.8. + */ +svn_stream_t * +svn_stream_buffered(apr_pool_t *result_pool); + +/** Return a stream that decompresses all data read and compresses all + * data written. The stream @a stream is used to read and write all + * compressed data. All compression data structures are allocated on + * @a pool. If compression support is not compiled in then + * svn_stream_compressed() returns @a stream unmodified. Make sure you + * call svn_stream_close() on the stream returned by this function, + * so that all data are flushed and cleaned up. + * + * @note From 1.4, compression support is always compiled in. + */ +svn_stream_t * +svn_stream_compressed(svn_stream_t *stream, + apr_pool_t *pool); + +/** Return a stream that calculates checksums for all data read + * and written. The stream @a stream is used to read and write all data. + * The stream and the resulting digests are allocated in @a pool. + * + * When the stream is closed, @a *read_checksum and @a *write_checksum + * are set to point to the resulting checksums, of type @a read_checksum_kind + * and @a write_checksum_kind, respectively. + * + * Both @a read_checksum and @a write_checksum can be @c NULL, in which case + * the respective checksum isn't calculated. + * + * If @a read_all is TRUE, make sure that all data available on @a + * stream is read (and checksummed) when the stream is closed. + * + * Read and write operations can be mixed without interfering. + * + * The @a stream passed into this function is closed when the created + * stream is closed. + * + * @since New in 1.6. + */ +svn_stream_t * +svn_stream_checksummed2(svn_stream_t *stream, + svn_checksum_t **read_checksum, + svn_checksum_t **write_checksum, + svn_checksum_kind_t checksum_kind, + svn_boolean_t read_all, + apr_pool_t *pool); + +/** + * Similar to svn_stream_checksummed2(), but always returning the MD5 + * checksum in @a read_digest and @a write_digest. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_stream_t * +svn_stream_checksummed(svn_stream_t *stream, + const unsigned char **read_digest, + const unsigned char **write_digest, + svn_boolean_t read_all, + apr_pool_t *pool); + +/** Read from a generic stream. @see svn_stream_t. */ +svn_error_t * +svn_stream_read(svn_stream_t *stream, + char *buffer, + apr_size_t *len); + +/** + * Skip @a len bytes from a generic @a stream. If the stream is exhausted + * before @a len bytes have been read, return an error. + * + * @note No assumption can be made on the semantics of this function + * other than that the stream read pointer will be advanced by *len + * bytes. Depending on the capabilities of the underlying stream + * implementation, this may for instance be translated into a sequence + * of reads or a simple seek operation. If the stream implementation has + * not provided a skip function, this will read from the stream and + * discard the data. + */ +svn_error_t * +svn_stream_skip(svn_stream_t *stream, + apr_size_t len); + +/** Write to a generic stream. @see svn_stream_t. */ +svn_error_t * +svn_stream_write(svn_stream_t *stream, + const char *data, + apr_size_t *len); + +/** Close a generic stream. @see svn_stream_t. */ +svn_error_t * +svn_stream_close(svn_stream_t *stream); + +/** Reset a generic stream back to its origin. (E.g. On a file this would be + * implemented as a seek to position 0). This function returns a + * #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error when the stream doesn't + * implement resetting. + * + * @since New in 1.7. + */ +svn_error_t * +svn_stream_reset(svn_stream_t *stream); + +/** Returns @c TRUE if the generic @a stream supports svn_stream_mark(). + * + * @see svn_stream_mark() + * @since New in 1.7. + */ +svn_boolean_t +svn_stream_supports_mark(svn_stream_t *stream); + +/** Set a @a mark at the current position of a generic @a stream, + * which can later be sought back to using svn_stream_seek(). + * The @a mark is allocated in @a pool. + * + * This function returns the #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error + * if the stream doesn't implement seeking. + * + * @see svn_stream_seek() + * @since New in 1.7. + */ +svn_error_t * +svn_stream_mark(svn_stream_t *stream, + svn_stream_mark_t **mark, + apr_pool_t *pool); + +/** Seek to a @a mark in a generic @a stream. + * This function returns the #SVN_ERR_STREAM_SEEK_NOT_SUPPORTED error + * if the stream doesn't implement seeking. Passing NULL as @a mark, + * seeks to the start of the stream. + * + * @see svn_stream_mark() + * @since New in 1.7. + */ +svn_error_t * +svn_stream_seek(svn_stream_t *stream, const svn_stream_mark_t *mark); + +/** Return a writable stream which, when written to, writes to both of the + * underlying streams. Both of these streams will be closed upon closure of + * the returned stream; use svn_stream_disown() if this is not the desired + * behavior. One or both of @a out1 and @a out2 may be @c NULL. If both are + * @c NULL, @c NULL is returned. + * + * @since New in 1.7. + */ +svn_stream_t * +svn_stream_tee(svn_stream_t *out1, + svn_stream_t *out2, + apr_pool_t *pool); + +/** Write NULL-terminated string @a str to @a stream. + * + * @since New in 1.8. + * + */ +svn_error_t * +svn_stream_puts(svn_stream_t *stream, + const char *str); + +/** Write to @a stream using a printf-style @a fmt specifier, passed through + * apr_psprintf() using memory from @a pool. + */ +svn_error_t * +svn_stream_printf(svn_stream_t *stream, + apr_pool_t *pool, + const char *fmt, + ...) + __attribute__((format(printf, 3, 4))); + +/** Write to @a stream using a printf-style @a fmt specifier, passed through + * apr_psprintf() using memory from @a pool. The resulting string + * will be translated to @a encoding before it is sent to @a stream. + * + * @note Use @c APR_LOCALE_CHARSET to translate to the encoding of the + * current locale. + * + * @since New in 1.3. + */ +svn_error_t * +svn_stream_printf_from_utf8(svn_stream_t *stream, + const char *encoding, + apr_pool_t *pool, + const char *fmt, + ...) + __attribute__((format(printf, 4, 5))); + +/** Allocate @a *stringbuf in @a pool, and read into it one line (terminated + * by @a eol) from @a stream. The line-terminator is read from the stream, + * but is not added to the end of the stringbuf. Instead, the stringbuf + * ends with a usual '\\0'. + * + * If @a stream runs out of bytes before encountering a line-terminator, + * then set @a *eof to @c TRUE, otherwise set @a *eof to FALSE. + */ +svn_error_t * +svn_stream_readline(svn_stream_t *stream, + svn_stringbuf_t **stringbuf, + const char *eol, + svn_boolean_t *eof, + apr_pool_t *pool); + +/** + * Read the contents of the readable stream @a from and write them to the + * writable stream @a to calling @a cancel_func before copying each chunk. + * + * @a cancel_func may be @c NULL. + * + * @note both @a from and @a to will be closed upon successful completion of + * the copy (but an error may still be returned, based on trying to close + * the two streams). If the closure is not desired, then you can use + * svn_stream_disown() to protect either or both of the streams from + * being closed. + * + * @since New in 1.6. + */ +svn_error_t * +svn_stream_copy3(svn_stream_t *from, + svn_stream_t *to, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Same as svn_stream_copy3() but the streams are not closed. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_stream_copy2(svn_stream_t *from, + svn_stream_t *to, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Same as svn_stream_copy3(), but without the cancellation function + * or stream closing. + * + * @since New in 1.1. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_stream_copy(svn_stream_t *from, + svn_stream_t *to, + apr_pool_t *pool); + + +/** Set @a *same to TRUE if @a stream1 and @a stream2 have the same + * contents, else set it to FALSE. + * + * Both streams will be closed before this function returns (regardless of + * the result, or any possible error). + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_stream_contents_same2(svn_boolean_t *same, + svn_stream_t *stream1, + svn_stream_t *stream2, + apr_pool_t *pool); + + +/** + * Same as svn_stream_contents_same2(), but the streams will not be closed. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_stream_contents_same(svn_boolean_t *same, + svn_stream_t *stream1, + svn_stream_t *stream2, + apr_pool_t *pool); + + +/** Read the contents of @a stream into memory, returning the data in + * @a result. The stream will be closed when it has been successfully and + * completely read. + * + * The returned memory is allocated in @a result_pool, and any temporary + * allocations are performed in @a scratch_pool. + * + * @note due to memory pseudo-reallocation behavior (due to pools), this + * can be a memory-intensive operation for large files. + * + * @since New in 1.6 + */ +svn_error_t * +svn_string_from_stream(svn_string_t **result, + svn_stream_t *stream, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** A function type provided for use as a callback from + * @c svn_stream_lazyopen_create(). + * + * The callback function shall open a new stream and set @a *stream to + * the stream object, allocated in @a result_pool. @a baton is the + * callback baton that was passed to svn_stream_lazyopen_create(). + * + * @a result_pool is the result pool that was passed to + * svn_stream_lazyopen_create(). The callback function may use + * @a scratch_pool for temporary allocations; the caller may clear or + * destroy @a scratch_pool any time after the function returns. + * + * @since New in 1.8. + */ +typedef svn_error_t * +(*svn_stream_lazyopen_func_t)(svn_stream_t **stream, + void *baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Return a generic stream which wraps another primary stream, + * delaying the "opening" of that stream until the first time the + * returned stream is accessed. + * + * @a open_func and @a open_baton are a callback function/baton pair + * which will be invoked upon the first access of the returned + * stream (read, write, mark, seek, skip, or possibly close). The + * callback shall open the primary stream. + * + * If the only "access" the returned stream gets is to close it + * then @a open_func will only be called if @a open_on_close is TRUE. + * + * @since New in 1.8. + */ +svn_stream_t * +svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func, + void *open_baton, + svn_boolean_t open_on_close, + apr_pool_t *result_pool); + +/** @} */ + +/** Set @a *result to a string containing the contents of @a + * filename, which is either "-" (indicating that stdin should be + * read) or the utf8-encoded path of a real file. + * + * @warning Callers should be aware of possible unexpected results + * when using this function to read from stdin where additional + * stdin-reading processes abound. For example, if a program tries + * both to invoke an external editor and to read from stdin, stdin + * could be trashed and the editor might act funky or die outright. + * + * @note due to memory pseudo-reallocation behavior (due to pools), this + * can be a memory-intensive operation for large files. + * + * @since New in 1.5. + */ +svn_error_t * +svn_stringbuf_from_file2(svn_stringbuf_t **result, + const char *filename, + apr_pool_t *pool); + +/** Similar to svn_stringbuf_from_file2(), except that if @a filename + * is "-", return the error #SVN_ERR_UNSUPPORTED_FEATURE and don't + * touch @a *result. + * + * @deprecated Provided for backwards compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_stringbuf_from_file(svn_stringbuf_t **result, + const char *filename, + apr_pool_t *pool); + +/** Sets @a *result to a string containing the contents of the already opened + * @a file. Reads from the current position in file to the end. Does not + * close the file or reset the cursor position. + * + * @note due to memory pseudo-reallocation behavior (due to pools), this + * can be a memory-intensive operation for large files. + */ +svn_error_t * +svn_stringbuf_from_aprfile(svn_stringbuf_t **result, + apr_file_t *file, + apr_pool_t *pool); + +/** Remove file @a path, a utf8-encoded path. This wraps apr_file_remove(), + * converting any error to a Subversion error. If @a ignore_enoent is TRUE, and + * the file is not present (APR_STATUS_IS_ENOENT returns TRUE), then no + * error will be returned. + * + * The file will be removed even if it is not writable. (On Windows and + * OS/2, this function first clears the file's read-only bit.) + * + * @since New in 1.7. + */ +svn_error_t * +svn_io_remove_file2(const char *path, + svn_boolean_t ignore_enoent, + apr_pool_t *scratch_pool); + +/** Similar to svn_io_remove_file2(), except with @a ignore_enoent set to FALSE. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_remove_file(const char *path, + apr_pool_t *pool); + +/** Recursively remove directory @a path. @a path is utf8-encoded. + * If @a ignore_enoent is @c TRUE, don't fail if the target directory + * doesn't exist. Use @a pool for temporary allocations. + * + * Because recursive delete of a directory tree can be a lengthy operation, + * provide @a cancel_func and @a cancel_baton for interruptibility. + * + * @since New in 1.5. + */ +svn_error_t * +svn_io_remove_dir2(const char *path, + svn_boolean_t ignore_enoent, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Similar to svn_io_remove_dir2(), but with @a ignore_enoent set to + * @c FALSE and @a cancel_func and @a cancel_baton set to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.4 API + */ +SVN_DEPRECATED +svn_error_t * +svn_io_remove_dir(const char *path, + apr_pool_t *pool); + +/** Read all of the disk entries in directory @a path, a utf8-encoded + * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to + * undefined non-NULL values, allocated in @a pool. + * + * @note The `.' and `..' directories normally returned by + * apr_dir_read() are NOT returned in the hash. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_get_dir_filenames(apr_hash_t **dirents, + const char *path, + apr_pool_t *pool); + +/** Read all of the disk entries in directory @a path, a utf8-encoded + * path. Set @a *dirents to a hash mapping dirent names (<tt>char *</tt>) to + * #svn_io_dirent2_t structures, allocated in @a pool. + * + * If @a only_check_type is set to @c TRUE, only the kind and special + * fields of the svn_io_dirent2_t are filled. + * + * @note The `.' and `..' directories normally returned by + * apr_dir_read() are NOT returned in the hash. + * + * @note The kind field in the @a dirents is set according to the mapping + * as documented for svn_io_check_path(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_io_get_dirents3(apr_hash_t **dirents, + const char *path, + svn_boolean_t only_check_type, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Similar to svn_io_get_dirents3, but returns a mapping to svn_io_dirent_t + * structures instead of svn_io_dirent2_t and with only a single pool. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_get_dirents2(apr_hash_t **dirents, + const char *path, + apr_pool_t *pool); + +/** Similar to svn_io_get_dirents2(), but @a *dirents is a hash table + * with #svn_node_kind_t values. + * + * @deprecated Provided for backwards compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_get_dirents(apr_hash_t **dirents, + const char *path, + apr_pool_t *pool); + +/** Create a svn_io_dirent2_t instance for path. Specialized variant of + * svn_io_stat() that directly translates node_kind and special. + * + * If @a verify_truename is @c TRUE, an additional check is performed to + * verify the truename of the last path component on case insensitive + * filesystems. This check is expensive compared to a just a stat, + * but certainly cheaper than a full truename calculation using + * apr_filepath_merge() which verifies all path components. + * + * If @a ignore_enoent is set to @c TRUE, set *dirent_p->kind to + * svn_node_none instead of returning an error. + * + * @since New in 1.8. + */ +svn_error_t * +svn_io_stat_dirent2(const svn_io_dirent2_t **dirent_p, + const char *path, + svn_boolean_t verify_truename, + svn_boolean_t ignore_enoent, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Similar to svn_io_stat_dirent2, but always passes FALSE for + * verify_truename. + * + * @since New in 1.7. + * @deprecated Provided for backwards compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_stat_dirent(const svn_io_dirent2_t **dirent_p, + const char *path, + svn_boolean_t ignore_enoent, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Callback function type for svn_io_dir_walk() */ +typedef svn_error_t * (*svn_io_walk_func_t)(void *baton, + const char *path, + const apr_finfo_t *finfo, + apr_pool_t *pool); + +/** Recursively walk the directory rooted at @a dirname, a + * utf8-encoded path, invoking @a walk_func (with @a walk_baton) for + * each item in the tree. For a given directory, invoke @a walk_func + * on the directory itself before invoking it on any children thereof. + * + * Deliver to @a walk_func the information specified by @a wanted, + * which is a combination of @c APR_FINFO_* flags, plus the + * information specified by @c APR_FINFO_TYPE and @c APR_FINFO_NAME. + * + * Use @a pool for all allocations. + * + * @note This function does not currently pass all file types to @a + * walk_func -- only APR_DIR, APR_REG, and APR_LNK. We reserve the + * right to pass additional file types through this interface in the + * future, though, so implementations of this callback should + * explicitly test FINFO->filetype. See the APR library's + * apr_filetype_e enum for the various filetypes and their meanings. + * + * @since New in 1.7. + */ +svn_error_t * +svn_io_dir_walk2(const char *dirname, + apr_int32_t wanted, + svn_io_walk_func_t walk_func, + void *walk_baton, + apr_pool_t *pool); + +/** Similar to svn_io_dir_walk(), but only calls @a walk_func for + * files of type APR_DIR (directory) and APR_REG (regular file). + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_dir_walk(const char *dirname, + apr_int32_t wanted, + svn_io_walk_func_t walk_func, + void *walk_baton, + apr_pool_t *pool); + +/** + * Start @a cmd with @a args, using utf8-encoded @a path as working + * directory. Return the process handle for the invoked program in @a + * *cmd_proc. + * + * If @a infile_pipe is TRUE, connect @a cmd's stdin to a pipe; + * otherwise, connect it to @a infile (which may be NULL). If + * @a outfile_pipe is TRUE, connect @a cmd's stdout to a pipe; otherwise, + * connect it to @a outfile (which may be NULL). If @a errfile_pipe + * is TRUE, connect @a cmd's stderr to a pipe; otherwise, connect it + * to @a errfile (which may be NULL). (Callers must pass FALSE for + * each of these boolean values for which the corresponding file + * handle is non-NULL.) + * + * @a args is a list of utf8-encoded <tt>const char *</tt> arguments, + * terminated by @c NULL. @a args[0] is the name of the program, though it + * need not be the same as @a cmd. + * + * If @a inherit is TRUE, the invoked program inherits its environment from + * the caller and @a cmd, if not absolute, is searched for in PATH. + * + * If @a inherit is FALSE @a cmd must be an absolute path and the invoked + * program inherits the environment defined by @a env or runs with an empty + * environment in @a env is NULL. + * + * @note On some platforms, failure to execute @a cmd in the child process + * will result in error output being written to @a errfile, if non-NULL, and + * a non-zero exit status being returned to the parent process. + * + * @note An APR bug affects Windows: passing a NULL @a env does not + * guarantee the invoked program to run with an empty environment when + * @a inherits is FALSE, the program may inherit its parent's environment. + * Explicitly pass an empty @a env to get an empty environment. + * + * @since New in 1.8. + */ +svn_error_t *svn_io_start_cmd3(apr_proc_t *cmd_proc, + const char *path, + const char *cmd, + const char *const *args, + const char *const *env, + svn_boolean_t inherit, + svn_boolean_t infile_pipe, + apr_file_t *infile, + svn_boolean_t outfile_pipe, + apr_file_t *outfile, + svn_boolean_t errfile_pipe, + apr_file_t *errfile, + apr_pool_t *pool); + + +/** + * Similar to svn_io_start_cmd3() but with @a env always set to NULL. + * + * @deprecated Provided for backward compatibility with the 1.7 API + * @since New in 1.7. + */ +SVN_DEPRECATED +svn_error_t *svn_io_start_cmd2(apr_proc_t *cmd_proc, + const char *path, + const char *cmd, + const char *const *args, + svn_boolean_t inherit, + svn_boolean_t infile_pipe, + apr_file_t *infile, + svn_boolean_t outfile_pipe, + apr_file_t *outfile, + svn_boolean_t errfile_pipe, + apr_file_t *errfile, + apr_pool_t *pool); + +/** + * Similar to svn_io_start_cmd2() but with @a infile_pipe, @a + * outfile_pipe, and @a errfile_pipe always FALSE. + * + * @deprecated Provided for backward compatibility with the 1.6 API + * @since New in 1.3. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_start_cmd(apr_proc_t *cmd_proc, + const char *path, + const char *cmd, + const char *const *args, + svn_boolean_t inherit, + apr_file_t *infile, + apr_file_t *outfile, + apr_file_t *errfile, + apr_pool_t *pool); + +/** + * Wait for the process @a *cmd_proc to complete and optionally retrieve + * its exit code. @a cmd is used only in error messages. + * + * If @a exitcode is not NULL, set @a *exitcode to the exit code of the + * process and do not consider any exit code to be an error. If @a exitcode + * is NULL, then if the exit code of the process is non-zero then return an + * #SVN_ERR_EXTERNAL_PROGRAM error. + * + * If @a exitwhy is not NULL, set @a *exitwhy to indicate why the process + * terminated and do not consider any reason to be an error. If @a exitwhy + * is NULL, then if the termination reason is not @c APR_PROC_CHECK_EXIT() + * then return an #SVN_ERR_EXTERNAL_PROGRAM error. + * + * @since New in 1.3. + */ +svn_error_t * +svn_io_wait_for_cmd(apr_proc_t *cmd_proc, + const char *cmd, + int *exitcode, + apr_exit_why_e *exitwhy, + apr_pool_t *pool); + +/** Run a command to completion, by first calling svn_io_start_cmd() and + * then calling svn_io_wait_for_cmd(). The parameters correspond to + * the same-named parameters of those two functions. + */ +svn_error_t * +svn_io_run_cmd(const char *path, + const char *cmd, + const char *const *args, + int *exitcode, + apr_exit_why_e *exitwhy, + svn_boolean_t inherit, + apr_file_t *infile, + apr_file_t *outfile, + apr_file_t *errfile, + apr_pool_t *pool); + +/** Invoke the configured @c diff program, with @a user_args (an array + * of utf8-encoded @a num_user_args arguments) if they are specified + * (that is, if @a user_args is non-NULL), or "-u" if they are not. + * If @a user_args is NULL, the value of @a num_user_args is ignored. + * + * Diff runs in utf8-encoded @a dir, and its exit status is stored in + * @a exitcode, if it is not @c NULL. + * + * If @a label1 and/or @a label2 are not NULL they will be passed to the diff + * process as the arguments of "-L" options. @a label1 and @a label2 are also + * in utf8, and will be converted to native charset along with the other args. + * + * @a from is the first file passed to diff, and @a to is the second. The + * stdout of diff will be sent to @a outfile, and the stderr to @a errfile. + * + * @a diff_cmd must be non-NULL. + * + * Do all allocation in @a pool. + * @since New in 1.6.0. + */ +svn_error_t * +svn_io_run_diff2(const char *dir, + const char *const *user_args, + int num_user_args, + const char *label1, + const char *label2, + const char *from, + const char *to, + int *exitcode, + apr_file_t *outfile, + apr_file_t *errfile, + const char *diff_cmd, + apr_pool_t *pool); + +/** Similar to svn_io_run_diff2() but with @a diff_cmd encoded in internal + * encoding used by APR. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. */ +SVN_DEPRECATED +svn_error_t * +svn_io_run_diff(const char *dir, + const char *const *user_args, + int num_user_args, + const char *label1, + const char *label2, + const char *from, + const char *to, + int *exitcode, + apr_file_t *outfile, + apr_file_t *errfile, + const char *diff_cmd, + apr_pool_t *pool); + + + +/** Invoke the configured @c diff3 program, in utf8-encoded @a dir + * like this: + * + * diff3 -E -m @a mine @a older @a yours > @a merged + * + * (See the diff3 documentation for details.) + * + * If @a user_args is non-NULL, replace "-E" with the <tt>const char*</tt> + * elements that @a user_args contains. + * + * @a mine, @a older and @a yours are utf8-encoded paths (relative to + * @a dir or absolute) to three files that already exist. + * + * @a merged is an open file handle, and is left open after the merge + * result is written to it. (@a merged should *not* be the same file + * as @a mine, or nondeterministic things may happen!) + * + * @a mine_label, @a older_label, @a yours_label are utf8-encoded label + * parameters for diff3's -L option. Any of them may be @c NULL, in + * which case the corresponding @a mine, @a older, or @a yours parameter is + * used instead. + * + * Set @a *exitcode to diff3's exit status. If @a *exitcode is anything + * other than 0 or 1, then return #SVN_ERR_EXTERNAL_PROGRAM. (Note the + * following from the diff3 info pages: "An exit status of 0 means + * `diff3' was successful, 1 means some conflicts were found, and 2 + * means trouble.") + * + * @a diff3_cmd must be non-NULL. + * + * Do all allocation in @a pool. + * + * @since New in 1.4. + */ +svn_error_t * +svn_io_run_diff3_3(int *exitcode, + const char *dir, + const char *mine, + const char *older, + const char *yours, + const char *mine_label, + const char *older_label, + const char *yours_label, + apr_file_t *merged, + const char *diff3_cmd, + const apr_array_header_t *user_args, + apr_pool_t *pool); + +/** Similar to svn_io_run_diff3_3(), but with @a diff3_cmd encoded in + * internal encoding used by APR. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. + * @since New in 1.4. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_run_diff3_2(int *exitcode, + const char *dir, + const char *mine, + const char *older, + const char *yours, + const char *mine_label, + const char *older_label, + const char *yours_label, + apr_file_t *merged, + const char *diff3_cmd, + const apr_array_header_t *user_args, + apr_pool_t *pool); + +/** Similar to svn_io_run_diff3_2(), but with @a user_args set to @c NULL. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_io_run_diff3(const char *dir, + const char *mine, + const char *older, + const char *yours, + const char *mine_label, + const char *older_label, + const char *yours_label, + apr_file_t *merged, + int *exitcode, + const char *diff3_cmd, + apr_pool_t *pool); + + +/** Parse utf8-encoded @a mimetypes_file as a MIME types file (such as + * is provided with Apache HTTP Server), and set @a *type_map to a + * hash mapping <tt>const char *</tt> filename extensions to + * <tt>const char *</tt> MIME types. + * + * @since New in 1.5. + */ +svn_error_t * +svn_io_parse_mimetypes_file(apr_hash_t **type_map, + const char *mimetypes_file, + apr_pool_t *pool); + + +/** Examine utf8-encoded @a file to determine if it can be described by a + * known (as in, known by this function) Multipurpose Internet Mail + * Extension (MIME) type. If so, set @a *mimetype to a character string + * describing the MIME type, else set it to @c NULL. + * + * If not @c NULL, @a mimetype_map is a hash mapping <tt>const char *</tt> + * filename extensions to <tt>const char *</tt> MIME types, and is the + * first source consulted regarding @a file's MIME type. + * + * Use @a pool for any necessary allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_io_detect_mimetype2(const char **mimetype, + const char *file, + apr_hash_t *mimetype_map, + apr_pool_t *pool); + + +/** Like svn_io_detect_mimetype2, but with @a mimetypes_map set to + * @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.4 API + */ +SVN_DEPRECATED +svn_error_t * +svn_io_detect_mimetype(const char **mimetype, + const char *file, + apr_pool_t *pool); + + +/** Examine up to @a len bytes of data in @a buf to determine if the + * can be considered binary data, in which case return TRUE. + * If the data can be considered plain-text data, return FALSE. + * + * @since New in 1.7. + */ +svn_boolean_t +svn_io_is_binary_data(const void *buf, apr_size_t len); + + +/** Wrapper for apr_file_open(). @a fname is utf8-encoded. + Always passed flag | APR_BINARY to apr. */ +svn_error_t * +svn_io_file_open(apr_file_t **new_file, + const char *fname, + apr_int32_t flag, + apr_fileperms_t perm, + apr_pool_t *pool); + + +/** Wrapper for apr_file_close(). */ +svn_error_t * +svn_io_file_close(apr_file_t *file, + apr_pool_t *pool); + + +/** Wrapper for apr_file_getc(). */ +svn_error_t * +svn_io_file_getc(char *ch, + apr_file_t *file, + apr_pool_t *pool); + + +/** Wrapper for apr_file_putc(). + * @since New in 1.7 + */ +svn_error_t * +svn_io_file_putc(char ch, + apr_file_t *file, + apr_pool_t *pool); + + +/** Wrapper for apr_file_info_get(). */ +svn_error_t * +svn_io_file_info_get(apr_finfo_t *finfo, + apr_int32_t wanted, + apr_file_t *file, + apr_pool_t *pool); + + +/** Wrapper for apr_file_read(). */ +svn_error_t * +svn_io_file_read(apr_file_t *file, + void *buf, + apr_size_t *nbytes, + apr_pool_t *pool); + + +/** Wrapper for apr_file_read_full(). + * + * If @a hit_eof is not NULL, EOF will be indicated there and no + * svn_error_t error object will be created upon EOF. + * + * @since New in 1.7 + */ +svn_error_t * +svn_io_file_read_full2(apr_file_t *file, + void *buf, + apr_size_t nbytes, + apr_size_t *bytes_read, + svn_boolean_t *hit_eof, + apr_pool_t *pool); + + +/** Similar to svn_io_file_read_full2 with hit_eof being set + * to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.6 API + */ +SVN_DEPRECATED +svn_error_t * +svn_io_file_read_full(apr_file_t *file, + void *buf, + apr_size_t nbytes, + apr_size_t *bytes_read, + apr_pool_t *pool); + + +/** Wrapper for apr_file_seek(). */ +svn_error_t * +svn_io_file_seek(apr_file_t *file, + apr_seek_where_t where, + apr_off_t *offset, + apr_pool_t *pool); + + +/** Wrapper for apr_file_write(). */ +svn_error_t * +svn_io_file_write(apr_file_t *file, + const void *buf, + apr_size_t *nbytes, + apr_pool_t *pool); + + +/** Wrapper for apr_file_write_full(). */ +svn_error_t * +svn_io_file_write_full(apr_file_t *file, + const void *buf, + apr_size_t nbytes, + apr_size_t *bytes_written, + apr_pool_t *pool); + +/** + * Open a unique file in @a dirpath, and write @a nbytes from @a buf to + * the file before flushing it to disk and closing it. Return the name + * of the newly created file in @a *tmp_path, allocated in @a pool. + * + * If @a dirpath is @c NULL, use the path returned from svn_io_temp_dir(). + * (Note that when using the system-provided temp directory, it may not + * be possible to atomically rename the resulting file due to cross-device + * issues.) + * + * The file will be deleted according to @a delete_when. + * + * @since New in 1.6. + */ +svn_error_t * +svn_io_write_unique(const char **tmp_path, + const char *dirpath, + const void *buf, + apr_size_t nbytes, + svn_io_file_del_t delete_when, + apr_pool_t *pool); + +/** Wrapper for apr_file_trunc(). + * @since New in 1.6. */ +svn_error_t * +svn_io_file_trunc(apr_file_t *file, + apr_off_t offset, + apr_pool_t *pool); + + +/** Wrapper for apr_stat(). @a fname is utf8-encoded. */ +svn_error_t * +svn_io_stat(apr_finfo_t *finfo, + const char *fname, + apr_int32_t wanted, + apr_pool_t *pool); + + +/** Rename and/or move the node (not necessarily a regular file) at + * @a from_path to a new path @a to_path within the same filesystem. + * In some cases, an existing node at @a to_path will be overwritten. + * + * A wrapper for apr_file_rename(). @a from_path and @a to_path are + * utf8-encoded. + */ +svn_error_t * +svn_io_file_rename(const char *from_path, + const char *to_path, + apr_pool_t *pool); + + +/** Move the file from @a from_path to @a to_path, even across device + * boundaries. Overwrite @a to_path if it exists. + * + * @note This function is different from svn_io_file_rename in that the + * latter fails in the 'across device boundaries' case. + * + * @since New in 1.3. + */ +svn_error_t * +svn_io_file_move(const char *from_path, + const char *to_path, + apr_pool_t *pool); + + +/** Wrapper for apr_dir_make(). @a path is utf8-encoded. */ +svn_error_t * +svn_io_dir_make(const char *path, + apr_fileperms_t perm, + apr_pool_t *pool); + +/** Same as svn_io_dir_make(), but sets the hidden attribute on the + directory on systems that support it. */ +svn_error_t * +svn_io_dir_make_hidden(const char *path, + apr_fileperms_t perm, + apr_pool_t *pool); + +/** + * Same as svn_io_dir_make(), but attempts to set the sgid on the + * directory on systems that support it. Does not return an error if + * the attempt to set the sgid bit fails. On Unix filesystems, + * setting the sgid bit on a directory ensures that files and + * subdirectories created within inherit group ownership from the + * parent instead of from the primary gid. + * + * @since New in 1.1. + */ +svn_error_t * +svn_io_dir_make_sgid(const char *path, + apr_fileperms_t perm, + apr_pool_t *pool); + +/** Wrapper for apr_dir_open(). @a dirname is utf8-encoded. */ +svn_error_t * +svn_io_dir_open(apr_dir_t **new_dir, + const char *dirname, + apr_pool_t *pool); + +/** Wrapper for apr_dir_close(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_io_dir_close(apr_dir_t *thedir); + +/** Wrapper for apr_dir_remove(). @a dirname is utf8-encoded. + * @note This function has this name to avoid confusion with + * svn_io_remove_dir2(), which is recursive. + */ +svn_error_t * +svn_io_dir_remove_nonrecursive(const char *dirname, + apr_pool_t *pool); + + +/** Wrapper for apr_dir_read(). Ensures that @a finfo->name is + * utf8-encoded, which means allocating @a finfo->name in @a pool, + * which may or may not be the same as @a finfo's pool. Use @a pool + * for error allocation as well. + */ +svn_error_t * +svn_io_dir_read(apr_finfo_t *finfo, + apr_int32_t wanted, + apr_dir_t *thedir, + apr_pool_t *pool); + +/** Wrapper for apr_file_name_get(). @a *filename is utf8-encoded. + * + * @note The file name may be NULL. + * + * @since New in 1.7. */ +svn_error_t * +svn_io_file_name_get(const char **filename, + apr_file_t *file, + apr_pool_t *pool); + + + +/** Version/format files. + * + * @defgroup svn_io_format_files Version/format files + * @{ + */ + +/** Set @a *version to the integer that starts the file at @a path. If the + * file does not begin with a series of digits followed by a newline, + * return the error #SVN_ERR_BAD_VERSION_FILE_FORMAT. Use @a pool for + * all allocations. + */ +svn_error_t * +svn_io_read_version_file(int *version, + const char *path, + apr_pool_t *pool); + +/** Create (or overwrite) the file at @a path with new contents, + * formatted as a non-negative integer @a version followed by a single + * newline. On successful completion the file will be read-only. Use + * @a pool for all allocations. + */ +svn_error_t * +svn_io_write_version_file(const char *path, + int version, + apr_pool_t *pool); + +/** Read a line of text from a file, up to a specified length. + * + * Allocate @a *stringbuf in @a result_pool, and read into it one line + * from @a file. Reading stops either after a line-terminator was found + * or after @a max_len bytes have been read. + * + * If end-of-file is reached or @a max_len bytes have been read, and @a eof + * is not NULL, then set @a *eof to @c TRUE. + * + * The line-terminator is not stored in @a *stringbuf. + * The line-terminator is detected automatically and stored in @a *eol + * if @a eol is not NULL. If EOF is reached and @a file does not end + * with a newline character, and @a eol is not NULL, @ *eol is set to NULL. + * + * @a scratch_pool is used for temporary allocations. + * + * Hint: To read all data until a line-terminator is hit, pass APR_SIZE_MAX + * for @a max_len. + * + * @since New in 1.8. + */ +svn_error_t * +svn_io_file_readline(apr_file_t *file, + svn_stringbuf_t **stringbuf, + const char **eol, + svn_boolean_t *eof, + apr_size_t max_len, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_IO_H */ diff --git a/subversion/include/svn_iter.h b/subversion/include/svn_iter.h new file mode 100644 index 0000000..ab88935 --- /dev/null +++ b/subversion/include/svn_iter.h @@ -0,0 +1,139 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_iter.h + * @brief The Subversion Iteration drivers helper routines + * + */ + +#ifndef SVN_ITER_H +#define SVN_ITER_H + +#include <apr.h> /* for apr_ssize_t */ +#include <apr_pools.h> /* for apr_pool_t */ +#include <apr_hash.h> /* for apr_hash_t */ +#include <apr_tables.h> /* for apr_array_header_t */ + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Callback function for use with svn_iter_apr_hash(). + * Use @a pool for temporary allocation, it's cleared between invocations. + * + * @a key, @a klen and @a val are the values normally retrieved with + * apr_hash_this(). + * + * @a baton is the baton passed into svn_iter_apr_hash(). + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_iter_apr_hash_cb_t)(void *baton, + const void *key, + apr_ssize_t klen, + void *val, apr_pool_t *pool); + +/** Iterate over the elements in @a hash, calling @a func for each one until + * there are no more elements or @a func returns an error. + * + * Uses @a pool for temporary allocations. + * + * If @a completed is not NULL, then on return - if @a func returns no + * errors - @a *completed will be set to @c TRUE. + * + * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that + * error is returned. When @a func returns @c SVN_ERR_ITER_BREAK, + * iteration is interrupted, but no error is returned and @a *completed is + * set to @c FALSE (even if this iteration was the last one). + * + * @since New in 1.5. + */ +svn_error_t * +svn_iter_apr_hash(svn_boolean_t *completed, + apr_hash_t *hash, + svn_iter_apr_hash_cb_t func, + void *baton, + apr_pool_t *pool); + +/** Iteration callback used in conjuction with svn_iter_apr_array(). + * + * Use @a pool for temporary allocation, it's cleared between invocations. + * + * @a baton is the baton passed to svn_iter_apr_array(). @a item + * is a pointer to the item written to the array with the APR_ARRAY_PUSH() + * macro. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_iter_apr_array_cb_t)(void *baton, + void *item, + apr_pool_t *pool); + +/** Iterate over the elements in @a array calling @a func for each one until + * there are no more elements or @a func returns an error. + * + * Uses @a pool for temporary allocations. + * + * If @a completed is not NULL, then on return - if @a func returns no + * errors - @a *completed will be set to @c TRUE. + * + * If @a func returns an error other than @c SVN_ERR_ITER_BREAK, that + * error is returned. When @a func returns @c SVN_ERR_ITER_BREAK, + * iteration is interrupted, but no error is returned and @a *completed is + * set to @c FALSE (even if this iteration was the last one). + * + * @since New in 1.5. + */ +svn_error_t * +svn_iter_apr_array(svn_boolean_t *completed, + const apr_array_header_t *array, + svn_iter_apr_array_cb_t func, + void *baton, + apr_pool_t *pool); + + +/** Internal routine used by svn_iter_break() macro. + */ +svn_error_t * +svn_iter__break(void); + + +/** Helper macro to break looping in svn_iter_apr_array() and + * svn_iter_apr_hash() driven loops. + * + * @note The error is just a means of communicating between + * driver and callback. There is no need for it to exist + * past the lifetime of the iterpool. + * + * @since New in 1.5. + */ +#define svn_iter_break(pool) return svn_iter__break() + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_ITER_H */ diff --git a/subversion/include/svn_md5.h b/subversion/include/svn_md5.h new file mode 100644 index 0000000..e6e330d --- /dev/null +++ b/subversion/include/svn_md5.h @@ -0,0 +1,91 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_md5.h + * @brief Converting and comparing MD5 checksums. + */ + +#ifndef SVN_MD5_H +#define SVN_MD5_H + +#include <apr_pools.h> /* for apr_pool_t */ + +#include "svn_types.h" /* for svn_boolean_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** + * The MD5 digest for the empty string. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + * */ +SVN_DEPRECATED +const unsigned char * +svn_md5_empty_string_digest(void); + + +/** + * Return the hex representation of @a digest, which must be + * @c APR_MD5_DIGESTSIZE bytes long, allocating the string in @a pool. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +const char * +svn_md5_digest_to_cstring_display(const unsigned char digest[], + apr_pool_t *pool); + + +/** + * Return the hex representation of @a digest, which must be + * @c APR_MD5_DIGESTSIZE bytes long, allocating the string in @a pool. + * If @a digest is all zeros, then return NULL. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +const char * +svn_md5_digest_to_cstring(const unsigned char digest[], + apr_pool_t *pool); + + +/** + * Compare digests @a d1 and @a d2, each @c APR_MD5_DIGESTSIZE bytes long. + * If neither is all zeros, and they do not match, then return FALSE; + * else return TRUE. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_boolean_t +svn_md5_digests_match(const unsigned char d1[], + const unsigned char d2[]); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_MD5_H */ diff --git a/subversion/include/svn_mergeinfo.h b/subversion/include/svn_mergeinfo.h new file mode 100644 index 0000000..ada70a2 --- /dev/null +++ b/subversion/include/svn_mergeinfo.h @@ -0,0 +1,612 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_mergeinfo.h + * @brief mergeinfo handling and processing + */ + + +#ifndef SVN_MERGEINFO_H +#define SVN_MERGEINFO_H + +#include <apr_pools.h> +#include <apr_tables.h> /* for apr_array_header_t */ +#include <apr_hash.h> + +#include "svn_types.h" +#include "svn_string.h" /* for svn_string_t */ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Overview of the @c SVN_PROP_MERGEINFO property. + * + * Merge history is stored in the @c SVN_PROP_MERGEINFO property of files + * and directories. The @c SVN_PROP_MERGEINFO property on a path stores the + * complete list of changes merged to that path, either directly or via the + * path's parent, grand-parent, etc.. A path may have empty mergeinfo which + * means that nothing has been merged to that path or all previous merges + * to the path were reversed. Note that a path may have no mergeinfo, this + * is not the same as empty mergeinfo. + * + * Every path in a tree may have @c SVN_PROP_MERGEINFO set, but if the + * @c SVN_PROP_MERGEINFO for a path is equivalent to the + * @c SVN_PROP_MERGEINFO for its parent, then the @c SVN_PROP_MERGEINFO on + * the path will 'elide' (be removed) from the path as a post step to any + * merge. If a path's parent does not have any @c SVN_PROP_MERGEINFO set, + * the path's mergeinfo can elide to its nearest grand-parent, + * great-grand-parent, etc. that has equivalent @c SVN_PROP_MERGEINFO set + * on it. + * + * If a path has no @c SVN_PROP_MERGEINFO of its own, it inherits mergeinfo + * from its nearest parent that has @c SVN_PROP_MERGEINFO set. The + * exception to this is @c SVN_PROP_MERGEINFO with non-inheritable revision + * ranges. These non-inheritable ranges apply only to the path which they + * are set on. + * + * Due to Subversion's allowance for mixed revision working copies, both + * elision and inheritance within the working copy presume the path + * between a path and its nearest parent with mergeinfo is at the same + * working revision. If this is not the case then neither inheritance nor + * elision can occur. + * + * The value of the @c SVN_PROP_MERGEINFO property is either an empty string + * (representing empty mergeinfo) or a non-empty string consisting of + * a path, a colon, and comma separated revision list, containing one or more + * revision or revision ranges. Revision range start and end points are + * separated by "-". Revisions and revision ranges may have the optional + * @c SVN_MERGEINFO_NONINHERITABLE_STR suffix to signify a non-inheritable + * revision/revision range. + * + * @c SVN_PROP_MERGEINFO Value Grammar: + * + * Token Definition + * ----- ---------- + * revisionrange REVISION1 "-" REVISION2 + * revisioneelement (revisionrange | REVISION)"*"? + * rangelist revisioneelement (COMMA revisioneelement)* + * revisionline PATHNAME COLON rangelist + * top "" | (revisionline (NEWLINE revisionline))* + * + * The PATHNAME is the source of a merge and the rangelist the revision(s) + * merged to the path @c SVN_PROP_MERGEINFO is set on directly or indirectly + * via inheritance. PATHNAME must always exist at the specified rangelist + * and thus a single merge may result in multiple revisionlines if the source + * was renamed. + * + * Rangelists must be sorted from lowest to highest revision and cannot + * contain overlapping revisionlistelements. REVISION1 must be less than + * REVISION2. Consecutive single revisions that can be represented by a + * revisionrange are allowed however (e.g. '5,6,7,8,9-12' or '5-12' are + * both acceptable). + */ + +/* Suffix for SVN_PROP_MERGEINFO revision ranges indicating a given + range is non-inheritable. */ +#define SVN_MERGEINFO_NONINHERITABLE_STR "*" + +/** Terminology for data structures that contain mergeinfo. + * + * Subversion commonly uses several data structures to represent + * mergeinfo in RAM: + * + * (a) Strings (@c svn_string_t *) containing "unparsed mergeinfo". + * + * (b) @c svn_rangelist_t, called a "rangelist". An array of non- + * overlapping merge ranges (@c svn_merge_range_t *), sorted as said by + * @c svn_sort_compare_ranges(). An empty range list is represented by + * an empty array. Unless specifically noted otherwise, all APIs require + * rangelists that describe only forward ranges, i.e. the range's start + * revision is less than its end revision. + * + * (c) @c svn_mergeinfo_t, called "mergeinfo". A hash mapping merge + * source paths (@c const char *, starting with slashes) to + * non-empty rangelist arrays. A @c NULL hash is used to represent + * no mergeinfo and an empty hash is used to represent empty + * mergeinfo. + * + * (d) @c svn_mergeinfo_catalog_t, called a "mergeinfo catalog". A hash + * mapping paths (@c const char *) to @c svn_mergeinfo_t. + * + * Both @c svn_mergeinfo_t and @c svn_mergeinfo_catalog_t are just + * typedefs for @c apr_hash_t *; there is no static type-checking, and + * you still use standard @c apr_hash_t functions to interact with + * them. + * + * Note that while the keys of mergeinfos are always absolute from the + * repository root, the keys of a catalog may be relative to something + * else, such as an RA session root. + */ + +typedef apr_array_header_t svn_rangelist_t; +typedef apr_hash_t *svn_mergeinfo_t; +typedef apr_hash_t *svn_mergeinfo_catalog_t; + +/** Parse the mergeinfo from @a input into @a *mergeinfo. If no + * mergeinfo is available, return an empty mergeinfo (never @c NULL). + * Perform temporary allocations in @a pool. + * + * If @a input is not a grammatically correct @c SVN_PROP_MERGEINFO + * property, contains overlapping revision ranges of differing + * inheritability, or revision ranges with a start revision greater + * than or equal to its end revision, or contains paths mapped to empty + * revision ranges, then return @c SVN_ERR_MERGEINFO_PARSE_ERROR. + * Unordered revision ranges are allowed, but will be sorted when + * placed into @a *mergeinfo. Overlapping revision ranges of the same + * inheritability are also allowed, but will be combined into a single + * range when placed into @a *mergeinfo. + * + * @a input may contain relative merge source paths, but these are + * converted to absolute paths in @a *mergeinfo. + * + * @since New in 1.5. + */ +svn_error_t * +svn_mergeinfo_parse(svn_mergeinfo_t *mergeinfo, const char *input, + apr_pool_t *pool); + +/** Calculate the delta between two mergeinfos, @a mergefrom and @a mergeto + * (either or both of which may be @c NULL meaning an empty mergeinfo). + * Place the result in @a *deleted and @a *added (neither output argument + * may be @c NULL), both allocated in @a result_pool. The resulting + * @a *deleted and @a *added will not be null. + * + * @a consider_inheritance determines how the rangelists in the two + * hashes are compared for equality. If @a consider_inheritance is FALSE, + * then the start and end revisions of the @c svn_merge_range_t's being + * compared are the only factors considered when determining equality. + * + * e.g. '/trunk: 1,3-4*,5' == '/trunk: 1,3-5' + * + * If @a consider_inheritance is TRUE, then the inheritability of the + * @c svn_merge_range_t's is also considered and must be the same for two + * otherwise identical ranges to be judged equal. + * + * e.g. '/trunk: 1,3-4*,5' != '/trunk: 1,3-5' + * '/trunk: 1,3-4*,5' == '/trunk: 1,3-4*,5' + * '/trunk: 1,3-4,5' == '/trunk: 1,3-4,5' + * + * @since New in 1.8. + */ +svn_error_t * +svn_mergeinfo_diff2(svn_mergeinfo_t *deleted, svn_mergeinfo_t *added, + svn_mergeinfo_t mergefrom, svn_mergeinfo_t mergeto, + svn_boolean_t consider_inheritance, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_mergeinfo_diff2(), but users only one pool. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_mergeinfo_diff(svn_mergeinfo_t *deleted, svn_mergeinfo_t *added, + svn_mergeinfo_t mergefrom, svn_mergeinfo_t mergeto, + svn_boolean_t consider_inheritance, + apr_pool_t *pool); + +/** Merge a shallow copy of one mergeinfo, @a changes, into another mergeinfo + * @a mergeinfo. + * + * Rangelists for merge source paths common to @a changes and @a mergeinfo may + * result in new rangelists; these are allocated in @a result_pool. + * Temporary allocations are made in @a scratch_pool. + * + * When intersecting rangelists for a path are merged, the inheritability of + * the resulting svn_merge_range_t depends on the inheritability of the + * operands. If two non-inheritable ranges are merged the result is always + * non-inheritable, in all other cases the resulting range is inheritable. + * + * e.g. '/A: 1,3-4' merged with '/A: 1,3,4*,5' --> '/A: 1,3-5' + * '/A: 1,3-4*' merged with '/A: 1,3,4*,5' --> '/A: 1,3,4*,5' + * + * @since New in 1.8. + */ +svn_error_t * +svn_mergeinfo_merge2(svn_mergeinfo_t mergeinfo, + svn_mergeinfo_t changes, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Like svn_mergeinfo_merge2, but uses only one pool. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_mergeinfo_merge(svn_mergeinfo_t mergeinfo, + svn_mergeinfo_t changes, + apr_pool_t *pool); + +/** Combine one mergeinfo catalog, @a changes_catalog, into another mergeinfo + * catalog @a mergeinfo_catalog. If both catalogs have mergeinfo for the same + * key, use svn_mergeinfo_merge() to combine the mergeinfos. + * + * Additions to @a mergeinfo_catalog are deep copies allocated in + * @a result_pool. Temporary allocations are made in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_mergeinfo_catalog_merge(svn_mergeinfo_catalog_t mergeinfo_catalog, + svn_mergeinfo_catalog_t changes_catalog, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Like svn_mergeinfo_remove2, but always considers inheritance. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_mergeinfo_remove(svn_mergeinfo_t *mergeinfo, svn_mergeinfo_t eraser, + svn_mergeinfo_t whiteboard, apr_pool_t *pool); + +/** Removes @a eraser (the subtrahend) from @a whiteboard (the + * minuend), and places the resulting difference in @a *mergeinfo. + * Allocates @a *mergeinfo in @a result_pool. Temporary allocations + * will be performed in @a scratch_pool. + * + * @a consider_inheritance determines how to account for the inheritability + * of the two mergeinfo's ranges when calculating the range equivalence, + * as described for svn_mergeinfo_diff(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_mergeinfo_remove2(svn_mergeinfo_t *mergeinfo, + svn_mergeinfo_t eraser, + svn_mergeinfo_t whiteboard, + svn_boolean_t consider_inheritance, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Calculate the delta between two rangelists consisting of @c + * svn_merge_range_t * elements (sorted in ascending order), @a from + * and @a to, and place the result in @a *deleted and @a *added + * (neither output argument will ever be @c NULL). + * + * @a consider_inheritance determines how to account for the inheritability + * of the two rangelist's ranges when calculating the diff, + * as described for svn_mergeinfo_diff(). + * + * @since New in 1.5. + */ +svn_error_t * +svn_rangelist_diff(svn_rangelist_t **deleted, svn_rangelist_t **added, + const svn_rangelist_t *from, const svn_rangelist_t *to, + svn_boolean_t consider_inheritance, + apr_pool_t *pool); + +/** Merge two rangelists consisting of @c svn_merge_range_t * + * elements, @a rangelist and @a changes, placing the results in + * @a rangelist. New elements added to @a rangelist are allocated + * in @a result_pool. Either rangelist may be empty. + * + * When intersecting rangelists are merged, the inheritability of + * the resulting svn_merge_range_t depends on the inheritability of the + * operands: see svn_mergeinfo_merge(). + * + * Note: @a rangelist and @a changes must be sorted as said by @c + * svn_sort_compare_ranges(). @a rangelist is guaranteed to remain + * in sorted order and be compacted to the minimal number of ranges + * needed to represent the merged result. + * + * If the original rangelist contains non-collapsed adjacent ranges, + * the final result is not guaranteed to be compacted either. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_rangelist_merge2(svn_rangelist_t *rangelist, + const svn_rangelist_t *changes, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Like svn_rangelist_merge2(), but with @a rangelist as an input/output + * argument. This function always allocates a new rangelist in @a pool and + * returns its result in @a *rangelist. It does not modify @a *rangelist + * in place. If not used carefully, this function can use up a lot of memory + * if called in a loop. + * + * It performs an extra adjacent range compaction round to make sure non + * collapsed input ranges are compacted in the result. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_rangelist_merge(svn_rangelist_t **rangelist, + const svn_rangelist_t *changes, + apr_pool_t *pool); + +/** Removes @a eraser (the subtrahend) from @a whiteboard (the + * minuend), and places the resulting difference in @a output. + * + * Note: @a eraser and @a whiteboard must be sorted as said by @c + * svn_sort_compare_ranges(). @a output is guaranteed to be in sorted + * order. + * + * @a consider_inheritance determines how to account for the + * @c svn_merge_range_t inheritable field when comparing @a whiteboard's + * and @a *eraser's rangelists for equality. @see svn_mergeinfo_diff(). + * + * @since New in 1.5. + */ +svn_error_t * +svn_rangelist_remove(svn_rangelist_t **output, const svn_rangelist_t *eraser, + const svn_rangelist_t *whiteboard, + svn_boolean_t consider_inheritance, + apr_pool_t *pool); + +/** Find the intersection of two mergeinfos, @a mergeinfo1 and @a + * mergeinfo2, and place the result in @a *mergeinfo, which is (deeply) + * allocated in @a result_pool. Temporary allocations will be performed + * in @a scratch_pool. + * + * @a consider_inheritance determines how to account for the inheritability + * of the two mergeinfo's ranges when calculating the range equivalence, + * @see svn_rangelist_intersect(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_mergeinfo_intersect2(svn_mergeinfo_t *mergeinfo, + svn_mergeinfo_t mergeinfo1, + svn_mergeinfo_t mergeinfo2, + svn_boolean_t consider_inheritance, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Like svn_mergeinfo_intersect2, but always considers inheritance. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_mergeinfo_intersect(svn_mergeinfo_t *mergeinfo, + svn_mergeinfo_t mergeinfo1, + svn_mergeinfo_t mergeinfo2, + apr_pool_t *pool); + +/** Find the intersection of two rangelists consisting of @c + * svn_merge_range_t * elements, @a rangelist1 and @a rangelist2, and + * place the result in @a *rangelist (which is never @c NULL). + * + * @a consider_inheritance determines how to account for the inheritability + * of the two rangelist's ranges when calculating the intersection, + * @see svn_mergeinfo_diff(). If @a consider_inheritance is FALSE then + * ranges with different inheritance can intersect, but the resulting + * @a *rangelist is non-inheritable only if the corresponding ranges from + * both @a rangelist1 and @a rangelist2 are non-inheritable. + * If @a consider_inheritance is TRUE, then ranges with different + * inheritance can never intersect. + * + * Note: @a rangelist1 and @a rangelist2 must be sorted as said by @c + * svn_sort_compare_ranges(). @a *rangelist is guaranteed to be in sorted + * order. + * @since New in 1.5. + */ +svn_error_t * +svn_rangelist_intersect(svn_rangelist_t **rangelist, + const svn_rangelist_t *rangelist1, + const svn_rangelist_t *rangelist2, + svn_boolean_t consider_inheritance, + apr_pool_t *pool); + +/** Reverse @a rangelist, and the @c start and @c end fields of each + * range in @a rangelist, in place. + * + * TODO(miapi): Is this really a valid function? Rangelists that + * aren't sorted, or rangelists containing reverse ranges, are + * generally not valid in mergeinfo code. Can we rewrite the two + * places where this is used? + * + * @since New in 1.5. + */ +svn_error_t * +svn_rangelist_reverse(svn_rangelist_t *rangelist, apr_pool_t *pool); + +/** Take an array of svn_merge_range_t *'s in @a rangelist, and convert it + * back to a text format rangelist in @a output. If @a rangelist contains + * no elements, sets @a output to the empty string. + * + * @since New in 1.5. + */ +svn_error_t * +svn_rangelist_to_string(svn_string_t **output, + const svn_rangelist_t *rangelist, + apr_pool_t *pool); + +/** Return a deep copy of @c svn_merge_range_t *'s in @a rangelist excluding + * all non-inheritable @c svn_merge_range_t if @a inheritable is TRUE or + * excluding all inheritable @c svn_merge_range_t otherwise. If @a start and + * @a end are valid revisions and @a start is less than or equal to @a end, + * then exclude only the non-inheritable revision ranges that intersect + * inclusively with the range defined by @a start and @a end. If + * @a rangelist contains no elements, return an empty array. Allocate the + * copy in @a result_pool, use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_rangelist_inheritable2(svn_rangelist_t **inheritable_rangelist, + const svn_rangelist_t *rangelist, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t inheritable, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Like svn_rangelist_inheritable2, but always finds inheritable ranges. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_rangelist_inheritable(svn_rangelist_t **inheritable_rangelist, + const svn_rangelist_t *rangelist, + svn_revnum_t start, + svn_revnum_t end, + apr_pool_t *pool); + +/** Return a deep copy of @a mergeinfo, excluding all non-inheritable + * @c svn_merge_range_t if @a inheritable is TRUE or excluding all + * inheritable @c svn_merge_range_t otherwise. If @a start and @a end + * are valid revisions and @a start is less than or equal to @a end, + * then exclude only the non-inheritable revisions that intersect + * inclusively with the range defined by @a start and @a end. If @a path + * is not NULL remove non-inheritable ranges only for @a path. If all + * ranges are removed for a given path then remove that path as well. + * If all paths are removed or @a rangelist is empty then set + * @a *inheritable_rangelist to an empty array. Allocate the copy in + * @a result_pool, use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_mergeinfo_inheritable2(svn_mergeinfo_t *inheritable_mergeinfo, + svn_mergeinfo_t mergeinfo, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t inheritable, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Like svn_mergeinfo_inheritable2, but always finds inheritable mergeinfo. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_mergeinfo_inheritable(svn_mergeinfo_t *inheritable_mergeinfo, + svn_mergeinfo_t mergeinfo, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + apr_pool_t *pool); + +/** Take a mergeinfo in @a mergeinput, and convert it to unparsed + * mergeinfo. Set @a *output to the result, allocated in @a pool. + * If @a input contains no elements, set @a *output to the empty string. + * + * @a mergeinput may contain relative merge source paths, but these are + * converted to absolute paths in @a *output. + * + * @since New in 1.5. +*/ +svn_error_t * +svn_mergeinfo_to_string(svn_string_t **output, + svn_mergeinfo_t mergeinput, + apr_pool_t *pool); + +/** Take a hash of mergeinfo in @a mergeinfo, and sort the rangelists + * associated with each key (in place). + * + * TODO(miapi): mergeinfos should *always* be sorted. This should be + * a private function. + * + * @since New in 1.5 + */ +svn_error_t * +svn_mergeinfo_sort(svn_mergeinfo_t mergeinfo, apr_pool_t *pool); + +/** Return a deep copy of @a mergeinfo_catalog, allocated in @a pool. + * + * @since New in 1.6. + */ +svn_mergeinfo_catalog_t +svn_mergeinfo_catalog_dup(svn_mergeinfo_catalog_t mergeinfo_catalog, + apr_pool_t *pool); + +/** Return a deep copy of @a mergeinfo, allocated in @a pool. + * + * @since New in 1.5. + */ +svn_mergeinfo_t +svn_mergeinfo_dup(svn_mergeinfo_t mergeinfo, apr_pool_t *pool); + +/** Return a deep copy of @a rangelist, allocated in @a pool. + * + * @since New in 1.5. + */ +svn_rangelist_t * +svn_rangelist_dup(const svn_rangelist_t *rangelist, apr_pool_t *pool); + + +/** + * The three ways to request mergeinfo affecting a given path. + * + * @since New in 1.5. + */ +typedef enum svn_mergeinfo_inheritance_t +{ + /** Explicit mergeinfo only. */ + svn_mergeinfo_explicit, + + /** Explicit mergeinfo, or if that doesn't exist, the inherited + mergeinfo from a target's nearest (path-wise, not history-wise) + ancestor. */ + svn_mergeinfo_inherited, + + /** Mergeinfo inherited from a target's nearest (path-wise, not + history-wise) ancestor, regardless of whether target has explicit + mergeinfo. */ + svn_mergeinfo_nearest_ancestor +} svn_mergeinfo_inheritance_t; + +/** Return a constant string expressing @a inherit as an English word, + * i.e., "explicit" (default), "inherited", or "nearest_ancestor". + * The string is not localized, as it may be used for client<->server + * communications. + * + * @since New in 1.5. + */ +const char * +svn_inheritance_to_word(svn_mergeinfo_inheritance_t inherit); + + +/** Return the appropriate @c svn_mergeinfo_inheritance_t for @a word. + * @a word is as returned from svn_inheritance_to_word(). Defaults to + * @c svn_mergeinfo_explicit. + * + * @since New in 1.5. + */ +svn_mergeinfo_inheritance_t +svn_inheritance_from_word(const char *word); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_MERGEINFO_H */ diff --git a/subversion/include/svn_nls.h b/subversion/include/svn_nls.h new file mode 100644 index 0000000..6a5bc1b --- /dev/null +++ b/subversion/include/svn_nls.h @@ -0,0 +1,56 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_nls.h + * @brief Support functions for NLS programs + */ + + + +#ifndef SVN_NLS_H +#define SVN_NLS_H + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Set up the NLS. + * Return the error @c APR_EINVAL or @c APR_INCOMPLETE if an + * error occurs. + * + * @note This function is for bindings. You should usually + * use svn_cmdline_init() instead of calling this + * function directly. This function should be called + * after initializing APR. + * + * @since New in 1.3. + */ +svn_error_t * +svn_nls_init(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_NLS_H */ diff --git a/subversion/include/svn_opt.h b/subversion/include/svn_opt.h new file mode 100644 index 0000000..25da44f --- /dev/null +++ b/subversion/include/svn_opt.h @@ -0,0 +1,779 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_opt.h + * @brief Option and argument parsing for Subversion command lines + */ + +#ifndef SVN_OPTS_H +#define SVN_OPTS_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_getopt.h> +#include <apr_tables.h> +#include <apr_hash.h> + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +#define APR_WANT_STDIO +#endif +#include <apr_want.h> /* for FILE* */ + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** + * All subcommand procedures in Subversion conform to this prototype. + * + * @a os is the apr option state after getopt processing has been run; in + * other words, it still contains the non-option arguments following + * the subcommand. See @a os->argv and @a os->ind. + * + * @a baton is anything you need it to be. + * + * @a pool is used for allocating errors, and for any other allocation + * unless the instance is explicitly documented to allocate from a + * pool in @a baton. + */ +typedef svn_error_t *(svn_opt_subcommand_t)( + apr_getopt_t *os, void *baton, apr_pool_t *pool); + + +/** The maximum number of aliases a subcommand can have. */ +#define SVN_OPT_MAX_ALIASES 3 + +/** The maximum number of options that can be accepted by a subcommand. */ +#define SVN_OPT_MAX_OPTIONS 50 + +/** Options that have no short option char should use an identifying + * integer equal to or greater than this. + */ +#define SVN_OPT_FIRST_LONGOPT_ID 256 + + +/** One element of a subcommand dispatch table. + * + * @since New in 1.4. + */ +typedef struct svn_opt_subcommand_desc2_t +{ + /** The full name of this command. */ + const char *name; + + /** The function this command invokes. */ + svn_opt_subcommand_t *cmd_func; + + /** A list of alias names for this command (e.g., 'up' for 'update'). */ + const char *aliases[SVN_OPT_MAX_ALIASES]; + + /** A brief string describing this command, for usage messages. */ + const char *help; + + /** A list of options accepted by this command. Each value in the + * array is a unique enum (the 2nd field in apr_getopt_option_t) + */ + int valid_options[SVN_OPT_MAX_OPTIONS]; + + /** A list of option help descriptions, keyed by the option unique enum + * (the 2nd field in apr_getopt_option_t), which override the generic + * descriptions given in an apr_getopt_option_t on a per-subcommand basis. + */ + struct { int optch; const char *desc; } desc_overrides[SVN_OPT_MAX_OPTIONS]; +} svn_opt_subcommand_desc2_t; + + +/** One element of a subcommand dispatch table. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + * + * Like #svn_opt_subcommand_desc2_t but lacking the @c desc_overrides + * member. + */ +typedef struct svn_opt_subcommand_desc_t +{ + /** The full name of this command. */ + const char *name; + + /** The function this command invokes. */ + svn_opt_subcommand_t *cmd_func; + + /** A list of alias names for this command (e.g., 'up' for 'update'). */ + const char *aliases[SVN_OPT_MAX_ALIASES]; + + /** A brief string describing this command, for usage messages. */ + const char *help; + + /** A list of options accepted by this command. Each value in the + * array is a unique enum (the 2nd field in apr_getopt_option_t) + */ + int valid_options[SVN_OPT_MAX_OPTIONS]; + +} svn_opt_subcommand_desc_t; + + +/** + * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if + * none. @a cmd_name may be an alias. + * + * @since New in 1.4. + */ +const svn_opt_subcommand_desc2_t * +svn_opt_get_canonical_subcommand2(const svn_opt_subcommand_desc2_t *table, + const char *cmd_name); + + +/** + * Return the entry in @a table whose name matches @a cmd_name, or @c NULL if + * none. @a cmd_name may be an alias. + * + * Same as svn_opt_get_canonical_subcommand2(), but acts on + * #svn_opt_subcommand_desc_t. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +const svn_opt_subcommand_desc_t * +svn_opt_get_canonical_subcommand(const svn_opt_subcommand_desc_t *table, + const char *cmd_name); + + +/** + * Return pointer to an @c apr_getopt_option_t for the option whose + * option code is @a code, or @c NULL if no match. @a option_table must end + * with an element whose every field is zero. If @a command is non-NULL, + * then return the subcommand-specific option description instead of the + * generic one, if a specific description is defined. + * + * The returned value may be statically allocated, or allocated in @a pool. + * + * @since New in 1.4. + */ +const apr_getopt_option_t * +svn_opt_get_option_from_code2(int code, + const apr_getopt_option_t *option_table, + const svn_opt_subcommand_desc2_t *command, + apr_pool_t *pool); + + +/** + * Return the first entry from @a option_table whose option code is @a code, + * or @c NULL if no match. @a option_table must end with an element whose + * every field is zero. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +const apr_getopt_option_t * +svn_opt_get_option_from_code(int code, + const apr_getopt_option_t *option_table); + + +/** + * Return @c TRUE iff subcommand @a command supports option @a + * option_code, else return @c FALSE. If @a global_options is + * non-NULL, it is a zero-terminated array, and all subcommands take + * the options listed in it. + * + * @since New in 1.5. + */ +svn_boolean_t +svn_opt_subcommand_takes_option3(const svn_opt_subcommand_desc2_t *command, + int option_code, + const int *global_options); + +/** + * Same as svn_opt_subcommand_takes_option3(), but with @c NULL for @a + * global_options. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_boolean_t +svn_opt_subcommand_takes_option2(const svn_opt_subcommand_desc2_t *command, + int option_code); + + +/** + * Return @c TRUE iff subcommand @a command supports option @a option_code, + * else return @c FALSE. + * + * Same as svn_opt_subcommand_takes_option2(), but acts on + * #svn_opt_subcommand_desc_t. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_boolean_t +svn_opt_subcommand_takes_option(const svn_opt_subcommand_desc_t *command, + int option_code); + + +/** + * Print a generic (not command-specific) usage message to @a stream. + * + * ### @todo Why is @a stream a stdio file instead of an svn stream? + * + * If @a header is non-NULL, print @a header followed by a newline. Then + * loop over @a cmd_table printing the usage for each command (getting + * option usages from @a opt_table). Then if @a footer is non-NULL, print + * @a footer followed by a newline. + * + * Use @a pool for temporary allocation. + * + * @since New in 1.4. + */ +void +svn_opt_print_generic_help2(const char *header, + const svn_opt_subcommand_desc2_t *cmd_table, + const apr_getopt_option_t *opt_table, + const char *footer, + apr_pool_t *pool, + FILE *stream); + + +/** + * Same as svn_opt_print_generic_help2(), but acts on + * #svn_opt_subcommand_desc_t. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +void +svn_opt_print_generic_help(const char *header, + const svn_opt_subcommand_desc_t *cmd_table, + const apr_getopt_option_t *opt_table, + const char *footer, + apr_pool_t *pool, + FILE *stream); + + +/** + * Print an option @a opt nicely into a @a string allocated in @a pool. + * If @a doc is set, include the generic documentation string of @a opt, + * localized to the current locale if a translation is available. + */ +void +svn_opt_format_option(const char **string, + const apr_getopt_option_t *opt, + svn_boolean_t doc, + apr_pool_t *pool); + + + +/** + * Get @a subcommand's usage from @a table, and print it to @c stdout. + * Obtain option usage from @a options_table. If not @c NULL, @a + * global_options is a zero-terminated list of global options. Use @a + * pool for temporary allocation. @a subcommand may be a canonical + * command name or an alias. ### @todo Why does this only print to + * @c stdout, whereas svn_opt_print_generic_help() gives us a choice? + * + * When printing the description of an option, if the same option code + * appears a second time in @a options_table with a different name, then + * use that second name as an alias for the first name. This additional + * behaviour is new in 1.7. + * + * @since New in 1.5. + */ +void +svn_opt_subcommand_help3(const char *subcommand, + const svn_opt_subcommand_desc2_t *table, + const apr_getopt_option_t *options_table, + const int *global_options, + apr_pool_t *pool); + +/** + * Same as svn_opt_subcommand_help3(), but with @a global_options + * always NULL. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +void +svn_opt_subcommand_help2(const char *subcommand, + const svn_opt_subcommand_desc2_t *table, + const apr_getopt_option_t *options_table, + apr_pool_t *pool); + + +/** + * Same as svn_opt_subcommand_help2(), but acts on + * #svn_opt_subcommand_desc_t. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +void +svn_opt_subcommand_help(const char *subcommand, + const svn_opt_subcommand_desc_t *table, + const apr_getopt_option_t *options_table, + apr_pool_t *pool); + + + +/* Parsing revision and date options. */ + +/** + * Various ways of specifying revisions. + * + * @note + * In contexts where local mods are relevant, the `working' kind + * refers to the uncommitted "working" revision, which may be modified + * with respect to its base revision. In other contexts, `working' + * should behave the same as `committed' or `current'. + */ +enum svn_opt_revision_kind { + /** No revision information given. */ + svn_opt_revision_unspecified, + + /** revision given as number */ + svn_opt_revision_number, + + /** revision given as date */ + svn_opt_revision_date, + + /** rev of most recent change */ + svn_opt_revision_committed, + + /** (rev of most recent change) - 1 */ + svn_opt_revision_previous, + + /** .svn/entries current revision */ + svn_opt_revision_base, + + /** current, plus local mods */ + svn_opt_revision_working, + + /** repository youngest */ + svn_opt_revision_head + + /* please update svn_opt__revision_to_string() when extending this enum */ +}; + +/** + * A revision value, which can be specified as a number or a date. + * + * @note This union was formerly an anonymous inline type in + * @c svn_opt_revision_t, and was converted to a named type just to + * make things easier for SWIG. + * + * @since New in 1.3. + */ +typedef union svn_opt_revision_value_t +{ + /** The revision number */ + svn_revnum_t number; + + /** the date of the revision */ + apr_time_t date; +} svn_opt_revision_value_t; + +/** A revision, specified in one of @c svn_opt_revision_kind ways. */ +typedef struct svn_opt_revision_t +{ + enum svn_opt_revision_kind kind; /**< See svn_opt_revision_kind */ + svn_opt_revision_value_t value; /**< Extra data qualifying the @c kind */ +} svn_opt_revision_t; + +/** A revision range, specified in one of @c svn_opt_revision_kind ways. */ +typedef struct svn_opt_revision_range_t +{ + /** The first revision in the range */ + svn_opt_revision_t start; + + /** The last revision in the range */ + svn_opt_revision_t end; +} svn_opt_revision_range_t; + +/** + * Set @a *start_revision and/or @a *end_revision according to @a arg, + * where @a arg is "N" or "N:M", like so: + * + * - If @a arg is "N", set @a *start_revision to represent N, and + * leave @a *end_revision untouched. + * + * - If @a arg is "N:M", set @a *start_revision and @a *end_revision + * to represent N and M respectively. + * + * N and/or M may be one of the special revision descriptors + * recognized by revision_from_word(), or a date in curly braces. + * + * If @a arg is invalid, return -1; else return 0. + * It is invalid to omit a revision (as in, ":", "N:" or ":M"). + * + * @note It is typical, though not required, for @a *start_revision and + * @a *end_revision to be @c svn_opt_revision_unspecified kind on entry. + * + * Use @a pool for temporary allocations. + */ +int +svn_opt_parse_revision(svn_opt_revision_t *start_revision, + svn_opt_revision_t *end_revision, + const char *arg, + apr_pool_t *pool); + +/** + * Parse @a arg, where @a arg is "N" or "N:M", into a + * @c svn_opt_revision_range_t and push that onto @a opt_ranges. + * + * - If @a arg is "N", set the @c start field of the + * @c svn_opt_revision_range_t to represent N and the @c end field + * to @c svn_opt_revision_unspecified. + * + * - If @a arg is "N:M", set the @c start field of the + * @c svn_opt_revision_range_t to represent N and the @c end field + * to represent M. + * + * If @a arg is invalid, return -1; else return 0. It is invalid to omit + * a revision (as in, ":", "N:" or ":M"). + * + * Use @a pool to allocate @c svn_opt_revision_range_t pushed to the array. + * + * @since New in 1.5. + */ +int +svn_opt_parse_revision_to_range(apr_array_header_t *opt_ranges, + const char *arg, + apr_pool_t *pool); + +/** + * Resolve peg revisions and operational revisions in the following way: + * + * - If @a is_url is set and @a peg_rev->kind is + * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to + * @c svn_opt_revision_head. + * + * - If @a is_url is not set, and @a peg_rev->kind is + * @c svn_opt_revision_unspecified, @a peg_rev->kind defaults to + * @c svn_opt_revision_base. + * + * - If @a op_rev->kind is @c svn_opt_revision_unspecified, @a op_rev + * defaults to @a peg_rev. + * + * Both @a peg_rev and @a op_rev may be modified as a result of this + * function. @a is_url should be set if the path the revisions refer to is + * a url, and unset otherwise. + * + * If @a notice_local_mods is set, @c svn_opt_revision_working is used, + * instead of @c svn_opt_revision_base. + * + * Use @a pool for allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_opt_resolve_revisions(svn_opt_revision_t *peg_rev, + svn_opt_revision_t *op_rev, + svn_boolean_t is_url, + svn_boolean_t notice_local_mods, + apr_pool_t *pool); + + +/* Parsing arguments. */ + +/** + * Pull remaining target arguments from @a os into @a *targets_p, + * converting them to UTF-8, followed by targets from @a known_targets + * (which might come from, for example, the "--targets" command line + * option), which are already in UTF-8. + * + * On each URL target, do some IRI-to-URI encoding and some + * auto-escaping. On each local path, canonicalize case and path + * separators. + * + * Allocate @a *targets_p and its elements in @a pool. + * + * If a path has the same name as a Subversion working copy + * administrative directory, return SVN_ERR_RESERVED_FILENAME_SPECIFIED; + * if multiple reserved paths are encountered, return a chain of + * errors, all of which are SVN_ERR_RESERVED_FILENAME_SPECIFIED. Do + * not return this type of error in a chain with any other type of + * error, and if this is the only type of error encountered, complete + * the operation before returning the error(s). + * + * @deprecated Provided for backward compatibility with the 1.5 API. + * @see svn_client_args_to_target_array() + */ +SVN_DEPRECATED +svn_error_t * +svn_opt_args_to_target_array3(apr_array_header_t **targets_p, + apr_getopt_t *os, + const apr_array_header_t *known_targets, + apr_pool_t *pool); + +/** + * This is the same as svn_opt_args_to_target_array3() except that it + * silently ignores paths that have the same name as a working copy + * administrative directory. + * + * @since New in 1.2. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_opt_args_to_target_array2(apr_array_header_t **targets_p, + apr_getopt_t *os, + const apr_array_header_t *known_targets, + apr_pool_t *pool); + + +/** + * The same as svn_opt_args_to_target_array2() except that, in + * addition, if @a extract_revisions is set, then look for trailing + * "@rev" syntax on the first two paths. If the first target in @a + * *targets_p ends in "@rev", replace it with a canonicalized version of + * the part before "@rev" and replace @a *start_revision with the value + * of "rev". If the second target in @a *targets_p ends in "@rev", + * replace it with a canonicalized version of the part before "@rev" + * and replace @a *end_revision with the value of "rev". Ignore + * revision specifiers on any further paths. "rev" can be any form of + * single revision specifier, as accepted by svn_opt_parse_revision(). + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_opt_args_to_target_array(apr_array_header_t **targets_p, + apr_getopt_t *os, + const apr_array_header_t *known_targets, + svn_opt_revision_t *start_revision, + svn_opt_revision_t *end_revision, + svn_boolean_t extract_revisions, + apr_pool_t *pool); + + +/** + * Parse revprop key/value pair from @a revprop_spec (name[=value]) into + * @a revprops, making copies of both with @a pool. If @a revprops is + * @c NULL, allocate a new apr_hash_t in it. @a revprops maps + * const char * revprop names to svn_string_t * revprop values for use + * with svn_repos_get_commit_editor5 and other get_commit_editor APIs. + * + * @since New in 1.6. + */ +svn_error_t * +svn_opt_parse_revprop(apr_hash_t **revprops, const char *revprop_spec, + apr_pool_t *pool); + + +/** + * If no targets exist in @a *targets, add `.' as the lone target. + * + * (Some commands take an implicit "." string argument when invoked + * with no arguments. Those commands make use of this function to + * add "." to the target array if the user passes no args.) + */ +void +svn_opt_push_implicit_dot_target(apr_array_header_t *targets, + apr_pool_t *pool); + + +/** + * Parse @a num_args non-target arguments from the list of arguments in + * @a os->argv, return them as <tt>const char *</tt> in @a *args_p, without + * doing any UTF-8 conversion. Allocate @a *args_p and its values in @a pool. + */ +svn_error_t * +svn_opt_parse_num_args(apr_array_header_t **args_p, + apr_getopt_t *os, + int num_args, + apr_pool_t *pool); + + +/** + * Parse all remaining arguments from @a os->argv, return them as + * <tt>const char *</tt> in @a *args_p, without doing any UTF-8 conversion. + * Allocate @a *args_p and its values in @a pool. + */ +svn_error_t * +svn_opt_parse_all_args(apr_array_header_t **args_p, + apr_getopt_t *os, + apr_pool_t *pool); + +/** + * Parse a working-copy path or URL in @a path, extracting any trailing + * revision specifier of the form "@rev" from the last component of + * the path. + * + * Some examples would be: + * + * - "foo/bar" -> "foo/bar", (unspecified) + * - "foo/bar@13" -> "foo/bar", (number, 13) + * - "foo/bar@HEAD" -> "foo/bar", (head) + * - "foo/bar@{1999-12-31}" -> "foo/bar", (date, 1999-12-31) + * - "http://a/b@27" -> "http://a/b", (number, 27) + * - "http://a/b@COMMITTED" -> "http://a/b", (committed) [*] + * - "http://a/b@{1999-12-31}" -> "http://a/b", (date, 1999-12-31) + * - "http://a/b@%7B1999-12-31%7D" -> "http://a/b", (date, 1999-12-31) + * - "foo/bar@1:2" -> error + * - "foo/bar@baz" -> error + * - "foo/bar@" -> "foo/bar", (unspecified) + * - "foo/@bar@" -> "foo/@bar", (unspecified) + * - "foo/bar/@13" -> "foo/bar/", (number, 13) + * - "foo/bar@@13" -> "foo/bar@", (number, 13) + * - "foo/@bar@HEAD" -> "foo/@bar", (head) + * - "foo@/bar" -> "foo@/bar", (unspecified) + * - "foo@HEAD/bar" -> "foo@HEAD/bar", (unspecified) + * - "@foo/bar" -> "@foo/bar", (unspecified) + * - "@foo/bar@" -> "@foo/bar", (unspecified) + * + * [*] Syntactically valid but probably not semantically useful. + * + * If a trailing revision specifier is found, parse it into @a *rev and + * put the rest of the path into @a *truepath, allocating from @a pool; + * or return an @c SVN_ERR_CL_ARG_PARSING_ERROR (with the effect on + * @a *truepath undefined) if the revision specifier is invalid. + * If no trailing revision specifier is found, set @a *truepath to + * @a path and @a rev->kind to @c svn_opt_revision_unspecified. + * + * This function does not require that @a path be in canonical form. + * No canonicalization is done and @a *truepath will only be in + * canonical form if @a path is in canonical form. + * + * @since New in 1.1. + */ +svn_error_t * +svn_opt_parse_path(svn_opt_revision_t *rev, + const char **truepath, + const char *path, + apr_pool_t *pool); + +/** + * Central dispatcher function for various kinds of help message. + * Prints one of: + * * subcommand-specific help (svn_opt_subcommand_help) + * * generic help (svn_opt_print_generic_help) + * * version info + * * simple usage complaint: "Type '@a pgm_name help' for usage." + * + * If @a os is not @c NULL and it contains arguments, then try + * printing help for them as though they are subcommands, using @a + * cmd_table and @a option_table for option information. If not @c + * NULL, @a global_options is a zero-terminated array of options taken + * by all subcommands. + * + * Else, if @a print_version is TRUE, then print version info, in + * brief form if @a quiet is also TRUE; if @a quiet is FALSE, then if + * @a version_footer is non-NULL, print it following the version + * information. If @a verbose is TRUE, also print information about + * the running system and loaded shared libraries, where available. + * + * Else, if @a os is not @c NULL and does not contain arguments, print + * generic help, via svn_opt_print_generic_help2() with the @a header, + * @a cmd_table, @a option_table, and @a footer arguments. + * + * Else, when @a os is @c NULL, print the simple usage complaint. + * + * Use @a pool for temporary allocations. + * + * Notes: The reason this function handles both version printing and + * general usage help is that a confused user might put both the + * --version flag *and* subcommand arguments on a help command line. + * The logic for handling such a situation should be in one place. + * + * @since New in 1.8. + */ + +svn_error_t * +svn_opt_print_help4(apr_getopt_t *os, + const char *pgm_name, + svn_boolean_t print_version, + svn_boolean_t quiet, + svn_boolean_t verbose, + const char *version_footer, + const char *header, + const svn_opt_subcommand_desc2_t *cmd_table, + const apr_getopt_option_t *option_table, + const int *global_options, + const char *footer, + apr_pool_t *pool); + +/** + * Same as svn_opt_print_help4(), but with @a verbose always @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ + +SVN_DEPRECATED +svn_error_t * +svn_opt_print_help3(apr_getopt_t *os, + const char *pgm_name, + svn_boolean_t print_version, + svn_boolean_t quiet, + const char *version_footer, + const char *header, + const svn_opt_subcommand_desc2_t *cmd_table, + const apr_getopt_option_t *option_table, + const int *global_options, + const char *footer, + apr_pool_t *pool); + +/** + * Same as svn_opt_print_help3(), but with @a global_options always @c + * NULL. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ + +SVN_DEPRECATED +svn_error_t * +svn_opt_print_help2(apr_getopt_t *os, + const char *pgm_name, + svn_boolean_t print_version, + svn_boolean_t quiet, + const char *version_footer, + const char *header, + const svn_opt_subcommand_desc2_t *cmd_table, + const apr_getopt_option_t *option_table, + const char *footer, + apr_pool_t *pool); + + +/** + * Same as svn_opt_print_help2(), but acts on #svn_opt_subcommand_desc_t. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_opt_print_help(apr_getopt_t *os, + const char *pgm_name, + svn_boolean_t print_version, + svn_boolean_t quiet, + const char *version_footer, + const char *header, + const svn_opt_subcommand_desc_t *cmd_table, + const apr_getopt_option_t *option_table, + const char *footer, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_OPTS_H */ diff --git a/subversion/include/svn_path.h b/subversion/include/svn_path.h new file mode 100644 index 0000000..3478003 --- /dev/null +++ b/subversion/include/svn_path.h @@ -0,0 +1,734 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_path.h + * @brief A path manipulation library + * + * All incoming and outgoing paths are non-NULL and in UTF-8, unless + * otherwise documented. + * + * No result path ever ends with a separator, no matter whether the + * path is a file or directory, because we always canonicalize() it. + * + * Nearly all the @c svn_path_xxx functions expect paths passed into + * them to be in canonical form as defined by the Subversion path + * library itself. The only functions which do *not* have such + * expectations are: + * + * - @c svn_path_canonicalize() + * - @c svn_path_is_canonical() + * - @c svn_path_internal_style() + * - @c svn_path_uri_encode() + * + * For the most part, we mean what most anyone would mean when talking + * about canonical paths, but to be on the safe side, you must run + * your paths through @c svn_path_canonicalize() before passing them to + * other functions in this API. + */ + +#ifndef SVN_PATH_H +#define SVN_PATH_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_tables.h> + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_dirent_uri.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** Convert @a path from the local style to the canonical internal style. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_internal_style(). + */ +SVN_DEPRECATED +const char * +svn_path_internal_style(const char *path, apr_pool_t *pool); + +/** Convert @a path from the canonical internal style to the local style. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_local_style(). + */ +SVN_DEPRECATED +const char * +svn_path_local_style(const char *path, apr_pool_t *pool); + + +/** Join a base path (@a base) with a component (@a component), allocating + * the result in @a pool. @a component need not be a single component: it + * can be any path, absolute or relative to @a base. + * + * If either @a base or @a component is the empty path, then the other + * argument will be copied and returned. If both are the empty path the + * empty path is returned. + * + * If the @a component is an absolute path, then it is copied and returned. + * Exactly one slash character ('/') is used to join the components, + * accounting for any trailing slash in @a base. + * + * Note that the contents of @a base are not examined, so it is possible to + * use this function for constructing URLs, or for relative URLs or + * repository paths. + * + * This function is NOT appropriate for native (local) file + * paths. Only for "internal" canonicalized paths, since it uses '/' + * for the separator. Further, an absolute path (for @a component) is + * based on a leading '/' character. Thus, an "absolute URI" for the + * @a component won't be detected. An absolute URI can only be used + * for the base. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_join(), svn_relpath_join() or + * svn_fspath__join(). + */ +SVN_DEPRECATED +char * +svn_path_join(const char *base, const char *component, apr_pool_t *pool); + +/** Join multiple components onto a @a base path, allocated in @a pool. The + * components are terminated by a @c NULL. + * + * If any component is the empty string, it will be ignored. + * + * If any component is an absolute path, then it resets the base and + * further components will be appended to it. + * + * This function does not support URLs. + * + * See svn_path_join() for further notes about joining paths. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * For new code, consider using svn_dirent_join_many() or a sequence of + * calls to one of the *_join() functions. + */ +SVN_DEPRECATED +char * +svn_path_join_many(apr_pool_t *pool, const char *base, ...); + + +/** Get the basename of the specified canonicalized @a path. The + * basename is defined as the last component of the path (ignoring any + * trailing slashes). If the @a path is root ("/"), then that is + * returned. Otherwise, the returned value will have no slashes in + * it. + * + * Example: svn_path_basename("/foo/bar") -> "bar" + * + * The returned basename will be allocated in @a pool. + * + * @note If an empty string is passed, then an empty string will be returned. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_basename(), svn_uri_basename(), + * svn_relpath_basename() or svn_fspath__basename(). + */ +SVN_DEPRECATED +char * +svn_path_basename(const char *path, apr_pool_t *pool); + +/** Get the dirname of the specified canonicalized @a path, defined as + * the path with its basename removed. If @a path is root ("/"), it is + * returned unchanged. + * + * The returned dirname will be allocated in @a pool. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_dirname(), svn_uri_dirname(), + * svn_relpath_dirname() or svn_fspath__dirname(). + */ +SVN_DEPRECATED +char * +svn_path_dirname(const char *path, apr_pool_t *pool); + +/** Split @a path into a root portion and an extension such that + * the root + the extension = the original path, and where the + * extension contains no period (.) characters. If not @c NULL, set + * @a *path_root to the root portion. If not @c NULL, set + * @a *path_ext to the extension (or "" if there is no extension + * found). Allocate both @a *path_root and @a *path_ext in @a pool. + * + * @since New in 1.5. + */ +void +svn_path_splitext(const char **path_root, const char **path_ext, + const char *path, apr_pool_t *pool); + +/** Return the number of components in the canonicalized @a path. + * + * @since New in 1.1. +*/ +apr_size_t +svn_path_component_count(const char *path); + +/** Add a @a component (a NULL-terminated C-string) to the + * canonicalized @a path. @a component is allowed to contain + * directory separators. + * + * If @a path is non-empty, append the appropriate directory separator + * character, and then @a component. If @a path is empty, simply set it to + * @a component; don't add any separator character. + * + * If the result ends in a separator character, then remove the separator. + */ +void +svn_path_add_component(svn_stringbuf_t *path, const char *component); + +/** Remove one component off the end of the canonicalized @a path. */ +void +svn_path_remove_component(svn_stringbuf_t *path); + +/** Remove @a n components off the end of the canonicalized @a path. + * Equivalent to calling svn_path_remove_component() @a n times. + * + * @since New in 1.1. + */ +void +svn_path_remove_components(svn_stringbuf_t *path, apr_size_t n); + +/** Divide the canonicalized @a path into @a *dirpath and @a + * *base_name, allocated in @a pool. + * + * If @a dirpath or @a base_name is NULL, then don't set that one. + * + * Either @a dirpath or @a base_name may be @a path's own address, but they + * may not both be the same address, or the results are undefined. + * + * If @a path has two or more components, the separator between @a dirpath + * and @a base_name is not included in either of the new names. + * + * examples: + * - <pre>"/foo/bar/baz" ==> "/foo/bar" and "baz"</pre> + * - <pre>"/bar" ==> "/" and "bar"</pre> + * - <pre>"/" ==> "/" and "/"</pre> + * - <pre>"X:/" ==> "X:/" and "X:/"</pre> + * - <pre>"bar" ==> "" and "bar"</pre> + * - <pre>"" ==> "" and ""</pre> + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_split(), svn_uri_split(), + * svn_relpath_split() or svn_fspath__split(). + */ +SVN_DEPRECATED +void +svn_path_split(const char *path, + const char **dirpath, + const char **base_name, + apr_pool_t *pool); + + +/** Return non-zero iff @a path is empty ("") or represents the current + * directory -- that is, if prepending it as a component to an existing + * path would result in no meaningful change. + */ +int +svn_path_is_empty(const char *path); + + +#ifndef SVN_DIRENT_URI_H +/* This declaration has been moved to svn_dirent_uri.h, and remains + here only for compatibility reasons. */ +svn_boolean_t +svn_dirent_is_root(const char *dirent, apr_size_t len); +#endif /* SVN_DIRENT_URI_H */ + + +/** Return a new path (or URL) like @a path, but transformed such that + * some types of path specification redundancies are removed. + * + * This involves collapsing redundant "/./" elements, removing + * multiple adjacent separator characters, removing trailing + * separator characters, and possibly other semantically inoperative + * transformations. + * + * Convert the scheme and hostname to lowercase (see issue #2475) + * + * The returned path may be statically allocated, equal to @a path, or + * allocated from @a pool. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_canonicalize(), svn_uri_canonicalize(), + * svn_relpath_canonicalize() or svn_fspath__canonicalize(). + */ +SVN_DEPRECATED +const char * +svn_path_canonicalize(const char *path, apr_pool_t *pool); + +/** Return @c TRUE iff path is canonical. Use @a pool for temporary + * allocations. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_is_canonical(), svn_uri_is_canonical(), + * svn_relpath_is_canonical() or svn_fspath__is_canonical(). + */ +SVN_DEPRECATED +svn_boolean_t +svn_path_is_canonical(const char *path, apr_pool_t *pool); + + +/** Return an integer greater than, equal to, or less than 0, according + * as @a path1 is greater than, equal to, or less than @a path2. + * + * This function works like strcmp() except that it orders children in + * subdirectories directly after their parents. This allows using the + * given ordering for a depth first walk. + */ +int +svn_path_compare_paths(const char *path1, const char *path2); + + +/** Return the longest common path shared by two canonicalized paths, + * @a path1 and @a path2. If there's no common ancestor, return the + * empty path. + * + * @a path1 and @a path2 may be URLs. In order for two URLs to have + * a common ancestor, they must (a) have the same protocol (since two URLs + * with the same path but different protocols may point at completely + * different resources), and (b) share a common ancestor in their path + * component, i.e. 'protocol://' is not a sufficient ancestor. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_get_longest_ancestor(), + * svn_uri_get_longest_ancestor(), svn_relpath_get_longest_ancestor() or + * svn_fspath__get_longest_ancestor(). + */ +SVN_DEPRECATED +char * +svn_path_get_longest_ancestor(const char *path1, + const char *path2, + apr_pool_t *pool); + +/** Convert @a relative canonicalized path to an absolute path and + * return the results in @a *pabsolute, allocated in @a pool. + * + * @a relative may be a URL, in which case no attempt is made to convert it, + * and a copy of the URL is returned. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_get_absolute() on a non-URL input. + */ +SVN_DEPRECATED +svn_error_t * +svn_path_get_absolute(const char **pabsolute, + const char *relative, + apr_pool_t *pool); + +/** Return the path part of the canonicalized @a path in @a + * *pdirectory, and the file part in @a *pfile. If @a path is a + * directory, set @a *pdirectory to @a path, and @a *pfile to the + * empty string. If @a path does not exist it is treated as if it is + * a file, since directories do not normally vanish. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should implement the required logic directly; no direct + * replacement is provided. + */ +SVN_DEPRECATED +svn_error_t * +svn_path_split_if_file(const char *path, + const char **pdirectory, + const char **pfile, + apr_pool_t *pool); + +/** Find the common prefix of the canonicalized paths in @a targets + * (an array of <tt>const char *</tt>'s), and remove redundant paths if @a + * remove_redundancies is TRUE. + * + * - Set @a *pcommon to the absolute path of the path or URL common to + * all of the targets. If the targets have no common prefix, or + * are a mix of URLs and local paths, set @a *pcommon to the + * empty string. + * + * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets + * to an array of targets relative to @a *pcommon, and if + * @a remove_redundancies is TRUE, omit any paths/URLs that are + * descendants of another path/URL in @a targets. If *pcommon + * is empty, @a *pcondensed_targets will contain full URLs and/or + * absolute paths; redundancies can still be removed (from both URLs + * and paths). If @a pcondensed_targets is NULL, leave it alone. + * + * Else if there is exactly one target, then + * + * - Set @a *pcommon to that target, and + * + * - If @a pcondensed_targets is non-NULL, set @a *pcondensed_targets + * to an array containing zero elements. Else if + * @a pcondensed_targets is NULL, leave it alone. + * + * If there are no items in @a targets, set @a *pcommon and (if + * applicable) @a *pcondensed_targets to @c NULL. + * + * @note There is no guarantee that @a *pcommon is within a working + * copy. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_dirent_condense_targets() or + * svn_uri_condense_targets(). + */ +SVN_DEPRECATED +svn_error_t * +svn_path_condense_targets(const char **pcommon, + apr_array_header_t **pcondensed_targets, + const apr_array_header_t *targets, + svn_boolean_t remove_redundancies, + apr_pool_t *pool); + + +/** Copy a list of canonicalized @a targets, one at a time, into @a + * pcondensed_targets, omitting any targets that are found earlier in + * the list, or whose ancestor is found earlier in the list. Ordering + * of targets in the original list is preserved in the condensed list + * of targets. Use @a pool for any allocations. + * + * How does this differ in functionality from svn_path_condense_targets()? + * + * Here's the short version: + * + * 1. Disclaimer: if you wish to debate the following, talk to Karl. :-) + * Order matters for updates because a multi-arg update is not + * atomic, and CVS users are used to, when doing 'cvs up targetA + * targetB' seeing targetA get updated, then targetB. I think the + * idea is that if you're in a time-sensitive or flaky-network + * situation, a user can say, "I really *need* to update + * wc/A/D/G/tau, but I might as well update my whole working copy if + * I can." So that user will do 'svn up wc/A/D/G/tau wc', and if + * something dies in the middles of the 'wc' update, at least the + * user has 'tau' up-to-date. + * + * 2. Also, we have this notion of an anchor and a target for updates + * (the anchor is where the update editor is rooted, the target is + * the actual thing we want to update). I needed a function that + * would NOT screw with my input paths so that I could tell the + * difference between someone being in A/D and saying 'svn up G' and + * being in A/D/G and saying 'svn up .' -- believe it or not, these + * two things don't mean the same thing. svn_path_condense_targets() + * plays with absolute paths (which is fine, so does + * svn_path_remove_redundancies()), but the difference is that it + * actually tweaks those targets to be relative to the "grandfather + * path" common to all the targets. Updates don't require a + * "grandfather path" at all, and even if it did, the whole + * conversion to an absolute path drops the crucial difference + * between saying "i'm in foo, update bar" and "i'm in foo/bar, + * update '.'" + */ +svn_error_t * +svn_path_remove_redundancies(apr_array_header_t **pcondensed_targets, + const apr_array_header_t *targets, + apr_pool_t *pool); + + +/** Decompose the canonicalized @a path into an array of <tt>const + * char *</tt> components, allocated in @a pool. If @a path is + * absolute, the first component will be a lone dir separator (the + * root directory). + */ +apr_array_header_t * +svn_path_decompose(const char *path, apr_pool_t *pool); + +/** Join an array of <tt>const char *</tt> components into a '/' + * separated path, allocated in @a pool. The joined path is absolute if + * the first component is a lone dir separator. + * + * Calling svn_path_compose() on the output of svn_path_decompose() + * will return the exact same path. + * + * @since New in 1.5. + */ +const char * +svn_path_compose(const apr_array_header_t *components, apr_pool_t *pool); + +/** Test that @a name is a single path component, that is: + * - not @c NULL or empty. + * - not a `/'-separated directory path + * - not empty or `..' + */ +svn_boolean_t +svn_path_is_single_path_component(const char *name); + + +/** + * Test to see if a backpath, i.e. '..', is present in @a path. + * If not, return @c FALSE. + * If so, return @c TRUE. + * + * @since New in 1.1. + */ +svn_boolean_t +svn_path_is_backpath_present(const char *path); + + +/** + * Test to see if a dotpath, i.e. '.', is present in @a path. + * If not, return @c FALSE. + * If so, return @c TRUE. + * + * @since New in 1.6. + */ +svn_boolean_t +svn_path_is_dotpath_present(const char *path); + + +/** Test if @a path2 is a child of @a path1. + * If not, return @c NULL. + * If so, return a copy of the remainder path, allocated in @a pool. + * (The remainder is the component which, added to @a path1, yields + * @a path2. The remainder does not begin with a dir separator.) + * + * Both paths must be in canonical form, and must either be absolute, + * or contain no ".." components. + * + * If @a path2 is the same as @a path1, it is not considered a child, so the + * result is @c NULL; an empty string is never returned. + * + * @note In 1.5 this function has been extended to allow a @c NULL @a pool + * in which case a pointer into @a path2 will be returned to + * identify the remainder path. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * For replacement functionality, see svn_dirent_skip_ancestor(), + * svn_dirent_is_child(), svn_uri_skip_ancestor(), and + * svn_relpath_skip_ancestor(). + */ +SVN_DEPRECATED +const char * +svn_path_is_child(const char *path1, const char *path2, apr_pool_t *pool); + +/** Return TRUE if @a path1 is an ancestor of @a path2 or the paths are equal + * and FALSE otherwise. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * For replacement functionality, see svn_dirent_skip_ancestor(), + * svn_uri_skip_ancestor(), and svn_relpath_skip_ancestor(). + */ +SVN_DEPRECATED +svn_boolean_t +svn_path_is_ancestor(const char *path1, const char *path2); + +/** + * Check whether @a path is a valid Subversion path. + * + * A valid Subversion pathname is a UTF-8 string without control + * characters. "Valid" means Subversion can store the pathname in + * a repository. There may be other, OS-specific, limitations on + * what paths can be represented in a working copy. + * + * ASSUMPTION: @a path is a valid UTF-8 string. This function does + * not check UTF-8 validity. + * + * Return @c SVN_NO_ERROR if valid and @c SVN_ERR_FS_PATH_SYNTAX if + * invalid. + * + * @note Despite returning an @c SVN_ERR_FS_* error, this function has + * nothing to do with the versioned filesystem's concept of validity. + * + * @since New in 1.2. + */ +svn_error_t * +svn_path_check_valid(const char *path, apr_pool_t *pool); + + +/** URI/URL stuff + * + * @defgroup svn_path_uri_stuff URI/URL conversion + * @{ + */ + +/** Return TRUE iff @a path looks like a valid absolute URL. */ +svn_boolean_t +svn_path_is_url(const char *path); + +/** Return @c TRUE iff @a path is URI-safe, @c FALSE otherwise. */ +svn_boolean_t +svn_path_is_uri_safe(const char *path); + +/** Return a URI-encoded copy of @a path, allocated in @a pool. (@a + path can be an arbitrary UTF-8 string and does not have to be a + canonical path.) */ +const char * +svn_path_uri_encode(const char *path, apr_pool_t *pool); + +/** Return a URI-decoded copy of @a path, allocated in @a pool. */ +const char * +svn_path_uri_decode(const char *path, apr_pool_t *pool); + +/** Extend @a url by @a component, URI-encoding that @a component + * before adding it to the @a url; return the new @a url, allocated in + * @a pool. If @a component is @c NULL, just return a copy of @a url, + * allocated in @a pool. + * + * @a component need not be a single path segment, but if it contains + * multiple segments, they must be separated by '/'. @a component + * should not begin with '/', however; if it does, the behavior is + * undefined. + * + * @a url must be in canonical format; it may not have a trailing '/'. + * + * @note To add a component that is already URI-encoded, use + * <tt>svn_path_join(url, component, pool)</tt> instead. + * + * @note gstein suggests this for when @a component begins with '/': + * + * "replace the path entirely + * https://example.com:4444/base/path joined with /leading/slash, + * should return: https://example.com:4444/leading/slash + * per the RFCs on combining URIs" + * + * We may implement that someday, which is why leading '/' is + * merely undefined right now. + * + * @since New in 1.6. + */ +const char * +svn_path_url_add_component2(const char *url, + const char *component, + apr_pool_t *pool); + +/** Like svn_path_url_add_component2(), but allows path components that + * end with a trailing '/' + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +const char * +svn_path_url_add_component(const char *url, + const char *component, + apr_pool_t *pool); + +/** + * Convert @a iri (Internationalized URI) to an URI. + * The return value may be the same as @a iri if it was already + * a URI. Else, allocate the return value in @a pool. + * + * @since New in 1.1. + */ +const char * +svn_path_uri_from_iri(const char *iri, apr_pool_t *pool); + +/** + * URI-encode certain characters in @a uri that are not valid in an URI, but + * doesn't have any special meaning in @a uri at their positions. If no + * characters need escaping, just return @a uri. + * + * @note Currently, this function escapes <, >, ", space, {, }, |, \, ^, and `. + * This may be extended in the future to do context-dependent escaping. + * + * @since New in 1.1. + */ +const char * +svn_path_uri_autoescape(const char *uri, apr_pool_t *pool); + +/** @} */ + +/** Charset conversion stuff + * + * @defgroup svn_path_charset_stuff Charset conversion + * @{ + */ + +/** Convert @a path_utf8 from UTF-8 to the internal encoding used by APR. */ +svn_error_t * +svn_path_cstring_from_utf8(const char **path_apr, + const char *path_utf8, + apr_pool_t *pool); + +/** Convert @a path_apr from the internal encoding used by APR to UTF-8. */ +svn_error_t * +svn_path_cstring_to_utf8(const char **path_utf8, + const char *path_apr, + apr_pool_t *pool); + + +/** @} */ + + +/** Repository relative URLs + * + * @defgroup svn_path_repos_relative_urls Repository relative URLs + * @{ + */ + +/** + * Return @c TRUE iff @a path is a repository-relative URL: specifically + * that it starts with the characters "^/" + * + * @a path is in UTF-8 encoding. + * + * Does not check whether @a path is a properly URI-encoded, canonical, or + * valid in any other way. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_path_is_repos_relative_url(const char *path); + +/** + * Set @a absolute_url to the absolute URL represented by @a relative_url + * relative to @a repos_root_url, preserving any peg revision + * specifier present in @a relative_url. Allocate @a absolute_url + * from @a pool. + * + * @a relative_url is in repository-relative syntax: "^/[REL-URL][@PEG]" + * + * @a repos_root_url is the absolute URL of the repository root. + * + * All strings are in UTF-8 encoding. + * + * @a repos_root_url and @a relative_url do not have to be properly + * URI-encoded, canonical, or valid in any other way. The caller is + * expected to perform canonicalization on @a absolute_url after the + * call to the function. + * + * @since New in 1.8. + */ +svn_error_t * +svn_path_resolve_repos_relative_url(const char **absolute_url, + const char *relative_url, + const char *repos_root_url, + apr_pool_t *pool); + +/* Return a copy of @a path, allocated from @a pool, for which control + * characters have been escaped using the form \NNN (where NNN is the + * octal representation of the byte's ordinal value). + * + * @since New in 1.8. */ +const char * +svn_path_illegal_path_escape(const char *path, apr_pool_t *pool); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* SVN_PATH_H */ diff --git a/subversion/include/svn_pools.h b/subversion/include/svn_pools.h new file mode 100644 index 0000000..d4c3a53 --- /dev/null +++ b/subversion/include/svn_pools.h @@ -0,0 +1,114 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_pools.h + * @brief APR pool management for Subversion + */ + + + + +#ifndef SVN_POOLS_H +#define SVN_POOLS_H + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/* Wrappers around APR pools, so we get debugging. */ + +/** The recommended maximum amount of memory (4MB) to keep in an APR + * allocator on the free list, conveniently defined here to share + * between all our applications. + */ +#define SVN_ALLOCATOR_RECOMMENDED_MAX_FREE (4096 * 1024) + + +/** Wrapper around apr_pool_create_ex(), with a simpler interface. + * The return pool will have an abort function set, which will call + * abort() on OOM. + */ +apr_pool_t * +svn_pool_create_ex(apr_pool_t *parent_pool, + apr_allocator_t *allocator); + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +apr_pool_t * +svn_pool_create_ex_debug(apr_pool_t *parent_pool, + apr_allocator_t *allocator, + const char *file_line); + +#if APR_POOL_DEBUG +#define svn_pool_create_ex(pool, allocator) \ +svn_pool_create_ex_debug(pool, allocator, APR_POOL__FILE_LINE__) + +#endif /* APR_POOL_DEBUG */ +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ + + +/** Create a pool as a subpool of @a parent_pool */ +#define svn_pool_create(parent_pool) svn_pool_create_ex(parent_pool, NULL) + +/** Clear a @a pool destroying its children. + * + * This define for @c svn_pool_clear exists for completeness. + */ +#define svn_pool_clear apr_pool_clear + + +/** Destroy a @a pool and all of its children. + * + * This define for @c svn_pool_destroy exists for symmetry and + * completeness. + */ +#define svn_pool_destroy apr_pool_destroy + +/** Return a new allocator. This function limits the unused memory in the + * new allocator to #SVN_ALLOCATOR_RECOMMENDED_MAX_FREE and ensures + * proper synchronization if the allocator is used by multiple threads. + * + * If your application uses multiple threads, creating a separate + * allocator for each of these threads may not be feasible. Set the + * @a thread_safe parameter to @c TRUE in that case; otherwise, set @a + * thread_safe to @c FALSE to maximize performance. + * + * @note Even if @a thread_safe is @c TRUE, pools themselves will + * still not be thread-safe and their access may require explicit + * serialization. + * + * To access the owner pool, which can also serve as the root pool for + * your sub-pools, call @c apr_allocator_get_owner(). + * + * @since: New in 1.8 + */ +apr_allocator_t * +svn_pool_create_allocator(svn_boolean_t thread_safe); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_POOLS_H */ diff --git a/subversion/include/svn_props.h b/subversion/include/svn_props.h new file mode 100644 index 0000000..1f2bbbf --- /dev/null +++ b/subversion/include/svn_props.h @@ -0,0 +1,714 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_props.h + * @brief Subversion properties + */ + +/* ==================================================================== */ + +#ifndef SVN_PROPS_H +#define SVN_PROPS_H + +#include <apr_pools.h> /* for apr_pool_t */ +#include <apr_tables.h> /* for apr_array_header_t */ +#include <apr_hash.h> /* for apr_hash_t */ + +#include "svn_types.h" /* for svn_boolean_t, svn_error_t */ +#include "svn_string.h" /* for svn_string_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup svn_props_support Properties management utilities + * @{ + */ + + + +/** A general in-memory representation of a single property. Most of + * the time, property lists will be stored completely in hashes. But + * sometimes it's useful to have an "ordered" collection of + * properties, in which case we use an array of these structures. + * + * Also: sometimes we want a list that represents a set of property + * *changes*, and in this case, an @c apr_hash_t won't work -- there's no + * way to represent a property deletion, because we can't store a @c NULL + * value in a hash. So instead, we use these structures. + */ +typedef struct svn_prop_t +{ + const char *name; /**< Property name */ + const svn_string_t *value; /**< Property value */ +} svn_prop_t; + + +/** + * Return a duplicate of @a prop, allocated in @a pool. No part of the new + * structure will be shared with @a prop. + * + * @since New in 1.3. + */ +svn_prop_t * +svn_prop_dup(const svn_prop_t *prop, + apr_pool_t *pool); + + +/** + * Duplicate an @a array of svn_prop_t items using @a pool. + * + * @since New in 1.3. + */ +apr_array_header_t * +svn_prop_array_dup(const apr_array_header_t *array, + apr_pool_t *pool); + + +/** A structure to represent inherited properties. + * + * @since New in 1.8. + */ +typedef struct svn_prop_inherited_item_t +{ + /** The absolute working copy path, relative filesystem path, or URL + * from which the properties in @a prop_hash are inherited. (For + * details about which path specification format is in use for a + * particular instance of this structure, consult the documentation + * for the API which produced it.) */ + const char *path_or_url; + + /** A hash of (<tt>const char *</tt>) inherited property names, and + * (<tt>svn_string_t *</tt>) property values. */ + apr_hash_t *prop_hash; + +} svn_prop_inherited_item_t; + + +/** + * Given a hash (keys <tt>const char *</tt> and values <tt>const + * svn_string_t</tt>) of properties, returns an array of svn_prop_t + * items using @a pool. + * + * @since New in 1.5. + */ +apr_array_header_t * +svn_prop_hash_to_array(const apr_hash_t *hash, + apr_pool_t *pool); + +/** + * Given an array of svn_prop_t items, return a hash mapping const char * + * property names to const svn_string_t * values. + * + * @warning The behaviour on #svn_prop_t objects with a @c NULL @c + * svn_prop_t.value member is undefined. + * + * @since New in 1.7. + */ +apr_hash_t * +svn_prop_array_to_hash(const apr_array_header_t *properties, + apr_pool_t *result); + +/** + * Creates a deep copy of @a hash (keys <tt>const char *</tt> and + * values <tt>const svn_string_t *</tt>) in @a pool. + * + * @since New in 1.6. + */ +apr_hash_t * +svn_prop_hash_dup(const apr_hash_t *hash, + apr_pool_t *pool); + +/** + * Return the value of property @a prop_name as it is in @a properties, + * with values <tt>const svn_string_t</tt>. If @a prop_name is not + * in @a properties or @a properties is NULL, return NULL. + * + * @since New in 1.7. + */ +const char * +svn_prop_get_value(const apr_hash_t *properties, + const char *prop_name); + +/** + * Subversion distinguishes among several kinds of properties, + * particularly on the client-side. There is no "unknown" kind; if + * there's nothing special about a property name, the default category + * is @c svn_prop_regular_kind. + */ +typedef enum svn_prop_kind +{ + /** In .svn/entries, i.e., author, date, etc. */ + svn_prop_entry_kind, + + /** Client-side only, stored by specific RA layer. */ + svn_prop_wc_kind, + + /** Seen if user does "svn proplist"; note that this includes some "svn:" + * props and all user props, i.e. ones stored in the repository fs. + */ + svn_prop_regular_kind +} svn_prop_kind_t; + +/** Return the property kind of a property named @a prop_name. + * + * @since New in 1.8. + */ +svn_prop_kind_t +svn_property_kind2(const char *prop_name); + +/** Return the prop kind of a property named @a prop_name, and + * (if @a prefix_len is non-@c NULL) set @a *prefix_len to the length of + * the prefix of @a prop_name that was sufficient to distinguish its kind. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_prop_kind_t +svn_property_kind(int *prefix_len, + const char *prop_name); + + +/** Return @c TRUE iff @a prop_name represents the name of a Subversion + * property. That is, any property name in Subversion's name space for + * versioned or unversioned properties, regardless whether the particular + * property name is recognized. + */ +svn_boolean_t +svn_prop_is_svn_prop(const char *prop_name); + + +/** Return @c TRUE iff @a props has at least one property whose name + * represents the name of a Subversion property, in the sense of + * svn_prop_is_svn_prop(). + * + * @since New in 1.5. + */ +svn_boolean_t +svn_prop_has_svn_prop(const apr_hash_t *props, + apr_pool_t *pool); + +/** Return @c TRUE iff @a prop_name is a Subversion property whose + * value is interpreted as a boolean. + * + * @since New in 1.5. + */ +svn_boolean_t +svn_prop_is_boolean(const char *prop_name); + +/** Return @c TRUE iff @a prop_name is in the "svn:" name space and is a + * known revision property ("svn:log" or "svn:date", e.g.). + * + * This will return @c FALSE for any property name that is not known by this + * version of the library, even though the name may be known to other (for + * example, later) Subversion software. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_prop_is_known_svn_rev_prop(const char *prop_name); + +/** Return @c TRUE iff @a prop_name is in the "svn:" name space and is a + * known versioned property that is allowed on a file and/or on a + * directory ("svn:eol-style", "svn:ignore", or "svn:mergeinfo", e.g.). + * + * This will return @c FALSE for any property name that is not known + * by this version of the library, even though the name may be known + * to other (for example, later) Subversion software. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_prop_is_known_svn_node_prop(const char *prop_name); + +/** Return @c TRUE iff @a prop_name is in the "svn:" name space and is + * a known versioned property that is allowed on a file + * ("svn:eol-style" or "svn:mergeinfo", e.g.). + * + * This will return @c FALSE for any property name that is not known + * by this version of the library, even though the name may be known + * to other (for example, later) Subversion software. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_prop_is_known_svn_file_prop(const char *prop_name); + +/** Return @c TRUE iff @a prop_name is in the "svn:" name space and is + * a known versioned property that is allowed on a directory + * ("svn:ignore" or "svn:mergeinfo", e.g.). + * + * This will return @c FALSE for any property name that is not known + * by this version of the library, even though the name may be known + * to other (for example, later) Subversion software. + * + * @since New in 1.8. + */ +svn_boolean_t +svn_prop_is_known_svn_dir_prop(const char *prop_name); + +/** If @a prop_name requires that its value be stored as UTF8/LF in the + * repository, then return @c TRUE. Else return @c FALSE. This is for + * users of libsvn_client or libsvn_fs, since it their responsibility + * to do this translation in both directions. (See + * svn_subst_translate_string()/svn_subst_detranslate_string() for + * help with this task.) + */ +svn_boolean_t +svn_prop_needs_translation(const char *prop_name); + + +/** Given a @a proplist array of @c svn_prop_t structures, allocate + * three new arrays in @a pool. Categorize each property and then + * create new @c svn_prop_t structures in the proper lists. Each new + * @c svn_prop_t structure's fields will point to the same data within + * @a proplist's structures. + * + * Callers may pass NULL for each of the property lists in which they + * are uninterested. If no props exist in a certain category, and the + * property list argument for that category is non-NULL, then that + * array will come back with <tt>->nelts == 0</tt>. + */ +svn_error_t * +svn_categorize_props(const apr_array_header_t *proplist, + apr_array_header_t **entry_props, + apr_array_header_t **wc_props, + apr_array_header_t **regular_props, + apr_pool_t *pool); + + +/** Given two property hashes (<tt>const char *name</tt> -> <tt>const + * svn_string_t *value</tt>), deduce the differences between them (from + * @a source_props -> @c target_props). Set @a propdiffs to a new array of + * @c svn_prop_t structures, with one entry for each property that differs, + * including properties that exist in @a source_props or @a target_props but + * not both. The @c value field of each entry is that property's value from + * @a target_props or NULL if that property only exists in @a source_props. + * + * Allocate the array from @a pool. Allocate the contents of the array from + * @a pool or by reference to the storage of the input hashes or both. + * + * For note, here's a quick little table describing the logic of this + * routine: + * + * @verbatim + source_props target_props event + ------------ ------------ ----- + value = foo value = NULL Deletion occurred. + value = foo value = bar Set occurred (modification) + value = NULL value = baz Set occurred (creation) @endverbatim + */ +svn_error_t * +svn_prop_diffs(apr_array_header_t **propdiffs, + const apr_hash_t *target_props, + const apr_hash_t *source_props, + apr_pool_t *pool); + + +/** + * Return @c TRUE iff @a prop_name is a valid property name. + * + * For now, "valid" means the ASCII subset of an XML "Name". + * XML "Name" is defined at http://www.w3.org/TR/REC-xml#sec-common-syn + * + * @since New in 1.5. + */ +svn_boolean_t +svn_prop_name_is_valid(const char *prop_name); + + + +/* Defines for reserved ("svn:") property names. */ + +/** All Subversion property names start with this. */ +#define SVN_PROP_PREFIX "svn:" + + +/** Visible properties + * + * These are regular properties that are attached to ordinary files + * and dirs, and are visible (and tweakable) by svn client programs + * and users. Adding these properties causes specific effects. + * + * @note the values of these properties are always UTF8-encoded with + * LF line-endings. It is the burden of svn library users to enforce + * this. Use svn_prop_needs_translation() to discover if a + * certain property needs translation, and you can use + * svn_subst_translate_string()/svn_subst_detranslate_string() + * to do the translation. + * + * @defgroup svn_prop_visible_props Visible properties + * @{ + */ + +/** Properties whose values are interpreted as booleans (such as + * svn:executable, svn:needs_lock, and svn:special) always fold their + * value to this. + * + * @since New in 1.5. + */ +#define SVN_PROP_BOOLEAN_TRUE "*" + +/** The mime-type of a given file. */ +#define SVN_PROP_MIME_TYPE SVN_PROP_PREFIX "mime-type" + +/** The ignore patterns for a given directory. */ +#define SVN_PROP_IGNORE SVN_PROP_PREFIX "ignore" + +/** The line ending style for a given file. */ +#define SVN_PROP_EOL_STYLE SVN_PROP_PREFIX "eol-style" + +/** The "activated" keywords (for keyword substitution) for a given file. */ +#define SVN_PROP_KEYWORDS SVN_PROP_PREFIX "keywords" + +/** Set to either TRUE or FALSE if we want a file to be executable or not. */ +#define SVN_PROP_EXECUTABLE SVN_PROP_PREFIX "executable" + +/** The value to force the executable property to when set. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * Use @c SVN_PROP_BOOLEAN_TRUE instead. + */ +#define SVN_PROP_EXECUTABLE_VALUE SVN_PROP_BOOLEAN_TRUE + +/** Set to TRUE ('*') if we want a file to be set to read-only when + * not locked. FALSE is indicated by deleting the property. */ +#define SVN_PROP_NEEDS_LOCK SVN_PROP_PREFIX "needs-lock" + +/** The value to force the needs-lock property to when set. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * Use @c SVN_PROP_BOOLEAN_TRUE instead. + */ +#define SVN_PROP_NEEDS_LOCK_VALUE SVN_PROP_BOOLEAN_TRUE + +/** Set if the file should be treated as a special file. */ +#define SVN_PROP_SPECIAL SVN_PROP_PREFIX "special" + +/** The value to force the special property to when set. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * Use @c SVN_PROP_BOOLEAN_TRUE instead. + */ +#define SVN_PROP_SPECIAL_VALUE SVN_PROP_BOOLEAN_TRUE + +/** Describes external items to check out into this directory. + * + * The format is a series of lines, each in the following format: + * [-r REV] URL[@PEG] LOCALPATH + * LOCALPATH is relative to the directory having this property. + * REV pins the external to revision REV. + * URL may be a full URL or a relative URL starting with one of: + * ../ to the parent directory of the extracted external + * ^/ to the repository root + * / to the server root + * // to the URL scheme + * The following format is supported for interoperability with + * Subversion 1.4 and earlier clients: + * LOCALPATH [-r PEG] URL + * The ambiguous format 'relative_path relative_path' is taken as + * 'relative_url relative_path' with peg revision support. + * Lines starting with a '#' character are ignored. + */ +#define SVN_PROP_EXTERNALS SVN_PROP_PREFIX "externals" + +/** Merge info property used to record a resource's merge history. + * + * The format is a series of lines containing merge paths and revision + * ranges, such as: + * + * @verbatim + /trunk: 1-6,9,37-38 + /trunk/foo: 10 @endverbatim + */ +#define SVN_PROP_MERGEINFO SVN_PROP_PREFIX "mergeinfo" + +/** Property used to record inheritable configuration auto-props. */ +#define SVN_PROP_INHERITABLE_AUTO_PROPS SVN_PROP_PREFIX "auto-props" + +/** Property used to record inheritable configuration ignores. */ +#define SVN_PROP_INHERITABLE_IGNORES SVN_PROP_PREFIX "global-ignores" + +/** Meta-data properties. + * + * The following properties are used for storing meta-data about + * individual entries in the meta-data branches of subversion, + * see issue #1256 or browseable at + * http://svn.apache.org/viewvc/subversion/branches/meta-data-versioning/ . + * Furthermore @c svntar (http://svn.borg.ch/svntar/) and @c FSVS + * (http://fsvs.tigris.org/) use these, too. + * + * Please note that these formats are very UNIX-centric currently; + * a bit of discussion about Windows can be read at + * http://article.gmane.org/gmane.comp.version-control.subversion.devel/103991 + * + * @defgroup svn_prop_meta_data Meta-data properties + * @{ */ + +/** The files' last modification time. + * This is stored as string in the form @c "2008-08-07T07:38:51.008782Z", to + * be converted by the functions @c svn_time_to_cstring() and + * @c svn_time_from_cstring(). */ +#define SVN_PROP_TEXT_TIME SVN_PROP_PREFIX "text-time" + +/** The files' owner. + * Stored as numeric ID, optionally followed by whitespace and the string: + * @c "1000 pmarek". Parsers @b should accept any number of whitespace, + * and writers @b should put exactly a single space. */ +#define SVN_PROP_OWNER SVN_PROP_PREFIX "owner" + +/** The files' group. + * The same format as for @c SVN_PROP_OWNER, the owner-property. */ +#define SVN_PROP_GROUP SVN_PROP_PREFIX "group" + +/** The files' unix-mode. + * Stored in octal, with a leading @c 0; may have 5 digits if any of @c setuid, + * @c setgid or @c sticky are set; an example is @c "0644". */ +#define SVN_PROP_UNIX_MODE SVN_PROP_PREFIX "unix-mode" + +/** @} */ /* Meta-data properties */ + +/** + * This is a list of all user-visible and -settable versioned node + * properties. + * + * @since New in 1.8. + */ +#define SVN_PROP_NODE_ALL_PROPS SVN_PROP_MIME_TYPE, \ + SVN_PROP_IGNORE, \ + SVN_PROP_EOL_STYLE, \ + SVN_PROP_KEYWORDS, \ + SVN_PROP_EXECUTABLE, \ + SVN_PROP_NEEDS_LOCK, \ + SVN_PROP_SPECIAL, \ + SVN_PROP_EXTERNALS, \ + SVN_PROP_MERGEINFO, \ + SVN_PROP_INHERITABLE_AUTO_PROPS, \ + SVN_PROP_INHERITABLE_IGNORES, \ + \ + SVN_PROP_TEXT_TIME, \ + SVN_PROP_OWNER, \ + SVN_PROP_GROUP, \ + SVN_PROP_UNIX_MODE, + +/** @} */ + +/** WC props are props that are invisible to users: they're generated + * by an RA layer, and stored in secret parts of .svn/. + * + * @defgroup svn_prop_invisible_props Invisible properties + * @{ + */ + +/** The property name *prefix* that makes a property a "WC property". + * + * For example, WebDAV RA implementations might store a versioned-resource + * url as a WC prop like this: + * + * <pre reason="Should use 'verbatim' instead, but Doxygen v1.6.1 & v1.7.1 + * then doesn't recognize the #define; presumably a bug."> + name = svn:wc:dav_url + val = http://www.example.com/repos/452348/e.289 </pre> + * + * The client will try to protect WC props by warning users against + * changing them. The client will also send them back to the RA layer + * when committing. + */ +#define SVN_PROP_WC_PREFIX SVN_PROP_PREFIX "wc:" + +/** Another type of non-user-visible property. "Entry properties" are + * stored as fields with the administrative 'entries' file. + */ +#define SVN_PROP_ENTRY_PREFIX SVN_PROP_PREFIX "entry:" + +/** The revision this entry was last committed to on. */ +#define SVN_PROP_ENTRY_COMMITTED_REV SVN_PROP_ENTRY_PREFIX "committed-rev" + +/** The date this entry was last committed to on. */ +#define SVN_PROP_ENTRY_COMMITTED_DATE SVN_PROP_ENTRY_PREFIX "committed-date" + +/** The author who last committed to this entry. */ +#define SVN_PROP_ENTRY_LAST_AUTHOR SVN_PROP_ENTRY_PREFIX "last-author" + +/** The UUID of this entry's repository. */ +#define SVN_PROP_ENTRY_UUID SVN_PROP_ENTRY_PREFIX "uuid" + +/** The lock token for this entry. + * @since New in 1.2. */ +#define SVN_PROP_ENTRY_LOCK_TOKEN SVN_PROP_ENTRY_PREFIX "lock-token" + +/** When custom, user-defined properties are passed over the wire, they will + * have this prefix added to their name. + */ +#define SVN_PROP_CUSTOM_PREFIX SVN_PROP_PREFIX "custom:" + +/** @} */ + +/** + * These are reserved properties attached to a "revision" object in + * the repository filesystem. They can be queried by using + * svn_fs_revision_prop(). + * + * @defgroup svn_props_revision_props Revision properties + * @{ + */ + +/** The fs revision property that stores a commit's author. */ +#define SVN_PROP_REVISION_AUTHOR SVN_PROP_PREFIX "author" + +/** The fs revision property that stores a commit's log message. */ +#define SVN_PROP_REVISION_LOG SVN_PROP_PREFIX "log" + +/** The fs revision property that stores a commit's date. */ +#define SVN_PROP_REVISION_DATE SVN_PROP_PREFIX "date" + +/** The fs revision property that stores a commit's "original" date. + * + * The svn:date property must be monotonically increasing, along with + * the revision number. In certain scenarios, this may pose a problem + * when the revision represents a commit that occurred at a time which + * does not fit within the sequencing required for svn:date. This can + * happen, for instance, when the revision represents a commit to a + * foreign version control system, or possibly when two Subversion + * repositories are combined. This property can be used to record the + * TRUE, original date of the commit. + */ +#define SVN_PROP_REVISION_ORIG_DATE SVN_PROP_PREFIX "original-date" + +/** The presence of this fs revision property indicates that the + * revision was automatically generated by the mod_dav_svn + * autoversioning feature. The value is irrelevant. + */ +#define SVN_PROP_REVISION_AUTOVERSIONED SVN_PROP_PREFIX "autoversioned" + + +/* More reserved revision props in the 'svn:' namespace, used by the + svnsync tool: */ + +/** Prefix for all svnsync custom properties. + * @since New in 1.4. + */ +#define SVNSYNC_PROP_PREFIX SVN_PROP_PREFIX "sync-" + +/* The following revision properties are set on revision 0 of + * destination repositories by svnsync: + */ + +/** Used to enforce mutually exclusive destination repository access. + * @since New in 1.4. + */ +#define SVNSYNC_PROP_LOCK SVNSYNC_PROP_PREFIX "lock" + +/** Identifies the repository's source URL. + * @since New in 1.4. + */ +#define SVNSYNC_PROP_FROM_URL SVNSYNC_PROP_PREFIX "from-url" +/** Identifies the repository's source UUID. + * @since New in 1.4. + */ +#define SVNSYNC_PROP_FROM_UUID SVNSYNC_PROP_PREFIX "from-uuid" + +/** Identifies the last completely mirrored revision. + * @since New in 1.4. + */ +#define SVNSYNC_PROP_LAST_MERGED_REV SVNSYNC_PROP_PREFIX "last-merged-rev" + +/** Identifies the revision currently being copied. + * @since New in 1.4. + */ +#define SVNSYNC_PROP_CURRENTLY_COPYING SVNSYNC_PROP_PREFIX "currently-copying" + + +/** + * This is a list of all revision properties. + */ +#define SVN_PROP_REVISION_ALL_PROPS SVN_PROP_REVISION_AUTHOR, \ + SVN_PROP_REVISION_LOG, \ + SVN_PROP_REVISION_DATE, \ + SVN_PROP_REVISION_AUTOVERSIONED, \ + SVN_PROP_REVISION_ORIG_DATE, \ + SVNSYNC_PROP_LOCK, \ + SVNSYNC_PROP_FROM_URL, \ + SVNSYNC_PROP_FROM_UUID, \ + SVNSYNC_PROP_LAST_MERGED_REV, \ + SVNSYNC_PROP_CURRENTLY_COPYING, + +/** @} */ + +/** + * These are reserved properties attached to a "transaction" object in + * the repository filesystem in advance of the pre-commit hook script + * running on the server, but then automatically removed from the + * transaction before its promotion to a new revision. + * + * @defgroup svn_props_ephemeral_txnprops Ephemeral transaction properties + * @{ + */ + +/** The prefix used for all (ephemeral) transaction properties. + * + * @since New in 1.8. + */ +#define SVN_PROP_TXN_PREFIX SVN_PROP_PREFIX "txn-" + +/** Identifies the client version compability level. For clients + * compiled against Subversion libraries, this is @c SVN_VER_NUMBER. + * Third-party implementations are advised to use similar formatting + * for values of this property. + * + * @since New in 1.8. + */ +#define SVN_PROP_TXN_CLIENT_COMPAT_VERSION \ + SVN_PROP_TXN_PREFIX "client-compat-version" + +/** Identifies the client's user agent string, if any. + * + * @since New in 1.8. + */ +#define SVN_PROP_TXN_USER_AGENT \ + SVN_PROP_TXN_PREFIX "user-agent" + +/** The prefix reserved for copies of (ephemeral) transaction + * properties designed to outlive the transaction. Administrators may + * choose to, in their pre-commit hook scripts, copy the values of one + * or more properties named @c SVN_PROP_TXN_PREFIX + "something" + * to new properties named @c SVN_PROP_REVISION_PREFIX + "something", + * allowing that information to survive the commit-time removal of + * ephemeral transaction properties. + * + * @since New in 1.8. + */ +#define SVN_PROP_REVISION_PREFIX SVN_PROP_PREFIX "revision-" + + +/** @} */ + +/** @} */ + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_PROPS_H */ diff --git a/subversion/include/svn_quoprint.h b/subversion/include/svn_quoprint.h new file mode 100644 index 0000000..abbbe17 --- /dev/null +++ b/subversion/include/svn_quoprint.h @@ -0,0 +1,77 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_quoprint.h + * @brief quoted-printable encoding and decoding functions. + */ + +#ifndef SVN_QUOPRINT_H +#define SVN_QUOPRINT_H + +#include <apr_pools.h> + +#include "svn_string.h" /* for svn_strinbuf_t */ +#include "svn_io.h" /* for svn_stream_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Return a writable generic stream which will encode binary data in + * quoted-printable format and write the encoded data to @a output. Be + * sure to close the stream when done writing in order to squeeze out + * the last bit of encoded data. + */ +svn_stream_t * +svn_quoprint_encode(svn_stream_t *output, + apr_pool_t *pool); + +/** Return a writable generic stream which will decode binary data in + * quoted-printable format and write the decoded data to @a output. Be + * sure to close the stream when done writing in order to squeeze out + * the last bit of encoded data. + */ +svn_stream_t * +svn_quoprint_decode(svn_stream_t *output, + apr_pool_t *pool); + + +/** Simpler interface for encoding quoted-printable data assuming we have all + * of it present at once. The returned string will be allocated from @a pool. + */ +svn_stringbuf_t * +svn_quoprint_encode_string(const svn_stringbuf_t *str, + apr_pool_t *pool); + +/** Simpler interface for decoding quoted-printable data assuming we have all + * of it present at once. The returned string will be allocated from @a pool. + */ +svn_stringbuf_t * +svn_quoprint_decode_string(const svn_stringbuf_t *str, + apr_pool_t *pool); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_QUOPRINT_H */ diff --git a/subversion/include/svn_ra.h b/subversion/include/svn_ra.h new file mode 100644 index 0000000..cf6f612 --- /dev/null +++ b/subversion/include/svn_ra.h @@ -0,0 +1,2468 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_ra.h + * @brief Repository Access + */ + +#ifndef SVN_RA_H +#define SVN_RA_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_time.h> +#include <apr_file_io.h> /* for apr_file_t */ + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_delta.h" +#include "svn_auth.h" +#include "svn_mergeinfo.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/* Misc. declarations */ + +/** + * Get libsvn_ra version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_ra_version(void); + + +/** This is a function type which allows the RA layer to fetch working + * copy (WC) properties. + * + * The @a baton is provided along with the function pointer and should + * be passed back in. This will be the @a callback_baton or the + * @a close_baton as appropriate. + * + * @a path is relative to the "root" of the session, defined by the + * @a repos_URL passed to svn_ra_open4() vtable call. + * + * @a name is the name of the property to fetch. If the property is present, + * then it is returned in @a value. Otherwise, @a *value is set to @c NULL. + */ +typedef svn_error_t *(*svn_ra_get_wc_prop_func_t)(void *baton, + const char *path, + const char *name, + const svn_string_t **value, + apr_pool_t *pool); + +/** This is a function type which allows the RA layer to store new + * working copy properties during update-like operations. See the + * comments for @c svn_ra_get_wc_prop_func_t for @a baton, @a path, and + * @a name. The @a value is the value that will be stored for the property; + * a NULL @a value means the property will be deleted. + */ +typedef svn_error_t *(*svn_ra_set_wc_prop_func_t)(void *baton, + const char *path, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + +/** This is a function type which allows the RA layer to store new + * working copy properties as part of a commit. See the comments for + * @c svn_ra_get_wc_prop_func_t for @a baton, @a path, and @a name. + * The @a value is the value that will be stored for the property; a + * @c NULL @a value means the property will be deleted. + * + * Note that this might not actually store the new property before + * returning, but instead schedule it to be changed as part of + * post-commit processing (in which case a successful commit means the + * properties got written). Thus, during the commit, it is possible + * to invoke this function to set a new value for a wc prop, then read + * the wc prop back from the working copy and get the *old* value. + * Callers beware. + */ +typedef svn_error_t *(*svn_ra_push_wc_prop_func_t)(void *baton, + const char *path, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + +/** This is a function type which allows the RA layer to invalidate + * (i.e., remove) wcprops recursively. See the documentation for + * @c svn_ra_get_wc_prop_func_t for @a baton, @a path, and @a name. + * + * Unlike @c svn_ra_push_wc_prop_func_t, this has immediate effect. If + * it returns success, the wcprops have been removed. + */ +typedef svn_error_t *(*svn_ra_invalidate_wc_props_func_t)(void *baton, + const char *path, + const char *name, + apr_pool_t *pool); + +/** This is a function type which allows the RA layer to fetch the + * cached pristine file contents whose checksum is @a checksum, if + * any. @a *contents will be a read stream containing those contents + * if they are found; NULL otherwise. + * + * @since New in 1.8. + */ +typedef svn_error_t * +(*svn_ra_get_wc_contents_func_t)(void *baton, + svn_stream_t **contents, + const svn_checksum_t *checksum, + apr_pool_t *pool); + + +/** A function type for retrieving the youngest revision from a repos. */ +typedef svn_error_t *(*svn_ra_get_latest_revnum_func_t)( + void *session_baton, + svn_revnum_t *latest_revnum); + +/** A function type which allows the RA layer to ask about any + * customizations to the client name string. This is primarily used + * by HTTP-based RA layers wishing to extend the string reported to + * Apache/mod_dav_svn via the User-agent HTTP header. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_ra_get_client_string_func_t)(void *baton, + const char **name, + apr_pool_t *pool); + + + +/** + * A callback function type for use in @c get_file_revs. + * @a baton is provided by the caller, @a path is the pathname of the file + * in revision @a rev and @a rev_props are the revision properties. + * If @a delta_handler and @a delta_baton are non-NULL, they may be set to a + * handler/baton which will be called with the delta between the previous + * revision and this one after the return of this callback. They may be + * left as NULL/NULL. + * @a prop_diffs is an array of svn_prop_t elements indicating the property + * delta for this and the previous revision. + * @a pool may be used for temporary allocations, but you can't rely + * on objects allocated to live outside of this particular call and the + * immediately following calls to @a *delta_handler, if any. + * + * @since New in 1.1. + */ +typedef svn_error_t *(*svn_ra_file_rev_handler_t)( + void *baton, + const char *path, + svn_revnum_t rev, + apr_hash_t *rev_props, + svn_txdelta_window_handler_t *delta_handler, + void **delta_baton, + apr_array_header_t *prop_diffs, + apr_pool_t *pool); + +/** + * Callback function type for locking and unlocking actions. + * + * @since New in 1.2. + * + * @a do_lock is TRUE when locking @a path, and FALSE + * otherwise. + * + * @a lock is a lock for @a path or NULL if @a do_lock is FALSE or @a ra_err is + * non-NULL. + * + * @a ra_err is NULL unless the ra layer encounters a locking related + * error which it passes back for notification purposes. The caller + * is responsible for clearing @a ra_err after the callback is run. + * + * @a baton is a closure object; it should be provided by the + * implementation, and passed by the caller. @a pool may be used for + * temporary allocation. + */ +typedef svn_error_t *(*svn_ra_lock_callback_t)(void *baton, + const char *path, + svn_boolean_t do_lock, + const svn_lock_t *lock, + svn_error_t *ra_err, + apr_pool_t *pool); + +/** + * Callback function type for progress notification. + * + * @a progress is the number of bytes already transferred, @a total is + * the total number of bytes to transfer or -1 if it's not known, @a + * baton is the callback baton. + * + * @since New in 1.3. + */ +typedef void (*svn_ra_progress_notify_func_t)(apr_off_t progress, + apr_off_t total, + void *baton, + apr_pool_t *pool); + +/** + * Callback function type for replay_range actions. + * + * This callback function should provide replay_range with an editor which + * will be driven with the received replay reports from the master repository. + * + * @a revision is the target revision number of the received replay report. + * + * @a editor and @a edit_baton should provided by the callback implementation. + * + * @a replay_baton is the baton as originally passed to replay_range. + * + * @a revprops contains key/value pairs for each revision properties for this + * revision. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_ra_replay_revstart_callback_t)( + svn_revnum_t revision, + void *replay_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_hash_t *rev_props, + apr_pool_t *pool); + +/** + * Callback function type for replay_range actions. + * + * This callback function should close the editor. + * + * @a revision is the target revision number of the received replay report. + * + * @a editor and @a edit_baton should provided by the callback implementation. + * + * @a replay_baton is the baton as originally passed to replay_range. + * + * @a revprops contains key/value pairs for each revision properties for this + * revision. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_ra_replay_revfinish_callback_t)( + svn_revnum_t revision, + void *replay_baton, + const svn_delta_editor_t *editor, + void *edit_baton, + apr_hash_t *rev_props, + apr_pool_t *pool); + + +/** + * The update Reporter. + * + * A vtable structure which allows a working copy to describe a subset + * (or possibly all) of its working-copy to an RA layer, for the + * purposes of an update, switch, status, or diff operation. + * + * Paths for report calls are relative to the target (not the anchor) + * of the operation. Report calls must be made in depth-first order: + * parents before children, all children of a parent before any + * siblings of the parent. The first report call must be a set_path + * with a @a path argument of "" and a valid revision. (If the target + * of the operation is locally deleted or missing, use the anchor's + * revision.) If the target of the operation is deleted or switched + * relative to the anchor, follow up the initial set_path call with a + * link_path or delete_path call with a @a path argument of "" to + * indicate that. In no other case may there be two report + * descriptions for the same path. If the target of the operation is + * a locally added file or directory (which previously did not exist), + * it may be reported as having revision 0 or as having the parent + * directory's revision. + * + * @since New in 1.5. + */ +typedef struct svn_ra_reporter3_t +{ + /** Describe a working copy @a path as being at a particular + * @a revision and having depth @a depth. + * + * @a revision may be SVN_INVALID_REVNUM if (for example) @a path + * represents a locally-added path with no revision number, or @a + * depth is @c svn_depth_exclude. + * + * @a path may not be underneath a path on which set_path() was + * previously called with @c svn_depth_exclude in this report. + * + * If @a start_empty is set and @a path is a directory, the + * implementor should assume the directory has no entries or props. + * + * This will *override* any previous set_path() calls made on parent + * paths. @a path is relative to the URL specified in svn_ra_open4(). + * + * If @a lock_token is non-NULL, it is the lock token for @a path in the WC. + * + * All temporary allocations are done in @a pool. + */ + svn_error_t *(*set_path)(void *report_baton, + const char *path, + svn_revnum_t revision, + svn_depth_t depth, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + + /** Describing a working copy @a path as missing. + * + * @a path may not be underneath a path on which set_path() was + * previously called with @c svn_depth_exclude in this report. + * + * All temporary allocations are done in @a pool. + */ + svn_error_t *(*delete_path)(void *report_baton, + const char *path, + apr_pool_t *pool); + + /** Like set_path(), but differs in that @a path in the working copy + * (relative to the root of the report driver) isn't a reflection of + * @a path in the repository (relative to the URL specified when + * opening the RA layer), but is instead a reflection of a different + * repository @a url at @a revision, and has depth @a depth. + * + * @a path may not be underneath a path on which set_path() was + * previously called with @c svn_depth_exclude in this report. + * + * If @a start_empty is set and @a path is a directory, + * the implementor should assume the directory has no entries or props. + * + * If @a lock_token is non-NULL, it is the lock token for @a path in the WC. + * + * All temporary allocations are done in @a pool. + */ + svn_error_t *(*link_path)(void *report_baton, + const char *path, + const char *url, + svn_revnum_t revision, + svn_depth_t depth, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + + /** WC calls this when the state report is finished; any directories + * or files not explicitly `set' are assumed to be at the + * baseline revision originally passed into do_update(). No other + * reporting functions, including abort_report, should be called after + * calling this function. + */ + svn_error_t *(*finish_report)(void *report_baton, + apr_pool_t *pool); + + /** If an error occurs during a report, this routine should cause the + * filesystem transaction to be aborted & cleaned up. No other reporting + * functions should be called after calling this function. + */ + svn_error_t *(*abort_report)(void *report_baton, + apr_pool_t *pool); + +} svn_ra_reporter3_t; + +/** + * Similar to @c svn_ra_reporter3_t, but without support for depths. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +typedef struct svn_ra_reporter2_t +{ + /** Similar to the corresponding field in @c svn_ra_reporter3_t, but + * with @a depth always set to @c svn_depth_infinity. */ + svn_error_t *(*set_path)(void *report_baton, + const char *path, + svn_revnum_t revision, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + + /** Same as the corresponding field in @c svn_ra_reporter3_t. */ + svn_error_t *(*delete_path)(void *report_baton, + const char *path, + apr_pool_t *pool); + + /** Similar to the corresponding field in @c svn_ra_reporter3_t, but + * with @a depth always set to @c svn_depth_infinity. */ + svn_error_t *(*link_path)(void *report_baton, + const char *path, + const char *url, + svn_revnum_t revision, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + + /** Same as the corresponding field in @c svn_ra_reporter3_t. */ + svn_error_t *(*finish_report)(void *report_baton, + apr_pool_t *pool); + + /** Same as the corresponding field in @c svn_ra_reporter3_t. */ + svn_error_t *(*abort_report)(void *report_baton, + apr_pool_t *pool); + +} svn_ra_reporter2_t; + +/** + * Similar to @c svn_ra_reporter2_t, but without support for lock tokens. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef struct svn_ra_reporter_t +{ + /** Similar to the corresponding field in @c svn_ra_reporter2_t, but + * with @a lock_token always set to NULL. */ + svn_error_t *(*set_path)(void *report_baton, + const char *path, + svn_revnum_t revision, + svn_boolean_t start_empty, + apr_pool_t *pool); + + /** Same as the corresponding field in @c svn_ra_reporter2_t. */ + svn_error_t *(*delete_path)(void *report_baton, + const char *path, + apr_pool_t *pool); + + /** Similar to the corresponding field in @c svn_ra_reporter2_t, but + * with @a lock_token always set to NULL. */ + svn_error_t *(*link_path)(void *report_baton, + const char *path, + const char *url, + svn_revnum_t revision, + svn_boolean_t start_empty, + apr_pool_t *pool); + + /** Same as the corresponding field in @c svn_ra_reporter2_t. */ + svn_error_t *(*finish_report)(void *report_baton, + apr_pool_t *pool); + + /** Same as the corresponding field in @c svn_ra_reporter2_t. */ + svn_error_t *(*abort_report)(void *report_baton, + apr_pool_t *pool); +} svn_ra_reporter_t; + + +/** A collection of callbacks implemented by libsvn_client which allows + * an RA layer to "pull" information from the client application, or + * possibly store information. libsvn_client passes this vtable to + * svn_ra_open4(). + * + * Each routine takes a @a callback_baton originally provided with the + * vtable. + * + * Clients must use svn_ra_create_callbacks() to allocate and + * initialize this structure. + * + * @since New in 1.3. + */ +typedef struct svn_ra_callbacks2_t +{ + /** Open a unique temporary file for writing in the working copy. + * This file will be automatically deleted when @a fp is closed. + * + * @deprecated This callback should no longer be used by RA layers. + */ + svn_error_t *(*open_tmp_file)(apr_file_t **fp, + void *callback_baton, + apr_pool_t *pool); + + /** An authentication baton, created by the application, which is + * capable of retrieving all known types of credentials. + */ + svn_auth_baton_t *auth_baton; + + /*** The following items may be set to NULL to disallow the RA layer + to perform the respective operations of the vtable functions. + Perhaps WC props are not defined or are in invalid for this + session, or perhaps the commit operation this RA session will + perform is a server-side only one that shouldn't do post-commit + processing on a working copy path. ***/ + + /** Fetch working copy properties. + * + *<pre> ### we might have a problem if the RA layer ever wants a property + * ### that corresponds to a different revision of the file than + * ### what is in the WC. we'll cross that bridge one day...</pre> + */ + svn_ra_get_wc_prop_func_t get_wc_prop; + + /** Immediately set new values for working copy properties. */ + svn_ra_set_wc_prop_func_t set_wc_prop; + + /** Schedule new values for working copy properties. */ + svn_ra_push_wc_prop_func_t push_wc_prop; + + /** Invalidate working copy properties. */ + svn_ra_invalidate_wc_props_func_t invalidate_wc_props; + + /** Notification callback used for progress information. + * May be NULL if not used. + */ + svn_ra_progress_notify_func_t progress_func; + + /** Notification callback baton, used with progress_func. */ + void *progress_baton; + + /** Cancellation function + * + * As its baton, the general callback baton is used + * + * @since New in 1.5 + */ + svn_cancel_func_t cancel_func; + + /** Client string customization callback function + * @since New in 1.5 + */ + svn_ra_get_client_string_func_t get_client_string; + + /** Working copy file content fetching function. + * @since New in 1.8. + */ + svn_ra_get_wc_contents_func_t get_wc_contents; + +} svn_ra_callbacks2_t; + +/** Similar to svn_ra_callbacks2_t, except that the progress + * notification function and baton is missing. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +typedef struct svn_ra_callbacks_t +{ + svn_error_t *(*open_tmp_file)(apr_file_t **fp, + void *callback_baton, + apr_pool_t *pool); + + svn_auth_baton_t *auth_baton; + + svn_ra_get_wc_prop_func_t get_wc_prop; + + svn_ra_set_wc_prop_func_t set_wc_prop; + + svn_ra_push_wc_prop_func_t push_wc_prop; + + svn_ra_invalidate_wc_props_func_t invalidate_wc_props; + +} svn_ra_callbacks_t; + + + +/*----------------------------------------------------------------------*/ + +/* Public Interfaces. */ + +/** + * Initialize the RA library. This function must be called before using + * any function in this header, except the deprecated APIs based on + * @c svn_ra_plugin_t, or svn_ra_version(). This function must not be called + * simultaneously in multiple threads. @a pool must live + * longer than any open RA sessions. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_initialize(apr_pool_t *pool); + +/** Initialize a callback structure. +* Set @a *callbacks to a ra callbacks object, allocated in @a pool. +* +* Clients must use this function to allocate and initialize @c +* svn_ra_callbacks2_t structures. +* +* @since New in 1.3. +*/ +svn_error_t * +svn_ra_create_callbacks(svn_ra_callbacks2_t **callbacks, + apr_pool_t *pool); + +/** + * A repository access session. This object is used to perform requests + * to a repository, identified by a URL. + * + * @since New in 1.2. + */ +typedef struct svn_ra_session_t svn_ra_session_t; + +/** + * Open a repository access session to the repository at @a repos_URL, + * or inform the caller regarding a correct URL by which to access + * that repository. + * + * If @a repos_URL can be used successfully to access the repository, + * set @a *session_p to an opaque object representing a repository + * session for the repository and (if @a corrected_url is non-NULL) + * set @a *corrected_url to NULL. If there's a better URL that the + * caller should try and @a corrected_url is non-NULL, set + * @a *session_p to NULL and @a *corrected_url to the corrected URL. If + * there's a better URL that the caller should try, and @a + * corrected_url is NULL, return an #SVN_ERR_RA_SESSION_URL_MISMATCH + * error. Allocate all returned items in @a pool. + * + * The @a repos_URL need not point to the root of the repository: subject + * to authorization, it may point to any path within the repository, even + * a path at which no node exists in the repository. The session will + * remember this URL as its "session URL" (also called "session root URL"), + * until changed by svn_ra_reparent(). Many RA functions take or return + * paths that are relative to the session URL. + * + * If a @a corrected_url is returned, it will point to the same path + * within the new repository root URL that @a repos_URL pointed to within + * the old repository root URL. + * + * Return @c SVN_ERR_RA_UUID_MISMATCH if @a uuid is non-NULL and not equal + * to the UUID of the repository at @c repos_URL. + * + * @a callbacks/@a callback_baton is a table of callbacks provided by the + * client; see @c svn_ra_callbacks2_t. + * + * @a config is a hash mapping <tt>const char *</tt> keys to + * @c svn_config_t * values. For example, the @c svn_config_t for the + * "~/.subversion/config" file is under the key "config". @a config may + * be NULL. This function examines some config settings under the + * "servers" key (if present) before loading the required RA module, and + * the RA module may also examine any config settings. + * + * All RA requests require a session; they will continue to + * use @a pool for memory allocation. + * + * @see svn_client_open_ra_session(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra_open4(svn_ra_session_t **session_p, + const char **corrected_url, + const char *repos_URL, + const char *uuid, + const svn_ra_callbacks2_t *callbacks, + void *callback_baton, + apr_hash_t *config, + apr_pool_t *pool); + +/** Similar to svn_ra_open4(), but with @a corrected_url always passed + * as @c NULL. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_open3(svn_ra_session_t **session_p, + const char *repos_URL, + const char *uuid, + const svn_ra_callbacks2_t *callbacks, + void *callback_baton, + apr_hash_t *config, + apr_pool_t *pool); + +/** + * Similar to svn_ra_open3(), but with @a uuid set to @c NULL. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_open2(svn_ra_session_t **session_p, + const char *repos_URL, + const svn_ra_callbacks2_t *callbacks, + void *callback_baton, + apr_hash_t *config, + apr_pool_t *pool); + +/** + * @see svn_ra_open2(). + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_open(svn_ra_session_t **session_p, + const char *repos_URL, + const svn_ra_callbacks_t *callbacks, + void *callback_baton, + apr_hash_t *config, + apr_pool_t *pool); + +/** Change the root URL of an open @a ra_session to point to a new path in the + * same repository. @a url is the new root URL. Use @a pool for + * temporary allocations. + * + * If @a url has a different repository root than the current session + * URL, return @c SVN_ERR_RA_ILLEGAL_URL. + * + * @since New in 1.4. + */ +svn_error_t * +svn_ra_reparent(svn_ra_session_t *ra_session, + const char *url, + apr_pool_t *pool); + +/** Set @a *url to the session URL -- the URL to which @a ra_session was + * opened or most recently reparented. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_session_url(svn_ra_session_t *ra_session, + const char **url, + apr_pool_t *pool); + + +/** Convert @a url into a path relative to the session URL of @a ra_session, + * setting @a *rel_path to that value. If @a url is not + * a child of the session URL, return @c SVN_ERR_RA_ILLEGAL_URL. + * + * The returned path is uri decoded to allow using it with the ra or other + * apis as a valid relpath. + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra_get_path_relative_to_session(svn_ra_session_t *ra_session, + const char **rel_path, + const char *url, + apr_pool_t *pool); + +/** Convert @a url into a path relative to the repository root URL of + * the repository with which @a ra_session is associated, setting @a + * *rel_path to that value. If @a url is not a child of repository + * root URL, return @c SVN_ERR_RA_ILLEGAL_URL. + * + * The returned path is uri decoded to allow using it with the ra or other + * apis as a valid relpath. + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra_get_path_relative_to_root(svn_ra_session_t *ra_session, + const char **rel_path, + const char *url, + apr_pool_t *pool); + +/** + * Get the latest revision number from the repository of @a session. + * + * Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_get_latest_revnum(svn_ra_session_t *session, + svn_revnum_t *latest_revnum, + apr_pool_t *pool); + +/** + * Get the latest revision number at time @a tm in the repository of + * @a session. + * + * Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_get_dated_revision(svn_ra_session_t *session, + svn_revnum_t *revision, + apr_time_t tm, + apr_pool_t *pool); + +/** + * Set the property @a name to @a value on revision @a rev in the repository + * of @a session. + * + * If @a value is @c NULL, delete the named revision property. + * + * If the server advertises the #SVN_RA_CAPABILITY_ATOMIC_REVPROPS capability + * and @a old_value_p is not @c NULL, then changing the property will fail with + * an error chain that contains #SVN_ERR_FS_PROP_BASEVALUE_MISMATCH if the + * present value of the property is not @a *old_value_p. (This is an atomic + * test-and-set). + * @a *old_value_p may be @c NULL, representing that the property must be not + * already set. + * + * If the capability is not advertised, then @a old_value_p MUST be @c NULL. + * + * Please note that properties attached to revisions are @em unversioned. + * + * Use @a pool for memory allocation. + * + * @see svn_fs_change_rev_prop2(), svn_error_find_cause(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra_change_rev_prop2(svn_ra_session_t *session, + svn_revnum_t rev, + const char *name, + const svn_string_t *const *old_value_p, + const svn_string_t *value, + apr_pool_t *pool); + +/** + * Similar to svn_ra_change_rev_prop2(), but with @a old_value_p set + * to @c NULL. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_change_rev_prop(svn_ra_session_t *session, + svn_revnum_t rev, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + +/** + * Set @a *props to the list of unversioned properties attached to revision + * @a rev in the repository of @a session. The hash maps + * (<tt>const char *</tt>) names to (<tt>@c svn_string_t *</tt>) values. + * + * Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_rev_proplist(svn_ra_session_t *session, + svn_revnum_t rev, + apr_hash_t **props, + apr_pool_t *pool); + +/** + * Set @a *value to the value of unversioned property @a name attached to + * revision @a rev in the repository of @a session. If @a rev has no + * property by that name, set @a *value to @c NULL. + * + * Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_rev_prop(svn_ra_session_t *session, + svn_revnum_t rev, + const char *name, + svn_string_t **value, + apr_pool_t *pool); + +/** + * Set @a *editor and @a *edit_baton to an editor for committing + * changes to the repository of @a session, setting the revision + * properties from @a revprop_table. The revisions being committed + * against are passed to the editor functions, starting with the rev + * argument to @c open_root. The path root of the commit is the @a + * session's URL. + * + * @a revprop_table is a hash mapping <tt>const char *</tt> property + * names to @c svn_string_t property values. The commit log message + * is expected to be in the @c SVN_PROP_REVISION_LOG element. @a + * revprop_table can not contain either of @c SVN_PROP_REVISION_DATE + * or @c SVN_PROP_REVISION_AUTHOR. + * + * Before @c close_edit returns, but after the commit has succeeded, + * it will invoke @a commit_callback (if non-NULL) with filled-in + * #svn_commit_info_t *, @a commit_baton, and @a pool or some subpool + * thereof as arguments. If @a commit_callback returns an error, that error + * will be returned from @c * close_edit, otherwise @c close_edit will return + * successfully (unless it encountered an error before invoking + * @a commit_callback). + * + * The callback will not be called if the commit was a no-op + * (i.e. nothing was committed); + * + * @a lock_tokens, if non-NULL, is a hash mapping <tt>const char + * *</tt> paths (relative to the URL of @a session) to <tt> + * const char *</tt> lock tokens. The server checks that the + * correct token is provided for each committed, locked path. @a lock_tokens + * must live during the whole commit operation. + * + * If @a keep_locks is @c TRUE, then do not release locks on + * committed objects. Else, automatically release such locks. + * + * The caller may not perform any RA operations using @a session before + * finishing the edit. + * + * Use @a pool for memory allocation. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_commit_editor3(svn_ra_session_t *session, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + apr_hash_t *lock_tokens, + svn_boolean_t keep_locks, + apr_pool_t *pool); + +/** + * Same as svn_ra_get_commit_editor3(), but with @c revprop_table set + * to a hash containing the @c SVN_PROP_REVISION_LOG property set + * to the value of @a log_msg. + * + * @since New in 1.4. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_commit_editor2(svn_ra_session_t *session, + const svn_delta_editor_t **editor, + void **edit_baton, + const char *log_msg, + svn_commit_callback2_t commit_callback, + void *commit_baton, + apr_hash_t *lock_tokens, + svn_boolean_t keep_locks, + apr_pool_t *pool); + +/** + * Same as svn_ra_get_commit_editor2(), but uses @c svn_commit_callback_t. + * + * @since New in 1.2. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_commit_editor(svn_ra_session_t *session, + const svn_delta_editor_t **editor, + void **edit_baton, + const char *log_msg, + svn_commit_callback_t callback, + void *callback_baton, + apr_hash_t *lock_tokens, + svn_boolean_t keep_locks, + apr_pool_t *pool); + +/** + * Fetch the contents and properties of file @a path at @a revision. + * @a revision may be SVN_INVALID_REVNUM, indicating that the HEAD + * revision should be used. Interpret @a path relative to the URL in + * @a session. Use @a pool for all allocations. + * + * If @a revision is @c SVN_INVALID_REVNUM and @a fetched_rev is not + * @c NULL, then set @a *fetched_rev to the actual revision that was + * retrieved. + * + * If @a stream is non @c NULL, push the contents of the file at @a + * stream, do not call svn_stream_close() when finished. + * + * If @a props is non @c NULL, set @a *props to contain the properties of + * the file. This means @em all properties: not just ones controlled by + * the user and stored in the repository fs, but non-tweakable ones + * generated by the SCM system itself (e.g. 'wcprops', 'entryprops', + * etc.) The keys are <tt>const char *</tt>, values are + * <tt>@c svn_string_t *</tt>. + * + * The stream handlers for @a stream may not perform any RA + * operations using @a session. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_get_file(svn_ra_session_t *session, + const char *path, + svn_revnum_t revision, + svn_stream_t *stream, + svn_revnum_t *fetched_rev, + apr_hash_t **props, + apr_pool_t *pool); + +/** + * If @a dirents is non @c NULL, set @a *dirents to contain all the entries + * of directory @a path at @a revision. The keys of @a dirents will be + * entry names (<tt>const char *</tt>), and the values dirents + * (<tt>@c svn_dirent_t *</tt>). Use @a pool for all allocations. + * + * @a dirent_fields controls which portions of the <tt>@c svn_dirent_t</tt> + * objects are filled in. To have them completely filled in just pass + * @c SVN_DIRENT_ALL, otherwise pass the bitwise OR of all the @c SVN_DIRENT_ + * fields you would like to have returned to you. + * + * @a path is interpreted relative to the URL in @a session. + * + * If @a revision is @c SVN_INVALID_REVNUM (meaning 'head') and + * @a *fetched_rev is not @c NULL, then this function will set + * @a *fetched_rev to the actual revision that was retrieved. (Some + * callers want to know, and some don't.) + * + * If @a props is non @c NULL, set @a *props to contain the properties of + * the directory. This means @em all properties: not just ones controlled by + * the user and stored in the repository fs, but non-tweakable ones + * generated by the SCM system itself (e.g. 'wcprops', 'entryprops', + * etc.) The keys are <tt>const char *</tt>, values are + * <tt>@c svn_string_t *</tt>. + * + * @since New in 1.4. + */ +svn_error_t * +svn_ra_get_dir2(svn_ra_session_t *session, + apr_hash_t **dirents, + svn_revnum_t *fetched_rev, + apr_hash_t **props, + const char *path, + svn_revnum_t revision, + apr_uint32_t dirent_fields, + apr_pool_t *pool); + +/** + * Similar to @c svn_ra_get_dir2, but with @c SVN_DIRENT_ALL for the + * @a dirent_fields parameter. + * + * @since New in 1.2. + * + * @deprecated Provided for compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_dir(svn_ra_session_t *session, + const char *path, + svn_revnum_t revision, + apr_hash_t **dirents, + svn_revnum_t *fetched_rev, + apr_hash_t **props, + apr_pool_t *pool); + +/** + * Set @a *catalog to a mergeinfo catalog for the paths in @a paths. + * If no mergeinfo is available, set @a *catalog to @c NULL. The + * requested mergeinfo hashes are for @a paths (which are relative to + * @a session's URL) in @a revision. If one of the paths does not exist + * in that revision, return SVN_ERR_FS_NOT_FOUND. + * + * @a inherit indicates whether explicit, explicit or inherited, or + * only inherited mergeinfo for @a paths is retrieved. + * + * If @a include_descendants is TRUE, then additionally return the + * mergeinfo for any descendant of any element of @a paths which has + * the @c SVN_PROP_MERGEINFO property explicitly set on it. (Note + * that inheritance is only taken into account for the elements in @a + * paths; descendants of the elements in @a paths which get their + * mergeinfo via inheritance are not included in @a *catalog.) + * + * Allocate the returned values in @a pool. + * + * If @a revision is @c SVN_INVALID_REVNUM, it defaults to youngest. + * + * If the server doesn't support retrieval of mergeinfo (which can + * happen even for file:// URLs, if the repository itself hasn't been + * upgraded), return @c SVN_ERR_UNSUPPORTED_FEATURE in preference to + * any other error that might otherwise be returned. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_mergeinfo(svn_ra_session_t *session, + svn_mergeinfo_catalog_t *catalog, + const apr_array_header_t *paths, + svn_revnum_t revision, + svn_mergeinfo_inheritance_t inherit, + svn_boolean_t include_descendants, + apr_pool_t *pool); + +/** + * Ask the RA layer to update a working copy to a new revision. + * + * The client initially provides an @a update_editor/@a update_baton to the + * RA layer; this editor contains knowledge of where the change will + * begin in the working copy (when @c open_root() is called). + * + * In return, the client receives a @a reporter/@a report_baton. The + * client then describes its working copy by making calls into the + * @a reporter. + * + * When finished, the client calls @a reporter->finish_report(). The + * RA layer then does a complete drive of @a update_editor, ending with + * @a update_editor->close_edit(), to update the working copy. + * + * @a update_target is an optional single path component to restrict + * the scope of the update to just that entry (in the directory + * represented by the @a session's URL). If @a update_target is the + * empty string, the entire directory is updated. + * + * Update the target only as deeply as @a depth indicates. + * + * If @a send_copyfrom_args is TRUE, then ask the server to send + * copyfrom arguments to add_file() and add_directory() when possible. + * (Note: this means that any subsequent txdeltas coming from the + * server are presumed to apply against the copied file!) + * + * Use @a ignore_ancestry to control whether or not items being + * updated will be checked for relatedness first. Unrelated items + * are typically transmitted to the editor as a deletion of one thing + * and the addition of another, but if this flag is @c TRUE, + * unrelated items will be diffed as if they were related. + * + * The working copy will be updated to @a revision_to_update_to, or the + * "latest" revision if this arg is invalid. + * + * The caller may not perform any RA operations using @a session before + * finishing the report, and may not perform any RA operations using + * @a session from within the editing operations of @a update_editor. + * + * Allocate @a *reporter and @a *report_baton in @a result_pool. Use + * @a scratch_pool for temporary allocations. + * + * @note The reporter provided by this function does NOT supply copy- + * from information to the diff editor callbacks. + * + * @note In order to prevent pre-1.5 servers from doing more work than + * needed, and sending too much data back, a pre-1.5 'recurse' + * directive may be sent to the server, based on @a depth. + * + * @note Pre Subversion 1.8 svnserve based servers never ignore ancestry. + * + * @note This differs from calling svn_ra_do_switch3() with the current + * URL of the target node. Update changes only the revision numbers, + * leaving any switched subtrees still switched, whereas switch changes + * every node in the tree to a child of the same URL. + * + * @since New in 1.8. + */ +svn_error_t * +svn_ra_do_update3(svn_ra_session_t *session, + const svn_ra_reporter3_t **reporter, + void **report_baton, + svn_revnum_t revision_to_update_to, + const char *update_target, + svn_depth_t depth, + svn_boolean_t send_copyfrom_args, + svn_boolean_t ignore_ancestry, + const svn_delta_editor_t *update_editor, + void *update_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_ra_do_update3(), but always ignoring ancestry. + * + * @since New in 1.5. + * @deprecated Provided for compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_update2(svn_ra_session_t *session, + const svn_ra_reporter3_t **reporter, + void **report_baton, + svn_revnum_t revision_to_update_to, + const char *update_target, + svn_depth_t depth, + svn_boolean_t send_copyfrom_args, + const svn_delta_editor_t *update_editor, + void *update_baton, + apr_pool_t *pool); + +/** + * Similar to svn_ra_do_update2(), but taking @c svn_ra_reporter2_t + * instead of @c svn_ra_reporter3_t; if @a recurse is true, pass @c + * svn_depth_infinity for @a depth, else pass @c svn_depth_files; and + * with @a send_copyfrom_args always false. + * + * @deprecated Provided for compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_update(svn_ra_session_t *session, + const svn_ra_reporter2_t **reporter, + void **report_baton, + svn_revnum_t revision_to_update_to, + const char *update_target, + svn_boolean_t recurse, + const svn_delta_editor_t *update_editor, + void *update_baton, + apr_pool_t *pool); + + +/** + * Ask the RA layer to switch a working copy to a new revision and URL. + * + * This is similar to svn_ra_do_update3(), but also changes the URL of + * every node in the target tree to a child of the @a switch_url. In + * contrast, update changes only the revision numbers, leaving any + * switched subtrees still switched. + * + * @note Pre Subversion 1.8 svnserve based servers always ignore ancestry + * and never send copyfrom data. + * + * @since New in 1.8. + */ +svn_error_t * +svn_ra_do_switch3(svn_ra_session_t *session, + const svn_ra_reporter3_t **reporter, + void **report_baton, + svn_revnum_t revision_to_switch_to, + const char *switch_target, + svn_depth_t depth, + const char *switch_url, + svn_boolean_t send_copyfrom_args, + svn_boolean_t ignore_ancestry, + const svn_delta_editor_t *switch_editor, + void *switch_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_ra_do_switch3(), but always ignoring ancestry and + * never sending copyfrom_args. + * + * @since New in 1.5. + * @deprecated Provided for compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_switch2(svn_ra_session_t *session, + const svn_ra_reporter3_t **reporter, + void **report_baton, + svn_revnum_t revision_to_switch_to, + const char *switch_target, + svn_depth_t depth, + const char *switch_url, + const svn_delta_editor_t *switch_editor, + void *switch_baton, + apr_pool_t *pool); + +/** + * Similar to svn_ra_do_switch2(), but taking @c svn_ra_reporter2_t + * instead of @c svn_ra_reporter3_t, and therefore only able to report + * @c svn_depth_infinity for depths. The switch itself is performed + * according to @a recurse: if TRUE, then use @c svn_depth_infinity + * for @a depth, else use @c svn_depth_files. + * + * @deprecated Provided for compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_switch(svn_ra_session_t *session, + const svn_ra_reporter2_t **reporter, + void **report_baton, + svn_revnum_t revision_to_switch_to, + const char *switch_target, + svn_boolean_t recurse, + const char *switch_url, + const svn_delta_editor_t *switch_editor, + void *switch_baton, + apr_pool_t *pool); + +/** + * Ask the RA layer to describe the status of a working copy with respect + * to @a revision of the repository (or HEAD, if @a revision is invalid). + * + * The client initially provides a @a status_editor/@a status_baton to the RA + * layer; this editor contains knowledge of where the change will + * begin in the working copy (when open_root() is called). + * + * In return, the client receives a @a reporter/@a report_baton. The + * client then describes its working copy by making calls into the + * @a reporter. + * + * When finished, the client calls @a reporter->finish_report(). The RA + * layer then does a complete drive of @a status_editor, ending with + * close_edit(), to report, essentially, what would be modified in + * the working copy were the client to call do_update(). + * @a status_target is an optional single path component will restrict + * the scope of the status report to an entry in the directory + * represented by the @a session's URL, or empty if the entire directory + * is meant to be examined. + * + * Get status as deeply as @a depth indicates. If @a depth is + * #svn_depth_unknown, get the status down to the ambient depth of the + * working copy. If @a depth is deeper than the working copy, include changes + * that would be needed to populate the working copy to that depth. + * + * The caller may not perform any RA operations using @a session + * before finishing the report, and may not perform any RA operations + * using @a session from within the editing operations of @a status_editor. + * + * Use @a pool for memory allocation. + * + * @note The reporter provided by this function does NOT supply copy- + * from information to the diff editor callbacks. + * + * @note In order to prevent pre-1.5 servers from doing more work than + * needed, and sending too much data back, a pre-1.5 'recurse' + * directive may be sent to the server, based on @a depth. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_do_status2(svn_ra_session_t *session, + const svn_ra_reporter3_t **reporter, + void **report_baton, + const char *status_target, + svn_revnum_t revision, + svn_depth_t depth, + const svn_delta_editor_t *status_editor, + void *status_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_ra_do_status2(), but taking @c svn_ra_reporter2_t + * instead of @c svn_ra_reporter3_t, and therefore only able to report + * @c svn_depth_infinity for depths. The status operation itself is + * performed according to @a recurse: if TRUE, then @a depth is + * @c svn_depth_infinity, else it is @c svn_depth_immediates. + * + * @deprecated Provided for compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_status(svn_ra_session_t *session, + const svn_ra_reporter2_t **reporter, + void **report_baton, + const char *status_target, + svn_revnum_t revision, + svn_boolean_t recurse, + const svn_delta_editor_t *status_editor, + void *status_baton, + apr_pool_t *pool); + +/** + * Ask the RA layer to 'diff' a working copy against @a versus_url; + * it's another form of svn_ra_do_update2(). + * + * @note This function cannot be used to diff a single file, only a + * working copy directory. See the svn_ra_do_switch3() function + * for more details. + * + * The client initially provides a @a diff_editor/@a diff_baton to the RA + * layer; this editor contains knowledge of where the common diff + * root is in the working copy (when open_root() is called). + * + * In return, the client receives a @a reporter/@a report_baton. The + * client then describes its working copy by making calls into the + * @a reporter. + * + * When finished, the client calls @a reporter->finish_report(). The + * RA layer then does a complete drive of @a diff_editor, ending with + * close_edit(), to transmit the diff. + * + * @a diff_target is an optional single path component will restrict + * the scope of the diff to an entry in the directory represented by + * the @a session's URL, or empty if the entire directory is meant to be + * one of the diff paths. + * + * The working copy will be diffed against @a versus_url as it exists + * in revision @a revision, or as it is in head if @a revision is + * @c SVN_INVALID_REVNUM. + * + * Use @a ignore_ancestry to control whether or not items being + * diffed will be checked for relatedness first. Unrelated items + * are typically transmitted to the editor as a deletion of one thing + * and the addition of another, but if this flag is @c TRUE, + * unrelated items will be diffed as if they were related. + * + * Diff only as deeply as @a depth indicates. + * + * The caller may not perform any RA operations using @a session before + * finishing the report, and may not perform any RA operations using + * @a session from within the editing operations of @a diff_editor. + * + * @a text_deltas instructs the driver of the @a diff_editor to enable + * the generation of text deltas. If @a text_deltas is FALSE the window + * handler returned by apply_textdelta will be called once with a NULL + * @c svn_txdelta_window_t pointer. + * + * Use @a pool for memory allocation. + * + * @note The reporter provided by this function does NOT supply copy- + * from information to the diff editor callbacks. + * + * @note In order to prevent pre-1.5 servers from doing more work than + * needed, and sending too much data back, a pre-1.5 'recurse' + * directive may be sent to the server, based on @a depth. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_do_diff3(svn_ra_session_t *session, + const svn_ra_reporter3_t **reporter, + void **report_baton, + svn_revnum_t revision, + const char *diff_target, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t text_deltas, + const char *versus_url, + const svn_delta_editor_t *diff_editor, + void *diff_baton, + apr_pool_t *pool); + +/** + * Similar to svn_ra_do_diff3(), but taking @c svn_ra_reporter2_t + * instead of @c svn_ra_reporter3_t, and therefore only able to report + * @c svn_depth_infinity for depths. Perform the diff according to + * @a recurse: if TRUE, then @a depth is @c svn_depth_infinity, else + * it is @c svn_depth_files. + * + * @deprecated Provided for compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_diff2(svn_ra_session_t *session, + const svn_ra_reporter2_t **reporter, + void **report_baton, + svn_revnum_t revision, + const char *diff_target, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t text_deltas, + const char *versus_url, + const svn_delta_editor_t *diff_editor, + void *diff_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_ra_do_diff2(), but with @a text_deltas set to @c TRUE. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_do_diff(svn_ra_session_t *session, + const svn_ra_reporter2_t **reporter, + void **report_baton, + svn_revnum_t revision, + const char *diff_target, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + const char *versus_url, + const svn_delta_editor_t *diff_editor, + void *diff_baton, + apr_pool_t *pool); + +/** + * Invoke @a receiver with @a receiver_baton on each log message from + * @a start to @a end. @a start may be greater or less than @a end; + * this just controls whether the log messages are processed in descending + * or ascending revision number order. + * + * If @a start or @a end is @c SVN_INVALID_REVNUM, it defaults to youngest. + * + * If @a paths is non-NULL and has one or more elements, then only show + * revisions in which at least one of @a paths was changed (i.e., if + * file, text or props changed; if dir, props changed or an entry + * was added or deleted). Each path is an <tt>const char *</tt>, relative + * to the @a session's common parent. + * + * If @a limit is non-zero only invoke @a receiver on the first @a limit + * logs. + * + * If @a discover_changed_paths, then each call to @a receiver passes a + * <tt>const apr_hash_t *</tt> for the receiver's @a changed_paths argument; + * the hash's keys are all the paths committed in that revision, the hash's + * values are <tt>const svn_log_changed_path2_t *</tt> for each committed + * path. Otherwise, each call to receiver passes NULL for @a changed_paths. + * + * If @a strict_node_history is set, copy history will not be traversed + * (if any exists) when harvesting the revision logs for each path. + * + * If @a include_merged_revisions is set, log information for revisions + * which have been merged to @a targets will also be returned. + * + * If @a revprops is NULL, retrieve all revision properties; else, retrieve + * only the revision properties named by the (const char *) array elements + * (i.e. retrieve none if the array is empty). + * + * If any invocation of @a receiver returns error, return that error + * immediately and without wrapping it. + * + * If @a start or @a end is a non-existent revision, return the error + * @c SVN_ERR_FS_NO_SUCH_REVISION, without ever invoking @a receiver. + * + * See also the documentation for @c svn_log_message_receiver_t. + * + * The caller may not invoke any RA operations using @a session from + * within @a receiver. + * + * Use @a pool for memory allocation. + * + * @note If @a paths is NULL or empty, the result depends on the + * server. Pre-1.5 servers will send nothing; 1.5 servers will + * effectively perform the log operation on the root of the + * repository. This behavior may be changed in the future to ensure + * consistency across all pedigrees of server. + * + * @note Pre-1.5 servers do not support custom revprop retrieval; if @a + * revprops is NULL or contains a revprop other than svn:author, svn:date, + * or svn:log, an @c SVN_ERR_RA_NOT_IMPLEMENTED error is returned. + * + * @since New in 1.5. + */ + +svn_error_t * +svn_ra_get_log2(svn_ra_session_t *session, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_boolean_t include_merged_revisions, + const apr_array_header_t *revprops, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + +/** + * Similar to svn_ra_get_log2(), but uses @c svn_log_message_receiver_t + * instead of @c svn_log_entry_receiver_t. Also, @a + * include_merged_revisions is set to @c FALSE and @a revprops is + * svn:author, svn:date, and svn:log. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_log(svn_ra_session_t *session, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_log_message_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + +/** + * Set @a *kind to the node kind associated with @a path at @a revision. + * If @a path does not exist under @a revision, set @a *kind to + * @c svn_node_none. @a path is relative to the @a session's parent URL. + * + * Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_check_path(svn_ra_session_t *session, + const char *path, + svn_revnum_t revision, + svn_node_kind_t *kind, + apr_pool_t *pool); + +/** + * Set @a *dirent to an @c svn_dirent_t associated with @a path at @a + * revision. @a path is relative to the @a session's parent's URL. + * If @a path does not exist in @a revision, set @a *dirent to NULL. + * + * Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_stat(svn_ra_session_t *session, + const char *path, + svn_revnum_t revision, + svn_dirent_t **dirent, + apr_pool_t *pool); + + +/** + * Set @a *uuid to the repository's UUID, allocated in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_uuid2(svn_ra_session_t *session, + const char **uuid, + apr_pool_t *pool); + +/** + * Similar to svn_ra_get_uuid2(), but returns the value allocated in + * @a session's pool. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_uuid(svn_ra_session_t *session, + const char **uuid, + apr_pool_t *pool); + +/** + * Set @a *url to the repository's root URL, allocated in @a pool. + * The value will not include a trailing '/'. The returned URL is + * guaranteed to be a prefix of the @a session's URL. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_repos_root2(svn_ra_session_t *session, + const char **url, + apr_pool_t *pool); + + +/** + * Similar to svn_ra_get_repos_root2(), but returns the value + * allocated in @a session's pool. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_repos_root(svn_ra_session_t *session, + const char **url, + apr_pool_t *pool); + +/** + * Set @a *locations to the locations (at the repository revisions + * @a location_revisions) of the file identified by @a path in + * @a peg_revision. @a path is relative to the URL to which + * @a session was opened. @a location_revisions is an array of + * @c svn_revnum_t's. @a *locations will be a mapping from the revisions to + * their appropriate absolute paths. If the file doesn't exist in a + * location_revision, that revision will be ignored. + * + * Use @a pool for all allocations. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_get_locations(svn_ra_session_t *session, + apr_hash_t **locations, + const char *path, + svn_revnum_t peg_revision, + const apr_array_header_t *location_revisions, + apr_pool_t *pool); + + +/** + * Call @a receiver (with @a receiver_baton) for each segment in the + * location history of @a path in @a peg_revision, working backwards in + * time from @a start_rev to @a end_rev. + * + * @a end_rev may be @c SVN_INVALID_REVNUM to indicate that you want + * to trace the history of the object to its origin. + * + * @a start_rev may be @c SVN_INVALID_REVNUM to indicate "the HEAD + * revision". Otherwise, @a start_rev must be younger than @a end_rev + * (unless @a end_rev is @c SVN_INVALID_REVNUM). + * + * @a peg_revision may be @c SVN_INVALID_REVNUM to indicate "the HEAD + * revision", and must evaluate to be at least as young as @a start_rev. + * + * Use @a pool for all allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_location_segments(svn_ra_session_t *session, + const char *path, + svn_revnum_t peg_revision, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_location_segment_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + +/** + * Retrieve a subset of the interesting revisions of a file @a path + * as seen in revision @a end (see svn_fs_history_prev() for a + * definition of "interesting revisions"). Invoke @a handler with + * @a handler_baton as its first argument for each such revision. + * @a session is an open RA session. Use @a pool for all allocations. + * + * If there is an interesting revision of the file that is less than or + * equal to @a start, the iteration will begin at that revision. + * Else, the iteration will begin at the first revision of the file in + * the repository, which has to be less than or equal to @a end. Note + * that if the function succeeds, @a handler will have been called at + * least once. + * + * In a series of calls to @a handler, the file contents for the first + * interesting revision will be provided as a text delta against the + * empty file. In the following calls, the delta will be against the + * fulltext contents for the previous call. + * + * If @a include_merged_revisions is TRUE, revisions which are + * included as a result of a merge between @a start and @a end will be + * included. + * + * @note This functionality is not available in pre-1.1 servers. If the + * server doesn't implement it, an alternative (but much slower) + * implementation based on svn_ra_get_log2() is used. + * + * On subversion 1.8 and newer servers this function has been enabled + * to support reversion of the revision range for @a include_merged_revision + * @c FALSE reporting by switching @a end with @a start. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_get_file_revs2(svn_ra_session_t *session, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t include_merged_revisions, + svn_file_rev_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + +/** + * Similar to svn_ra_get_file_revs2(), but with @a include_merged_revisions + * set to FALSE. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_file_revs(svn_ra_session_t *session, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_ra_file_rev_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + +/** + * Lock each path in @a path_revs, which is a hash whose keys are the + * paths to be locked, and whose values are the corresponding base + * revisions for each path. The keys are (const char *) and the + * revisions are (svn_revnum_t *). + * + * Note that locking is never anonymous, so any server implementing + * this function will have to "pull" a username from the client, if + * it hasn't done so already. + * + * @a comment is optional: it's either an xml-escapable string + * which describes the lock, or it is NULL. + * + * If any path is already locked by a different user, then call @a + * lock_func/@a lock_baton with an error. If @a steal_lock is TRUE, + * then "steal" the existing lock(s) anyway, even if the RA username + * does not match the current lock's owner. Delete any lock on the + * path, and unconditionally create a new lock. + * + * For each path, if its base revision (in @a path_revs) is a valid + * revnum, then do an out-of-dateness check. If the revnum is less + * than the last-changed-revision of any path (or if a path doesn't + * exist in HEAD), call @a lock_func/@a lock_baton with an + * SVN_ERR_RA_OUT_OF_DATE error. + * + * After successfully locking a file, @a lock_func is called with the + * @a lock_baton. + * + * Use @a pool for temporary allocations. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_lock(svn_ra_session_t *session, + apr_hash_t *path_revs, + const char *comment, + svn_boolean_t steal_lock, + svn_ra_lock_callback_t lock_func, + void *lock_baton, + apr_pool_t *pool); + +/** + * Remove the repository lock for each path in @a path_tokens. + * @a path_tokens is a hash whose keys are the paths to be locked, and + * whose values are the corresponding lock tokens for each path. If + * the path has no corresponding lock token, or if @a break_lock is TRUE, + * then the corresponding value shall be "". + * + * Note that unlocking is never anonymous, so any server + * implementing this function will have to "pull" a username from + * the client, if it hasn't done so already. + * + * If @a token points to a lock, but the RA username doesn't match the + * lock's owner, call @a lock_func/@a lock_baton with an error. If @a + * break_lock is TRUE, however, instead allow the lock to be "broken" + * by the RA user. + * + * After successfully unlocking a path, @a lock_func is called with + * the @a lock_baton. + * + * Use @a pool for temporary allocations. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_unlock(svn_ra_session_t *session, + apr_hash_t *path_tokens, + svn_boolean_t break_lock, + svn_ra_lock_callback_t lock_func, + void *lock_baton, + apr_pool_t *pool); + +/** + * If @a path is locked, set @a *lock to an svn_lock_t which + * represents the lock, allocated in @a pool. If @a path is not + * locked, set @a *lock to NULL. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_get_lock(svn_ra_session_t *session, + svn_lock_t **lock, + const char *path, + apr_pool_t *pool); + +/** + * Set @a *locks to a hashtable which represents all locks on or + * below @a path. + * + * @a depth limits the returned locks to those associated with paths + * within the specified depth of @a path, and must be one of the + * following values: #svn_depth_empty, #svn_depth_files, + * #svn_depth_immediates, or #svn_depth_infinity. + * + * The hashtable maps (const char *) absolute fs paths to (const + * svn_lock_t *) structures. The hashtable -- and all keys and + * values -- are allocated in @a pool. + * + * @note It is not considered an error for @a path to not exist in HEAD. + * Such a search will simply return no locks. + * + * @note This functionality is not available in pre-1.2 servers. If the + * server doesn't implement it, an @c SVN_ERR_RA_NOT_IMPLEMENTED error is + * returned. + * + * @since New in 1.7. + */ +svn_error_t * +svn_ra_get_locks2(svn_ra_session_t *session, + apr_hash_t **locks, + const char *path, + svn_depth_t depth, + apr_pool_t *pool); + +/** + * Similar to svn_ra_get_locks2(), but with @a depth always passed as + * #svn_depth_infinity. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_locks(svn_ra_session_t *session, + apr_hash_t **locks, + const char *path, + apr_pool_t *pool); + + +/** + * Replay the changes from a range of revisions between @a start_revision + * and @a end_revision. + * + * When receiving information for one revision, a callback @a revstart_func is + * called; this callback will provide an editor and baton through which the + * revision will be replayed. + * When replaying the revision is finished, callback @a revfinish_func will be + * called so the editor can be closed. + * + * Changes will be limited to those that occur under @a session's URL, and + * the server will assume that the client has no knowledge of revisions + * prior to @a low_water_mark. These two limiting factors define the portion + * of the tree that the server will assume the client already has knowledge of, + * and thus any copies of data from outside that part of the tree will be + * sent in their entirety, not as simple copies or deltas against a previous + * version. + * + * If @a send_deltas is @c TRUE, the actual text and property changes in + * the revision will be sent, otherwise dummy text deltas and NULL property + * changes will be sent instead. + * + * @a pool is used for all allocation. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_replay_range(svn_ra_session_t *session, + svn_revnum_t start_revision, + svn_revnum_t end_revision, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas, + svn_ra_replay_revstart_callback_t revstart_func, + svn_ra_replay_revfinish_callback_t revfinish_func, + void *replay_baton, + apr_pool_t *pool); + +/** + * Replay the changes from @a revision through @a editor and @a edit_baton. + * + * Changes will be limited to those that occur under @a session's URL, and + * the server will assume that the client has no knowledge of revisions + * prior to @a low_water_mark. These two limiting factors define the portion + * of the tree that the server will assume the client already has knowledge of, + * and thus any copies of data from outside that part of the tree will be + * sent in their entirety, not as simple copies or deltas against a previous + * version. + * + * If @a send_deltas is @c TRUE, the actual text and property changes in + * the revision will be sent, otherwise dummy text deltas and null property + * changes will be sent instead. + * + * @a pool is used for all allocation. + * + * @since New in 1.4. + */ +svn_error_t * +svn_ra_replay(svn_ra_session_t *session, + svn_revnum_t revision, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas, + const svn_delta_editor_t *editor, + void *edit_baton, + apr_pool_t *pool); + +/** + * Given @a path at revision @a peg_revision, set @a *revision_deleted to the + * revision @a path was first deleted, within the inclusive revision range + * defined by @a peg_revision and @a end_revision. @a path is relative + * to the URL in @a session. + * + * If @a path does not exist at @a peg_revision or was not deleted within + * the specified range, then set @a *revision_deleted to @c SVN_INVALID_REVNUM. + * If @a peg_revision or @a end_revision are invalid or if @a peg_revision is + * greater than @a end_revision, then return @c SVN_ERR_CLIENT_BAD_REVISION. + * + * Use @a pool for all allocations. + * + * @since New in 1.6. + */ +svn_error_t * +svn_ra_get_deleted_rev(svn_ra_session_t *session, + const char *path, + svn_revnum_t peg_revision, + svn_revnum_t end_revision, + svn_revnum_t *revision_deleted, + apr_pool_t *pool); + +/** + * Set @a *inherited_props to a depth-first ordered array of + * #svn_prop_inherited_item_t * structures representing the properties + * inherited by @a path at @a revision (or the 'head' revision if + * @a revision is @c SVN_INVALID_REVNUM). Interpret @a path relative to + * the URL in @a session. Use @a pool for all allocations. If no + * inheritable properties are found, then set @a *inherited_props to + * an empty array. + * + * The #svn_prop_inherited_item_t->path_or_url members of the + * #svn_prop_inherited_item_t * structures in @a *inherited_props are + * paths relative to the repository root URL (of the repository which + * @a ra_session is associated). + * + * Allocate @a *inherited_props in @a result_pool. Use @a scratch_pool + * for temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_ra_get_inherited_props(svn_ra_session_t *session, + apr_array_header_t **inherited_props, + const char *path, + svn_revnum_t revision, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * @defgroup Capabilities Dynamically query the server's capabilities. + * + * @{ + */ + +/** + * Set @a *has to TRUE if the server represented by @a session has + * @a capability (one of the capabilities beginning with + * @c "SVN_RA_CAPABILITY_"), else set @a *has to FALSE. + * + * If @a capability isn't recognized, throw @c SVN_ERR_UNKNOWN_CAPABILITY, + * with the effect on @a *has undefined. + * + * Use @a pool for all allocation. + * + * @since New in 1.5. + */ +svn_error_t * +svn_ra_has_capability(svn_ra_session_t *session, + svn_boolean_t *has, + const char *capability, + apr_pool_t *pool); + +/** + * The capability of understanding @c svn_depth_t (e.g., the server + * understands what the client means when the client describes the + * depth of a working copy to the server.) + * + * @since New in 1.5. + */ +#define SVN_RA_CAPABILITY_DEPTH "depth" + +/** + * The capability of doing the right thing with merge-tracking + * information. This capability should be reported bidirectionally, + * because some repositories may want to reject clients that do not + * self-report as knowing how to handle merge-tracking. + * + * @since New in 1.5. + */ +#define SVN_RA_CAPABILITY_MERGEINFO "mergeinfo" + +/** + * The capability of retrieving arbitrary revprops in svn_ra_get_log2. + * + * @since New in 1.5. + */ +#define SVN_RA_CAPABILITY_LOG_REVPROPS "log-revprops" + +/** + * The capability of replaying a directory in the repository (partial replay). + * + * @since New in 1.5. + */ +#define SVN_RA_CAPABILITY_PARTIAL_REPLAY "partial-replay" + +/** + * The capability of including revision properties in a commit. + * + * @since New in 1.5. + */ +#define SVN_RA_CAPABILITY_COMMIT_REVPROPS "commit-revprops" + +/** + * The capability of specifying (and atomically verifying) expected + * preexisting values when modifying revprops. + * + * @since New in 1.7. + */ +#define SVN_RA_CAPABILITY_ATOMIC_REVPROPS "atomic-revprops" + +/** + * The capability to get inherited properties. + * + * @since New in 1.8. + */ +#define SVN_RA_CAPABILITY_INHERITED_PROPS "inherited-props" + +/** + * The capability of a server to automatically remove transaction + * properties prefixed with SVN_PROP_EPHEMERAL_PREFIX. + * + * @since New in 1.8. + */ +#define SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS "ephemeral-txnprops" + +/** + * The capability of a server to walk revisions backwards in + * svn_ra_get_file_revs2 + * + * @since New in 1.8. + */ +#define SVN_RA_CAPABILITY_GET_FILE_REVS_REVERSE "get-file-revs-reversed" + + +/* *** PLEASE READ THIS IF YOU ADD A NEW CAPABILITY *** + * + * RA layers generally fetch all capabilities when asked about any + * capability, to save future round trips. So if you add a new + * capability here, make sure to update the RA layers to remember + * it after any capabilities query. + * + * Also note that capability strings should not include colons, + * because we pass a list of client capabilities to the start-commit + * hook as a single, colon-separated string. + */ + +/** @} */ + + +/** + * Append a textual list of all available RA modules to the stringbuf + * @a output. + * + * @since New in 1.2. + */ +svn_error_t * +svn_ra_print_modules(svn_stringbuf_t *output, + apr_pool_t *pool); + + +/** + * Similar to svn_ra_print_modules(). + * @a ra_baton is ignored. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_print_ra_libraries(svn_stringbuf_t **descriptions, + void *ra_baton, + apr_pool_t *pool); + + + +/** + * Using this callback struct is similar to calling the newer public + * interface that is based on @c svn_ra_session_t. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef struct svn_ra_plugin_t +{ + /** The proper name of the RA library, (like "ra_serf" or "ra_local") */ + const char *name; + + /** Short doc string printed out by `svn --version` */ + const char *description; + + /* The vtable hooks */ + + /** Call svn_ra_open() and set @a session_baton to an object representing + * the new session. All other arguments are passed to svn_ra_open(). + */ + svn_error_t *(*open)(void **session_baton, + const char *repos_URL, + const svn_ra_callbacks_t *callbacks, + void *callback_baton, + apr_hash_t *config, + apr_pool_t *pool); + + /** Call svn_ra_get_latest_revnum() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*get_latest_revnum)(void *session_baton, + svn_revnum_t *latest_revnum, + apr_pool_t *pool); + + /** Call svn_ra_get_dated_revision() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*get_dated_revision)(void *session_baton, + svn_revnum_t *revision, + apr_time_t tm, + apr_pool_t *pool); + + /** Call svn_ra_change_rev_prop() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*change_rev_prop)(void *session_baton, + svn_revnum_t rev, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + + /** Call svn_ra_rev_proplist() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*rev_proplist)(void *session_baton, + svn_revnum_t rev, + apr_hash_t **props, + apr_pool_t *pool); + + /** Call svn_ra_rev_prop() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*rev_prop)(void *session_baton, + svn_revnum_t rev, + const char *name, + svn_string_t **value, + apr_pool_t *pool); + + /** Call svn_ra_get_commit_editor() with the session associated with + * @a session_baton and all other arguments plus @a lock_tokens set to + * @c NULL and @a keep_locks set to @c TRUE. + */ + svn_error_t *(*get_commit_editor)(void *session_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + const char *log_msg, + svn_commit_callback_t callback, + void *callback_baton, + apr_pool_t *pool); + + /** Call svn_ra_get_file() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*get_file)(void *session_baton, + const char *path, + svn_revnum_t revision, + svn_stream_t *stream, + svn_revnum_t *fetched_rev, + apr_hash_t **props, + apr_pool_t *pool); + + /** Call svn_ra_get_dir() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*get_dir)(void *session_baton, + const char *path, + svn_revnum_t revision, + apr_hash_t **dirents, + svn_revnum_t *fetched_rev, + apr_hash_t **props, + apr_pool_t *pool); + + /** Call svn_ra_do_update() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*do_update)(void *session_baton, + const svn_ra_reporter_t **reporter, + void **report_baton, + svn_revnum_t revision_to_update_to, + const char *update_target, + svn_boolean_t recurse, + const svn_delta_editor_t *update_editor, + void *update_baton, + apr_pool_t *pool); + + /** Call svn_ra_do_switch() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*do_switch)(void *session_baton, + const svn_ra_reporter_t **reporter, + void **report_baton, + svn_revnum_t revision_to_switch_to, + const char *switch_target, + svn_boolean_t recurse, + const char *switch_url, + const svn_delta_editor_t *switch_editor, + void *switch_baton, + apr_pool_t *pool); + + /** Call svn_ra_do_status() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*do_status)(void *session_baton, + const svn_ra_reporter_t **reporter, + void **report_baton, + const char *status_target, + svn_revnum_t revision, + svn_boolean_t recurse, + const svn_delta_editor_t *status_editor, + void *status_baton, + apr_pool_t *pool); + + /** Call svn_ra_do_diff() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*do_diff)(void *session_baton, + const svn_ra_reporter_t **reporter, + void **report_baton, + svn_revnum_t revision, + const char *diff_target, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + const char *versus_url, + const svn_delta_editor_t *diff_editor, + void *diff_baton, + apr_pool_t *pool); + + /** Call svn_ra_get_log() with the session associated with + * @a session_baton and all other arguments. @a limit is set to 0. + */ + svn_error_t *(*get_log)(void *session_baton, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_log_message_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + + /** Call svn_ra_check_path() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*check_path)(void *session_baton, + const char *path, + svn_revnum_t revision, + svn_node_kind_t *kind, + apr_pool_t *pool); + + /** Call svn_ra_get_uuid() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*get_uuid)(void *session_baton, + const char **uuid, + apr_pool_t *pool); + + /** Call svn_ra_get_repos_root() with the session associated with + * @a session_baton and all other arguments. + */ + svn_error_t *(*get_repos_root)(void *session_baton, + const char **url, + apr_pool_t *pool); + + /** + * Call svn_ra_get_locations() with the session associated with + * @a session_baton and all other arguments. + * + * @since New in 1.1. + */ + svn_error_t *(*get_locations)(void *session_baton, + apr_hash_t **locations, + const char *path, + svn_revnum_t peg_revision, + apr_array_header_t *location_revisions, + apr_pool_t *pool); + + /** + * Call svn_ra_get_file_revs() with the session associated with + * @a session_baton and all other arguments. + * + * @since New in 1.1. + */ + svn_error_t *(*get_file_revs)(void *session_baton, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_ra_file_rev_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + + /** + * Return the plugin's version information. + * + * @since New in 1.1. + */ + const svn_version_t *(*get_version)(void); + + +} svn_ra_plugin_t; + +/** + * All "ra_FOO" implementations *must* export a function named + * svn_ra_FOO_init() of type @c svn_ra_init_func_t. + * + * When called by libsvn_client, this routine adds an entry (or + * entries) to the hash table for any URL schemes it handles. The hash + * value must be of type (<tt>@c svn_ra_plugin_t *</tt>). @a pool is a + * pool for allocating configuration / one-time data. + * + * This type is defined to use the "C Calling Conventions" to ensure that + * abi_version is the first parameter. The RA plugin must check that value + * before accessing the other parameters. + * + * ### need to force this to be __cdecl on Windows... how?? + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef svn_error_t *(*svn_ra_init_func_t)(int abi_version, + apr_pool_t *pool, + apr_hash_t *hash); + +/** + * The current ABI (Application Binary Interface) version for the + * RA plugin model. This version number will change when the ABI + * between the SVN core (e.g. libsvn_client) and the RA plugin changes. + * + * An RA plugin should verify that the passed version number is acceptable + * before accessing the rest of the parameters, and before returning any + * information. + * + * It is entirely acceptable for an RA plugin to accept multiple ABI + * versions. It can simply interpret the parameters based on the version, + * and it can return different plugin structures. + * + * + * <pre> + * VSN DATE REASON FOR CHANGE + * --- ---------- ------------------------------------------------ + * 1 2001-02-17 Initial revision. + * 2 2004-06-29 Preparing for svn 1.1, which adds new RA vtable funcs. + * 2005-01-19 Rework the plugin interface and don't provide the vtable + * to the client. Separate ABI versions are no longer used. + * </pre> + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +#define SVN_RA_ABI_VERSION 2 + +/* Public RA implementations. */ + +/** Initialize libsvn_ra_serf. + * + * @deprecated Provided for backward compatibility with the 1.1 API. */ +SVN_DEPRECATED +svn_error_t * +svn_ra_dav_init(int abi_version, + apr_pool_t *pool, + apr_hash_t *hash); + +/** Initialize libsvn_ra_local. + * + * @deprecated Provided for backward compatibility with the 1.1 API. */ +SVN_DEPRECATED +svn_error_t * +svn_ra_local_init(int abi_version, + apr_pool_t *pool, + apr_hash_t *hash); + +/** Initialize libsvn_ra_svn. + * + * @deprecated Provided for backward compatibility with the 1.1 API. */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_init(int abi_version, + apr_pool_t *pool, + apr_hash_t *hash); + +/** Initialize libsvn_ra_serf. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.1 API. */ +SVN_DEPRECATED +svn_error_t * +svn_ra_serf_init(int abi_version, + apr_pool_t *pool, + apr_hash_t *hash); + + +/** + * Initialize the compatibility wrapper, using @a pool for any allocations. + * The caller must hold on to @a ra_baton as long as the RA library is used. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_init_ra_libs(void **ra_baton, + apr_pool_t *pool); + +/** + * Return an RA vtable-@a library which can handle URL. A number of + * svn_client_* routines will call this internally, but client apps might + * use it too. $a ra_baton is a baton obtained by a call to + * svn_ra_init_ra_libs(). + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_get_ra_library(svn_ra_plugin_t **library, + void *ra_baton, + const char *url, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_RA_H */ + diff --git a/subversion/include/svn_ra_svn.h b/subversion/include/svn_ra_svn.h new file mode 100644 index 0000000..9c556b8 --- /dev/null +++ b/subversion/include/svn_ra_svn.h @@ -0,0 +1,668 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_ra_svn.h + * @brief libsvn_ra_svn functions used by the server + */ + +#ifndef SVN_RA_SVN_H +#define SVN_RA_SVN_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_file_io.h> /* for apr_file_t */ +#include <apr_network_io.h> /* for apr_socket_t */ + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_config.h" +#include "svn_delta.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** The well-known svn port number. */ +#define SVN_RA_SVN_PORT 3690 + +/** Currently-defined capabilities. */ +#define SVN_RA_SVN_CAP_EDIT_PIPELINE "edit-pipeline" +#define SVN_RA_SVN_CAP_SVNDIFF1 "svndiff1" +#define SVN_RA_SVN_CAP_ABSENT_ENTRIES "absent-entries" +/* maps to SVN_RA_CAPABILITY_COMMIT_REVPROPS: */ +#define SVN_RA_SVN_CAP_COMMIT_REVPROPS "commit-revprops" +/* maps to SVN_RA_CAPABILITY_MERGEINFO: */ +#define SVN_RA_SVN_CAP_MERGEINFO "mergeinfo" +/* maps to SVN_RA_CAPABILITY_DEPTH: */ +#define SVN_RA_SVN_CAP_DEPTH "depth" +/* maps to SVN_RA_CAPABILITY_LOG_REVPROPS */ +#define SVN_RA_SVN_CAP_LOG_REVPROPS "log-revprops" +/* maps to SVN_RA_CAPABILITY_PARTIAL_REPLAY */ +#define SVN_RA_SVN_CAP_PARTIAL_REPLAY "partial-replay" +/* maps to SVN_RA_CAPABILITY_ATOMIC_REVPROPS */ +#define SVN_RA_SVN_CAP_ATOMIC_REVPROPS "atomic-revprops" +/* maps to SVN_RA_CAPABILITY_INHERITED_PROPERTIES: */ +#define SVN_RA_SVN_CAP_INHERITED_PROPS "inherited-props" +/* maps to SVN_RA_CAPABILITY_EPHEMERAL_TXNPROPS */ +#define SVN_RA_SVN_CAP_EPHEMERAL_TXNPROPS "ephemeral-txnprops" +/* maps to SVN_RA_CAPABILITY_GET_FILE_REVS_REVERSE */ +#define SVN_RA_SVN_CAP_GET_FILE_REVS_REVERSE "file-revs-reverse" + + +/** ra_svn passes @c svn_dirent_t fields over the wire as a list of + * words, these are the values used to represent each field. + * + * @defgroup ra_svn_dirent_fields Definitions of ra_svn dirent fields + * @{ + */ + +/** The ra_svn way of saying @c SVN_DIRENT_KIND. */ +#define SVN_RA_SVN_DIRENT_KIND "kind" + +/** The ra_svn way of saying @c SVN_DIRENT_SIZE. */ +#define SVN_RA_SVN_DIRENT_SIZE "size" + +/** The ra_svn way of saying @c SVN_DIRENT_HAS_PROPS. */ +#define SVN_RA_SVN_DIRENT_HAS_PROPS "has-props" + +/** The ra_svn way of saying @c SVN_DIRENT_CREATED_REV. */ +#define SVN_RA_SVN_DIRENT_CREATED_REV "created-rev" + +/** The ra_svn way of saying @c SVN_DIRENT_TIME. */ +#define SVN_RA_SVN_DIRENT_TIME "time" + +/** The ra_svn way of saying @c SVN_DIRENT_LAST_AUTHOR. */ +#define SVN_RA_SVN_DIRENT_LAST_AUTHOR "last-author" + +/** @} */ + +/** A value used to indicate an optional number element in a tuple that was + * not received. + */ +#define SVN_RA_SVN_UNSPECIFIED_NUMBER ~((apr_uint64_t) 0) + +/** A specialized form of @c SVN_ERR to deal with errors which occur in an + * svn_ra_svn_command_handler(). + * + * An error returned with this macro will be passed back to the other side + * of the connection. Use this macro when performing the requested operation; + * use the regular @c SVN_ERR when performing I/O with the client. + */ +#define SVN_CMD_ERR(expr) \ + do { \ + svn_error_t *svn_err__temp = (expr); \ + if (svn_err__temp) \ + return svn_error_create(SVN_ERR_RA_SVN_CMD_ERR, \ + svn_err__temp, NULL); \ + } while (0) + +/** an ra_svn connection. */ +typedef struct svn_ra_svn_conn_st svn_ra_svn_conn_t; + +/** Command handler, used by svn_ra_svn_handle_commands(). */ +typedef svn_error_t *(*svn_ra_svn_command_handler)(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + apr_array_header_t *params, + void *baton); + +/** Command table, used by svn_ra_svn_handle_commands(). + */ +typedef struct svn_ra_svn_cmd_entry_t +{ + /** Name of the command */ + const char *cmdname; + + /** Handler for the command */ + svn_ra_svn_command_handler handler; + + /** Termination flag. If set, command-handling will cease after + * command is processed. */ + svn_boolean_t terminate; +} svn_ra_svn_cmd_entry_t; + +/** Memory representation of an on-the-wire data item. */ +typedef struct svn_ra_svn_item_t +{ + /** Variant indicator. */ + enum { + SVN_RA_SVN_NUMBER, + SVN_RA_SVN_STRING, + SVN_RA_SVN_WORD, + SVN_RA_SVN_LIST + } kind; + /** Variant data. */ + union { + apr_uint64_t number; + svn_string_t *string; + const char *word; + + /** Contains @c svn_ra_svn_item_t's. */ + apr_array_header_t *list; + } u; +} svn_ra_svn_item_t; + +typedef svn_error_t *(*svn_ra_svn_edit_callback)(void *baton); + +/** Initialize a connection structure for the given socket or + * input/output files. + * + * Either @a sock or @a in_file/@a out_file must be set, not both. + * @a compression_level specifies the desired network data compression + * level (zlib) from 0 (no compression) to 9 (best but slowest). + * + * If @a zero_copy_limit is not 0, cached file contents smaller than the + * given limit may be sent directly to the network socket. Otherwise, + * it will be copied into a temporary buffer before being forwarded to + * the network stack. Since the zero-copy code path has to enforce strict + * time-outs, the receiver must be able to process @a zero_copy_limit + * bytes within one second. Even temporary failure to do so may cause + * the server to cancel the respective operation with a time-out error. + * + * To reduce the overhead of checking for cancellation requests from the + * data receiver, set @a error_check_interval to some non-zero value. + * It defines the number of bytes that must have been sent since the last + * check before the next check will be made. + * + * Allocate the result in @a pool. + * + * @since New in 1.8 + */ +svn_ra_svn_conn_t *svn_ra_svn_create_conn3(apr_socket_t *sock, + apr_file_t *in_file, + apr_file_t *out_file, + int compression_level, + apr_size_t zero_copy_limit, + apr_size_t error_check_interval, + apr_pool_t *pool); + +/** Similar to svn_ra_svn_create_conn3() but disables the zero copy code + * path and sets the error checking interval to 0. + * + * @since New in 1.7. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_ra_svn_conn_t * +svn_ra_svn_create_conn2(apr_socket_t *sock, + apr_file_t *in_file, + apr_file_t *out_file, + int compression_level, + apr_pool_t *pool); + +/** Similar to svn_ra_svn_create_conn2() but uses the default + * compression level (#SVN_DELTA_COMPRESSION_LEVEL_DEFAULT) for network + * transmissions. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_ra_svn_conn_t * +svn_ra_svn_create_conn(apr_socket_t *sock, + apr_file_t *in_file, + apr_file_t *out_file, + apr_pool_t *pool); + +/** Add the capabilities in @a list to @a conn's capabilities. + * @a list contains svn_ra_svn_item_t entries (which should be of type + * SVN_RA_SVN_WORD; a malformed data error will result if any are not). + * + * This is idempotent: if a given capability was already set for + * @a conn, it remains set. + */ +svn_error_t * +svn_ra_svn_set_capabilities(svn_ra_svn_conn_t *conn, + const apr_array_header_t *list); + +/** Return @c TRUE if @a conn has the capability @a capability, or + * @c FALSE if it does not. */ +svn_boolean_t +svn_ra_svn_has_capability(svn_ra_svn_conn_t *conn, + const char *capability); + +/** Return the data compression level to use for network transmissions. + * + * @since New in 1.7. + */ +int +svn_ra_svn_compression_level(svn_ra_svn_conn_t *conn); + +/** Return the zero-copy data block limit to use for network + * transmissions. + * + * @see http://en.wikipedia.org/wiki/Zero-copy + * + * @since New in 1.8. + */ +apr_size_t +svn_ra_svn_zero_copy_limit(svn_ra_svn_conn_t *conn); + +/** Returns the remote address of the connection as a string, if known, + * or NULL if inapplicable. */ +const char * +svn_ra_svn_conn_remote_host(svn_ra_svn_conn_t *conn); + +/** Set @a *editor and @a *edit_baton to an editor which will pass editing + * operations over the network, using @a conn and @a pool. + * + * Upon successful completion of the edit, the editor will invoke @a callback + * with @a callback_baton as an argument. + */ +void +svn_ra_svn_get_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_ra_svn_edit_callback callback, + void *callback_baton); + +/** Receive edit commands over the network and use them to drive @a editor + * with @a edit_baton. On return, @a *aborted will be set if the edit was + * aborted. The drive can be terminated with a finish-replay command only + * if @a for_replay is TRUE. + * + * @since New in 1.4. + */ +svn_error_t * +svn_ra_svn_drive_editor2(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_boolean_t *aborted, + svn_boolean_t for_replay); + +/** Like svn_ra_svn_drive_editor2, but with @a for_replay always FALSE. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_drive_editor(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_boolean_t *aborted); + +/** This function is only intended for use by svnserve. + * + * Perform CRAM-MD5 password authentication. On success, return + * SVN_NO_ERROR with *user set to the username and *success set to + * TRUE. On an error which can be reported to the client, report the + * error and return SVN_NO_ERROR with *success set to FALSE. On + * communications failure, return an error. + */ +svn_error_t * +svn_ra_svn_cram_server(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_config_t *pwdb, + const char **user, + svn_boolean_t *success); + +/** + * Get libsvn_ra_svn version information. + * @since New in 1.1. + */ +const svn_version_t * +svn_ra_svn_version(void); + +/** + * @defgroup ra_svn_deprecated ra_svn low-level functions + * @{ + */ + +/** Write a number over the net. + * + * Writes will be buffered until the next read or flush. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_number(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + apr_uint64_t number); + +/** Write a string over the net. + * + * Writes will be buffered until the next read or flush. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_string(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_string_t *str); + +/** Write a cstring over the net. + * + * Writes will be buffered until the next read or flush. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_cstring(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *s); + +/** Write a word over the net. + * + * Writes will be buffered until the next read or flush. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_word(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *word); + +/** Write a list of properties over the net. @a props is allowed to be NULL, + * in which case an empty list will be written out. + * + * @since New in 1.5. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_proplist(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + apr_hash_t *props); + +/** Begin a list. Writes will be buffered until the next read or flush. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_start_list(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** End a list. Writes will be buffered until the next read or flush. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_end_list(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Flush the write buffer. + * + * Normally this shouldn't be necessary, since the write buffer is flushed + * when a read is attempted. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_flush(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Write a tuple, using a printf-like interface. + * + * The format string @a fmt may contain: + * + *@verbatim + Spec Argument type Item type + ---- -------------------- --------- + n apr_uint64_t Number + r svn_revnum_t Number + s const svn_string_t * String + c const char * String + w const char * Word + b svn_boolean_t Word ("true" or "false") + ( Begin tuple + ) End tuple + ? Remaining elements optional + ! (at beginning or end) Suppress opening or closing of tuple + @endverbatim + * + * Inside the optional part of a tuple, 'r' values may be @c + * SVN_INVALID_REVNUM, 'n' values may be + * SVN_RA_SVN_UNSPECIFIED_NUMBER, and 's', 'c', and 'w' values may be + * @c NULL; in these cases no data will be written. 'b' and '(' may + * not appear in the optional part of a tuple. Either all or none of + * the optional values should be valid. + * + * (If we ever have a need for an optional boolean value, we should + * invent a 'B' specifier which stores a boolean into an int, using -1 + * for unspecified. Right now there is no need for such a thing.) + * + * Use the '!' format specifier to write partial tuples when you have + * to transmit an array or other unusual data. For example, to write + * a tuple containing a revision, an array of words, and a boolean: + * @code + SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "r(!", rev)); + for (i = 0; i < n; i++) + SVN_ERR(svn_ra_svn_write_word(conn, pool, words[i])); + SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "!)b", flag)); @endcode + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_tuple(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Read an item from the network into @a *item. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_read_item(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_ra_svn_item_t **item); + +/** Scan data on @a conn until we find something which looks like the + * beginning of an svn server greeting (an open paren followed by a + * whitespace character). This function is appropriate for beginning + * a client connection opened in tunnel mode, since people's dotfiles + * sometimes write output to stdout. It may only be called at the + * beginning of a client connection. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_skip_leading_garbage(svn_ra_svn_conn_t *conn, + apr_pool_t *pool); + +/** Parse an array of @c svn_sort__item_t structures as a tuple, using a + * printf-like interface. The format string @a fmt may contain: + * + *@verbatim + Spec Argument type Item type + ---- -------------------- --------- + n apr_uint64_t * Number + r svn_revnum_t * Number + s svn_string_t ** String + c const char ** String + w const char ** Word + b svn_boolean_t * Word ("true" or "false") + B apr_uint64_t * Word ("true" or "false") + l apr_array_header_t ** List + ( Begin tuple + ) End tuple + ? Tuple is allowed to end here + @endverbatim + * + * Note that a tuple is only allowed to end precisely at a '?', or at + * the end of the specification. So if @a fmt is "c?cc" and @a list + * contains two elements, an error will result. + * + * 'B' is similar to 'b', but may be used in the optional tuple specification. + * It returns TRUE, FALSE, or SVN_RA_SVN_UNSPECIFIED_NUMBER. + * + * If an optional part of a tuple contains no data, 'r' values will be + * set to @c SVN_INVALID_REVNUM, 'n' and 'B' values will be set to + * SVN_RA_SVN_UNSPECIFIED_NUMBER, and 's', 'c', 'w', and 'l' values + * will be set to @c NULL. 'b' may not appear inside an optional + * tuple specification; use 'B' instead. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_parse_tuple(const apr_array_header_t *list, + apr_pool_t *pool, + const char *fmt, ...); + +/** Read a tuple from the network and parse it as a tuple, using the + * format string notation from svn_ra_svn_parse_tuple(). + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_read_tuple(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Parse an array of @c svn_ra_svn_item_t structures as a list of + * properties, storing the properties in a hash table. + * + * @since New in 1.5. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_parse_proplist(const apr_array_header_t *list, + apr_pool_t *pool, + apr_hash_t **props); + +/** Read a command response from the network and parse it as a tuple, using + * the format string notation from svn_ra_svn_parse_tuple(). + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_read_cmd_response(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Accept commands over the network and handle them according to @a + * commands. Command handlers will be passed @a conn, a subpool of @a + * pool (cleared after each command is handled), the parameters of the + * command, and @a baton. Commands will be accepted until a + * terminating command is received (a command with "terminate" set in + * the command table). If a command handler returns an error wrapped + * in SVN_RA_SVN_CMD_ERR (see the @c SVN_CMD_ERR macro), the error + * will be reported to the other side of the connection and the + * command loop will continue; any other kind of error (typically a + * network or protocol error) is passed through to the caller. + * + * @since New in 1.6. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_handle_commands2(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_ra_svn_cmd_entry_t *commands, + void *baton, + svn_boolean_t error_on_disconnect); + +/** Similar to svn_ra_svn_handle_commands2 but @a error_on_disconnect + * is always @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_handle_commands(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const svn_ra_svn_cmd_entry_t *commands, + void *baton); + +/** Write a command over the network, using the same format string notation + * as svn_ra_svn_write_tuple(). + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_cmd(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *cmdname, + const char *fmt, ...); + +/** Write a successful command response over the network, using the + * same format string notation as svn_ra_svn_write_tuple(). Do not use + * partial tuples with this function; if you need to use partial + * tuples, just write out the "success" and argument tuple by hand. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_cmd_response(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + const char *fmt, ...); + +/** Write an unsuccessful command response over the network. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * RA_SVN low-level functions are no longer considered public. + */ +SVN_DEPRECATED +svn_error_t * +svn_ra_svn_write_cmd_failure(svn_ra_svn_conn_t *conn, + apr_pool_t *pool, + svn_error_t *err); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_RA_SVN_H */ diff --git a/subversion/include/svn_repos.h b/subversion/include/svn_repos.h new file mode 100644 index 0000000..2cec6dd --- /dev/null +++ b/subversion/include/svn_repos.h @@ -0,0 +1,3406 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_repos.h + * @brief Tools built on top of the filesystem. + */ + +#ifndef SVN_REPOS_H +#define SVN_REPOS_H + +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_tables.h> +#include <apr_time.h> + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_delta.h" +#include "svn_fs.h" +#include "svn_io.h" +#include "svn_mergeinfo.h" + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* ---------------------------------------------------------------*/ + +/** + * Get libsvn_repos version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_repos_version(void); + + +/* Some useful enums. They need to be declared here for the notification + system to pick them up. */ +/** The different "actions" attached to nodes in the dumpfile. */ +enum svn_node_action +{ + svn_node_action_change, + svn_node_action_add, + svn_node_action_delete, + svn_node_action_replace +}; + +/** The different policies for processing the UUID in the dumpfile. */ +enum svn_repos_load_uuid +{ + /** only update uuid if the repos has no revisions. */ + svn_repos_load_uuid_default, + /** never update uuid. */ + svn_repos_load_uuid_ignore, + /** always update uuid. */ + svn_repos_load_uuid_force +}; + + +/** Callback type for checking authorization on paths produced by (at + * least) svn_repos_dir_delta2(). + * + * Set @a *allowed to TRUE to indicate that some operation is + * authorized for @a path in @a root, or set it to FALSE to indicate + * unauthorized (presumably according to state stored in @a baton). + * + * Do not assume @a pool has any lifetime beyond this call. + * + * The exact operation being authorized depends on the callback + * implementation. For read authorization, for example, the caller + * would implement an instance that does read checking, and pass it as + * a parameter named [perhaps] 'authz_read_func'. The receiver of + * that parameter might also take another parameter named + * 'authz_write_func', which although sharing this type, would be a + * different implementation. + * + * @note If someday we want more sophisticated authorization states + * than just yes/no, @a allowed can become an enum type. + */ +typedef svn_error_t *(*svn_repos_authz_func_t)(svn_boolean_t *allowed, + svn_fs_root_t *root, + const char *path, + void *baton, + apr_pool_t *pool); + + +/** An enum defining the kinds of access authz looks up. + * + * @since New in 1.3. + */ +typedef enum svn_repos_authz_access_t +{ + /** No access. */ + svn_authz_none = 0, + + /** Path can be read. */ + svn_authz_read = 1, + + /** Path can be altered. */ + svn_authz_write = 2, + + /** The other access credentials are recursive. */ + svn_authz_recursive = 4 +} svn_repos_authz_access_t; + + +/** Callback type for checking authorization on paths produced by + * the repository commit editor. + * + * Set @a *allowed to TRUE to indicate that the @a required access on + * @a path in @a root is authorized, or set it to FALSE to indicate + * unauthorized (presumable according to state stored in @a baton). + * + * If @a path is NULL, the callback should perform a global authz + * lookup for the @a required access. That is, the lookup should + * check if the @a required access is granted for at least one path of + * the repository, and set @a *allowed to TRUE if so. @a root may + * also be NULL if @a path is NULL. + * + * This callback is very similar to svn_repos_authz_func_t, with the + * exception of the addition of the @a required parameter. + * This is due to historical reasons: when authz was first implemented + * for svn_repos_dir_delta2(), it seemed there would need only checks + * for read and write operations, hence the svn_repos_authz_func_t + * callback prototype and usage scenario. But it was then realized + * that lookups due to copying needed to be recursive, and that + * brute-force recursive lookups didn't square with the O(1) + * performances a copy operation should have. + * + * So a special way to ask for a recursive lookup was introduced. The + * commit editor needs this capability to retain acceptable + * performance. Instead of revving the existing callback, causing + * unnecessary revving of functions that don't actually need the + * extended functionality, this second, more complete callback was + * introduced, for use by the commit editor. + * + * Some day, it would be nice to reunite these two callbacks and do + * the necessary revving anyway, but for the time being, this dual + * callback mechanism will do. + */ +typedef svn_error_t *(*svn_repos_authz_callback_t) + (svn_repos_authz_access_t required, + svn_boolean_t *allowed, + svn_fs_root_t *root, + const char *path, + void *baton, + apr_pool_t *pool); + +/** + * Similar to #svn_file_rev_handler_t, but without the @a + * result_of_merge parameter. + * + * @deprecated Provided for backward compatibility with 1.4 API. + * @since New in 1.1. + */ +typedef svn_error_t *(*svn_repos_file_rev_handler_t) + (void *baton, + const char *path, + svn_revnum_t rev, + apr_hash_t *rev_props, + svn_txdelta_window_handler_t *delta_handler, + void **delta_baton, + apr_array_header_t *prop_diffs, + apr_pool_t *pool); + + +/* Notification system. */ + +/** The type of action occurring. + * + * @since New in 1.7. + */ +typedef enum svn_repos_notify_action_t +{ + /** A warning message is waiting. */ + svn_repos_notify_warning = 0, + + /** A revision has finished being dumped. */ + svn_repos_notify_dump_rev_end, + + /** A revision has finished being verified. */ + svn_repos_notify_verify_rev_end, + + /** All revisions have finished being dumped. */ + svn_repos_notify_dump_end, + + /** All revisions have finished being verified. */ + svn_repos_notify_verify_end, + + /** packing of an FSFS shard has commenced */ + svn_repos_notify_pack_shard_start, + + /** packing of an FSFS shard is completed */ + svn_repos_notify_pack_shard_end, + + /** packing of the shard revprops has commenced */ + svn_repos_notify_pack_shard_start_revprop, + + /** packing of the shard revprops has completed */ + svn_repos_notify_pack_shard_end_revprop, + + /** A revision has begun loading */ + svn_repos_notify_load_txn_start, + + /** A revision has finished loading */ + svn_repos_notify_load_txn_committed, + + /** A node has begun loading */ + svn_repos_notify_load_node_start, + + /** A node has finished loading */ + svn_repos_notify_load_node_done, + + /** A copied node has been encountered */ + svn_repos_notify_load_copied_node, + + /** Mergeinfo has been normalized */ + svn_repos_notify_load_normalized_mergeinfo, + + /** The operation has acquired a mutex for the repo. */ + svn_repos_notify_mutex_acquired, + + /** Recover has started. */ + svn_repos_notify_recover_start, + + /** Upgrade has started. */ + svn_repos_notify_upgrade_start, + + /** A revision was skipped during loading. @since New in 1.8. */ + svn_repos_notify_load_skipped_rev, + + /** The structure of a revision is being verified. @since New in 1.8. */ + svn_repos_notify_verify_rev_structure + +} svn_repos_notify_action_t; + +/** The type of error occurring. + * + * @since New in 1.7. + */ +typedef enum svn_repos_notify_warning_t +{ + /** Referencing copy source data from a revision earlier than the + * first revision dumped. */ + svn_repos_notify_warning_found_old_reference, + + /** An #SVN_PROP_MERGEINFO property's encoded mergeinfo references a + * revision earlier than the first revision dumped. */ + svn_repos_notify_warning_found_old_mergeinfo, + + /** Found an invalid path in the filesystem. + * @see svn_fs.h:"Directory entry names and directory paths" */ + /* ### TODO(doxygen): make that a proper doxygen link */ + /* See svn_fs__path_valid(). */ + svn_repos_notify_warning_invalid_fspath + +} svn_repos_notify_warning_t; + +/** + * Structure used by #svn_repos_notify_func_t. + * + * The only field guaranteed to be populated is @c action. Other fields are + * dependent upon the @c action. (See individual fields for more information.) + * + * @note Callers of notification functions should use + * svn_repos_notify_create() to create structures of this type to allow for + * future extensibility. + * + * @since New in 1.7. + */ +typedef struct svn_repos_notify_t +{ + /** Action that describes what happened in the repository. */ + svn_repos_notify_action_t action; + + /** For #svn_repos_notify_dump_rev_end and #svn_repos_notify_verify_rev_end, + * the revision which just completed. */ + svn_revnum_t revision; + + /** For #svn_repos_notify_warning, the warning object. Must be cleared + by the consumer of the notification. */ + const char *warning_str; + svn_repos_notify_warning_t warning; + + /** For #svn_repos_notify_pack_shard_start, + #svn_repos_notify_pack_shard_end, + #svn_repos_notify_pack_shard_start_revprop, and + #svn_repos_notify_pack_shard_end_revprop, the shard processed. */ + apr_int64_t shard; + + /** For #svn_repos_notify_load_node_done, the revision committed. */ + svn_revnum_t new_revision; + + /** For #svn_repos_notify_load_node_done, the source revision, if + different from @a new_revision, otherwise #SVN_INVALID_REVNUM. + For #svn_repos_notify_load_txn_start, the source revision. */ + svn_revnum_t old_revision; + + /** For #svn_repos_notify_load_node_start, the action being taken on the + node. */ + enum svn_node_action node_action; + + /** For #svn_repos_notify_load_node_start, the path of the node. */ + const char *path; + + /* NOTE: Add new fields at the end to preserve binary compatibility. + Also, if you add fields here, you have to update + svn_repos_notify_create(). */ +} svn_repos_notify_t; + +/** Callback for providing notification from the repository. + * Returns @c void. Justification: success of an operation is not dependent + * upon successful notification of that operation. + * + * @since New in 1.7. */ +typedef void (*svn_repos_notify_func_t)(void *baton, + const svn_repos_notify_t *notify, + apr_pool_t *scratch_pool); + +/** + * Allocate an #svn_repos_notify_t structure in @a result_pool, initialize + * and return it. + * + * @since New in 1.7. + */ +svn_repos_notify_t * +svn_repos_notify_create(svn_repos_notify_action_t action, + apr_pool_t *result_pool); + + +/** The repository object. */ +typedef struct svn_repos_t svn_repos_t; + +/* Opening and creating repositories. */ + + +/** Find the root path of the repository that contains @a path. + * + * If a repository was found, the path to the root of the repository + * is returned, else @c NULL. The pointer to the returned path may be + * equal to @a path. + */ +const char * +svn_repos_find_root_path(const char *path, + apr_pool_t *pool); + +/** Set @a *repos_p to a repository object for the repository at @a path. + * + * Allocate @a *repos_p in @a pool. + * + * Acquires a shared lock on the repository, and attaches a cleanup + * function to @a pool to remove the lock. If no lock can be acquired, + * returns error, with undefined effect on @a *repos_p. If an exclusive + * lock is present, this blocks until it's gone. @a fs_config will be + * passed to the filesystem initialization function and may be @c NULL. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_open2(svn_repos_t **repos_p, + const char *path, + apr_hash_t *fs_config, + apr_pool_t *pool); + +/** Similar to svn_repos_open2() with @a fs_config set to NULL. + * + * @deprecated Provided for backward compatibility with 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_open(svn_repos_t **repos_p, + const char *path, + apr_pool_t *pool); + +/** Create a new Subversion repository at @a path, building the necessary + * directory structure, creating the filesystem, and so on. + * Return the repository object in @a *repos_p, allocated in @a pool. + * + * @a config is a client configuration hash of #svn_config_t * items + * keyed on config category names, and may be NULL. + * + * @a fs_config is passed to the filesystem, and may be NULL. + * + * @a unused_1 and @a unused_2 are not used and should be NULL. + */ +svn_error_t * +svn_repos_create(svn_repos_t **repos_p, + const char *path, + const char *unused_1, + const char *unused_2, + apr_hash_t *config, + apr_hash_t *fs_config, + apr_pool_t *pool); + +/** + * Upgrade the Subversion repository (and its underlying versioned + * filesystem) located in the directory @a path to the latest version + * supported by this library. If the requested upgrade is not + * supported due to the current state of the repository or it + * underlying filesystem, return #SVN_ERR_REPOS_UNSUPPORTED_UPGRADE + * or #SVN_ERR_FS_UNSUPPORTED_UPGRADE (respectively) and make no + * changes to the repository or filesystem. + * + * Acquires an exclusive lock on the repository, upgrades the + * repository, and releases the lock. If an exclusive lock can't be + * acquired, returns error. + * + * If @a nonblocking is TRUE, an error of type EWOULDBLOCK is + * returned if the lock is not immediately available. + * + * If @a start_callback is not NULL, it will be called with @a + * start_callback_baton as argument before the upgrade starts, but + * after the exclusive lock has been acquired. + * + * Use @a pool for necessary allocations. + * + * @note This functionality is provided as a convenience for + * administrators wishing to make use of new Subversion functionality + * without a potentially costly full repository dump/load. As such, + * the operation performs only the minimum amount of work needed to + * accomplish this while maintaining the integrity of the repository. + * It does *not* guarantee the most optimized repository state as a + * dump and subsequent load would. + * + * @note On some platforms the exclusive lock does not exclude other + * threads in the same process so this function should only be called + * by a single threaded process, or by a multi-threaded process when + * no other threads are accessing the repository. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_upgrade2(const char *path, + svn_boolean_t nonblocking, + svn_repos_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_upgrade2(), but with @a start_callback and baton, + * rather than a notify_callback / baton + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_upgrade(const char *path, + svn_boolean_t nonblocking, + svn_error_t *(*start_callback)(void *baton), + void *start_callback_baton, + apr_pool_t *pool); + +/** Destroy the Subversion repository found at @a path, using @a pool for any + * necessary allocations. + */ +svn_error_t * +svn_repos_delete(const char *path, + apr_pool_t *pool); + +/** + * Set @a *has to TRUE if @a repos has @a capability (one of the + * capabilities beginning with @c "SVN_REPOS_CAPABILITY_"), else set + * @a *has to FALSE. + * + * If @a capability isn't recognized, throw #SVN_ERR_UNKNOWN_CAPABILITY, + * with the effect on @a *has undefined. + * + * Use @a pool for all allocation. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_has_capability(svn_repos_t *repos, + svn_boolean_t *has, + const char *capability, + apr_pool_t *pool); + +/** @} */ + +/** + * The capability of doing the right thing with merge-tracking + * information, both storing it and responding to queries about it. + * + * @since New in 1.5. + */ +#define SVN_REPOS_CAPABILITY_MERGEINFO "mergeinfo" +/* *** PLEASE READ THIS IF YOU ADD A NEW CAPABILITY *** + * + * @c SVN_REPOS_CAPABILITY_foo strings should not include colons, to + * be consistent with @c SVN_RA_CAPABILITY_foo strings, which forbid + * colons for their own reasons. While this RA limitation has no + * direct impact on repository capabilities, there's no reason to be + * gratuitously different either. + * + * If you add a capability, update svn_repos_capabilities(). + */ + + +/** Return the filesystem associated with repository object @a repos. */ +svn_fs_t * +svn_repos_fs(svn_repos_t *repos); + + +/** Make a hot copy of the Subversion repository found at @a src_path + * to @a dst_path. + * + * Copy a possibly live Subversion repository from @a src_path to + * @a dst_path. If @a clean_logs is @c TRUE, perform cleanup on the + * source filesystem as part of the copy operation; currently, this + * means deleting copied, unused logfiles for a Berkeley DB source + * repository. + * + * If @a incremental is TRUE, make an effort to not re-copy information + * already present in the destination. If incremental hotcopy is not + * implemented by the filesystem backend, raise SVN_ERR_UNSUPPORTED_FEATURE. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_hotcopy2(const char *src_path, + const char *dst_path, + svn_boolean_t clean_logs, + svn_boolean_t incremental, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Like svn_repos_hotcopy2(), but with @a incremental always passed as + * @c FALSE and without cancellation support. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_hotcopy(const char *src_path, + const char *dst_path, + svn_boolean_t clean_logs, + apr_pool_t *pool); + + +/** + * Possibly update the repository, @a repos, to use a more efficient + * filesystem representation. Use @a pool for allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_fs_pack2(svn_repos_t *repos, + svn_repos_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_fs_pack2(), but with a #svn_fs_pack_notify_t instead + * of a #svn_repos_notify_t. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_pack(svn_repos_t *repos, + svn_fs_pack_notify_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Run database recovery procedures on the repository at @a path, + * returning the database to a consistent state. Use @a pool for all + * allocation. + * + * Acquires an exclusive lock on the repository, recovers the + * database, and releases the lock. If an exclusive lock can't be + * acquired, returns error. + * + * If @a nonblocking is TRUE, an error of type EWOULDBLOCK is + * returned if the lock is not immediately available. + * + * If @a notify_func is not NULL, it will be called with @a + * notify_baton as argument before the recovery starts, but + * after the exclusive lock has been acquired. + * + * If @a cancel_func is not @c NULL, it is called periodically with + * @a cancel_baton as argument to see if the client wishes to cancel + * the recovery. + * + * @note On some platforms the exclusive lock does not exclude other + * threads in the same process so this function should only be called + * by a single threaded process, or by a multi-threaded process when + * no other threads are accessing the repository. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_recover4(const char *path, + svn_boolean_t nonblocking, + svn_repos_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void * cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_recover4(), but with @a start callback in place of + * the notify_func / baton. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_recover3(const char *path, + svn_boolean_t nonblocking, + svn_error_t *(*start_callback)(void *baton), + void *start_callback_baton, + svn_cancel_func_t cancel_func, + void * cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_recover3(), but without cancellation support. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_recover2(const char *path, + svn_boolean_t nonblocking, + svn_error_t *(*start_callback)(void *baton), + void *start_callback_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_recover2(), but with nonblocking set to FALSE, and + * with no callbacks provided. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_recover(const char *path, + apr_pool_t *pool); + +/** + * Callback for svn_repos_freeze. + * + * @since New in 1.8. + */ +typedef svn_error_t *(*svn_repos_freeze_func_t)(void *baton, apr_pool_t *pool); + +/** + * Take an exclusive lock on each of the repositories in @a paths to + * prevent commits and then while holding all the locks invoke @a + * freeze_func passing @a freeze_baton. Each repository may be readable by + * Subversion while frozen, or may be unreadable, depending on which + * FS backend the repository uses. Repositories are locked in the + * order in which they are specified in the array. + * + * @note On some platforms the exclusive lock does not exclude other + * threads in the same process so this function should only be called + * by a single threaded process, or by a multi-threaded process when + * no other threads are accessing the repositories. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_freeze(apr_array_header_t *paths, + svn_repos_freeze_func_t freeze_func, + void *freeze_baton, + apr_pool_t *pool); + +/** This function is a wrapper around svn_fs_berkeley_logfiles(), + * returning log file paths relative to the root of the repository. + * + * @copydoc svn_fs_berkeley_logfiles() + */ +svn_error_t * +svn_repos_db_logfiles(apr_array_header_t **logfiles, + const char *path, + svn_boolean_t only_unused, + apr_pool_t *pool); + + + +/* Repository Paths */ + +/** Return the top-level repository path allocated in @a pool. */ +const char * +svn_repos_path(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's filesystem directory, allocated in + * @a pool. + */ +const char * +svn_repos_db_env(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return path to @a repos's config directory, allocated in @a pool. */ +const char * +svn_repos_conf_dir(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return path to @a repos's svnserve.conf, allocated in @a pool. */ +const char * +svn_repos_svnserve_conf(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return path to @a repos's lock directory, allocated in @a pool. */ +const char * +svn_repos_lock_dir(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return path to @a repos's db lockfile, allocated in @a pool. */ +const char * +svn_repos_db_lockfile(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return path to @a repos's db logs lockfile, allocated in @a pool. */ +const char * +svn_repos_db_logs_lockfile(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's hook directory, allocated in @a pool. */ +const char * +svn_repos_hook_dir(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's start-commit hook, allocated in @a pool. */ +const char * +svn_repos_start_commit_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's pre-commit hook, allocated in @a pool. */ +const char * +svn_repos_pre_commit_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's post-commit hook, allocated in @a pool. */ +const char * +svn_repos_post_commit_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's pre-revprop-change hook, allocated in + * @a pool. + */ +const char * +svn_repos_pre_revprop_change_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's post-revprop-change hook, allocated in + * @a pool. + */ +const char * +svn_repos_post_revprop_change_hook(svn_repos_t *repos, + apr_pool_t *pool); + + +/** @defgroup svn_repos_lock_hooks Paths to lock hooks + * @{ + * @since New in 1.2. */ + +/** Return the path to @a repos's pre-lock hook, allocated in @a pool. */ +const char * +svn_repos_pre_lock_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's post-lock hook, allocated in @a pool. */ +const char * +svn_repos_post_lock_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's pre-unlock hook, allocated in @a pool. */ +const char * +svn_repos_pre_unlock_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Return the path to @a repos's post-unlock hook, allocated in @a pool. */ +const char * +svn_repos_post_unlock_hook(svn_repos_t *repos, + apr_pool_t *pool); + +/** Specify that Subversion should consult the configuration file + * located at @a hooks_env_path to determine how to setup the + * environment for hook scripts invoked for the repository @a repos. + * As a special case, if @a hooks_env_path is @c NULL, look for the + * file in its default location within the repository disk structure. + * If @a hooks_env_path is not absolute, it specifies a path relative + * to the parent of the file's default location. + * + * Use @a scratch_pool for temporary allocations. + * + * If this function is not called, or if the specified configuration + * file does not define any environment variables, hooks will run in + * an empty environment. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_hooks_setenv(svn_repos_t *repos, + const char *hooks_env_path, + apr_pool_t *scratch_pool); + +/** @} */ + +/* ---------------------------------------------------------------*/ + +/* Reporting the state of a working copy, for updates. */ + + +/** + * Construct and return a @a report_baton that will be passed to the + * other functions in this section to describe the state of a pre-existing + * tree (typically, a working copy). When the report is finished, + * @a editor/@a edit_baton will be driven in such a way as to transform the + * existing tree to @a revnum and, if @a tgt_path is non-NULL, switch the + * reported hierarchy to @a tgt_path. + * + * @a fs_base is the absolute path of the node in the filesystem at which + * the comparison should be rooted. @a target is a single path component, + * used to limit the scope of the report to a single entry of @a fs_base, + * or "" if all of @a fs_base itself is the main subject of the report. + * + * @a tgt_path and @a revnum is the fs path/revision pair that is the + * "target" of the delta. @a tgt_path should be provided only when + * the source and target paths of the report differ. That is, @a tgt_path + * should *only* be specified when specifying that the resultant editor + * drive be one that transforms the reported hierarchy into a pristine tree + * of @a tgt_path at revision @a revnum. A @c NULL value for @a tgt_path + * will indicate that the editor should be driven in such a way as to + * transform the reported hierarchy to revision @a revnum, preserving the + * reported hierarchy. + * + * @a text_deltas instructs the driver of the @a editor to enable + * the generation of text deltas. + * + * @a ignore_ancestry instructs the driver to ignore node ancestry + * when determining how to transmit differences. + * + * @a send_copyfrom_args instructs the driver to send 'copyfrom' + * arguments to the editor's add_file() and add_directory() methods, + * whenever it deems feasible. + * + * Use @a authz_read_func and @a authz_read_baton (if not @c NULL) to + * avoid sending data through @a editor/@a edit_baton which is not + * authorized for transmission. + * + * @a zero_copy_limit controls the maximum size (in bytes) at which + * data blocks may be sent using the zero-copy code path. On that + * path, a number of in-memory copy operations have been eliminated to + * maximize throughput. However, until the whole block has been + * pushed to the network stack, other clients block, so be careful + * when using larger values here. Pass 0 for @a zero_copy_limit to + * disable this optimization altogether. + * + * @a note Never activate this optimization if @a editor might access + * any FSFS data structures (and, hence, caches). So, it is basically + * safe for networked editors only. + * + * All allocation for the context and collected state will occur in + * @a pool. + * + * @a depth is the requested depth of the editor drive. + * + * If @a depth is #svn_depth_unknown, the editor will affect only the + * paths reported by the individual calls to svn_repos_set_path3() and + * svn_repos_link_path3(). + * + * For example, if the reported tree is the @c A subdir of the Greek Tree + * (see Subversion's test suite), at depth #svn_depth_empty, but the + * @c A/B subdir is reported at depth #svn_depth_infinity, then + * repository-side changes to @c A/mu, or underneath @c A/C and @c + * A/D, would not be reflected in the editor drive, but changes + * underneath @c A/B would be. + * + * Additionally, the editor driver will call @c add_directory and + * and @c add_file for directories with an appropriate depth. For + * example, a directory reported at #svn_depth_files will receive + * file (but not directory) additions. A directory at #svn_depth_empty + * will receive neither. + * + * If @a depth is #svn_depth_files, #svn_depth_immediates or + * #svn_depth_infinity and @a depth is greater than the reported depth + * of the working copy, then the editor driver will emit editor + * operations so as to upgrade the working copy to this depth. + * + * If @a depth is #svn_depth_empty, #svn_depth_files, + * #svn_depth_immediates and @a depth is lower + * than or equal to the depth of the working copy, then the editor + * operations will affect only paths at or above @a depth. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_begin_report3(void **report_baton, + svn_revnum_t revnum, + svn_repos_t *repos, + const char *fs_base, + const char *target, + const char *tgt_path, + svn_boolean_t text_deltas, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t send_copyfrom_args, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_size_t zero_copy_limit, + apr_pool_t *pool); + +/** + * The same as svn_repos_begin_report3(), but with @a zero_copy_limit + * always passed as 0. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_begin_report2(void **report_baton, + svn_revnum_t revnum, + svn_repos_t *repos, + const char *fs_base, + const char *target, + const char *tgt_path, + svn_boolean_t text_deltas, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t send_copyfrom_args, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * The same as svn_repos_begin_report2(), but taking a boolean + * @a recurse flag, and sending FALSE for @a send_copyfrom_args. + * + * If @a recurse is TRUE, the editor driver will drive the editor with + * a depth of #svn_depth_infinity; if FALSE, then with a depth of + * #svn_depth_files. + * + * @note @a username is ignored, and has been removed in a revised + * version of this API. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_begin_report(void **report_baton, + svn_revnum_t revnum, + const char *username, + svn_repos_t *repos, + const char *fs_base, + const char *target, + const char *tgt_path, + svn_boolean_t text_deltas, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + + +/** + * Given a @a report_baton constructed by svn_repos_begin_report3(), + * record the presence of @a path, at @a revision with depth @a depth, + * in the current tree. + * + * @a path is relative to the anchor/target used in the creation of the + * @a report_baton. + * + * @a revision may be SVN_INVALID_REVNUM if (for example) @a path + * represents a locally-added path with no revision number, or @a + * depth is #svn_depth_exclude. + * + * @a path may not be underneath a path on which svn_repos_set_path3() + * was previously called with #svn_depth_exclude in this report. + * + * The first call of this in a given report usually passes an empty + * @a path; this is used to set up the correct root revision for the editor + * drive. + * + * A depth of #svn_depth_unknown is not allowed, and results in an + * error. + * + * If @a start_empty is TRUE and @a path is a directory, then require the + * caller to explicitly provide all the children of @a path - do not assume + * that the tree also contains all the children of @a path at @a revision. + * This is for 'low confidence' client reporting. + * + * If the caller has a lock token for @a path, then @a lock_token should + * be set to that token. Else, @a lock_token should be NULL. + * + * All temporary allocations are done in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_set_path3(void *report_baton, + const char *path, + svn_revnum_t revision, + svn_depth_t depth, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + +/** + * Similar to svn_repos_set_path3(), but with @a depth set to + * #svn_depth_infinity. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_set_path2(void *report_baton, + const char *path, + svn_revnum_t revision, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + +/** + * Similar to svn_repos_set_path2(), but with @a lock_token set to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_set_path(void *report_baton, + const char *path, + svn_revnum_t revision, + svn_boolean_t start_empty, + apr_pool_t *pool); + +/** + * Given a @a report_baton constructed by svn_repos_begin_report3(), + * record the presence of @a path in the current tree, containing the contents + * of @a link_path at @a revision with depth @a depth. + * + * A depth of #svn_depth_unknown is not allowed, and results in an + * error. + * + * @a path may not be underneath a path on which svn_repos_set_path3() + * was previously called with #svn_depth_exclude in this report. + * + * Note that while @a path is relative to the anchor/target used in the + * creation of the @a report_baton, @a link_path is an absolute filesystem + * path! + * + * If @a start_empty is TRUE and @a path is a directory, then require the + * caller to explicitly provide all the children of @a path - do not assume + * that the tree also contains all the children of @a link_path at + * @a revision. This is for 'low confidence' client reporting. + * + * If the caller has a lock token for @a link_path, then @a lock_token + * should be set to that token. Else, @a lock_token should be NULL. + * + * All temporary allocations are done in @a pool. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_link_path3(void *report_baton, + const char *path, + const char *link_path, + svn_revnum_t revision, + svn_depth_t depth, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + +/** + * Similar to svn_repos_link_path3(), but with @a depth set to + * #svn_depth_infinity. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_link_path2(void *report_baton, + const char *path, + const char *link_path, + svn_revnum_t revision, + svn_boolean_t start_empty, + const char *lock_token, + apr_pool_t *pool); + +/** + * Similar to svn_repos_link_path2(), but with @a lock_token set to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_link_path(void *report_baton, + const char *path, + const char *link_path, + svn_revnum_t revision, + svn_boolean_t start_empty, + apr_pool_t *pool); + +/** Given a @a report_baton constructed by svn_repos_begin_report3(), + * record the non-existence of @a path in the current tree. + * + * @a path may not be underneath a path on which svn_repos_set_path3() + * was previously called with #svn_depth_exclude in this report. + * + * (This allows the reporter's driver to describe missing pieces of a + * working copy, so that 'svn up' can recreate them.) + * + * All temporary allocations are done in @a pool. + */ +svn_error_t * +svn_repos_delete_path(void *report_baton, + const char *path, + apr_pool_t *pool); + +/** Given a @a report_baton constructed by svn_repos_begin_report3(), + * finish the report and drive the editor as specified when the report + * baton was constructed. + * + * If an error occurs during the driving of the editor, do NOT abort the + * edit; that responsibility belongs to the caller of this function, if + * it happens at all. + * + * After the call to this function, @a report_baton is no longer valid; + * it should not be passed to any other reporting functions, including + * svn_repos_abort_report(), even if this function returns an error. + */ +svn_error_t * +svn_repos_finish_report(void *report_baton, + apr_pool_t *pool); + + +/** Given a @a report_baton constructed by svn_repos_begin_report3(), + * abort the report. This function can be called anytime before + * svn_repos_finish_report() is called. + * + * After the call to this function, @a report_baton is no longer valid; + * it should not be passed to any other reporting functions. + */ +svn_error_t * +svn_repos_abort_report(void *report_baton, + apr_pool_t *pool); + + +/* ---------------------------------------------------------------*/ + +/* The magical dir_delta update routines. */ + +/** Use the provided @a editor and @a edit_baton to describe the changes + * necessary for making a given node (and its descendants, if it is a + * directory) under @a src_root look exactly like @a tgt_path under + * @a tgt_root. @a src_entry is the node to update. If @a src_entry + * is empty, then compute the difference between the entire tree + * anchored at @a src_parent_dir under @a src_root and @a tgt_path + * under @a tgt_root. Else, describe the changes needed to update + * only that entry in @a src_parent_dir. Typically, callers of this + * function will use a @a tgt_path that is the concatenation of @a + * src_parent_dir and @a src_entry. + * + * @a src_root and @a tgt_root can both be either revision or transaction + * roots. If @a tgt_root is a revision, @a editor's set_target_revision() + * will be called with the @a tgt_root's revision number, else it will + * not be called at all. + * + * If @a authz_read_func is non-NULL, invoke it before any call to + * + * @a editor->open_root + * @a editor->add_directory + * @a editor->open_directory + * @a editor->add_file + * @a editor->open_file + * + * passing @a tgt_root, the same path that would be passed to the + * editor function in question, and @a authz_read_baton. If the + * @a *allowed parameter comes back TRUE, then proceed with the planned + * editor call; else if FALSE, then invoke @a editor->absent_file or + * @a editor->absent_directory as appropriate, except if the planned + * editor call was open_root, throw SVN_ERR_AUTHZ_ROOT_UNREADABLE. + * + * If @a text_deltas is @c FALSE, send a single @c NULL txdelta window to + * the window handler returned by @a editor->apply_textdelta(). + * + * If @a depth is #svn_depth_empty, invoke @a editor calls only on + * @a src_entry (or @a src_parent_dir, if @a src_entry is empty). + * If @a depth is #svn_depth_files, also invoke the editor on file + * children, if any; if #svn_depth_immediates, invoke it on + * immediate subdirectories as well as files; if #svn_depth_infinity, + * recurse fully. + * + * If @a entry_props is @c TRUE, accompany each opened/added entry with + * propchange editor calls that relay special "entry props" (this + * is typically used only for working copy updates). + * + * @a ignore_ancestry instructs the function to ignore node ancestry + * when determining how to transmit differences. + * + * Before completing successfully, this function calls @a editor's + * close_edit(), so the caller should expect its @a edit_baton to be + * invalid after its use with this function. + * + * Do any allocation necessary for the delta computation in @a pool. + * This function's maximum memory consumption is at most roughly + * proportional to the greatest depth of the tree under @a tgt_root, not + * the total size of the delta. + * + * ### svn_repos_dir_delta2 is mostly superseded by the reporter + * ### functionality (svn_repos_begin_report3 and friends). + * ### svn_repos_dir_delta2 does allow the roots to be transaction + * ### roots rather than just revision roots, and it has the + * ### entry_props flag. Almost all of Subversion's own code uses the + * ### reporter instead; there are some stray references to the + * ### svn_repos_dir_delta[2] in comments which should probably + * ### actually refer to the reporter. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_dir_delta2(svn_fs_root_t *src_root, + const char *src_parent_dir, + const char *src_entry, + svn_fs_root_t *tgt_root, + const char *tgt_path, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_boolean_t text_deltas, + svn_depth_t depth, + svn_boolean_t entry_props, + svn_boolean_t ignore_ancestry, + apr_pool_t *pool); + +/** + * Similar to svn_repos_dir_delta2(), but if @a recurse is TRUE, pass + * #svn_depth_infinity for @a depth, and if @a recurse is FALSE, + * pass #svn_depth_files for @a depth. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_dir_delta(svn_fs_root_t *src_root, + const char *src_parent_dir, + const char *src_entry, + svn_fs_root_t *tgt_root, + const char *tgt_path, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_boolean_t text_deltas, + svn_boolean_t recurse, + svn_boolean_t entry_props, + svn_boolean_t ignore_ancestry, + apr_pool_t *pool); + + +/** Use the provided @a editor and @a edit_baton to describe the + * skeletal changes made in a particular filesystem @a root + * (revision or transaction). + * + * Changes will be limited to those within @a base_dir, and if + * @a low_water_mark is set to something other than #SVN_INVALID_REVNUM + * it is assumed that the client has no knowledge of revisions prior to + * @a low_water_mark. Together, these two arguments define the portion of + * the tree that the client is assumed to have knowledge of, and thus any + * copies of data from outside that part of the tree will be sent in their + * entirety, not as simple copies or deltas against a previous version. + * + * The @a editor passed to this function should be aware of the fact + * that, if @a send_deltas is FALSE, calls to its change_dir_prop(), + * change_file_prop(), and apply_textdelta() functions will not + * contain meaningful data, and merely serve as indications that + * properties or textual contents were changed. + * + * If @a send_deltas is @c TRUE, the text and property deltas for changes + * will be sent, otherwise NULL text deltas and empty prop changes will be + * used. + * + * If @a authz_read_func is non-NULL, it will be used to determine if the + * user has read access to the data being accessed. Data that the user + * cannot access will be skipped. + * + * @note This editor driver passes SVN_INVALID_REVNUM for all + * revision parameters in the editor interface except the copyfrom + * parameter of the add_file() and add_directory() editor functions. + * + * @since New in 1.4. + */ +svn_error_t * +svn_repos_replay2(svn_fs_root_t *root, + const char *base_dir, + svn_revnum_t low_water_mark, + svn_boolean_t send_deltas, + const svn_delta_editor_t *editor, + void *edit_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_replay2(), but with @a base_dir set to @c "", + * @a low_water_mark set to #SVN_INVALID_REVNUM, @a send_deltas + * set to @c FALSE, and @a authz_read_func and @a authz_read_baton + * set to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_replay(svn_fs_root_t *root, + const svn_delta_editor_t *editor, + void *edit_baton, + apr_pool_t *pool); + +/* ---------------------------------------------------------------*/ + +/* Making commits. */ + +/** + * Return an @a editor and @a edit_baton to commit changes to the + * filesystem of @a repos, beginning at location 'rev:@a base_path', + * where "rev" is the argument given to open_root(). + * + * @a repos is a previously opened repository. @a repos_url is the + * decoded URL to the base of the repository, and is used to check + * copyfrom paths. copyfrom paths passed to the editor must be full, + * URI-encoded, URLs. @a txn is a filesystem transaction object to use + * during the commit, or @c NULL to indicate that this function should + * create (and fully manage) a new transaction. + * + * Store the contents of @a revprop_table, a hash mapping <tt>const + * char *</tt> property names to #svn_string_t values, as properties + * of the commit transaction, including author and log message if + * present. + * + * @note #SVN_PROP_REVISION_DATE may be present in @a revprop_table, but + * it will be overwritten when the transaction is committed. + * + * Iff @a authz_callback is provided, check read/write authorizations + * on paths accessed by editor operations. An operation which fails + * due to authz will return SVN_ERR_AUTHZ_UNREADABLE or + * SVN_ERR_AUTHZ_UNWRITABLE. + * + * Calling @a (*editor)->close_edit completes the commit. + * + * If @a commit_callback is non-NULL, then before @c close_edit returns (but + * after the commit has succeeded) @c close_edit will invoke + * @a commit_callback with a filled-in #svn_commit_info_t *, @a commit_baton, + * and @a pool or some subpool thereof as arguments. If @a commit_callback + * returns an error, that error will be returned from @c close_edit, + * otherwise if there was a post-commit hook failure, then that error + * will be returned with code SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED. + * (Note that prior to Subversion 1.6, @a commit_callback cannot be NULL; if + * you don't need a callback, pass a dummy function.) + * + * Calling @a (*editor)->abort_edit aborts the commit, and will also + * abort the commit transaction unless @a txn was supplied (not @c + * NULL). Callers who supply their own transactions are responsible + * for cleaning them up (either by committing them, or aborting them). + * + * @since New in 1.5. + * + * @note Yes, @a repos_url is a <em>decoded</em> URL. We realize + * that's sorta wonky. Sorry about that. + */ +svn_error_t * +svn_repos_get_commit_editor5(const svn_delta_editor_t **editor, + void **edit_baton, + svn_repos_t *repos, + svn_fs_txn_t *txn, + const char *repos_url, + const char *base_path, + apr_hash_t *revprop_table, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_repos_authz_callback_t authz_callback, + void *authz_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_commit_editor5(), but with @a revprop_table + * set to a hash containing @a user and @a log_msg as the + * #SVN_PROP_REVISION_AUTHOR and #SVN_PROP_REVISION_LOG properties, + * respectively. @a user and @a log_msg may both be @c NULL. + * + * @since New in 1.4. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_commit_editor4(const svn_delta_editor_t **editor, + void **edit_baton, + svn_repos_t *repos, + svn_fs_txn_t *txn, + const char *repos_url, + const char *base_path, + const char *user, + const char *log_msg, + svn_commit_callback2_t commit_callback, + void *commit_baton, + svn_repos_authz_callback_t authz_callback, + void *authz_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_commit_editor4(), but + * uses the svn_commit_callback_t type. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_commit_editor3(const svn_delta_editor_t **editor, + void **edit_baton, + svn_repos_t *repos, + svn_fs_txn_t *txn, + const char *repos_url, + const char *base_path, + const char *user, + const char *log_msg, + svn_commit_callback_t callback, + void *callback_baton, + svn_repos_authz_callback_t authz_callback, + void *authz_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_commit_editor3(), but with @a + * authz_callback and @a authz_baton set to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_commit_editor2(const svn_delta_editor_t **editor, + void **edit_baton, + svn_repos_t *repos, + svn_fs_txn_t *txn, + const char *repos_url, + const char *base_path, + const char *user, + const char *log_msg, + svn_commit_callback_t callback, + void *callback_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_repos_get_commit_editor2(), but with @a txn always + * set to @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_commit_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_repos_t *repos, + const char *repos_url, + const char *base_path, + const char *user, + const char *log_msg, + svn_commit_callback_t callback, + void *callback_baton, + apr_pool_t *pool); + +/* ---------------------------------------------------------------*/ + +/* Finding particular revisions. */ + +/** Set @a *revision to the revision number in @a repos's filesystem that was + * youngest at time @a tm. + */ +svn_error_t * +svn_repos_dated_revision(svn_revnum_t *revision, + svn_repos_t *repos, + apr_time_t tm, + apr_pool_t *pool); + + +/** Given a @a root/@a path within some filesystem, return three pieces of + * information allocated in @a pool: + * + * - set @a *committed_rev to the revision in which the object was + * last modified. (In fs parlance, this is the revision in which + * the particular node-rev-id was 'created'.) + * + * - set @a *committed_date to the date of said revision, or @c NULL + * if not available. + * + * - set @a *last_author to the author of said revision, or @c NULL + * if not available. + */ +svn_error_t * +svn_repos_get_committed_info(svn_revnum_t *committed_rev, + const char **committed_date, + const char **last_author, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** + * Set @a *dirent to an #svn_dirent_t associated with @a path in @a + * root. If @a path does not exist in @a root, set @a *dirent to + * NULL. Use @a pool for memory allocation. + * + * @since New in 1.2. + */ +svn_error_t * +svn_repos_stat(svn_dirent_t **dirent, + svn_fs_root_t *root, + const char *path, + apr_pool_t *pool); + + +/** + * Given @a path which exists at revision @a start in @a fs, set + * @a *deleted to the revision @a path was first deleted, within the + * inclusive revision range bounded by @a start and @a end. If @a path + * does not exist at revision @a start or was not deleted within the + * specified range, then set @a *deleted to SVN_INVALID_REVNUM. + * Use @a pool for memory allocation. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_deleted_rev(svn_fs_t *fs, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_revnum_t *deleted, + apr_pool_t *pool); + + +/** Callback type for use with svn_repos_history(). @a path and @a + * revision represent interesting history locations in the lifetime + * of the path passed to svn_repos_history(). @a baton is the same + * baton given to svn_repos_history(). @a pool is provided for the + * convenience of the implementor, who should not expect it to live + * longer than a single callback call. + * + * Signal to callback driver to stop processing/invoking this callback + * by returning the #SVN_ERR_CEASE_INVOCATION error code. + * + * @note SVN_ERR_CEASE_INVOCATION is new in 1.5. + */ +typedef svn_error_t *(*svn_repos_history_func_t)(void *baton, + const char *path, + svn_revnum_t revision, + apr_pool_t *pool); + +/** + * Call @a history_func (with @a history_baton) for each interesting + * history location in the lifetime of @a path in @a fs, from the + * youngest of @a end and @a start to the oldest. Stop processing if + * @a history_func returns #SVN_ERR_CEASE_INVOCATION. Only cross + * filesystem copy history if @a cross_copies is @c TRUE. And do all + * of this in @a pool. + * + * If @a authz_read_func is non-NULL, then use it (and @a + * authz_read_baton) to verify that @a path in @a end is readable; if + * not, return SVN_ERR_AUTHZ_UNREADABLE. Also verify the readability + * of every ancestral path/revision pair before pushing them at @a + * history_func. If a pair is deemed unreadable, then do not send + * them; instead, immediately stop traversing history and return + * SVN_NO_ERROR. + * + * @since New in 1.1. + * + * @note SVN_ERR_CEASE_INVOCATION is new in 1.5. + */ +svn_error_t * +svn_repos_history2(svn_fs_t *fs, + const char *path, + svn_repos_history_func_t history_func, + void *history_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t cross_copies, + apr_pool_t *pool); + +/** + * Similar to svn_repos_history2(), but with @a authz_read_func + * and @a authz_read_baton always set to NULL. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_history(svn_fs_t *fs, + const char *path, + svn_repos_history_func_t history_func, + void *history_baton, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t cross_copies, + apr_pool_t *pool); + + +/** + * Set @a *locations to be a mapping of the revisions to the paths of + * the file @a fs_path present at the repository in revision + * @a peg_revision, where the revisions are taken out of the array + * @a location_revisions. + * + * @a location_revisions is an array of svn_revnum_t's and @a *locations + * maps 'svn_revnum_t *' to 'const char *'. + * + * If optional @a authz_read_func is non-NULL, then use it (and @a + * authz_read_baton) to verify that the peg-object is readable. If not, + * return SVN_ERR_AUTHZ_UNREADABLE. Also use the @a authz_read_func + * to check that every path returned in the hash is readable. If an + * unreadable path is encountered, stop tracing and return + * SVN_NO_ERROR. + * + * @a pool is used for all allocations. + * + * @since New in 1.1. + */ +svn_error_t * +svn_repos_trace_node_locations(svn_fs_t *fs, + apr_hash_t **locations, + const char *fs_path, + svn_revnum_t peg_revision, + const apr_array_header_t *location_revisions, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + + +/** + * Call @a receiver and @a receiver_baton to report successive + * location segments in revisions between @a start_rev and @a end_rev + * (inclusive) for the line of history identified by the peg-object @a + * path in @a peg_revision (and in @a repos). + * + * @a end_rev may be #SVN_INVALID_REVNUM to indicate that you want + * to trace the history of the object to its origin. + * + * @a start_rev may be #SVN_INVALID_REVNUM to indicate "the HEAD + * revision". Otherwise, @a start_rev must be younger than @a end_rev + * (unless @a end_rev is #SVN_INVALID_REVNUM). + * + * @a peg_revision may be #SVN_INVALID_REVNUM to indicate "the HEAD + * revision", and must evaluate to be at least as young as @a start_rev. + * + * If optional @a authz_read_func is not @c NULL, then use it (and @a + * authz_read_baton) to verify that the peg-object is readable. If + * not, return #SVN_ERR_AUTHZ_UNREADABLE. Also use the @a + * authz_read_func to check that every path reported in a location + * segment is readable. If an unreadable path is encountered, report + * a final (possibly truncated) location segment (if any), stop + * tracing history, and return #SVN_NO_ERROR. + * + * @a pool is used for all allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_node_location_segments(svn_repos_t *repos, + const char *path, + svn_revnum_t peg_revision, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_location_segment_receiver_t receiver, + void *receiver_baton, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + + +/* ### other queries we can do someday -- + + * fetch the last revision created by <user> + (once usernames become revision properties!) + * fetch the last revision where <path> was modified + +*/ + + + +/* ---------------------------------------------------------------*/ + +/* Retrieving log messages. */ + + +/** + * Invoke @a receiver with @a receiver_baton on each log message from + * @a start to @a end in @a repos's filesystem. @a start may be greater + * or less than @a end; this just controls whether the log messages are + * processed in descending or ascending revision number order. + * + * If @a start or @a end is #SVN_INVALID_REVNUM, it defaults to youngest. + * + * If @a paths is non-NULL and has one or more elements, then only show + * revisions in which at least one of @a paths was changed (i.e., if + * file, text or props changed; if dir, props or entries changed or any node + * changed below it). Each path is a <tt>const char *</tt> representing + * an absolute path in the repository. If @a paths is NULL or empty, + * show all revisions regardless of what paths were changed in those + * revisions. + * + * If @a limit is non-zero then only invoke @a receiver on the first + * @a limit logs. + * + * If @a discover_changed_paths, then each call to @a receiver passes a + * hash mapping paths committed in that revision to information about them + * as the receiver's @a changed_paths argument. + * Otherwise, each call to @a receiver passes NULL for @a changed_paths. + * + * If @a strict_node_history is set, copy history (if any exists) will + * not be traversed while harvesting revision logs for each path. + * + * If @a include_merged_revisions is set, log information for revisions + * which have been merged to @a paths will also be returned, unless these + * revisions are already part of @a start to @a end in @a repos's + * filesystem, as limited by @a paths. In the latter case those revisions + * are skipped and @a receiver is not invoked. + * + * If @a revprops is NULL, retrieve all revision properties; else, retrieve + * only the revision properties named by the (const char *) array elements + * (i.e. retrieve none if the array is empty). + * + * If any invocation of @a receiver returns error, return that error + * immediately and without wrapping it. + * + * If @a start or @a end is a non-existent revision, return the error + * #SVN_ERR_FS_NO_SUCH_REVISION, without ever invoking @a receiver. + * + * If optional @a authz_read_func is non-NULL, then use this function + * (along with optional @a authz_read_baton) to check the readability + * of each changed-path in each revision about to be "pushed" at + * @a receiver. If a revision has some changed-paths readable and + * others unreadable, unreadable paths are omitted from the + * changed_paths field and only svn:author and svn:date will be + * available in the revprops field. If a revision has no + * changed-paths readable at all, then all paths are omitted and no + * revprops are available. + * + * See also the documentation for #svn_log_entry_receiver_t. + * + * Use @a pool for temporary allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_get_logs4(svn_repos_t *repos, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_boolean_t include_merged_revisions, + const apr_array_header_t *revprops, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_log_entry_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + +/** + * Same as svn_repos_get_logs4(), but with @a receiver being + * #svn_log_message_receiver_t instead of #svn_log_entry_receiver_t. + * Also, @a include_merged_revisions is set to @c FALSE and @a revprops is + * svn:author, svn:date, and svn:log. If @a paths is empty, nothing + * is returned. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_logs3(svn_repos_t *repos, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + int limit, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_log_message_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + + +/** + * Same as svn_repos_get_logs3(), but with @a limit always set to 0. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_logs2(svn_repos_t *repos, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_log_message_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + +/** + * Same as svn_repos_get_logs2(), but with @a authz_read_func and + * @a authz_read_baton always set to NULL. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_logs(svn_repos_t *repos, + const apr_array_header_t *paths, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t discover_changed_paths, + svn_boolean_t strict_node_history, + svn_log_message_receiver_t receiver, + void *receiver_baton, + apr_pool_t *pool); + + + +/* ---------------------------------------------------------------*/ + +/* Retrieving mergeinfo. */ + +/** + * Fetch the mergeinfo for @a paths at @a revision in @a repos, and + * set @a *catalog to a catalog of this mergeinfo. @a *catalog will + * never be @c NULL but may be empty. + * + * The paths in @a paths, and the keys of @a catalog, start with '/'. + * + * @a inherit indicates whether explicit, explicit or inherited, or + * only inherited mergeinfo for @a paths is fetched. + * + * If @a revision is #SVN_INVALID_REVNUM, it defaults to youngest. + * + * If @a include_descendants is TRUE, then additionally return the + * mergeinfo for any descendant of any element of @a paths which has + * the #SVN_PROP_MERGEINFO property explicitly set on it. (Note + * that inheritance is only taken into account for the elements in @a + * paths; descendants of the elements in @a paths which get their + * mergeinfo via inheritance are not included in @a *catalog.) + * + * If optional @a authz_read_func is non-NULL, then use this function + * (along with optional @a authz_read_baton) to check the readability + * of each path which mergeinfo was requested for (from @a paths). + * Silently omit unreadable paths from the request for mergeinfo. + * + * Use @a pool for all allocations. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_fs_get_mergeinfo(svn_mergeinfo_catalog_t *catalog, + svn_repos_t *repos, + const apr_array_header_t *paths, + svn_revnum_t revision, + svn_mergeinfo_inheritance_t inherit, + svn_boolean_t include_descendants, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + + +/* ---------------------------------------------------------------*/ + +/* Retrieving multiple revisions of a file. */ + +/** + * Retrieve a subset of the interesting revisions of a file @a path in + * @a repos as seen in revision @a end. Invoke @a handler with + * @a handler_baton as its first argument for each such revision. + * @a pool is used for all allocations. See svn_fs_history_prev() for + * a discussion of interesting revisions. + * + * If optional @a authz_read_func is non-NULL, then use this function + * (along with optional @a authz_read_baton) to check the readability + * of the rev-path in each interesting revision encountered. + * + * Revision discovery happens from @a end to @a start, and if an + * unreadable revision is encountered before @a start is reached, then + * revision discovery stops and only the revisions from @a end to the + * oldest readable revision are returned (So it will appear that @a + * path was added without history in the latter revision). + * + * If there is an interesting revision of the file that is less than or + * equal to start, the iteration will start at that revision. Else, the + * iteration will start at the first revision of the file in the repository, + * which has to be less than or equal to end. Note that if the function + * succeeds, @a handler will have been called at least once. + * + * In a series of calls, the file contents for the first interesting revision + * will be provided as a text delta against the empty file. In the following + * calls, the delta will be against the contents for the previous call. + * + * If @a include_merged_revisions is TRUE, revisions which a included as a + * result of a merge between @a start and @a end will be included. + * + * Since Subversion 1.8 this function has been enabled to support reversion + * the revision range for @a include_merged_revision @c FALSE reporting by + * switching @a start with @a end. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_get_file_revs2(svn_repos_t *repos, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_boolean_t include_merged_revisions, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_file_rev_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_file_revs2(), with @a include_merged_revisions + * set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + * @since New in 1.1. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_file_revs(svn_repos_t *repos, + const char *path, + svn_revnum_t start, + svn_revnum_t end, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + svn_repos_file_rev_handler_t handler, + void *handler_baton, + apr_pool_t *pool); + + +/* ---------------------------------------------------------------*/ + +/** + * @defgroup svn_repos_hook_wrappers Hook-sensitive wrappers for libsvn_fs \ + * routines. + * @{ + */ + +/** Like svn_fs_commit_txn(), but invoke the @a repos' pre- and + * post-commit hooks around the commit. Use @a pool for any necessary + * allocations. + * + * If the pre-commit hook fails, do not attempt to commit the + * transaction and throw the original error to the caller. + * + * A successful commit is indicated by a valid revision value in @a + * *new_rev, not if svn_fs_commit_txn() returns an error, which can + * occur during its post commit FS processing. If the transaction was + * not committed, then return the associated error and do not execute + * the post-commit hook. + * + * If the commit succeeds the post-commit hook is executed. If the + * post-commit hook returns an error, always wrap it with + * SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED; this allows the caller to + * find the post-commit hook error in the returned error chain. If + * both svn_fs_commit_txn() and the post-commit hook return errors, + * then svn_fs_commit_txn()'s error is the parent error and the + * SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED wrapped error is the child + * error. + * + * @a conflict_p, @a new_rev, and @a txn are as in svn_fs_commit_txn(). + */ +svn_error_t * +svn_repos_fs_commit_txn(const char **conflict_p, + svn_repos_t *repos, + svn_revnum_t *new_rev, + svn_fs_txn_t *txn, + apr_pool_t *pool); + +/** Like svn_fs_begin_txn(), but use @a revprop_table, a hash mapping + * <tt>const char *</tt> property names to #svn_string_t values, to + * set the properties on transaction @a *txn_p. @a repos is the + * repository object which contains the filesystem. @a rev, @a + * *txn_p, and @a pool are as in svn_fs_begin_txn(). + * + * Before a txn is created, the repository's start-commit hooks are + * run; if any of them fail, no txn is created, @a *txn_p is unaffected, + * and #SVN_ERR_REPOS_HOOK_FAILURE is returned. + * + * @note @a revprop_table may contain an #SVN_PROP_REVISION_DATE property, + * which will be set on the transaction, but that will be overwritten + * when the transaction is committed. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_fs_begin_txn_for_commit2(svn_fs_txn_t **txn_p, + svn_repos_t *repos, + svn_revnum_t rev, + apr_hash_t *revprop_table, + apr_pool_t *pool); + + +/** + * Same as svn_repos_fs_begin_txn_for_commit2(), but with @a revprop_table + * set to a hash containing @a author and @a log_msg as the + * #SVN_PROP_REVISION_AUTHOR and #SVN_PROP_REVISION_LOG properties, + * respectively. @a author and @a log_msg may both be @c NULL. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_begin_txn_for_commit(svn_fs_txn_t **txn_p, + svn_repos_t *repos, + svn_revnum_t rev, + const char *author, + const char *log_msg, + apr_pool_t *pool); + + +/** Like svn_fs_begin_txn(), but use @a author to set the corresponding + * property on transaction @a *txn_p. @a repos is the repository object + * which contains the filesystem. @a rev, @a *txn_p, and @a pool are as in + * svn_fs_begin_txn(). + * + * ### Someday: before a txn is created, some kind of read-hook could + * be called here. + * + * @note This function was never fully implemented, nor used. Ignore it. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_begin_txn_for_update(svn_fs_txn_t **txn_p, + svn_repos_t *repos, + svn_revnum_t rev, + const char *author, + apr_pool_t *pool); + + +/** @} */ + +/** @defgroup svn_repos_fs_locks Repository lock wrappers + * @{ + */ + +/** Like svn_fs_lock(), but invoke the @a repos's pre- and + * post-lock hooks before and after the locking action. Use @a pool + * for any necessary allocations. + * + * If the pre-lock hook or svn_fs_lock() fails, throw the original + * error to caller. If an error occurs when running the post-lock + * hook, return the original error wrapped with + * SVN_ERR_REPOS_POST_LOCK_HOOK_FAILED. If the caller sees this + * error, it knows that the lock succeeded anyway. + * + * The pre-lock hook may cause a different token to be used for the + * lock, instead of @a token; see the pre-lock-hook documentation for + * more. + * + * @since New in 1.2. + */ +svn_error_t * +svn_repos_fs_lock(svn_lock_t **lock, + svn_repos_t *repos, + const char *path, + const char *token, + const char *comment, + svn_boolean_t is_dav_comment, + apr_time_t expiration_date, + svn_revnum_t current_rev, + svn_boolean_t steal_lock, + apr_pool_t *pool); + + +/** Like svn_fs_unlock(), but invoke the @a repos's pre- and + * post-unlock hooks before and after the unlocking action. Use @a + * pool for any necessary allocations. + * + * If the pre-unlock hook or svn_fs_unlock() fails, throw the original + * error to caller. If an error occurs when running the post-unlock + * hook, return the original error wrapped with + * SVN_ERR_REPOS_POST_UNLOCK_HOOK_FAILED. If the caller sees this + * error, it knows that the unlock succeeded anyway. + * + * @since New in 1.2. + */ +svn_error_t * +svn_repos_fs_unlock(svn_repos_t *repos, + const char *path, + const char *token, + svn_boolean_t break_lock, + apr_pool_t *pool); + + + +/** Look up all the locks in and under @a path in @a repos, setting @a + * *locks to a hash which maps <tt>const char *</tt> paths to the + * #svn_lock_t locks associated with those paths. Use @a + * authz_read_func and @a authz_read_baton to "screen" all returned + * locks. That is: do not return any locks on any paths that are + * unreadable in HEAD, just silently omit them. + * + * @a depth limits the returned locks to those associated with paths + * within the specified depth of @a path, and must be one of the + * following values: #svn_depth_empty, #svn_depth_files, + * #svn_depth_immediates, or #svn_depth_infinity. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_fs_get_locks2(apr_hash_t **locks, + svn_repos_t *repos, + const char *path, + svn_depth_t depth, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_fs_get_locks2(), but with @a depth always + * passed as svn_depth_infinity. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_get_locks(apr_hash_t **locks, + svn_repos_t *repos, + const char *path, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** @} */ + +/** + * Like svn_fs_change_rev_prop2(), but validate the name and value of the + * property and invoke the @a repos's pre- and post-revprop-change hooks + * around the change as specified by @a use_pre_revprop_change_hook and + * @a use_post_revprop_change_hook (respectively). + * + * @a rev is the revision whose property to change, @a name is the + * name of the property, and @a new_value is the new value of the + * property. If @a old_value_p is not @c NULL, then @a *old_value_p + * is the expected current (preexisting) value of the property (or @c NULL + * for "unset"). @a author is the authenticated username of the person + * changing the property value, or NULL if not available. + * + * If @a authz_read_func is non-NULL, then use it (with @a + * authz_read_baton) to validate the changed-paths associated with @a + * rev. If the revision contains any unreadable changed paths, then + * return #SVN_ERR_AUTHZ_UNREADABLE. + * + * Validate @a name and @a new_value like the same way + * svn_repos_fs_change_node_prop() does. + * + * Use @a pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_fs_change_rev_prop4(svn_repos_t *repos, + svn_revnum_t rev, + const char *author, + const char *name, + const svn_string_t *const *old_value_p, + const svn_string_t *new_value, + svn_boolean_t + use_pre_revprop_change_hook, + svn_boolean_t + use_post_revprop_change_hook, + svn_repos_authz_func_t + authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_fs_change_rev_prop4(), but with @a old_value_p always + * set to @c NULL. (In other words, it is similar to + * svn_fs_change_rev_prop().) + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_change_rev_prop3(svn_repos_t *repos, + svn_revnum_t rev, + const char *author, + const char *name, + const svn_string_t *new_value, + svn_boolean_t + use_pre_revprop_change_hook, + svn_boolean_t + use_post_revprop_change_hook, + svn_repos_authz_func_t + authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_fs_change_rev_prop3(), but with the @a + * use_pre_revprop_change_hook and @a use_post_revprop_change_hook + * always set to @c TRUE. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_change_rev_prop2(svn_repos_t *repos, + svn_revnum_t rev, + const char *author, + const char *name, + const svn_string_t *new_value, + svn_repos_authz_func_t + authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_fs_change_rev_prop2(), but with the + * @a authz_read_func parameter always NULL. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_fs_change_rev_prop(svn_repos_t *repos, + svn_revnum_t rev, + const char *author, + const char *name, + const svn_string_t *new_value, + apr_pool_t *pool); + + + +/** + * Set @a *value_p to the value of the property named @a propname on + * revision @a rev in the filesystem opened in @a repos. If @a rev + * has no property by that name, set @a *value_p to zero. Allocate + * the result in @a pool. + * + * If @a authz_read_func is non-NULL, then use it (with @a + * authz_read_baton) to validate the changed-paths associated with @a + * rev. If the changed-paths are all unreadable, then set @a *value_p + * to zero unconditionally. If only some of the changed-paths are + * unreadable, then allow 'svn:author' and 'svn:date' propvalues to be + * fetched, but return 0 for any other property. + * + * @since New in 1.1. + */ +svn_error_t * +svn_repos_fs_revision_prop(svn_string_t **value_p, + svn_repos_t *repos, + svn_revnum_t rev, + const char *propname, + svn_repos_authz_func_t + authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + + +/** + * Set @a *table_p to the entire property list of revision @a rev in + * filesystem opened in @a repos, as a hash table allocated in @a + * pool. The table maps <tt>char *</tt> property names to + * #svn_string_t * values; the names and values are allocated in @a + * pool. + * + * If @a authz_read_func is non-NULL, then use it (with @a + * authz_read_baton) to validate the changed-paths associated with @a + * rev. If the changed-paths are all unreadable, then return an empty + * hash. If only some of the changed-paths are unreadable, then return + * an empty hash, except for 'svn:author' and 'svn:date' properties + * (assuming those properties exist). + * + * @since New in 1.1. + */ +svn_error_t * +svn_repos_fs_revision_proplist(apr_hash_t **table_p, + svn_repos_t *repos, + svn_revnum_t rev, + svn_repos_authz_func_t + authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + + + +/* ---------------------------------------------------------------*/ + +/* Prop-changing wrappers for libsvn_fs routines. */ + +/* NOTE: svn_repos_fs_change_rev_prop() also exists, but is located + above with the hook-related functions. */ + + +/** Validating wrapper for svn_fs_change_node_prop() (which see for + * argument descriptions). + * + * If @a name's kind is not #svn_prop_regular_kind, return + * #SVN_ERR_REPOS_BAD_ARGS. If @a name is an "svn:" property, validate its + * @a value and return SVN_ERR_BAD_PROPERTY_VALUE if it is invalid for the + * property. + * + * @note Currently, the only properties validated are the "svn:" properties + * #SVN_PROP_REVISION_LOG and #SVN_PROP_REVISION_DATE. This may change + * in future releases. + */ +svn_error_t * +svn_repos_fs_change_node_prop(svn_fs_root_t *root, + const char *path, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + +/** Validating wrapper for svn_fs_change_txn_prop() (which see for + * argument descriptions). See svn_repos_fs_change_txn_props() for more + * information. + */ +svn_error_t * +svn_repos_fs_change_txn_prop(svn_fs_txn_t *txn, + const char *name, + const svn_string_t *value, + apr_pool_t *pool); + +/** Validating wrapper for svn_fs_change_txn_props() (which see for + * argument descriptions). Validate properties and their values the + * same way svn_repos_fs_change_node_prop() does. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_fs_change_txn_props(svn_fs_txn_t *txn, + const apr_array_header_t *props, + apr_pool_t *pool); + + +/* ---------------------------------------------------------------*/ + +/** + * @defgroup svn_repos_inspection Data structures and editor things for \ + * repository inspection. + * @{ + * + * As it turns out, the svn_repos_replay2(), svn_repos_dir_delta2() and + * svn_repos_begin_report3() interfaces can be extremely useful for + * examining the repository, or more exactly, changes to the repository. + * These drivers allows for differences between two trees to be + * described using an editor. + * + * By using the editor obtained from svn_repos_node_editor() with one of + * the drivers mentioned above, the description of how to transform one + * tree into another can be used to build an in-memory linked-list tree, + * which each node representing a repository node that was changed. + */ + +/** A node in the repository. */ +typedef struct svn_repos_node_t +{ + /** Node type (file, dir, etc.) */ + svn_node_kind_t kind; + + /** How this node entered the node tree: 'A'dd, 'D'elete, 'R'eplace */ + char action; + + /** Were there any textual mods? (files only) */ + svn_boolean_t text_mod; + + /** Where there any property mods? */ + svn_boolean_t prop_mod; + + /** The name of this node as it appears in its parent's entries list */ + const char *name; + + /** The filesystem revision where this was copied from (if any) */ + svn_revnum_t copyfrom_rev; + + /** The filesystem path where this was copied from (if any) */ + const char *copyfrom_path; + + /** Pointer to the next sibling of this node */ + struct svn_repos_node_t *sibling; + + /** Pointer to the first child of this node */ + struct svn_repos_node_t *child; + + /** Pointer to the parent of this node */ + struct svn_repos_node_t *parent; + +} svn_repos_node_t; + + +/** Set @a *editor and @a *edit_baton to an editor that, when driven by + * a driver such as svn_repos_replay2(), builds an <tt>svn_repos_node_t *</tt> + * tree representing the delta from @a base_root to @a root in @a + * repos's filesystem. + * + * The editor can also be driven by svn_repos_dir_delta2() or + * svn_repos_begin_report3(), but unless you have special needs, + * svn_repos_replay2() is preferred. + * + * Invoke svn_repos_node_from_baton() on @a edit_baton to obtain the root + * node afterwards. + * + * Note that the delta includes "bubbled-up" directories; that is, + * many of the directory nodes will have no prop_mods. + * + * Allocate the tree and its contents in @a node_pool; do all other + * allocation in @a pool. + */ +svn_error_t * +svn_repos_node_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_repos_t *repos, + svn_fs_root_t *base_root, + svn_fs_root_t *root, + apr_pool_t *node_pool, + apr_pool_t *pool); + +/** Return the root node of the linked-list tree generated by driving the + * editor (associated with @a edit_baton) created by svn_repos_node_editor(). + * This is only really useful if used *after* the editor drive is completed. + */ +svn_repos_node_t * +svn_repos_node_from_baton(void *edit_baton); + +/** @} */ + +/* ---------------------------------------------------------------*/ + +/** + * @defgroup svn_repos_dump_load Dumping and loading filesystem data + * @{ + * + * The filesystem 'dump' format contains nothing but the abstract + * structure of the filesystem -- independent of any internal node-id + * schema or database back-end. All of the data in the dumpfile is + * acquired by public function calls into svn_fs.h. Similarly, the + * parser which reads the dumpfile is able to reconstruct the + * filesystem using only public svn_fs.h routines. + * + * Thus the dump/load feature's main purpose is for *migrating* data + * from one svn filesystem to another -- presumably two filesystems + * which have different internal implementations. + * + * If you simply want to backup your filesystem, you're probably + * better off using the built-in facilities of the DB backend (using + * Berkeley DB's hot-backup feature, for example.) + * + * For a description of the dumpfile format, see + * /trunk/notes/fs_dumprestore.txt. + */ + +/* The RFC822-style headers in our dumpfile format. */ +#define SVN_REPOS_DUMPFILE_MAGIC_HEADER "SVN-fs-dump-format-version" +#define SVN_REPOS_DUMPFILE_FORMAT_VERSION 3 +#define SVN_REPOS_DUMPFILE_FORMAT_VERSION_DELTAS 3 +#define SVN_REPOS_DUMPFILE_UUID "UUID" +#define SVN_REPOS_DUMPFILE_CONTENT_LENGTH "Content-length" + +#define SVN_REPOS_DUMPFILE_REVISION_NUMBER "Revision-number" + +#define SVN_REPOS_DUMPFILE_NODE_PATH "Node-path" +#define SVN_REPOS_DUMPFILE_NODE_KIND "Node-kind" +#define SVN_REPOS_DUMPFILE_NODE_ACTION "Node-action" +#define SVN_REPOS_DUMPFILE_NODE_COPYFROM_PATH "Node-copyfrom-path" +#define SVN_REPOS_DUMPFILE_NODE_COPYFROM_REV "Node-copyfrom-rev" +/** @since New in 1.6. */ +#define SVN_REPOS_DUMPFILE_TEXT_COPY_SOURCE_MD5 "Text-copy-source-md5" +/** @since New in 1.6. */ +#define SVN_REPOS_DUMPFILE_TEXT_COPY_SOURCE_SHA1 "Text-copy-source-sha1" +#define SVN_REPOS_DUMPFILE_TEXT_COPY_SOURCE_CHECKSUM \ + SVN_REPOS_DUMPFILE_TEXT_COPY_SOURCE_MD5 +/** @since New in 1.6. */ +#define SVN_REPOS_DUMPFILE_TEXT_CONTENT_MD5 "Text-content-md5" +/** @since New in 1.6. */ +#define SVN_REPOS_DUMPFILE_TEXT_CONTENT_SHA1 "Text-content-sha1" +#define SVN_REPOS_DUMPFILE_TEXT_CONTENT_CHECKSUM \ + SVN_REPOS_DUMPFILE_TEXT_CONTENT_MD5 + +#define SVN_REPOS_DUMPFILE_PROP_CONTENT_LENGTH "Prop-content-length" +#define SVN_REPOS_DUMPFILE_TEXT_CONTENT_LENGTH "Text-content-length" + +/** @since New in 1.1. */ +#define SVN_REPOS_DUMPFILE_PROP_DELTA "Prop-delta" +/** @since New in 1.1. */ +#define SVN_REPOS_DUMPFILE_TEXT_DELTA "Text-delta" +/** @since New in 1.6. */ +#define SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_MD5 "Text-delta-base-md5" +/** @since New in 1.6. */ +#define SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_SHA1 "Text-delta-base-sha1" +/** @since New in 1.5. */ +#define SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_CHECKSUM \ + SVN_REPOS_DUMPFILE_TEXT_DELTA_BASE_MD5 + +/** + * Verify the contents of the file system in @a repos. + * + * If @a feedback_stream is not @c NULL, write feedback to it (lines of + * the form "* Verified revision %ld\n"). + * + * If @a start_rev is #SVN_INVALID_REVNUM, then start verifying at + * revision 0. If @a end_rev is #SVN_INVALID_REVNUM, then verify + * through the @c HEAD revision. + * + * For every verified revision call @a notify_func with @a rev set to + * the verified revision and @a warning_text @c NULL. For warnings call @a + * notify_func with @a warning_text set. + * + * If @a cancel_func is not @c NULL, call it periodically with @a + * cancel_baton as argument to see if the caller wishes to cancel the + * verification. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_verify_fs2(svn_repos_t *repos, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_repos_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_repos_verify_fs2(), but with a feedback_stream instead of + * handling feedback via the notify_func handler + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_verify_fs(svn_repos_t *repos, + svn_stream_t *feedback_stream, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Dump the contents of the filesystem within already-open @a repos into + * writable @a dumpstream. Begin at revision @a start_rev, and dump every + * revision up through @a end_rev. Use @a pool for all allocation. If + * non-@c NULL, send feedback to @a feedback_stream. If @a dumpstream is + * @c NULL, this is effectively a primitive verify. It is not complete, + * however; svn_repos_verify_fs2() and svn_fs_verify(). + * + * If @a start_rev is #SVN_INVALID_REVNUM, then start dumping at revision + * 0. If @a end_rev is #SVN_INVALID_REVNUM, then dump through the @c HEAD + * revision. + * + * If @a incremental is @c TRUE, the first revision dumped will be a diff + * against the previous revision (usually it looks like a full dump of + * the tree). + * + * If @a use_deltas is @c TRUE, output only node properties which have + * changed relative to the previous contents, and output text contents + * as svndiff data against the previous contents. Regardless of how + * this flag is set, the first revision of a non-incremental dump will + * be done with full plain text. A dump with @a use_deltas set cannot + * be loaded by Subversion 1.0.x. + * + * If @a notify_func is not @c NULL, then for every dumped revision call + * @a notify_func with @a rev set to the dumped revision and @a warning_text + * @c NULL. For warnings call @a notify_func with @a warning_text. + * + * If @a cancel_func is not @c NULL, it is called periodically with + * @a cancel_baton as argument to see if the client wishes to cancel + * the dump. + * + * @since New in 1.7. + */ +svn_error_t * +svn_repos_dump_fs3(svn_repos_t *repos, + svn_stream_t *dumpstream, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_boolean_t incremental, + svn_boolean_t use_deltas, + svn_repos_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_repos_dump_fs3(), but with a feedback_stream instead of + * handling feedback via the notify_func handler + * + * @since New in 1.1. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_dump_fs2(svn_repos_t *repos, + svn_stream_t *dumpstream, + svn_stream_t *feedback_stream, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_boolean_t incremental, + svn_boolean_t use_deltas, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_dump_fs2(), but with the @a use_deltas + * parameter always set to @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_dump_fs(svn_repos_t *repos, + svn_stream_t *dumpstream, + svn_stream_t *feedback_stream, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_boolean_t incremental, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Read and parse dumpfile-formatted @a dumpstream, reconstructing + * filesystem revisions in already-open @a repos, handling uuids in + * accordance with @a uuid_action. Use @a pool for all allocation. + * + * If the dumpstream contains copy history that is unavailable in the + * repository, an error will be thrown. + * + * The repository's UUID will be updated iff + * the dumpstream contains a UUID and + * @a uuid_action is not equal to #svn_repos_load_uuid_ignore and + * either the repository contains no revisions or + * @a uuid_action is equal to #svn_repos_load_uuid_force. + * + * If the dumpstream contains no UUID, then @a uuid_action is + * ignored and the repository UUID is not touched. + * + * @a start_rev and @a end_rev act as filters, the lower and upper + * (inclusive) range values of revisions in @a dumpstream which will + * be loaded. Either both of these values are #SVN_INVALID_REVNUM (in + * which case no revision-based filtering occurs at all), or both are + * valid revisions (where @a start_rev is older than or equivalent to + * @a end_rev). + * + * If @a parent_dir is not NULL, then the parser will reparent all the + * loaded nodes, from root to @a parent_dir. The directory @a parent_dir + * must be an existing directory in the repository. + * + * If @a use_pre_commit_hook is set, call the repository's pre-commit + * hook before committing each loaded revision. + * + * If @a use_post_commit_hook is set, call the repository's + * post-commit hook after committing each loaded revision. + * + * If @a validate_props is set, then validate Subversion revision and + * node properties (those in the svn: namespace) against established + * rules for those things. + * + * If non-NULL, use @a notify_func and @a notify_baton to send notification + * of events to the caller. + * + * If @a cancel_func is not @c NULL, it is called periodically with + * @a cancel_baton as argument to see if the client wishes to cancel + * the load. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_load_fs4(svn_repos_t *repos, + svn_stream_t *dumpstream, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + enum svn_repos_load_uuid uuid_action, + const char *parent_dir, + svn_boolean_t use_pre_commit_hook, + svn_boolean_t use_post_commit_hook, + svn_boolean_t validate_props, + svn_repos_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Similar to svn_repos_load_fs4(), but with @a start_rev and @a + * end_rev always passed as #SVN_INVALID_REVNUM. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_load_fs3(svn_repos_t *repos, + svn_stream_t *dumpstream, + enum svn_repos_load_uuid uuid_action, + const char *parent_dir, + svn_boolean_t use_pre_commit_hook, + svn_boolean_t use_post_commit_hook, + svn_boolean_t validate_props, + svn_repos_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_load_fs3(), but with @a feedback_stream in + * place of the #svn_repos_notify_func_t and baton and with + * @a validate_props always FALSE. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_load_fs2(svn_repos_t *repos, + svn_stream_t *dumpstream, + svn_stream_t *feedback_stream, + enum svn_repos_load_uuid uuid_action, + const char *parent_dir, + svn_boolean_t use_pre_commit_hook, + svn_boolean_t use_post_commit_hook, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_load_fs2(), but with @a use_pre_commit_hook and + * @a use_post_commit_hook always @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_load_fs(svn_repos_t *repos, + svn_stream_t *dumpstream, + svn_stream_t *feedback_stream, + enum svn_repos_load_uuid uuid_action, + const char *parent_dir, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * A vtable that is driven by svn_repos_parse_dumpstream3(). + * + * @since New in 1.8. + */ +typedef struct svn_repos_parse_fns3_t +{ + /** The parser has discovered a new "magic header" record within the + * parsing session represented by @a parse_baton. The dump-format + * version number is @a version. + */ + svn_error_t *(*magic_header_record)(int version, + void *parse_baton, + apr_pool_t *pool); + + /** The parser has discovered a new uuid record within the parsing + * session represented by @a parse_baton. The uuid's value is + * @a uuid, and it is allocated in @a pool. + */ + svn_error_t *(*uuid_record)(const char *uuid, + void *parse_baton, + apr_pool_t *pool); + + /** The parser has discovered a new revision record within the + * parsing session represented by @a parse_baton. All the headers are + * placed in @a headers (allocated in @a pool), which maps <tt>const + * char *</tt> header-name ==> <tt>const char *</tt> header-value. + * The @a revision_baton received back (also allocated in @a pool) + * represents the revision. + */ + svn_error_t *(*new_revision_record)(void **revision_baton, + apr_hash_t *headers, + void *parse_baton, + apr_pool_t *pool); + + /** The parser has discovered a new node record within the current + * revision represented by @a revision_baton. All the headers are + * placed in @a headers (as with @c new_revision_record), allocated in + * @a pool. The @a node_baton received back is allocated in @a pool + * and represents the node. + */ + svn_error_t *(*new_node_record)(void **node_baton, + apr_hash_t *headers, + void *revision_baton, + apr_pool_t *pool); + + /** For a given @a revision_baton, set a property @a name to @a value. */ + svn_error_t *(*set_revision_property)(void *revision_baton, + const char *name, + const svn_string_t *value); + + /** For a given @a node_baton, set a property @a name to @a value. */ + svn_error_t *(*set_node_property)(void *node_baton, + const char *name, + const svn_string_t *value); + + /** For a given @a node_baton, delete property @a name. */ + svn_error_t *(*delete_node_property)(void *node_baton, const char *name); + + /** For a given @a node_baton, remove all properties. */ + svn_error_t *(*remove_node_props)(void *node_baton); + + /** For a given @a node_baton, receive a writable @a stream capable of + * receiving the node's fulltext. After writing the fulltext, call + * the stream's close() function. + * + * If a @c NULL is returned instead of a stream, the vtable is + * indicating that no text is desired, and the parser will not + * attempt to send it. + */ + svn_error_t *(*set_fulltext)(svn_stream_t **stream, + void *node_baton); + + /** For a given @a node_baton, set @a handler and @a handler_baton + * to a window handler and baton capable of receiving a delta + * against the node's previous contents. A NULL window will be + * sent to the handler after all the windows are sent. + * + * If a @c NULL is returned instead of a handler, the vtable is + * indicating that no delta is desired, and the parser will not + * attempt to send it. + */ + svn_error_t *(*apply_textdelta)(svn_txdelta_window_handler_t *handler, + void **handler_baton, + void *node_baton); + + /** The parser has reached the end of the current node represented by + * @a node_baton, it can be freed. + */ + svn_error_t *(*close_node)(void *node_baton); + + /** The parser has reached the end of the current revision + * represented by @a revision_baton. In other words, there are no more + * changed nodes within the revision. The baton can be freed. + */ + svn_error_t *(*close_revision)(void *revision_baton); + +} svn_repos_parse_fns3_t; + + +/** + * Read and parse dumpfile-formatted @a stream, calling callbacks in + * @a parse_fns/@a parse_baton, and using @a pool for allocations. + * + * If @a deltas_are_text is @c TRUE, handle text-deltas with the @a + * set_fulltext callback. This is useful when manipulating a dump + * stream without loading it. Otherwise handle text-deltas with the + * @a apply_textdelta callback. + * + * If @a cancel_func is not @c NULL, it is called periodically with + * @a cancel_baton as argument to see if the client wishes to cancel + * the dump. + * + * This parser has built-in knowledge of the dumpfile format, but only + * in a limited sense: + * + * * it recognizes the "magic" format-version header. + * + * * it recognizes the UUID header. + * + * * it recognizes revision and node records by looking for either + * a REVISION_NUMBER or NODE_PATH headers. + * + * * it recognizes the CONTENT-LENGTH headers, so it knows if and + * how to suck up the content body. + * + * * it knows how to parse a content body into two parts: props + * and text, and pass the pieces to the vtable. + * + * This is enough knowledge to make it easy on vtable implementors, + * but still allow expansion of the format: most headers do not have + * to be handled explicitly. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_parse_dumpstream3(svn_stream_t *stream, + const svn_repos_parse_fns3_t *parse_fns, + void *parse_baton, + svn_boolean_t deltas_are_text, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Set @a *parser and @a *parse_baton to a vtable parser which commits new + * revisions to the fs in @a repos. The constructed parser will treat + * UUID records in a manner consistent with @a uuid_action. Use @a pool + * to operate on the fs. + * + * @a start_rev and @a end_rev act as filters, the lower and upper + * (inclusive) range values of revisions in @a dumpstream which will + * be loaded. Either both of these values are #SVN_INVALID_REVNUM (in + * which case no revision-based filtering occurs at all), or both are + * valid revisions (where @a start_rev is older than or equivalent to + * @a end_rev). + * + * If @a use_history is set, then the parser will require relative + * 'copyfrom' history to exist in the repository when it encounters + * nodes that are added-with-history. + * + * If @a validate_props is set, then validate Subversion revision and + * node properties (those in the svn: namespace) against established + * rules for those things. + * + * If @a parent_dir is not NULL, then the parser will reparent all the + * loaded nodes, from root to @a parent_dir. The directory @a parent_dir + * must be an existing directory in the repository. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_get_fs_build_parser4(const svn_repos_parse_fns3_t **parser, + void **parse_baton, + svn_repos_t *repos, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_boolean_t use_history, + svn_boolean_t validate_props, + enum svn_repos_load_uuid uuid_action, + const char *parent_dir, + svn_repos_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + + +/** + * A vtable that is driven by svn_repos_parse_dumpstream2(). + * Similar to #svn_repos_parse_fns3_t except that it lacks + * the delete_node_property and apply_textdelta callbacks. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +typedef struct svn_repos_parse_fns2_t +{ + /** Same as #svn_repos_parse_fns3_t.new_revision_record. */ + svn_error_t *(*new_revision_record)(void **revision_baton, + apr_hash_t *headers, + void *parse_baton, + apr_pool_t *pool); + /** Same as #svn_repos_parse_fns3_t.uuid_record. */ + svn_error_t *(*uuid_record)(const char *uuid, + void *parse_baton, + apr_pool_t *pool); + /** Same as #svn_repos_parse_fns3_t.new_node_record. */ + svn_error_t *(*new_node_record)(void **node_baton, + apr_hash_t *headers, + void *revision_baton, + apr_pool_t *pool); + /** Same as #svn_repos_parse_fns3_t.set_revision_property. */ + svn_error_t *(*set_revision_property)(void *revision_baton, + const char *name, + const svn_string_t *value); + /** Same as #svn_repos_parse_fns3_t.set_node_property. */ + svn_error_t *(*set_node_property)(void *node_baton, + const char *name, + const svn_string_t *value); + /** Same as #svn_repos_parse_fns3_t.delete_node_property. */ + svn_error_t *(*delete_node_property)(void *node_baton, + const char *name); + /** Same as #svn_repos_parse_fns3_t.remove_node_props. */ + svn_error_t *(*remove_node_props)(void *node_baton); + /** Same as #svn_repos_parse_fns3_t.set_fulltext. */ + svn_error_t *(*set_fulltext)(svn_stream_t **stream, + void *node_baton); + /** Same as #svn_repos_parse_fns3_t.apply_textdelta. */ + svn_error_t *(*apply_textdelta)(svn_txdelta_window_handler_t *handler, + void **handler_baton, + void *node_baton); + /** Same as #svn_repos_parse_fns3_t.close_node. */ + svn_error_t *(*close_node)(void *node_baton); + /** Same as #svn_repos_parse_fns3_t.close_revision. */ + svn_error_t *(*close_revision)(void *revision_baton); +} svn_repos_parse_fns2_t; + +/** @deprecated Provided for backward compatibility with the 1.7 API. */ +typedef svn_repos_parse_fns2_t svn_repos_parser_fns2_t; + + +/** + * A vtable that is driven by svn_repos_parse_dumpstream(). + * Similar to #svn_repos_parse_fns2_t except that it lacks + * the delete_node_property and apply_textdelta callbacks. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +typedef struct svn_repos_parse_fns_t +{ + /** Same as #svn_repos_parse_fns2_t.new_revision_record. */ + svn_error_t *(*new_revision_record)(void **revision_baton, + apr_hash_t *headers, + void *parse_baton, + apr_pool_t *pool); + /** Same as #svn_repos_parse_fns2_t.uuid_record. */ + svn_error_t *(*uuid_record)(const char *uuid, + void *parse_baton, + apr_pool_t *pool); + /** Same as #svn_repos_parse_fns2_t.new_node_record. */ + svn_error_t *(*new_node_record)(void **node_baton, + apr_hash_t *headers, + void *revision_baton, + apr_pool_t *pool); + /** Same as #svn_repos_parse_fns2_t.set_revision_property. */ + svn_error_t *(*set_revision_property)(void *revision_baton, + const char *name, + const svn_string_t *value); + /** Same as #svn_repos_parse_fns2_t.set_node_property. */ + svn_error_t *(*set_node_property)(void *node_baton, + const char *name, + const svn_string_t *value); + /** Same as #svn_repos_parse_fns2_t.remove_node_props. */ + svn_error_t *(*remove_node_props)(void *node_baton); + /** Same as #svn_repos_parse_fns2_t.set_fulltext. */ + svn_error_t *(*set_fulltext)(svn_stream_t **stream, + void *node_baton); + /** Same as #svn_repos_parse_fns2_t.close_node. */ + svn_error_t *(*close_node)(void *node_baton); + /** Same as #svn_repos_parse_fns2_t.close_revision. */ + svn_error_t *(*close_revision)(void *revision_baton); +} svn_repos_parser_fns_t; + + +/** + * Similar to svn_repos_parse_dumpstream3(), but uses the more limited + * #svn_repos_parser_fns2_t vtable type. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_parse_dumpstream2(svn_stream_t *stream, + const svn_repos_parser_fns2_t *parse_fns, + void *parse_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_parse_dumpstream2(), but uses the more limited + * #svn_repos_parser_fns_t vtable type. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_parse_dumpstream(svn_stream_t *stream, + const svn_repos_parser_fns_t *parse_fns, + void *parse_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_fs_build_parser4(), but with @a start_rev + * and @a end_rev always passed as #SVN_INVALID_REVNUM, and yielding + * the more limited svn_repos_parse_fns2_t. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_fs_build_parser3(const svn_repos_parse_fns2_t **parser, + void **parse_baton, + svn_repos_t *repos, + svn_boolean_t use_history, + svn_boolean_t validate_props, + enum svn_repos_load_uuid uuid_action, + const char *parent_dir, + svn_repos_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_fs_build_parser3(), but with @a outstream + * in place if a #svn_repos_notify_func_t and baton and with + * @a validate_props always FALSE. + * + * @since New in 1.1. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_fs_build_parser2(const svn_repos_parse_fns2_t **parser, + void **parse_baton, + svn_repos_t *repos, + svn_boolean_t use_history, + enum svn_repos_load_uuid uuid_action, + svn_stream_t *outstream, + const char *parent_dir, + apr_pool_t *pool); + +/** + * Similar to svn_repos_get_fs_build_parser2(), but yields the more + * limited svn_repos_parser_fns_t vtable type. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_get_fs_build_parser(const svn_repos_parser_fns_t **parser, + void **parse_baton, + svn_repos_t *repos, + svn_boolean_t use_history, + enum svn_repos_load_uuid uuid_action, + svn_stream_t *outstream, + const char *parent_dir, + apr_pool_t *pool); + + +/** @} */ + +/** A data type which stores the authz information. + * + * @since New in 1.3. + */ +typedef struct svn_authz_t svn_authz_t; + +/** + * Read authz configuration data from @a path (a dirent, an absolute file url + * or a registry path) into @a *authz_p, allocated in @a pool. + * + * If @a groups_path (a dirent, an absolute file url, or a registry path) is + * set, use the global groups parsed from it. + * + * If @a path or @a groups_path is not a valid authz rule file, then return + * #SVN_ERR_AUTHZ_INVALID_CONFIG. The contents of @a *authz_p is then + * undefined. If @a must_exist is TRUE, a missing authz or groups file + * is also an error other than #SVN_ERR_AUTHZ_INVALID_CONFIG (exact error + * depends on the access type). + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_authz_read2(svn_authz_t **authz_p, + const char *path, + const char *groups_path, + svn_boolean_t must_exist, + apr_pool_t *pool); + + +/** + * Similar to svn_repos_authz_read2(), but with @a groups_path and @a + * repos_root always passed as @c NULL. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_repos_authz_read(svn_authz_t **authz_p, + const char *file, + svn_boolean_t must_exist, + apr_pool_t *pool); + +/** + * Read authz configuration data from @a stream into @a *authz_p, + * allocated in @a pool. + * + * If @a groups_stream is set, use the global groups parsed from it. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_authz_parse(svn_authz_t **authz_p, + svn_stream_t *stream, + svn_stream_t *groups_stream, + apr_pool_t *pool); + +/** + * Check whether @a user can access @a path in the repository @a + * repos_name with the @a required_access. @a authz lists the ACLs to + * check against. Set @a *access_granted to indicate if the requested + * access is granted. + * + * If @a path is NULL, then check whether @a user has the @a + * required_access anywhere in the repository. Set @a *access_granted + * to TRUE if at least one path is accessible with the @a + * required_access. + * + * For compatibility with 1.6, and earlier, @a repos_name can be NULL + * in which case it is equivalent to a @a repos_name of "". + * + * @note Presently, @a repos_name must byte-for-byte match the repos_name + * specified in the authz file; it is treated as an opaque string, and not + * as a dirent. + * + * @since New in 1.3. + */ +svn_error_t * +svn_repos_authz_check_access(svn_authz_t *authz, + const char *repos_name, + const char *path, + const char *user, + svn_repos_authz_access_t required_access, + svn_boolean_t *access_granted, + apr_pool_t *pool); + + + +/** Revision Access Levels + * + * Like most version control systems, access to versioned objects in + * Subversion is determined on primarily path-based system. Users either + * do or don't have the ability to read a given path. + * + * However, unlike many version control systems where versioned objects + * maintain their own distinct version information (revision numbers, + * authors, log messages, change timestamps, etc.), Subversion binds + * multiple paths changed as part of a single commit operation into a + * set, calls the whole thing a revision, and hangs commit metadata + * (author, date, log message, etc.) off of that revision. So, commit + * metadata is shared across all the paths changed as part of a given + * commit operation. + * + * It is common (or, at least, we hope it is) for log messages to give + * detailed information about changes made in the commit to which the log + * message is attached. Such information might include a mention of all + * the files changed, what was changed in them, and so on. But this + * causes a problem when presenting information to readers who aren't + * authorized to read every path in the repository. Simply knowing that + * a given path exists may be a security leak, even if the user can't see + * the contents of the data located at that path. + * + * So Subversion does what it reasonably can to prevent the leak of this + * information, and does so via a staged revision access policy. A + * reader can be said to have one of three levels of access to a given + * revision's metadata, based solely on the reader's access rights to the + * paths changed or copied in that revision: + * + * 'full access' -- Granted when the reader has access to all paths + * changed or copied in the revision, or when no paths were + * changed in the revision at all, this access level permits + * full visibility of all revision property names and values, + * and the full changed-paths information. + * + * 'no access' -- Granted when the reader does not have access to any + * paths changed or copied in the revision, this access level + * denies the reader access to all revision properties and all + * changed-paths information. + * + * 'partial access' -- Granted when the reader has access to at least + * one, but not all, of the paths changed or copied in the revision, + * this access level permits visibility of the svn:date and + * svn:author revision properties and only the paths of the + * changed-paths information to which the reader has access. + * + */ + + +/** An enum defining levels of revision access. + * + * @since New in 1.5. + */ +typedef enum svn_repos_revision_access_level_t +{ + /** no access allowed to the revision properties and all changed-paths + * information. */ + svn_repos_revision_access_none, + /** access granted to some (svn:date and svn:author) revision properties and + * changed-paths information on paths the read has access to. */ + svn_repos_revision_access_partial, + /** access granted to all revision properites and changed-paths + * information. */ + svn_repos_revision_access_full +} +svn_repos_revision_access_level_t; + + +/** + * Set @a access to the access level granted for @a revision in @a + * repos, as determined by consulting the @a authz_read_func callback + * function and its associated @a authz_read_baton. + * + * @a authz_read_func may be @c NULL, in which case @a access will be + * set to #svn_repos_revision_access_full. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_check_revision_access(svn_repos_revision_access_level_t *access_level, + svn_repos_t *repos, + svn_revnum_t revision, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *pool); + +/** + * Set @a *inherited_values to a depth-first ordered array of + * #svn_prop_inherited_item_t * structures (the path_or_url members of + * which are relative filesystem paths) representing the properties + * inherited by @a path in @a root. If no properties are inherited, + * then set @a *inherited_values to an empty array. + * + * if @a propname is NULL then retrieve all explicit and/or inherited + * properties. Otherwise retrieve only the properties named @a propname. + * + * If optional @a authz_read_func is non-NULL, then use this function + * (along with optional @a authz_read_baton) to check the readability + * of each parent path from which properties are inherited. Silently omit + * properties for unreadable parent paths. + * + * Allocate @a *inherited_props in @a result_pool. Use @a scratch_pool for + * temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_repos_fs_get_inherited_props(apr_array_header_t **inherited_props, + svn_fs_root_t *root, + const char *path, + const char *propname, + svn_repos_authz_func_t authz_read_func, + void *authz_read_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Capabilities **/ + +/** + * Store in @a repos the client-reported capabilities @a capabilities, + * which must be allocated in memory at least as long-lived as @a repos. + * + * The elements of @a capabilities are 'const char *', a subset of + * the constants beginning with @c SVN_RA_CAPABILITY_. + * @a capabilities is not copied, so changing it later will affect + * what is remembered by @a repos. + * + * @note The capabilities are passed along to the start-commit hook; + * see that hook's template for details. + * + * @note As of Subversion 1.5, there are no error conditions defined, + * so this always returns SVN_NO_ERROR. In future releases it may + * return error, however, so callers should check. + * + * @since New in 1.5. + */ +svn_error_t * +svn_repos_remember_client_capabilities(svn_repos_t *repos, + const apr_array_header_t *capabilities); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_REPOS_H */ diff --git a/subversion/include/svn_sorts.h b/subversion/include/svn_sorts.h new file mode 100644 index 0000000..b9e05e5 --- /dev/null +++ b/subversion/include/svn_sorts.h @@ -0,0 +1,223 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_sorts.h + * @brief all sorts of sorts. + */ + + +#ifndef SVN_SORTS_H +#define SVN_SORTS_H + +#include <apr.h> /* for apr_ssize_t */ +#include <apr_pools.h> /* for apr_pool_t */ +#include <apr_tables.h> /* for apr_array_header_t */ +#include <apr_hash.h> /* for apr_hash_t */ + +/* Define a MAX macro if we don't already have one */ +#ifndef MAX +#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#endif + +/* Define a MIN macro if we don't already have one */ +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** This structure is used to hold a key/value from a hash table. + * @note Private. For use by Subversion's own code only. See issue #1644. + */ +typedef struct svn_sort__item_t { + /** pointer to the key */ + const void *key; + + /** size of the key */ + apr_ssize_t klen; + + /** pointer to the value */ + void *value; +} svn_sort__item_t; + + +/** Compare two @c svn_sort__item_t's, returning an integer greater than, + * equal to, or less than 0, according to whether the key of @a a is + * greater than, equal to, or less than the key of @a b as determined + * by comparing them with svn_path_compare_paths(). + * + * The key strings must be NULL-terminated, even though klen does not + * include the terminator. + * + * This is useful for converting a hash into a sorted + * @c apr_array_header_t. For example, to convert hash @a hsh to a sorted + * array, do this: + * + * @code + apr_array_header_t *array; + array = svn_sort__hash(hsh, svn_sort_compare_items_as_paths, pool); + @endcode + * + * This function works like svn_sort_compare_items_lexically() except that it + * orders children in subdirectories directly after their parents. This allows + * using the given ordering for a depth first walk, but at a performance + * penalty. Code that doesn't need this special behavior for children, e.g. when + * sorting files at a single directory level should use + * svn_sort_compare_items_lexically() instead. + */ +int +svn_sort_compare_items_as_paths(const svn_sort__item_t *a, + const svn_sort__item_t *b); + + +/** Compare two @c svn_sort__item_t's, returning an integer greater than, + * equal to, or less than 0, according as @a a is greater than, equal to, + * or less than @a b according to a lexical key comparison. The keys are + * not required to be zero-terminated. + */ +int +svn_sort_compare_items_lexically(const svn_sort__item_t *a, + const svn_sort__item_t *b); + +/** Compare two @c svn_revnum_t's, returning an integer greater than, equal + * to, or less than 0, according as @a b is greater than, equal to, or less + * than @a a. Note that this sorts newest revision to oldest (IOW, descending + * order). + * + * This function is compatible for use with qsort(). + * + * This is useful for converting an array of revisions into a sorted + * @c apr_array_header_t. You are responsible for detecting, preventing or + * removing duplicates. + */ +int +svn_sort_compare_revisions(const void *a, + const void *b); + + +/** + * Compare two @c const char * paths, @a *a and @a *b, returning an + * integer greater than, equal to, or less than 0, using the same + * comparison rules as are used by svn_path_compare_paths(). + * + * This function is compatible for use with qsort(). + * + * @since New in 1.1. + */ +int +svn_sort_compare_paths(const void *a, + const void *b); + +/** + * Compare two @c svn_merge_range_t *'s, @a *a and @a *b, returning an + * integer greater than, equal to, or less than 0 if the first range is + * greater than, equal to, or less than, the second range. + * + * Both @c svn_merge_range_t *'s must describe forward merge ranges. + * + * If @a *a and @a *b intersect then the range with the lower start revision + * is considered the lesser range. If the ranges' start revisions are + * equal then the range with the lower end revision is considered the + * lesser range. + * + * @since New in 1.5 + */ +int +svn_sort_compare_ranges(const void *a, + const void *b); + +/** Sort @a ht according to its keys, return an @c apr_array_header_t + * containing @c svn_sort__item_t structures holding those keys and values + * (i.e. for each @c svn_sort__item_t @a item in the returned array, + * @a item->key and @a item->size are the hash key, and @a item->value points to + * the hash value). + * + * Storage is shared with the original hash, not copied. + * + * @a comparison_func should take two @c svn_sort__item_t's and return an + * integer greater than, equal to, or less than 0, according as the first item + * is greater than, equal to, or less than the second. + * + * @note Private. For use by Subversion's own code only. See issue #1644. + * + * @note This function and the @c svn_sort__item_t should go over to APR. + */ +apr_array_header_t * +svn_sort__hash(apr_hash_t *ht, + int (*comparison_func)(const svn_sort__item_t *, + const svn_sort__item_t *), + apr_pool_t *pool); + +/* Return the lowest index at which the element @a *key should be inserted into + * the array @a array, according to the ordering defined by @a compare_func. + * The array must already be sorted in the ordering defined by @a compare_func. + * @a compare_func is defined as for the C stdlib function bsearch(). + * + * @note Private. For use by Subversion's own code only. + */ +int +svn_sort__bsearch_lower_bound(const void *key, + const apr_array_header_t *array, + int (*compare_func)(const void *, const void *)); + +/* Insert a shallow copy of @a *new_element into the array @a array at the index + * @a insert_index, growing the array and shuffling existing elements along to + * make room. + * + * @note Private. For use by Subversion's own code only. + */ +void +svn_sort__array_insert(const void *new_element, + apr_array_header_t *array, + int insert_index); + + +/* Remove @a elements_to_delete elements starting at @a delete_index from the + * array @a arr. If @a delete_index is not a valid element of @a arr, + * @a elements_to_delete is not greater than zero, or + * @a delete_index + @a elements_to_delete is greater than @a arr->nelts, + * then do nothing. + * + * @note Private. For use by Subversion's own code only. + */ +void +svn_sort__array_delete(apr_array_header_t *arr, + int delete_index, + int elements_to_delete); + +/* Reverse the order of elements in @a array, in place. + * + * @note Private. For use by Subversion's own code only. + */ +void +svn_sort__array_reverse(apr_array_header_t *array, + apr_pool_t *scratch_pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_SORTS_H */ diff --git a/subversion/include/svn_string.h b/subversion/include/svn_string.h new file mode 100644 index 0000000..d8ce02b --- /dev/null +++ b/subversion/include/svn_string.h @@ -0,0 +1,577 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_string.h + * @brief Counted-length strings for Subversion, plus some C string goodies. + * + * There are two string datatypes: @c svn_string_t and @c svn_stringbuf_t. + * The former is a simple pointer/length pair useful for passing around + * strings (or arbitrary bytes) with a counted length. @c svn_stringbuf_t is + * buffered to enable efficient appending of strings without an allocation + * and copy for each append operation. + * + * @c svn_string_t contains a <tt>const char *</tt> for its data, so it is + * most appropriate for constant data and for functions which expect constant, + * counted data. Functions should generally use <tt>const @c svn_string_t + * *</tt> as their parameter to indicate they are expecting a constant, + * counted string. + * + * @c svn_stringbuf_t uses a plain <tt>char *</tt> for its data, so it is + * most appropriate for modifiable data. + * + * <h3>Invariants</h3> + * + * 1. Null termination: + * + * Both structures maintain a significant invariant: + * + * <tt>s->data[s->len] == '\\0'</tt> + * + * The functions defined within this header file will maintain + * the invariant (which does imply that memory is + * allocated/defined as @c len+1 bytes). If code outside of the + * @c svn_string.h functions manually builds these structures, + * then they must enforce this invariant. + * + * Note that an @c svn_string(buf)_t may contain binary data, + * which means that strlen(s->data) does not have to equal @c + * s->len. The null terminator is provided to make it easier to + * pass @c s->data to C string interfaces. + * + * + * 2. Non-NULL input: + * + * All the functions assume their input data pointer is non-NULL, + * unless otherwise documented, and may seg fault if passed + * NULL. The input data may *contain* null bytes, of course, just + * the data pointer itself must not be NULL. + * + * <h3>Memory allocation</h3> + * + * All the functions make a deep copy of all input data, and never store + * a pointer to the original input data. + */ + + +#ifndef SVN_STRING_H +#define SVN_STRING_H + +#include <apr.h> /* for apr_size_t */ +#include <apr_pools.h> /* for apr_pool_t */ +#include <apr_tables.h> /* for apr_array_header_t */ + +#include "svn_types.h" /* for svn_boolean_t, svn_error_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup svn_string String handling + * @{ + */ + + + +/** A simple counted string. */ +typedef struct svn_string_t +{ + const char *data; /**< pointer to the bytestring */ + apr_size_t len; /**< length of bytestring */ +} svn_string_t; + +/** A buffered string, capable of appending without an allocation and copy + * for each append. */ +typedef struct svn_stringbuf_t +{ + /** a pool from which this string was originally allocated, and is not + * necessarily specific to this string. This is used only for allocating + * more memory from when the string needs to grow. + */ + apr_pool_t *pool; + + /** pointer to the bytestring */ + char *data; + + /** length of bytestring */ + apr_size_t len; + + /** total size of buffer allocated */ + apr_size_t blocksize; +} svn_stringbuf_t; + + +/** + * @defgroup svn_string_svn_string_t svn_string_t functions + * @{ + */ + +/** Create a new string copied from the null-terminated C string @a cstring. + */ +svn_string_t * +svn_string_create(const char *cstring, apr_pool_t *pool); + +/** Create a new, empty string. + * + * @since New in 1.8. + */ +svn_string_t * +svn_string_create_empty(apr_pool_t *pool); + +/** Create a new string copied from a generic string of bytes, @a bytes, of + * length @a size bytes. @a bytes is NOT assumed to be null-terminated, but + * the new string will be. + */ +svn_string_t * +svn_string_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool); + +/** Create a new string copied from the stringbuf @a strbuf. + */ +svn_string_t * +svn_string_create_from_buf(const svn_stringbuf_t *strbuf, apr_pool_t *pool); + +/** Create a new string by printf-style formatting using @a fmt and the + * variable arguments, which are as appropriate for apr_psprintf(). + */ +svn_string_t * +svn_string_createf(apr_pool_t *pool, const char *fmt, ...) + __attribute__((format(printf, 2, 3))); + +/** Create a new string by printf-style formatting using @c fmt and @a ap. + * This is the same as svn_string_createf() except for the different + * way of passing the variable arguments. + */ +svn_string_t * +svn_string_createv(apr_pool_t *pool, const char *fmt, va_list ap) + __attribute__((format(printf, 2, 0))); + +/** Return TRUE if @a str is empty (has length zero). */ +svn_boolean_t +svn_string_isempty(const svn_string_t *str); + +/** Return a duplicate of @a original_string. */ +svn_string_t * +svn_string_dup(const svn_string_t *original_string, apr_pool_t *pool); + +/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */ +svn_boolean_t +svn_string_compare(const svn_string_t *str1, const svn_string_t *str2); + +/** Return offset of first non-whitespace character in @a str, or return + * @a str->len if none. + */ +apr_size_t +svn_string_first_non_whitespace(const svn_string_t *str); + +/** Return position of last occurrence of @a ch in @a str, or return + * @a str->len if no occurrence. + */ +apr_size_t +svn_string_find_char_backward(const svn_string_t *str, char ch); + +/** @} */ + + +/** + * @defgroup svn_string_svn_stringbuf_t svn_stringbuf_t functions + * @{ + */ + +/** Create a new stringbuf copied from the null-terminated C string + * @a cstring. + */ +svn_stringbuf_t * +svn_stringbuf_create(const char *cstring, apr_pool_t *pool); + +/** Create a new stringbuf copied from the generic string of bytes, @a bytes, + * of length @a size bytes. @a bytes is NOT assumed to be null-terminated, + * but the new stringbuf will be. + */ +svn_stringbuf_t * +svn_stringbuf_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool); + +/** Create a new, empty stringbuf. + * + * @since New in 1.8. + */ +svn_stringbuf_t * +svn_stringbuf_create_empty(apr_pool_t *pool); + +/** Create a new, empty stringbuf with at least @a minimum_size bytes of + * space available in the memory block. + * + * The allocated string buffer will be at least one byte larger than + * @a minimum_size to account for a final '\\0'. + * + * @since New in 1.6. + */ +svn_stringbuf_t * +svn_stringbuf_create_ensure(apr_size_t minimum_size, apr_pool_t *pool); + +/** Create a new stringbuf copied from the string @a str. + */ +svn_stringbuf_t * +svn_stringbuf_create_from_string(const svn_string_t *str, apr_pool_t *pool); + +/** Create a new stringbuf by printf-style formatting using @a fmt and the + * variable arguments, which are as appropriate for apr_psprintf(). + */ +svn_stringbuf_t * +svn_stringbuf_createf(apr_pool_t *pool, const char *fmt, ...) + __attribute__((format(printf, 2, 3))); + +/** Create a new stringbuf by printf-style formatting using @c fmt and @a ap. + * This is the same as svn_stringbuf_createf() except for the different + * way of passing the variable arguments. + */ +svn_stringbuf_t * +svn_stringbuf_createv(apr_pool_t *pool, const char *fmt, va_list ap) + __attribute__((format(printf, 2, 0))); + +/** Make sure that @a str has at least @a minimum_size + * bytes of space available in the memory block. + * + * The allocated string buffer will be at least one byte larger than + * @a minimum_size to account for a final '\\0'. + * + * @note: Before Subversion 1.8 this function did not ensure space for + * one byte more than @a minimum_size. If compatibility with pre-1.8 + * behaviour is required callers must assume space for only + * @a minimum_size-1 data bytes plus a final '\\0'. + */ +void +svn_stringbuf_ensure(svn_stringbuf_t *str, apr_size_t minimum_size); + +/** Set @a str to a copy of the null-terminated C string @a value. */ +void +svn_stringbuf_set(svn_stringbuf_t *str, const char *value); + +/** Set @a str to empty (zero length). */ +void +svn_stringbuf_setempty(svn_stringbuf_t *str); + +/** Return @c TRUE if @a str is empty (has length zero). */ +svn_boolean_t +svn_stringbuf_isempty(const svn_stringbuf_t *str); + +/** Chop @a nbytes bytes off end of @a str, but not more than @a str->len. */ +void +svn_stringbuf_chop(svn_stringbuf_t *str, apr_size_t nbytes); + +/** Fill @a str with character @a c. */ +void +svn_stringbuf_fillchar(svn_stringbuf_t *str, unsigned char c); + +/** Append the single character @a byte onto @a targetstr. + * + * This is an optimized version of svn_stringbuf_appendbytes() + * that is much faster to call and execute. Gains vary with the ABI. + * The advantages extend beyond the actual call because the reduced + * register pressure allows for more optimization within the caller. + * + * reallocs if necessary. @a targetstr is affected, nothing else is. + * @since New in 1.7. + */ +void +svn_stringbuf_appendbyte(svn_stringbuf_t *targetstr, + char byte); + +/** Append an array of bytes onto @a targetstr. + * + * reallocs if necessary. @a targetstr is affected, nothing else is. + */ +void +svn_stringbuf_appendbytes(svn_stringbuf_t *targetstr, + const char *bytes, + apr_size_t count); + +/** Append the stringbuf @c appendstr onto @a targetstr. + * + * reallocs if necessary. @a targetstr is affected, nothing else is. + */ +void +svn_stringbuf_appendstr(svn_stringbuf_t *targetstr, + const svn_stringbuf_t *appendstr); + +/** Append the C string @a cstr onto @a targetstr. + * + * reallocs if necessary. @a targetstr is affected, nothing else is. + */ +void +svn_stringbuf_appendcstr(svn_stringbuf_t *targetstr, + const char *cstr); + +/** Read @a count bytes from @a bytes and insert them into @a str at + * position @a pos and following. The resulting string will be + * @c count+str->len bytes long. If @c pos is larger or equal to the + * number of bytes currently used in @a str, simply append @a bytes. + * + * Reallocs if necessary. @a str is affected, nothing else is. + * + * @note The inserted string may be a sub-range if @a str. + * + * @since New in 1.8. + */ +void +svn_stringbuf_insert(svn_stringbuf_t *str, + apr_size_t pos, + const char *bytes, + apr_size_t count); + +/** Removes @a count bytes from @a str, starting at position @a pos. + * If that range exceeds the current string data, @a str gets truncated + * at @a pos. If the latter is larger or equal to @c str->pos, this will + * be a no-op. Otherwise, the resulting string will be @c str->len-count + * bytes long. + * + * @since New in 1.8. + */ +void +svn_stringbuf_remove(svn_stringbuf_t *str, + apr_size_t pos, + apr_size_t count); + +/** Replace in @a str the substring which starts at @a pos and is @a + * old_count bytes long with a new substring @a bytes (which is @a + * new_count bytes long). + * + * This is faster but functionally equivalent to the following sequence: + * @code + svn_stringbuf_remove(str, pos, old_count); + svn_stringbuf_insert(str, pos, bytes, new_count); + * @endcode + * + * @since New in 1.8. + */ +void +svn_stringbuf_replace(svn_stringbuf_t *str, + apr_size_t pos, + apr_size_t old_count, + const char *bytes, + apr_size_t new_count); + +/** Return a duplicate of @a original_string. */ +svn_stringbuf_t * +svn_stringbuf_dup(const svn_stringbuf_t *original_string, apr_pool_t *pool); + +/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */ +svn_boolean_t +svn_stringbuf_compare(const svn_stringbuf_t *str1, + const svn_stringbuf_t *str2); + +/** Return offset of first non-whitespace character in @a str, or return + * @a str->len if none. + */ +apr_size_t +svn_stringbuf_first_non_whitespace(const svn_stringbuf_t *str); + +/** Strip whitespace from both sides of @a str (modified in place). */ +void +svn_stringbuf_strip_whitespace(svn_stringbuf_t *str); + +/** Return position of last occurrence of @a ch in @a str, or return + * @a str->len if no occurrence. + */ +apr_size_t +svn_stringbuf_find_char_backward(const svn_stringbuf_t *str, char ch); + +/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */ +svn_boolean_t +svn_string_compare_stringbuf(const svn_string_t *str1, + const svn_stringbuf_t *str2); + +/** @} */ + + +/** + * @defgroup svn_string_cstrings C string functions + * @{ + */ + +/** Divide @a input into substrings along @a sep_chars boundaries, return an + * array of copies of those substrings (plain const char*), allocating both + * the array and the copies in @a pool. + * + * None of the elements added to the array contain any of the + * characters in @a sep_chars, and none of the new elements are empty + * (thus, it is possible that the returned array will have length + * zero). + * + * If @a chop_whitespace is TRUE, then remove leading and trailing + * whitespace from the returned strings. + */ +apr_array_header_t * +svn_cstring_split(const char *input, + const char *sep_chars, + svn_boolean_t chop_whitespace, + apr_pool_t *pool); + +/** Like svn_cstring_split(), but append to existing @a array instead of + * creating a new one. Allocate the copied substrings in @a pool + * (i.e., caller decides whether or not to pass @a array->pool as @a pool). + */ +void +svn_cstring_split_append(apr_array_header_t *array, + const char *input, + const char *sep_chars, + svn_boolean_t chop_whitespace, + apr_pool_t *pool); + + +/** Return @c TRUE iff @a str matches any of the elements of @a list, a list + * of zero or more glob patterns. + */ +svn_boolean_t +svn_cstring_match_glob_list(const char *str, const apr_array_header_t *list); + +/** Return @c TRUE iff @a str exactly matches any of the elements of @a list. + * + * @since new in 1.7 + */ +svn_boolean_t +svn_cstring_match_list(const char *str, const apr_array_header_t *list); + +/** + * Get the next token from @a *str interpreting any char from @a sep as a + * token separator. Separators at the beginning of @a str will be skipped. + * Returns a pointer to the beginning of the first token in @a *str or NULL + * if no token is left. Modifies @a str such that the next call will return + * the next token. + * + * @note The content of @a *str may be modified by this function. + * + * @since New in 1.8. + */ +char * +svn_cstring_tokenize(const char *sep, char **str); + +/** + * Return the number of line breaks in @a msg, allowing any kind of newline + * termination (CR, LF, CRLF, or LFCR), even inconsistent. + * + * @since New in 1.2. + */ +int +svn_cstring_count_newlines(const char *msg); + +/** + * Return a cstring which is the concatenation of @a strings (an array + * of char *) each followed by @a separator (that is, @a separator + * will also end the resulting string). Allocate the result in @a pool. + * If @a strings is empty, then return the empty string. + * + * @since New in 1.2. + */ +char * +svn_cstring_join(const apr_array_header_t *strings, + const char *separator, + apr_pool_t *pool); + +/** + * Compare two strings @a atr1 and @a atr2, treating case-equivalent + * unaccented Latin (ASCII subset) letters as equal. + * + * Returns in integer greater than, equal to, or less than 0, + * according to whether @a str1 is considered greater than, equal to, + * or less than @a str2. + * + * @since New in 1.5. + */ +int +svn_cstring_casecmp(const char *str1, const char *str2); + +/** + * Parse the C string @a str into a 64 bit number, and return it in @a *n. + * Assume that the number is represented in base @a base. + * Raise an error if conversion fails (e.g. due to overflow), or if the + * converted number is smaller than @a minval or larger than @a maxval. + * + * @since New in 1.7. + */ +svn_error_t * +svn_cstring_strtoi64(apr_int64_t *n, const char *str, + apr_int64_t minval, apr_int64_t maxval, + int base); + +/** + * Parse the C string @a str into a 64 bit number, and return it in @a *n. + * Assume that the number is represented in base 10. + * Raise an error if conversion fails (e.g. due to overflow). + * + * @since New in 1.7. + */ +svn_error_t * +svn_cstring_atoi64(apr_int64_t *n, const char *str); + +/** + * Parse the C string @a str into a 32 bit number, and return it in @a *n. + * Assume that the number is represented in base 10. + * Raise an error if conversion fails (e.g. due to overflow). + * + * @since New in 1.7. + */ +svn_error_t * +svn_cstring_atoi(int *n, const char *str); + +/** + * Parse the C string @a str into an unsigned 64 bit number, and return + * it in @a *n. Assume that the number is represented in base @a base. + * Raise an error if conversion fails (e.g. due to overflow), or if the + * converted number is smaller than @a minval or larger than @a maxval. + * + * @since New in 1.7. + */ +svn_error_t * +svn_cstring_strtoui64(apr_uint64_t *n, const char *str, + apr_uint64_t minval, apr_uint64_t maxval, + int base); + +/** + * Parse the C string @a str into an unsigned 64 bit number, and return + * it in @a *n. Assume that the number is represented in base 10. + * Raise an error if conversion fails (e.g. due to overflow). + * + * @since New in 1.7. + */ +svn_error_t * +svn_cstring_atoui64(apr_uint64_t *n, const char *str); + +/** + * Parse the C string @a str into an unsigned 32 bit number, and return + * it in @a *n. Assume that the number is represented in base 10. + * Raise an error if conversion fails (e.g. due to overflow). + * + * @since New in 1.7. + */ +svn_error_t * +svn_cstring_atoui(unsigned int *n, const char *str); + +/** @} */ + +/** @} */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_STRING_H */ diff --git a/subversion/include/svn_subst.h b/subversion/include/svn_subst.h new file mode 100644 index 0000000..98aaf3e --- /dev/null +++ b/subversion/include/svn_subst.h @@ -0,0 +1,708 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_subst.h + * @brief Data substitution (keywords and EOL style) + */ + + + +#ifndef SVN_SUBST_H +#define SVN_SUBST_H + +#include <apr_pools.h> +#include <apr_hash.h> +#include <apr_time.h> + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_io.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* EOL conversion and keyword expansion. */ + +/** The EOL used in the Repository for "native" files */ +#define SVN_SUBST_NATIVE_EOL_STR "\n" + +/** Valid states for 'svn:eol-style' property. + * + * Property nonexistence is equivalent to 'none'. + */ +typedef enum svn_subst_eol_style +{ + /** An unrecognized style */ + svn_subst_eol_style_unknown, + + /** EOL translation is "off" or ignored value */ + svn_subst_eol_style_none, + + /** Translation is set to client's native eol */ + svn_subst_eol_style_native, + + /** Translation is set to one of LF, CR, CRLF */ + svn_subst_eol_style_fixed + +} svn_subst_eol_style_t; + +/** Set @a *style to the appropriate @c svn_subst_eol_style_t and @a *eol to + * the appropriate cstring for a given svn:eol-style property value. + * + * Set @a *eol to + * + * - @c NULL for @c svn_subst_eol_style_none, or + * + * - a NULL-terminated C string containing the native eol marker + * for this platform, for @c svn_subst_eol_style_native, or + * + * - a NULL-terminated C string containing the eol marker indicated + * by the property value, for @c svn_subst_eol_style_fixed. + * + * If @a *style is NULL, it is ignored. + */ +void +svn_subst_eol_style_from_value(svn_subst_eol_style_t *style, + const char **eol, + const char *value); + +/** Indicates whether the working copy and normalized versions of a file + * with the given the parameters differ. If @a force_eol_check is TRUE, + * the routine also accounts for all translations required due to repairing + * fixed eol styles. + * + * @since New in 1.4 + * + */ +svn_boolean_t +svn_subst_translation_required(svn_subst_eol_style_t style, + const char *eol, + apr_hash_t *keywords, + svn_boolean_t special, + svn_boolean_t force_eol_check); + + +/** Values used in keyword expansion. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +typedef struct svn_subst_keywords_t +{ + /** + * @name svn_subst_keywords_t fields + * String expansion of the like-named keyword, or NULL if the keyword + * was not selected in the svn:keywords property. + * @{ + */ + const svn_string_t *revision; + const svn_string_t *date; + const svn_string_t *author; + const svn_string_t *url; + const svn_string_t *id; + /** @} */ +} svn_subst_keywords_t; + + +/** + * Set @a *kw to a new keywords hash filled with the appropriate contents + * given a @a keywords_string (the contents of the svn:keywords + * property for the file in question), the revision @a rev, the @a url, + * the @a date the file was committed on, the @a author of the last + * commit, and the URL of the repository root @a repos_root_url. + * + * Custom keywords defined in svn:keywords properties are expanded + * using the provided parameters and in accordance with the following + * format substitutions in the @a keywords_string: + * %a - The author. + * %b - The basename of the URL. + * %d - Short format of the date. + * %D - Long format of the date. + * %P - The file's path, relative to the repository root URL. + * %r - The revision. + * %R - The URL to the root of the repository. + * %u - The URL of the file. + * %_ - A space (keyword definitions cannot contain a literal space). + * %% - A literal '%'. + * %H - Equivalent to %P%_%r%_%d%_%a. + * %I - Equivalent to %b%_%r%_%d%_%a. + * + * Custom keywords are defined by appending '=' to the keyword name, followed + * by a string containing any combination of the format substitutions. + * + * Any of the inputs @a rev, @a url, @a date, @a author, and @a repos_root_url + * can be @c NULL, or @c 0 for @a date, to indicate that the information is + * not present. Each piece of information that is not present expands to the + * empty string wherever it appears in an expanded keyword value. (This can + * result in multiple adjacent spaces in the expansion of a multi-valued + * keyword such as "Id".) + * + * Hash keys are of type <tt>const char *</tt>. + * Hash values are of type <tt>svn_string_t *</tt>. + * + * All memory is allocated out of @a pool. + * + * @since New in 1.8. + */ +svn_error_t * +svn_subst_build_keywords3(apr_hash_t **kw, + const char *keywords_string, + const char *rev, + const char *url, + const char *repos_root_url, + apr_time_t date, + const char *author, + apr_pool_t *pool); + +/** Similar to svn_subst_build_keywords3() except that it does not accept + * the @a repos_root_url parameter and hence supports less substitutions, + * and also does not support custom keyword definitions. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_build_keywords2(apr_hash_t **kw, + const char *keywords_string, + const char *rev, + const char *url, + apr_time_t date, + const char *author, + apr_pool_t *pool); + +/** Similar to svn_subst_build_keywords2() except that it populates + * an existing structure @a *kw instead of creating a keywords hash. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_build_keywords(svn_subst_keywords_t *kw, + const char *keywords_string, + const char *rev, + const char *url, + apr_time_t date, + const char *author, + apr_pool_t *pool); + + +/** Return @c TRUE if @a a and @a b do not hold the same keywords. + * + * @a a and @a b are hashes of the form produced by + * svn_subst_build_keywords2(). + * + * @since New in 1.3. + * + * If @a compare_values is @c TRUE, "same" means that the @a a and @a b + * contain exactly the same set of keywords, and the values of corresponding + * keywords match as well. Else if @a compare_values is @c FALSE, then + * "same" merely means that @a a and @a b hold the same set of keywords, + * although those keywords' values might differ. + * + * @a a and/or @a b may be @c NULL; for purposes of comparison, @c NULL is + * equivalent to holding no keywords. + */ +svn_boolean_t +svn_subst_keywords_differ2(apr_hash_t *a, + apr_hash_t *b, + svn_boolean_t compare_values, + apr_pool_t *pool); + +/** Similar to svn_subst_keywords_differ2() except that it compares + * two @c svn_subst_keywords_t structs instead of keyword hashes. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_boolean_t +svn_subst_keywords_differ(const svn_subst_keywords_t *a, + const svn_subst_keywords_t *b, + svn_boolean_t compare_values); + + +/** + * Copy and translate the data in @a src_stream into @a dst_stream. It is + * assumed that @a src_stream is a readable stream and @a dst_stream is a + * writable stream. + * + * If @a eol_str is non-@c NULL, replace whatever bytestring @a src_stream + * uses to denote line endings with @a eol_str in the output. If + * @a src_stream has an inconsistent line ending style, then: if @a repair + * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is + * @c TRUE, convert any line ending in @a src_stream to @a eol_str in + * @a dst_stream. Recognized line endings are: "\n", "\r", and "\r\n". + * + * See svn_subst_stream_translated() for details of the keyword substitution + * which is controlled by the @a expand and @a keywords parameters. + * + * Note that a translation request is *required*: one of @a eol_str or + * @a keywords must be non-@c NULL. + * + * Notes: + * + * See svn_wc__get_keywords() and svn_wc__get_eol_style() for a + * convenient way to get @a eol_str and @a keywords if in libsvn_wc. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + * Callers should use svn_subst_stream_translated() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_translate_stream3(svn_stream_t *src_stream, + svn_stream_t *dst_stream, + const char *eol_str, + svn_boolean_t repair, + apr_hash_t *keywords, + svn_boolean_t expand, + apr_pool_t *scratch_pool); + + +/** Similar to svn_subst_translate_stream3() except relies upon a + * @c svn_subst_keywords_t struct instead of a hash for the keywords. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_translate_stream2(svn_stream_t *src_stream, + svn_stream_t *dst_stream, + const char *eol_str, + svn_boolean_t repair, + const svn_subst_keywords_t *keywords, + svn_boolean_t expand, + apr_pool_t *scratch_pool); + + +/** + * Same as svn_subst_translate_stream2(), but does not take a @a pool + * argument, instead creates a temporary subpool of the global pool, and + * destroys it before returning. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_translate_stream(svn_stream_t *src_stream, + svn_stream_t *dst_stream, + const char *eol_str, + svn_boolean_t repair, + const svn_subst_keywords_t *keywords, + svn_boolean_t expand); + + +/** Return a stream which performs eol translation and keyword + * expansion when read from or written to. The stream @a stream + * is used to read and write all data. + * + * Make sure you call svn_stream_close() on the returned stream to + * ensure all data is flushed and cleaned up (this will also close + * the provided @a stream). + * + * Read operations from and write operations to the stream + * perform the same operation: if @a expand is @c FALSE, both + * contract keywords. One stream supports both read and write + * operations. Reads and writes may be mixed. + * + * If @a eol_str is non-@c NULL, replace whatever bytestring the input uses + * to denote line endings with @a eol_str in the output. If the input has + * an inconsistent line ending style, then: if @a repair is @c FALSE, then a + * subsequent read, write or other operation on the stream will return + * @c SVN_ERR_IO_INCONSISTENT_EOL when the inconsistency is detected, else + * if @a repair is @c TRUE, convert any line ending to @a eol_str. + * Recognized line endings are: "\n", "\r", and "\r\n". + * + * Expand and contract keywords using the contents of @a keywords as the + * new values. If @a expand is @c TRUE, expand contracted keywords and + * re-expand expanded keywords. If @a expand is @c FALSE, contract expanded + * keywords and ignore contracted ones. Keywords not found in the hash are + * ignored (not contracted or expanded). If the @a keywords hash + * itself is @c NULL, keyword substitution will be altogether ignored. + * + * Detect only keywords that are no longer than @c SVN_KEYWORD_MAX_LEN + * bytes, including the delimiters and the keyword itself. + * + * Recommendation: if @a expand is FALSE, then you don't care about the + * keyword values, so use empty strings as non-NULL signifiers when you + * build the keywords hash. + * + * The stream returned is allocated in @a result_pool. + * + * If the inner stream implements resetting via svn_stream_reset(), + * or marking and seeking via svn_stream_mark() and svn_stream_seek(), + * the translated stream will too. + * + * @since New in 1.4. + */ +svn_stream_t * +svn_subst_stream_translated(svn_stream_t *stream, + const char *eol_str, + svn_boolean_t repair, + apr_hash_t *keywords, + svn_boolean_t expand, + apr_pool_t *result_pool); + + +/** Set @a *stream to a stream which performs eol translation and keyword + * expansion when read from or written to. The stream @a source + * is used to read and write all data. Make sure you call + * svn_stream_close() on @a stream to make sure all data are flushed + * and cleaned up. + * + * When @a stream is closed, then @a source will be closed. + * + * Read and write operations perform the same transformation: + * all data is translated to normal form. + * + * @see svn_subst_translate_to_normal_form() + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_stream_translated_to_normal_form(svn_stream_t **stream, + svn_stream_t *source, + svn_subst_eol_style_t eol_style, + const char *eol_str, + svn_boolean_t always_repair_eols, + apr_hash_t *keywords, + apr_pool_t *pool); + + +/** Set @a *stream to a readable stream containing the "normal form" + * of the special file located at @a path. The stream will be allocated + * in @a result_pool, and any temporary allocations will be made in + * @a scratch_pool. + * + * If the file at @a path is in fact a regular file, just read its content, + * which should be in the "normal form" for a special file. This enables + * special files to be written and read on platforms that do not treat them + * as special. + * + * @since New in 1.6. + */ +svn_error_t * +svn_subst_read_specialfile(svn_stream_t **stream, + const char *path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Set @a *stream to a writable stream that accepts content in + * the "normal form" for a special file, to be located at @a path, and + * will create that file when the stream is closed. The stream will be + * allocated in @a result_pool, and any temporary allocations will be + * made in @a scratch_pool. + * + * If the platform does not support the semantics of the special file, write + * a regular file containing the "normal form" text. This enables special + * files to be written and read on platforms that do not treat them as + * special. + * + * Note: the target file is created in a temporary location, then renamed + * into position, so the creation can be considered "atomic". + * + * @since New in 1.6. + */ +svn_error_t * +svn_subst_create_specialfile(svn_stream_t **stream, + const char *path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Set @a *stream to a stream which translates the special file at @a path + * to the internal representation for special files when read from. When + * written to, it does the reverse: creating a special file when the + * stream is closed. + * + * @since New in 1.5. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + * Callers should use svn_subst_read_specialfile or + * svn_subst_create_specialfile as appropriate. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_stream_from_specialfile(svn_stream_t **stream, + const char *path, + apr_pool_t *pool); + + +/** + * Copy the contents of file-path @a src to file-path @a dst atomically, + * either creating @a dst or overwriting @a dst if it exists, possibly + * performing line ending and keyword translations. + * + * The parameters @a *eol_str, @a repair, @a *keywords and @a expand are + * defined the same as in svn_subst_translate_stream3(). + * + * In addition, it will create a special file from normal form or + * translate one to normal form if @a special is @c TRUE. + * + * If anything goes wrong during the copy, attempt to delete @a dst (if + * it exists). + * + * If @a eol_str and @a keywords are @c NULL, behavior is just a byte-for-byte + * copy. + * + * @a cancel_func and @a cancel_baton will be called (if not NULL) + * periodically to check for cancellation. + * + * @since New in 1.7. + */ +svn_error_t * +svn_subst_copy_and_translate4(const char *src, + const char *dst, + const char *eol_str, + svn_boolean_t repair, + apr_hash_t *keywords, + svn_boolean_t expand, + svn_boolean_t special, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_subst_copy_and_translate4() but without a cancellation + * function and baton. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_copy_and_translate3(const char *src, + const char *dst, + const char *eol_str, + svn_boolean_t repair, + apr_hash_t *keywords, + svn_boolean_t expand, + svn_boolean_t special, + apr_pool_t *pool); + + +/** + * Similar to svn_subst_copy_and_translate3() except that @a keywords is a + * @c svn_subst_keywords_t struct instead of a keywords hash. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + * @since New in 1.1. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_copy_and_translate2(const char *src, + const char *dst, + const char *eol_str, + svn_boolean_t repair, + const svn_subst_keywords_t *keywords, + svn_boolean_t expand, + svn_boolean_t special, + apr_pool_t *pool); + +/** + * Similar to svn_subst_copy_and_translate2() except that @a special is + * always set to @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_copy_and_translate(const char *src, + const char *dst, + const char *eol_str, + svn_boolean_t repair, + const svn_subst_keywords_t *keywords, + svn_boolean_t expand, + apr_pool_t *pool); + + +/** + * Set @a *dst to a copy of the string @a src, possibly performing line + * ending and keyword translations. + * + * This is a variant of svn_subst_translate_stream3() that operates on + * cstrings. @see svn_subst_stream_translated() for details of the + * translation and of @a eol_str, @a repair, @a keywords and @a expand. + * + * If @a eol_str and @a keywords are @c NULL, behavior is just a byte-for-byte + * copy. + * + * Allocate @a *dst in @a pool. + * + * @since New in 1.3. + */ +svn_error_t * +svn_subst_translate_cstring2(const char *src, + const char **dst, + const char *eol_str, + svn_boolean_t repair, + apr_hash_t *keywords, + svn_boolean_t expand, + apr_pool_t *pool); + +/** + * Similar to svn_subst_translate_cstring2() except that @a keywords is a + * @c svn_subst_keywords_t struct instead of a keywords hash. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_translate_cstring(const char *src, + const char **dst, + const char *eol_str, + svn_boolean_t repair, + const svn_subst_keywords_t *keywords, + svn_boolean_t expand, + apr_pool_t *pool); + +/** + * Translate the file @a src in working copy form to a file @a dst in + * normal form. + * + * The values specified for @a eol_style, @a *eol_str, @a keywords and + * @a special, should be the ones used to translate the file to its + * working copy form. Usually, these are the values specified by the + * user in the files' properties. + * + * Inconsistent line endings in the file will be automatically repaired + * (made consistent) for some eol styles. For all others, an error is + * returned. By setting @a always_repair_eols to @c TRUE, eols will be + * made consistent even for those styles which don't have it by default. + * + * @note To translate a file FROM normal form, use + * svn_subst_copy_and_translate3(). + * + * @since New in 1.4 + * @deprecated Provided for backward compatibility with the 1.5 API + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_translate_to_normal_form(const char *src, + const char *dst, + svn_subst_eol_style_t eol_style, + const char *eol_str, + svn_boolean_t always_repair_eols, + apr_hash_t *keywords, + svn_boolean_t special, + apr_pool_t *pool); + +/** + * Set @a *stream_p to a stream that detranslates the file @a src from + * working copy form to normal form, allocated in @a pool. + * + * The values specified for @a eol_style, @a *eol_str, @a keywords and + * @a special, should be the ones used to translate the file to its + * working copy form. Usually, these are the values specified by the + * user in the files' properties. + * + * Inconsistent line endings in the file will be automatically repaired + * (made consistent) for some eol styles. For all others, an error is + * returned. By setting @a always_repair_eols to @c TRUE, eols will be + * made consistent even for those styles which don't have it by default. + * + * @since New in 1.4. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + * Use svn_subst_stream_from_specialfile if the source is special; + * otherwise, use svn_subst_stream_translated_to_normal_form. + */ +SVN_DEPRECATED +svn_error_t * +svn_subst_stream_detranslated(svn_stream_t **stream_p, + const char *src, + svn_subst_eol_style_t eol_style, + const char *eol_str, + svn_boolean_t always_repair_eols, + apr_hash_t *keywords, + svn_boolean_t special, + apr_pool_t *pool); + + +/* EOL conversion and character encodings */ + +/** Translate the string @a value from character encoding @a encoding to + * UTF8, and also from its current line-ending style to LF line-endings. If + * @a encoding is @c NULL, translate from the system-default encoding. + * + * If @a translated_to_utf8 is not @c NULL, then set @a *translated_to_utf8 + * to @c TRUE if at least one character of @a value in the source character + * encoding was translated to UTF-8, or to @c FALSE otherwise. + * + * If @a translated_line_endings is not @c NULL, then set @a + * *translated_line_endings to @c TRUE if at least one line ending was + * changed to LF, or to @c FALSE otherwise. + * + * If @a value has an inconsistent line ending style, then: if @a repair + * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is + * @c TRUE, convert any line ending in @a value to "\n" in + * @a *new_value. Recognized line endings are: "\n", "\r", and "\r\n". + * + * Set @a *new_value to the translated string, allocated in @a result_pool. + * + * @a scratch_pool is used for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_subst_translate_string2(svn_string_t **new_value, + svn_boolean_t *translated_to_utf8, + svn_boolean_t *translated_line_endings, + const svn_string_t *value, + const char *encoding, + svn_boolean_t repair, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_subst_translate_string2(), except that the information about + * whether re-encoding or line ending translation were performed is discarded. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t *svn_subst_translate_string(svn_string_t **new_value, + const svn_string_t *value, + const char *encoding, + apr_pool_t *pool); + +/** Translate the string @a value from UTF8 and LF line-endings into native + * character encoding and native line-endings. If @a for_output is TRUE, + * translate to the character encoding of the output locale, else to that of + * the default locale. + * + * Set @a *new_value to the translated string, allocated in @a pool. + */ +svn_error_t *svn_subst_detranslate_string(svn_string_t **new_value, + const svn_string_t *value, + svn_boolean_t for_output, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_SUBST_H */ diff --git a/subversion/include/svn_time.h b/subversion/include/svn_time.h new file mode 100644 index 0000000..76517ca --- /dev/null +++ b/subversion/include/svn_time.h @@ -0,0 +1,94 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_time.h + * @brief Time/date utilities + */ + +#ifndef SVN_TIME_H +#define SVN_TIME_H + +#include <apr_pools.h> +#include <apr_time.h> + +#include "svn_error.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** Convert @a when to a <tt>const char *</tt> representation allocated + * in @a pool. Use svn_time_from_cstring() for the reverse + * conversion. + */ +const char * +svn_time_to_cstring(apr_time_t when, + apr_pool_t *pool); + +/** Convert @a data to an @c apr_time_t @a when. + * Use @a pool for temporary memory allocation. + */ +svn_error_t * +svn_time_from_cstring(apr_time_t *when, + const char *data, + apr_pool_t *pool); + +/** Convert @a when to a <tt>const char *</tt> representation allocated + * in @a pool, suitable for human display in UTF8. + */ +const char * +svn_time_to_human_cstring(apr_time_t when, + apr_pool_t *pool); + + +/** Convert a human-readable date @a text into an @c apr_time_t, using + * @a now as the current time and storing the result in @a result. + * The local time zone will be used to compute the appropriate GMT + * offset if @a text contains a local time specification. Set @a + * matched to indicate whether or not @a text was parsed successfully. + * Perform any allocation in @a pool. Return an error iff an internal + * error (rather than a simple parse error) occurs. + */ +svn_error_t * +svn_parse_date(svn_boolean_t *matched, + apr_time_t *result, + const char *text, + apr_time_t now, + apr_pool_t *pool); + + +/** Sleep until the next second, to ensure that any files modified + * after we exit have a different timestamp than the one we recorded. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + * Use svn_io_sleep_for_timestamps() instead. + */ +SVN_DEPRECATED +void +svn_sleep_for_timestamps(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_TIME_H */ diff --git a/subversion/include/svn_types.h b/subversion/include/svn_types.h new file mode 100644 index 0000000..6b3a087 --- /dev/null +++ b/subversion/include/svn_types.h @@ -0,0 +1,1287 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_types.h + * @brief Subversion's data types + */ + +#ifndef SVN_TYPES_H +#define SVN_TYPES_H + +/* ### this should go away, but it causes too much breakage right now */ +#include <stdlib.h> +#include <limits.h> /* for ULONG_MAX */ + +#include <apr.h> /* for apr_size_t, apr_int64_t, ... */ +#include <apr_errno.h> /* for apr_status_t */ +#include <apr_pools.h> /* for apr_pool_t */ +#include <apr_hash.h> /* for apr_hash_t */ +#include <apr_tables.h> /* for apr_array_push() */ +#include <apr_time.h> /* for apr_time_t */ +#include <apr_strings.h> /* for apr_atoi64() */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** Macro used to mark deprecated functions. + * + * @since New in 1.6. + */ +#ifndef SVN_DEPRECATED +# if !defined(SWIGPERL) && !defined(SWIGPYTHON) && !defined(SWIGRUBY) +# if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__==3 && __GNUC_MINOR__>=1)) +# define SVN_DEPRECATED __attribute__((deprecated)) +# elif defined(_MSC_VER) && _MSC_VER >= 1300 +# define SVN_DEPRECATED __declspec(deprecated) +# else +# define SVN_DEPRECATED +# endif +# else +# define SVN_DEPRECATED +# endif +#endif + + +/** Indicate whether the current platform supports unaligned data access. + * + * On the majority of machines running SVN (x86 / x64), unaligned access + * is much cheaper than repeated aligned access. Define this macro to 1 + * on those machines. + * Unaligned access on other machines (e.g. IA64) will trigger memory + * access faults or simply misbehave. + * + * Note: Some platforms may only support unaligned access for integers + * (PowerPC). As a result this macro should only be used to determine + * if unaligned access is supported for integers. + * + * @since New in 1.7. + */ +#ifndef SVN_UNALIGNED_ACCESS_IS_OK +# if defined(_M_IX86) || defined(i386) \ + || defined(_M_X64) || defined(__x86_64) \ + || defined(__powerpc__) || defined(__ppc__) +# define SVN_UNALIGNED_ACCESS_IS_OK 1 +# else +# define SVN_UNALIGNED_ACCESS_IS_OK 0 +# endif +#endif + + + +/** YABT: Yet Another Boolean Type */ +typedef int svn_boolean_t; + +#ifndef TRUE +/** uhh... true */ +#define TRUE 1 +#endif /* TRUE */ + +#ifndef FALSE +/** uhh... false */ +#define FALSE 0 +#endif /* FALSE */ + + + +/** Subversion error object. + * + * Defined here, rather than in svn_error.h, to avoid a recursive @#include + * situation. + */ +typedef struct svn_error_t +{ + /** APR error value; possibly an SVN_ custom error code (see + * `svn_error_codes.h' for a full listing). + */ + apr_status_t apr_err; + + /** Details from the producer of error. + * + * Note that if this error was generated by Subversion's API, you'll + * probably want to use svn_err_best_message() to get a single + * descriptive string for this error chain (see the @a child member) + * or svn_handle_error2() to print the error chain in full. This is + * because Subversion's API functions sometimes add many links to + * the error chain that lack details (used only to produce virtual + * stack traces). (Use svn_error_purge_tracing() to remove those + * trace-only links from the error chain.) + */ + const char *message; + + /** Pointer to the error we "wrap" (may be @c NULL). Via this + * member, individual error object can be strung together into an + * "error chain". + */ + struct svn_error_t *child; + + /** The pool in which this error object is allocated. (If + * Subversion's APIs are used to manage error chains, then this pool + * will contain the whole error chain of which this object is a + * member.) */ + apr_pool_t *pool; + + /** Source file where the error originated (iff @c SVN_DEBUG; + * undefined otherwise). + */ + const char *file; + + /** Source line where the error originated (iff @c SVN_DEBUG; + * undefined otherwise). + */ + long line; + +} svn_error_t; + + + +/* See svn_version.h. + Defined here to avoid including svn_version.h from all public headers. */ +typedef struct svn_version_t svn_version_t; + + + +/** @defgroup APR_ARRAY_compat_macros APR Array Compatibility Helper Macros + * These macros are provided by APR itself from version 1.3. + * Definitions are provided here for when using older versions of APR. + * @{ + */ + +/** index into an apr_array_header_t */ +#ifndef APR_ARRAY_IDX +#define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i]) +#endif + +/** easier array-pushing syntax */ +#ifndef APR_ARRAY_PUSH +#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary))) +#endif + +/** @} */ + + + +/** @defgroup apr_hash_utilities APR Hash Table Helpers + * These functions enable the caller to dereference an APR hash table index + * without type casts or temporary variables. + * + * ### These are private, and may go away when APR implements them natively. + * @{ + */ + +/** Return the key of the hash table entry indexed by @a hi. */ +const void * +svn__apr_hash_index_key(const apr_hash_index_t *hi); + +/** Return the key length of the hash table entry indexed by @a hi. */ +apr_ssize_t +svn__apr_hash_index_klen(const apr_hash_index_t *hi); + +/** Return the value of the hash table entry indexed by @a hi. */ +void * +svn__apr_hash_index_val(const apr_hash_index_t *hi); + +/** @} */ + + + +/** On Windows, APR_STATUS_IS_ENOTDIR includes several kinds of + * invalid-pathname error but not ERROR_INVALID_NAME, so we include it. + * We also include ERROR_DIRECTORY as that was not included in apr versions + * before 1.4.0 and this fix is not backported */ +/* ### These fixes should go into APR. */ +#ifndef WIN32 +#define SVN__APR_STATUS_IS_ENOTDIR(s) APR_STATUS_IS_ENOTDIR(s) +#else +#define SVN__APR_STATUS_IS_ENOTDIR(s) (APR_STATUS_IS_ENOTDIR(s) \ + || ((s) == APR_OS_START_SYSERR + ERROR_DIRECTORY) \ + || ((s) == APR_OS_START_SYSERR + ERROR_INVALID_NAME)) +#endif + +/** @} */ + + + +/** The various types of nodes in the Subversion filesystem. */ +typedef enum svn_node_kind_t +{ + /** absent */ + svn_node_none, + + /** regular file */ + svn_node_file, + + /** directory */ + svn_node_dir, + + /** something's here, but we don't know what */ + svn_node_unknown, + + /** + * symbolic link + * @note This value is not currently used by the public API. + * @since New in 1.8. + */ + svn_node_symlink +} svn_node_kind_t; + +/** Return a constant string expressing @a kind as an English word, e.g., + * "file", "dir", etc. The string is not localized, as it may be used for + * client<->server communications. If the kind is not recognized, return + * "unknown". + * + * @since New in 1.6. + */ +const char * +svn_node_kind_to_word(svn_node_kind_t kind); + +/** Return the appropriate node_kind for @a word. @a word is as + * returned from svn_node_kind_to_word(). If @a word does not + * represent a recognized kind or is @c NULL, return #svn_node_unknown. + * + * @since New in 1.6. + */ +svn_node_kind_t +svn_node_kind_from_word(const char *word); + + +/** Generic three-state property to represent an unknown value for values + * that are just like booleans. The values have been set deliberately to + * make tristates disjoint from #svn_boolean_t. + * + * @note It is unsafe to use apr_pcalloc() to allocate these, since '0' is + * not a valid value. + * + * @since New in 1.7. */ +typedef enum svn_tristate_t +{ + /** state known to be false (the constant does not evaulate to false) */ + svn_tristate_false = 2, + /** state known to be true */ + svn_tristate_true, + /** state could be true or false */ + svn_tristate_unknown +} svn_tristate_t; + +/** Return a constant string "true", "false" or NULL representing the value of + * @a tristate. + * + * @since New in 1.7. + */ +const char * +svn_tristate__to_word(svn_tristate_t tristate); + +/** Return the appropriate tristate for @a word. If @a word is "true", returns + * #svn_tristate_true; if @a word is "false", returns #svn_tristate_false, + * for all other values (including NULL) returns #svn_tristate_unknown. + * + * @since New in 1.7. + */ +svn_tristate_t +svn_tristate__from_word(const char * word); + + + +/** About Special Files in Subversion + * + * Subversion denotes files that cannot be portably created or + * modified as "special" files (svn_node_special). It stores these + * files in the repository as a plain text file with the svn:special + * property set. The file contents contain: a platform-specific type + * string, a space character, then any information necessary to create + * the file on a supported platform. For example, if a symbolic link + * were being represented, the repository file would have the + * following contents: + * + * "link /path/to/link/target" + * + * Where 'link' is the identifier string showing that this special + * file should be a symbolic link and '/path/to/link/target' is the + * destination of the symbolic link. + * + * Special files are stored in the text-base exactly as they are + * stored in the repository. The platform specific files are created + * in the working copy at EOL/keyword translation time using + * svn_subst_copy_and_translate2(). If the current platform does not + * support a specific special file type, the file is copied into the + * working copy as it is seen in the repository. Because of this, + * users of other platforms can still view and modify the special + * files, even if they do not have their unique properties. + * + * New types of special files can be added by: + * 1. Implementing a platform-dependent routine to create a uniquely + * named special file and one to read the special file in + * libsvn_subr/io.c. + * 2. Creating a new textual name similar to + * SVN_SUBST__SPECIAL_LINK_STR in libsvn_subr/subst.c. + * 3. Handling the translation/detranslation case for the new type in + * create_special_file and detranslate_special_file, using the + * routines from 1. + */ + + + +/** A revision number. */ +typedef long int svn_revnum_t; + +/** Valid revision numbers begin at 0 */ +#define SVN_IS_VALID_REVNUM(n) ((n) >= 0) + +/** The 'official' invalid revision num */ +#define SVN_INVALID_REVNUM ((svn_revnum_t) -1) + +/** Not really invalid...just unimportant -- one day, this can be its + * own unique value, for now, just make it the same as + * #SVN_INVALID_REVNUM. + */ +#define SVN_IGNORED_REVNUM ((svn_revnum_t) -1) + +/** Convert NULL-terminated C string @a str to a revision number. */ +#define SVN_STR_TO_REV(str) ((svn_revnum_t) atol(str)) + +/** + * Parse NULL-terminated C string @a str as a revision number and + * store its value in @a rev. If @a endptr is non-NULL, then the + * address of the first non-numeric character in @a str is stored in + * it. If there are no digits in @a str, then @a endptr is set (if + * non-NULL), and the error #SVN_ERR_REVNUM_PARSE_FAILURE error is + * returned. Negative numbers parsed from @a str are considered + * invalid, and result in the same error. + * + * @since New in 1.5. + */ +svn_error_t * +svn_revnum_parse(svn_revnum_t *rev, + const char *str, + const char **endptr); + +/** Originally intended to be used in printf()-style functions to format + * revision numbers. Deprecated due to incompatibilities with language + * translation tools (e.g. gettext). + * + * New code should use a bare "%ld" format specifier for formatting revision + * numbers. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +#define SVN_REVNUM_T_FMT "ld" + + + +/** The size of a file in the Subversion FS. */ +typedef apr_int64_t svn_filesize_t; + +/** The 'official' invalid file size constant. */ +#define SVN_INVALID_FILESIZE ((svn_filesize_t) -1) + +/** In printf()-style functions, format file sizes using this. */ +#define SVN_FILESIZE_T_FMT APR_INT64_T_FMT + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +/* Parse a base-10 numeric string into a 64-bit unsigned numeric value. */ +/* NOTE: Private. For use by Subversion's own code only. See issue #1644. */ +/* FIXME: APR should supply a function to do this, such as "apr_atoui64". */ +#define svn__atoui64(X) ((apr_uint64_t) apr_atoi64(X)) +#endif + + + +/** An enum to indicate whether recursion is needed. */ +enum svn_recurse_kind +{ + svn_nonrecursive = 1, + svn_recursive +}; + +/** The concept of depth for directories. + * + * @note This is similar to, but not exactly the same as, the WebDAV + * and LDAP concepts of depth. + * + * @since New in 1.5. + */ +typedef enum svn_depth_t +{ + /* The order of these depths is important: the higher the number, + the deeper it descends. This allows us to compare two depths + numerically to decide which should govern. */ + + /** Depth undetermined or ignored. In some contexts, this means the + client should choose an appropriate default depth. The server + will generally treat it as #svn_depth_infinity. */ + svn_depth_unknown = -2, + + /** Exclude (i.e., don't descend into) directory D. + @note In Subversion 1.5, svn_depth_exclude is *not* supported + anywhere in the client-side (libsvn_wc/libsvn_client/etc) code; + it is only supported as an argument to set_path functions in the + ra and repos reporters. (This will enable future versions of + Subversion to run updates, etc, against 1.5 servers with proper + svn_depth_exclude behavior, once we get a chance to implement + client-side support for svn_depth_exclude.) + */ + svn_depth_exclude = -1, + + /** Just the named directory D, no entries. Updates will not pull in + any files or subdirectories not already present. */ + svn_depth_empty = 0, + + /** D + its file children, but not subdirs. Updates will pull in any + files not already present, but not subdirectories. */ + svn_depth_files = 1, + + /** D + immediate children (D and its entries). Updates will pull in + any files or subdirectories not already present; those + subdirectories' this_dir entries will have depth-empty. */ + svn_depth_immediates = 2, + + /** D + all descendants (full recursion from D). Updates will pull + in any files or subdirectories not already present; those + subdirectories' this_dir entries will have depth-infinity. + Equivalent to the pre-1.5 default update behavior. */ + svn_depth_infinity = 3 + +} svn_depth_t; + +/** Return a constant string expressing @a depth as an English word, + * e.g., "infinity", "immediates", etc. The string is not localized, + * as it may be used for client<->server communications. + * + * @since New in 1.5. + */ +const char * +svn_depth_to_word(svn_depth_t depth); + +/** Return the appropriate depth for @a depth_str. @a word is as + * returned from svn_depth_to_word(). If @a depth_str does not + * represent a recognized depth, return #svn_depth_unknown. + * + * @since New in 1.5. + */ +svn_depth_t +svn_depth_from_word(const char *word); + +/** Return #svn_depth_infinity if boolean @a recurse is TRUE, else + * return #svn_depth_files. + * + * @note New code should never need to use this, it is called only + * from pre-depth APIs, for compatibility. + * + * @since New in 1.5. + */ +#define SVN_DEPTH_INFINITY_OR_FILES(recurse) \ + ((recurse) ? svn_depth_infinity : svn_depth_files) + +/** Return #svn_depth_infinity if boolean @a recurse is TRUE, else + * return #svn_depth_immediates. + * + * @note New code should never need to use this, it is called only + * from pre-depth APIs, for compatibility. + * + * @since New in 1.5. + */ +#define SVN_DEPTH_INFINITY_OR_IMMEDIATES(recurse) \ + ((recurse) ? svn_depth_infinity : svn_depth_immediates) + +/** Return #svn_depth_infinity if boolean @a recurse is TRUE, else + * return #svn_depth_empty. + * + * @note New code should never need to use this, it is called only + * from pre-depth APIs, for compatibility. + * + * @since New in 1.5. + */ +#define SVN_DEPTH_INFINITY_OR_EMPTY(recurse) \ + ((recurse) ? svn_depth_infinity : svn_depth_empty) + +/** Return a recursion boolean based on @a depth. + * + * Although much code has been converted to use depth, some code still + * takes a recurse boolean. In most cases, it makes sense to treat + * unknown or infinite depth as recursive, and any other depth as + * non-recursive (which in turn usually translates to #svn_depth_files). + */ +#define SVN_DEPTH_IS_RECURSIVE(depth) \ + ((depth) == svn_depth_infinity || (depth) == svn_depth_unknown) + + + +/** + * It is sometimes convenient to indicate which parts of an #svn_dirent_t + * object you are actually interested in, so that calculating and sending + * the data corresponding to the other fields can be avoided. These values + * can be used for that purpose. + * + * @defgroup svn_dirent_fields Dirent fields + * @{ + */ + +/** An indication that you are interested in the @c kind field */ +#define SVN_DIRENT_KIND 0x00001 + +/** An indication that you are interested in the @c size field */ +#define SVN_DIRENT_SIZE 0x00002 + +/** An indication that you are interested in the @c has_props field */ +#define SVN_DIRENT_HAS_PROPS 0x00004 + +/** An indication that you are interested in the @c created_rev field */ +#define SVN_DIRENT_CREATED_REV 0x00008 + +/** An indication that you are interested in the @c time field */ +#define SVN_DIRENT_TIME 0x00010 + +/** An indication that you are interested in the @c last_author field */ +#define SVN_DIRENT_LAST_AUTHOR 0x00020 + +/** A combination of all the dirent fields */ +#define SVN_DIRENT_ALL ~((apr_uint32_t ) 0) + +/** @} */ + +/** A general subversion directory entry. + * + * @note To allow for extending the #svn_dirent_t structure in future + * releases, always use svn_dirent_create() to allocate the stucture. + * + * @since New in 1.6. + */ +typedef struct svn_dirent_t +{ + /** node kind */ + svn_node_kind_t kind; + + /** length of file text, or 0 for directories */ + svn_filesize_t size; + + /** does the node have props? */ + svn_boolean_t has_props; + + /** last rev in which this node changed */ + svn_revnum_t created_rev; + + /** time of created_rev (mod-time) */ + apr_time_t time; + + /** author of created_rev */ + const char *last_author; + + /* IMPORTANT: If you extend this struct, check svn_dirent_dup(). */ +} svn_dirent_t; + +/** Return a deep copy of @a dirent, allocated in @a pool. + * + * @since New in 1.4. + */ +svn_dirent_t * +svn_dirent_dup(const svn_dirent_t *dirent, + apr_pool_t *pool); + +/** + * Create a new svn_dirent_t instance with all values initialized to their + * not-available values. + * + * @since New in 1.8. + */ +svn_dirent_t * +svn_dirent_create(apr_pool_t *result_pool); + + +/** Keyword substitution. + * + * All the keywords Subversion recognizes. + * + * Note that there is a better, more general proposal out there, which + * would take care of both internationalization issues and custom + * keywords (e.g., $NetBSD$). See + * + * @verbatim + http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=8921 + ===== + From: "Jonathan M. Manning" <jmanning@alisa-jon.net> + To: dev@subversion.tigris.org + Date: Fri, 14 Dec 2001 11:56:54 -0500 + Message-ID: <87970000.1008349014@bdldevel.bl.bdx.com> + Subject: Re: keywords @endverbatim + * + * and Eric Gillespie's support of same: + * + * @verbatim + http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=8757 + ===== + From: "Eric Gillespie, Jr." <epg@pretzelnet.org> + To: dev@subversion.tigris.org + Date: Wed, 12 Dec 2001 09:48:42 -0500 + Message-ID: <87k7vsebp1.fsf@vger.pretzelnet.org> + Subject: Re: Customizable Keywords @endverbatim + * + * However, it is considerably more complex than the scheme below. + * For now we're going with simplicity, hopefully the more general + * solution can be done post-1.0. + * + * @defgroup svn_types_keywords Keyword definitions + * @{ + */ + +/** The maximum size of an expanded or un-expanded keyword. */ +#define SVN_KEYWORD_MAX_LEN 255 + +/** The most recent revision in which this file was changed. */ +#define SVN_KEYWORD_REVISION_LONG "LastChangedRevision" + +/** Short version of LastChangedRevision */ +#define SVN_KEYWORD_REVISION_SHORT "Rev" + +/** Medium version of LastChangedRevision, matching the one CVS uses. + * @since New in 1.1. */ +#define SVN_KEYWORD_REVISION_MEDIUM "Revision" + +/** The most recent date (repository time) when this file was changed. */ +#define SVN_KEYWORD_DATE_LONG "LastChangedDate" + +/** Short version of LastChangedDate */ +#define SVN_KEYWORD_DATE_SHORT "Date" + +/** Who most recently committed to this file. */ +#define SVN_KEYWORD_AUTHOR_LONG "LastChangedBy" + +/** Short version of LastChangedBy */ +#define SVN_KEYWORD_AUTHOR_SHORT "Author" + +/** The URL for the head revision of this file. */ +#define SVN_KEYWORD_URL_LONG "HeadURL" + +/** Short version of HeadURL */ +#define SVN_KEYWORD_URL_SHORT "URL" + +/** A compressed combination of the other four keywords. */ +#define SVN_KEYWORD_ID "Id" + +/** A full combination of the first four keywords. + * @since New in 1.6. */ +#define SVN_KEYWORD_HEADER "Header" + +/** @} */ + + + +/** All information about a commit. + * + * @note Objects of this type should always be created using the + * svn_create_commit_info() function. + * + * @since New in 1.3. + */ +typedef struct svn_commit_info_t +{ + /** just-committed revision. */ + svn_revnum_t revision; + + /** server-side date of the commit. */ + const char *date; + + /** author of the commit. */ + const char *author; + + /** error message from post-commit hook, or NULL. */ + const char *post_commit_err; + + /** repository root, may be @c NULL if unknown. + @since New in 1.7. */ + const char *repos_root; + +} svn_commit_info_t; + +/** + * Allocate an object of type #svn_commit_info_t in @a pool and + * return it. + * + * The @c revision field of the new struct is set to #SVN_INVALID_REVNUM. + * All other fields are initialized to @c NULL. + * + * @note Any object of the type #svn_commit_info_t should + * be created using this function. + * This is to provide for extending the svn_commit_info_t in + * the future. + * + * @since New in 1.3. + */ +svn_commit_info_t * +svn_create_commit_info(apr_pool_t *pool); + +/** + * Return a deep copy @a src_commit_info allocated in @a pool. + * + * @since New in 1.4. + */ +svn_commit_info_t * +svn_commit_info_dup(const svn_commit_info_t *src_commit_info, + apr_pool_t *pool); + + + +/** + * A structure to represent a path that changed for a log entry. + * + * @note To allow for extending the #svn_log_changed_path2_t structure in + * future releases, always use svn_log_changed_path2_create() to allocate + * the structure. + * + * @since New in 1.6. + */ +typedef struct svn_log_changed_path2_t +{ + /** 'A'dd, 'D'elete, 'R'eplace, 'M'odify */ + char action; + + /** Source path of copy (if any). */ + const char *copyfrom_path; + + /** Source revision of copy (if any). */ + svn_revnum_t copyfrom_rev; + + /** The type of the node, may be svn_node_unknown. */ + svn_node_kind_t node_kind; + + /** Is the text modified, may be svn_tristate_unknown. + * @since New in 1.7. */ + svn_tristate_t text_modified; + + /** Are properties modified, may be svn_tristate_unknown. + * @since New in 1.7. */ + svn_tristate_t props_modified; + + /* NOTE: Add new fields at the end to preserve binary compatibility. + Also, if you add fields here, you have to update + svn_log_changed_path2_dup(). */ +} svn_log_changed_path2_t; + +/** + * Returns an #svn_log_changed_path2_t, allocated in @a pool with all fields + * initialized to NULL, None or empty values. + * + * @note To allow for extending the #svn_log_changed_path2_t structure in + * future releases, this function should always be used to allocate the + * structure. + * + * @since New in 1.6. + */ +svn_log_changed_path2_t * +svn_log_changed_path2_create(apr_pool_t *pool); + +/** + * Return a deep copy of @a changed_path, allocated in @a pool. + * + * @since New in 1.6. + */ +svn_log_changed_path2_t * +svn_log_changed_path2_dup(const svn_log_changed_path2_t *changed_path, + apr_pool_t *pool); + +/** + * A structure to represent a path that changed for a log entry. Same as + * the first three fields of #svn_log_changed_path2_t. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +typedef struct svn_log_changed_path_t +{ + /** 'A'dd, 'D'elete, 'R'eplace, 'M'odify */ + char action; + + /** Source path of copy (if any). */ + const char *copyfrom_path; + + /** Source revision of copy (if any). */ + svn_revnum_t copyfrom_rev; + +} svn_log_changed_path_t; + +/** + * Return a deep copy of @a changed_path, allocated in @a pool. + * + * @since New in 1.3. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_log_changed_path_t * +svn_log_changed_path_dup(const svn_log_changed_path_t *changed_path, + apr_pool_t *pool); + +/** + * A structure to represent all the information about a particular log entry. + * + * @note To allow for extending the #svn_log_entry_t structure in future + * releases, always use svn_log_entry_create() to allocate the structure. + * + * @since New in 1.5. + */ +typedef struct svn_log_entry_t +{ + /** A hash containing as keys every path committed in @a revision; the + * values are (#svn_log_changed_path_t *) structures. + * + * The subversion core libraries will always set this field to the same + * value as changed_paths2 for compatibility reasons. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ + apr_hash_t *changed_paths; + + /** The revision of the commit. */ + svn_revnum_t revision; + + /** The hash of requested revision properties, which may be NULL if it + * would contain no revprops. Maps (const char *) property name to + * (svn_string_t *) property value. */ + apr_hash_t *revprops; + + /** + * Whether or not this message has children. + * + * When a log operation requests additional merge information, extra log + * entries may be returned as a result of this entry. The new entries, are + * considered children of the original entry, and will follow it. When + * the HAS_CHILDREN flag is set, the receiver should increment its stack + * depth, and wait until an entry is provided with SVN_INVALID_REVNUM which + * indicates the end of the children. + * + * For log operations which do not request additional merge information, the + * HAS_CHILDREN flag is always FALSE. + * + * For more information see: + * https://svn.apache.org/repos/asf/subversion/trunk/notes/merge-tracking/design.html#commutative-reporting + */ + svn_boolean_t has_children; + + /** A hash containing as keys every path committed in @a revision; the + * values are (#svn_log_changed_path2_t *) structures. + * + * If this value is not @c NULL, it MUST have the same value as + * changed_paths or svn_log_entry_dup() will not create an identical copy. + * + * The subversion core libraries will always set this field to the same + * value as changed_paths for compatibility with users assuming an older + * version. + * + * @note See http://svn.haxx.se/dev/archive-2010-08/0362.shtml for + * further explanation. + * + * @since New in 1.6. + */ + apr_hash_t *changed_paths2; + + /** + * Whether @a revision should be interpreted as non-inheritable in the + * same sense of #svn_merge_range_t. + * + * Only set when this #svn_log_entry_t instance is returned by the + * libsvn_client mergeinfo apis. Currently always FALSE when the + * #svn_log_entry_t instance is reported by the ra layer. + * + * @since New in 1.7. + */ + svn_boolean_t non_inheritable; + + /** + * Whether @a revision is a merged revision resulting from a reverse merge. + * + * @since New in 1.7. + */ + svn_boolean_t subtractive_merge; + + /* NOTE: Add new fields at the end to preserve binary compatibility. + Also, if you add fields here, you have to update + svn_log_entry_dup(). */ +} svn_log_entry_t; + +/** + * Returns an #svn_log_entry_t, allocated in @a pool with all fields + * initialized to NULL values. + * + * @note To allow for extending the #svn_log_entry_t structure in future + * releases, this function should always be used to allocate the structure. + * + * @since New in 1.5. + */ +svn_log_entry_t * +svn_log_entry_create(apr_pool_t *pool); + +/** Return a deep copy of @a log_entry, allocated in @a pool. + * + * The resulting svn_log_entry_t has @c changed_paths set to the same + * value as @c changed_path2. @c changed_paths will be @c NULL if + * @c changed_paths2 was @c NULL. + * + * @since New in 1.6. + */ +svn_log_entry_t * +svn_log_entry_dup(const svn_log_entry_t *log_entry, apr_pool_t *pool); + +/** The callback invoked by log message loopers, such as + * #svn_ra_plugin_t.get_log() and svn_repos_get_logs(). + * + * This function is invoked once on each log message, in the order + * determined by the caller (see above-mentioned functions). + * + * @a baton is what you think it is, and @a log_entry contains relevant + * information for the log message. Any of @a log_entry->author, + * @a log_entry->date, or @a log_entry->message may be @c NULL. + * + * If @a log_entry->date is neither NULL nor the empty string, it was + * generated by svn_time_to_cstring() and can be converted to + * @c apr_time_t with svn_time_from_cstring(). + * + * If @a log_entry->changed_paths is non-@c NULL, then it contains as keys + * every path committed in @a log_entry->revision; the values are + * (#svn_log_changed_path_t *) structures. + * + * If @a log_entry->has_children is @c TRUE, the message will be followed + * immediately by any number of merged revisions (child messages), which are + * terminated by an invocation with SVN_INVALID_REVNUM. This usage may + * be recursive. + * + * Use @a pool for temporary allocation. If the caller is iterating + * over log messages, invoking this receiver on each, we recommend the + * standard pool loop recipe: create a subpool, pass it as @a pool to + * each call, clear it after each iteration, destroy it after the loop + * is done. (For allocation that must last beyond the lifetime of a + * given receiver call, use a pool in @a baton.) + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_log_entry_receiver_t)( + void *baton, + svn_log_entry_t *log_entry, + apr_pool_t *pool); + +/** + * Similar to #svn_log_entry_receiver_t, except this uses separate + * parameters for each part of the log entry. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +typedef svn_error_t *(*svn_log_message_receiver_t)( + void *baton, + apr_hash_t *changed_paths, + svn_revnum_t revision, + const char *author, + const char *date, /* use svn_time_from_cstring() if need apr_time_t */ + const char *message, + apr_pool_t *pool); + + + +/** Callback function type for commits. + * + * When a commit succeeds, an instance of this is invoked with the + * @a commit_info, along with the @a baton closure. + * @a pool can be used for temporary allocations. + * + * @since New in 1.4. + */ +typedef svn_error_t *(*svn_commit_callback2_t)( + const svn_commit_info_t *commit_info, + void *baton, + apr_pool_t *pool); + +/** Same as #svn_commit_callback2_t, but uses individual + * data elements instead of the #svn_commit_info_t structure + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +typedef svn_error_t *(*svn_commit_callback_t)( + svn_revnum_t new_revision, + const char *date, + const char *author, + void *baton); + + + +/** A buffer size that may be used when processing a stream of data. + * + * @note We don't use this constant any longer, since it is considered to be + * unnecessarily large. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +#define SVN_STREAM_CHUNK_SIZE 102400 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +/* + * The maximum amount we (ideally) hold in memory at a time when + * processing a stream of data. + * + * For example, when copying data from one stream to another, do it in + * blocks of this size. + * + * NOTE: This is an internal macro, put here for convenience. + * No public API may depend on the particular value of this macro. + */ +#define SVN__STREAM_CHUNK_SIZE 16384 +#endif + +/** The maximum amount we can ever hold in memory. */ +/* FIXME: Should this be the same as SVN_STREAM_CHUNK_SIZE? */ +#define SVN_MAX_OBJECT_SIZE (((apr_size_t) -1) / 2) + + + +/* ### Note: despite being about mime-TYPES, these probably don't + * ### belong in svn_types.h. However, no other header is more + * ### appropriate, and didn't feel like creating svn_validate.h for + * ### so little. + */ + +/** Validate @a mime_type. + * + * If @a mime_type does not contain a "/", or ends with non-alphanumeric + * data, return #SVN_ERR_BAD_MIME_TYPE, else return success. + * + * Use @a pool only to find error allocation. + * + * Goal: to match both "foo/bar" and "foo/bar; charset=blah", without + * being too strict about it, but to disallow mime types that have + * quotes, newlines, or other garbage on the end, such as might be + * unsafe in an HTTP header. + */ +svn_error_t * +svn_mime_type_validate(const char *mime_type, + apr_pool_t *pool); + +/** Return FALSE iff @a mime_type is a textual type. + * + * All mime types that start with "text/" are textual, plus some special + * cases (for example, "image/x-xbitmap"). + */ +svn_boolean_t +svn_mime_type_is_binary(const char *mime_type); + + + +/** A user defined callback that subversion will call with a user defined + * baton to see if the current operation should be continued. If the operation + * should continue, the function should return #SVN_NO_ERROR, if not, it + * should return #SVN_ERR_CANCELLED. + */ +typedef svn_error_t *(*svn_cancel_func_t)(void *cancel_baton); + + + +/** + * A lock object, for client & server to share. + * + * A lock represents the exclusive right to add, delete, or modify a + * path. A lock is created in a repository, wholly controlled by the + * repository. A "lock-token" is the lock's UUID, and can be used to + * learn more about a lock's fields, and or/make use of the lock. + * Because a lock is immutable, a client is free to not only cache the + * lock-token, but the lock's fields too, for convenience. + * + * Note that the 'is_dav_comment' field is wholly ignored by every + * library except for mod_dav_svn. The field isn't even marshalled + * over the network to the client. Assuming lock structures are + * created with apr_pcalloc(), a default value of 0 is universally safe. + * + * @note in the current implementation, only files are lockable. + * + * @since New in 1.2. + */ +typedef struct svn_lock_t +{ + const char *path; /**< the path this lock applies to */ + const char *token; /**< unique URI representing lock */ + const char *owner; /**< the username which owns the lock */ + const char *comment; /**< (optional) description of lock */ + svn_boolean_t is_dav_comment; /**< was comment made by generic DAV client? */ + apr_time_t creation_date; /**< when lock was made */ + apr_time_t expiration_date; /**< (optional) when lock will expire; + If value is 0, lock will never expire. */ +} svn_lock_t; + +/** + * Returns an #svn_lock_t, allocated in @a pool with all fields initialized + * to NULL values. + * + * @note To allow for extending the #svn_lock_t structure in the future + * releases, this function should always be used to allocate the structure. + * + * @since New in 1.2. + */ +svn_lock_t * +svn_lock_create(apr_pool_t *pool); + +/** + * Return a deep copy of @a lock, allocated in @a pool. + * + * @since New in 1.2. + */ +svn_lock_t * +svn_lock_dup(const svn_lock_t *lock, apr_pool_t *pool); + + + +/** + * Return a formatted Universal Unique IDentifier (UUID) string. + * + * @since New in 1.4. + */ +const char * +svn_uuid_generate(apr_pool_t *pool); + + + +/** + * Mergeinfo representing a merge of a range of revisions. + * + * @since New in 1.5 + */ +typedef struct svn_merge_range_t +{ + /** + * If the 'start' field is less than the 'end' field then 'start' is + * exclusive and 'end' inclusive of the range described. This is termed + * a forward merge range. If 'start' is greater than 'end' then the + * opposite is true. This is termed a reverse merge range. If 'start' + * equals 'end' the meaning of the range is not defined. + */ + svn_revnum_t start; + svn_revnum_t end; + + /** + * Whether this merge range should be inherited by treewise + * descendants of the path to which the range applies. */ + svn_boolean_t inheritable; +} svn_merge_range_t; + +/** + * Return a copy of @a range, allocated in @a pool. + * + * @since New in 1.5. + */ +svn_merge_range_t * +svn_merge_range_dup(const svn_merge_range_t *range, apr_pool_t *pool); + +/** + * Returns true if the changeset committed in revision @a rev is one + * of the changesets in the range @a range. + * + * @since New in 1.5. + */ +svn_boolean_t +svn_merge_range_contains_rev(const svn_merge_range_t *range, svn_revnum_t rev); + + + +/** @defgroup node_location_seg_reporting Node location segment reporting. + * @{ */ + +/** + * A representation of a segment of an object's version history with an + * emphasis on the object's location in the repository as of various + * revisions. + * + * @since New in 1.5. + */ +typedef struct svn_location_segment_t +{ + /** The beginning (oldest) and ending (youngest) revisions for this + segment, both inclusive. */ + svn_revnum_t range_start; + svn_revnum_t range_end; + + /** The absolute (sans leading slash) path for this segment. May be + NULL to indicate gaps in an object's history. */ + const char *path; + +} svn_location_segment_t; + +/** + * A callback invoked by generators of #svn_location_segment_t + * objects, used to report information about a versioned object's + * history in terms of its location in the repository filesystem over + * time. + */ +typedef svn_error_t *(*svn_location_segment_receiver_t)( + svn_location_segment_t *segment, + void *baton, + apr_pool_t *pool); + +/** + * Return a deep copy of @a segment, allocated in @a pool. + * + * @since New in 1.5. + */ +svn_location_segment_t * +svn_location_segment_dup(const svn_location_segment_t *segment, + apr_pool_t *pool); + +/** @} */ + + + +/** A line number, such as in a file or a stream. + * + * @since New in 1.7. + */ +typedef unsigned long svn_linenum_t; + +/** The maximum value of an svn_linenum_t. + * + * @since New in 1.7. + */ +#define SVN_LINENUM_MAX_VALUE ULONG_MAX + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/* + * Everybody and their brother needs to deal with svn_error_t, the error + * codes, and whatever else. While they *should* go and include svn_error.h + * in order to do that... bah. Let's just help everybody out and include + * that header whenever somebody grabs svn_types.h. + * + * Note that we do this at the END of this header so that its contents + * are available to svn_error.h (our guards will prevent the circular + * include). We also need to do the include *outside* of the cplusplus + * guard. + */ +#include "svn_error.h" + + +/* + * Subversion developers may want to use some additional debugging facilities + * while working on the code. We'll pull that in here, so individual source + * files don't have to include this header manually. + */ +#ifdef SVN_DEBUG +#include "private/svn_debug.h" +#endif + + +#endif /* SVN_TYPES_H */ diff --git a/subversion/include/svn_user.h b/subversion/include/svn_user.h new file mode 100644 index 0000000..65e2820 --- /dev/null +++ b/subversion/include/svn_user.h @@ -0,0 +1,56 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_user.h + * @brief Subversion's wrapper around APR's user information interface. + */ + +#ifndef SVN_USER_H +#define SVN_USER_H + +#include <apr_pools.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Get the name of the current user, using @a pool for any necessary + * allocation, returning NULL on error. + * + * @since New in 1.4. + */ +const char * +svn_user_get_name(apr_pool_t *pool); + +/** Get the path of the current user's home directory, using @a pool for + * any necessary allocation, returning NULL on error. + * + * @since New in 1.4. + */ +const char * +svn_user_get_homedir(apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_USER_H */ diff --git a/subversion/include/svn_utf.h b/subversion/include/svn_utf.h new file mode 100644 index 0000000..4a2c137 --- /dev/null +++ b/subversion/include/svn_utf.h @@ -0,0 +1,252 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_utf.h + * @brief UTF-8 conversion routines + * + * Whenever a conversion routine cannot convert to or from UTF-8, the + * error returned has code @c APR_EINVAL. + */ + + + +#ifndef SVN_UTF_H +#define SVN_UTF_H + +#include <apr_pools.h> +#include <apr_xlate.h> /* for APR_*_CHARSET */ + +#include "svn_types.h" +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SVN_APR_LOCALE_CHARSET APR_LOCALE_CHARSET +#define SVN_APR_DEFAULT_CHARSET APR_DEFAULT_CHARSET + +/** + * Initialize the UTF-8 encoding/decoding routines. + * Allocate cached translation handles in a subpool of @a pool. + * + * If @a assume_native_utf8 is TRUE, the native character set is + * assumed to be UTF-8, i.e. conversion is a no-op. This is useful + * in contexts where the native character set is ASCII but UTF-8 + * should be used regardless (e.g. for mod_dav_svn which runs within + * httpd and always uses the "C" locale). + * + * @note It is optional to call this function, but if it is used, no other + * svn function may be in use in other threads during the call of this + * function or when @a pool is cleared or destroyed. + * Initializing the UTF-8 routines will improve performance. + * + * @since New in 1.8. + */ +void +svn_utf_initialize2(svn_boolean_t assume_native_utf8, + apr_pool_t *pool); + +/** + * Like svn_utf_initialize2() but without the ability to force the + * native encoding to UTF-8. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +void +svn_utf_initialize(apr_pool_t *pool); + +/** Set @a *dest to a utf8-encoded stringbuf from native stringbuf @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_stringbuf_to_utf8(svn_stringbuf_t **dest, + const svn_stringbuf_t *src, + apr_pool_t *pool); + + +/** Set @a *dest to a utf8-encoded string from native string @a src; allocate + * @a *dest in @a pool. + */ +svn_error_t * +svn_utf_string_to_utf8(const svn_string_t **dest, + const svn_string_t *src, + apr_pool_t *pool); + + +/** Set @a *dest to a utf8-encoded C string from native C string @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_cstring_to_utf8(const char **dest, + const char *src, + apr_pool_t *pool); + + +/** Set @a *dest to a utf8 encoded C string from @a frompage encoded C + * string @a src; allocate @a *dest in @a pool. + * + * @since New in 1.4. + */ +svn_error_t * +svn_utf_cstring_to_utf8_ex2(const char **dest, + const char *src, + const char *frompage, + apr_pool_t *pool); + + +/** Like svn_utf_cstring_to_utf8_ex2() but with @a convset_key which is + * ignored. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_utf_cstring_to_utf8_ex(const char **dest, + const char *src, + const char *frompage, + const char *convset_key, + apr_pool_t *pool); + + +/** Set @a *dest to a natively-encoded stringbuf from utf8 stringbuf @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_stringbuf_from_utf8(svn_stringbuf_t **dest, + const svn_stringbuf_t *src, + apr_pool_t *pool); + + +/** Set @a *dest to a natively-encoded string from utf8 string @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_string_from_utf8(const svn_string_t **dest, + const svn_string_t *src, + apr_pool_t *pool); + + +/** Set @a *dest to a natively-encoded C string from utf8 C string @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_cstring_from_utf8(const char **dest, + const char *src, + apr_pool_t *pool); + + +/** Set @a *dest to a @a topage encoded C string from utf8 encoded C string + * @a src; allocate @a *dest in @a pool. + * + * @since New in 1.4. + */ +svn_error_t * +svn_utf_cstring_from_utf8_ex2(const char **dest, + const char *src, + const char *topage, + apr_pool_t *pool); + + +/** Like svn_utf_cstring_from_utf8_ex2() but with @a convset_key which is + * ignored. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_utf_cstring_from_utf8_ex(const char **dest, + const char *src, + const char *topage, + const char *convset_key, + apr_pool_t *pool); + + +/** Return a fuzzily native-encoded C string from utf8 C string @a src, + * allocated in @a pool. A fuzzy recoding leaves all 7-bit ascii + * characters the same, and substitutes "?\\XXX" for others, where XXX + * is the unsigned decimal code for that character. + * + * This function cannot error; it is guaranteed to return something. + * First it will recode as described above and then attempt to convert + * the (new) 7-bit UTF-8 string to native encoding. If that fails, it + * will return the raw fuzzily recoded string, which may or may not be + * meaningful in the client's locale, but is (presumably) better than + * nothing. + * + * ### Notes: + * + * Improvement is possible, even imminent. The original problem was + * that if you converted a UTF-8 string (say, a log message) into a + * locale that couldn't represent all the characters, you'd just get a + * static placeholder saying "[unconvertible log message]". Then + * Justin Erenkrantz pointed out how on platforms that didn't support + * conversion at all, "svn log" would still fail completely when it + * encountered unconvertible data. + * + * Now for both cases, the caller can at least fall back on this + * function, which converts the message as best it can, substituting + * "?\\XXX" escape codes for the non-ascii characters. + * + * Ultimately, some callers may prefer the iconv "//TRANSLIT" option, + * so when we can detect that at configure time, things will change. + * Also, this should (?) be moved to apr/apu eventually. + * + * See http://subversion.tigris.org/issues/show_bug.cgi?id=807 for + * details. + */ +const char * +svn_utf_cstring_from_utf8_fuzzy(const char *src, + apr_pool_t *pool); + + +/** Set @a *dest to a natively-encoded C string from utf8 stringbuf @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_cstring_from_utf8_stringbuf(const char **dest, + const svn_stringbuf_t *src, + apr_pool_t *pool); + + +/** Set @a *dest to a natively-encoded C string from utf8 string @a src; + * allocate @a *dest in @a pool. + */ +svn_error_t * +svn_utf_cstring_from_utf8_string(const char **dest, + const svn_string_t *src, + apr_pool_t *pool); + +/** Return the display width of UTF-8-encoded C string @a cstr. + * If the string is not printable or invalid UTF-8, return -1. + * + * @since New in 1.8. + */ +int +svn_utf_cstring_utf8_width(const char *cstr); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_UTF_H */ diff --git a/subversion/include/svn_version.h b/subversion/include/svn_version.h new file mode 100644 index 0000000..f8ce7c3 --- /dev/null +++ b/subversion/include/svn_version.h @@ -0,0 +1,411 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_version.h + * @brief Version information. + */ + +#ifndef SVN_VERSION_H +#define SVN_VERSION_H + +/* Hack to prevent the resource compiler from including + apr_general.h. It doesn't resolve the include paths + correctly and blows up without this. + */ +#ifndef APR_STRINGIFY +#include <apr_general.h> +#endif +#include <apr_tables.h> + +#include "svn_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Symbols that define the version number. */ + +/* Version numbers: <major>.<minor>.<micro> + * + * The version numbers in this file follow the rules established by: + * + * http://apr.apache.org/versioning.html + */ + +/** Major version number. + * + * Modify when incompatible changes are made to published interfaces. + */ +#define SVN_VER_MAJOR 1 + +/** Minor version number. + * + * Modify when new functionality is added or new interfaces are + * defined, but all changes are backward compatible. + */ +#define SVN_VER_MINOR 8 + +/** + * Patch number. + * + * Modify for every released patch. + * + * @since New in 1.1. + */ +#define SVN_VER_PATCH 0 + + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +#define SVN_VER_MICRO SVN_VER_PATCH + +/** @deprecated Provided for backward compatibility with the 1.0 API. */ +#define SVN_VER_LIBRARY SVN_VER_MAJOR + + +/** Version tag: a string describing the version. + * + * This tag remains " (dev build)" in the repository so that we can + * always see from "svn --version" that the software has been built + * from the repository rather than a "blessed" distribution. + * + * When rolling a tarball, we automatically replace this text with " (r1234)" + * (where 1234 is the last revision on the branch prior to the release) + * for final releases; in prereleases, it becomes " (Alpha 1)", + * " (Beta 1)", etc., as appropriate. + * + * Always change this at the same time as SVN_VER_NUMTAG. + */ +#define SVN_VER_TAG " (Release Candidate 3)" + + +/** Number tag: a string describing the version. + * + * This tag is used to generate a version number string to identify + * the client and server in HTTP requests, for example. It must not + * contain any spaces. This value remains "-dev" in the repository. + * + * When rolling a tarball, we automatically replace this text with "" + * for final releases; in prereleases, it becomes "-alpha1, "-beta1", + * etc., as appropriate. + * + * Always change this at the same time as SVN_VER_TAG. + */ +#define SVN_VER_NUMTAG "-rc3" + + +/** Revision number: The repository revision number of this release. + * + * This constant is used to generate the build number part of the Windows + * file version. Its value remains 0 in the repository. + * + * When rolling a tarball, we automatically replace it with what we + * guess to be the correct revision number. + */ +#define SVN_VER_REVISION 1490375 + + +/* Version strings composed from the above definitions. */ + +/** Version number */ +#define SVN_VER_NUM APR_STRINGIFY(SVN_VER_MAJOR) \ + "." APR_STRINGIFY(SVN_VER_MINOR) \ + "." APR_STRINGIFY(SVN_VER_PATCH) + +/** Version number with tag (contains no whitespace) */ +#define SVN_VER_NUMBER SVN_VER_NUM SVN_VER_NUMTAG + +/** Complete version string */ +#define SVN_VERSION SVN_VER_NUMBER SVN_VER_TAG + + + +/* Version queries and compatibility checks */ + +/** + * Version information. Each library contains a function called + * svn_<i>libname</i>_version() that returns a pointer to a statically + * allocated object of this type. + * + * @since New in 1.1. + */ +struct svn_version_t +{ + int major; /**< Major version number */ + int minor; /**< Minor version number */ + int patch; /**< Patch number */ + + /** + * The version tag (#SVN_VER_NUMTAG). Must always point to a + * statically allocated string. + */ + const char *tag; +}; + +/** + * Define a static svn_version_t object. + * + * @since New in 1.1. + */ +#define SVN_VERSION_DEFINE(name) \ + static const svn_version_t name = \ + { \ + SVN_VER_MAJOR, \ + SVN_VER_MINOR, \ + SVN_VER_PATCH, \ + SVN_VER_NUMTAG \ + } \ + +/** + * Generate the implementation of a version query function. + * + * @since New in 1.1. + */ +#define SVN_VERSION_BODY \ + SVN_VERSION_DEFINE(versioninfo); \ + return &versioninfo + +/** + * Check library version compatibility. Return #TRUE if the client's + * version, given in @a my_version, is compatible with the library + * version, provided in @a lib_version. + * + * This function checks for version compatibility as per our + * guarantees, but requires an exact match when linking to an + * unreleased library. A development client is always compatible with + * a previous released library. + * + * @since New in 1.1. + */ +svn_boolean_t +svn_ver_compatible(const svn_version_t *my_version, + const svn_version_t *lib_version); + +/** + * Check if @a my_version and @a lib_version encode the same version number. + * + * @since New in 1.2. + */ +svn_boolean_t +svn_ver_equal(const svn_version_t *my_version, + const svn_version_t *lib_version); + + +/** + * An entry in the compatibility checklist. + * @see svn_ver_check_list() + * + * @since New in 1.1. + */ +typedef struct svn_version_checklist_t +{ + const char *label; /**< Entry label */ + + /** Version query function for this entry */ + const svn_version_t *(*version_query)(void); +} svn_version_checklist_t; + + +/** + * Perform a series of version compatibility checks. Checks if @a + * my_version is compatible with each entry in @a checklist. @a + * checklist must end with an entry whose label is @c NULL. + * + * @see svn_ver_compatible() + * + * @since New in 1.1. + */ +svn_error_t * +svn_ver_check_list(const svn_version_t *my_version, + const svn_version_checklist_t *checklist); + + +/** + * Type of function returning library version. + * + * @since New in 1.6. + */ +typedef const svn_version_t *(*svn_version_func_t)(void); + + +/* libsvn_subr doesn't have an svn_subr header, so put the prototype here. */ +/** + * Get libsvn_subr version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_subr_version(void); + + +/** + * Extended version information, including info about the running system. + * + * @since New in 1.8. + */ +typedef struct svn_version_extended_t svn_version_extended_t; + +/** + * Return version information for the running program. If @a verbose + * is #TRUE, collect extra information that may be expensive to + * retrieve (for example, the OS release name, list of shared + * libraries, etc.). Use @a pool for all allocations. + * + * @since New in 1.8. + */ +const svn_version_extended_t * +svn_version_extended(svn_boolean_t verbose, + apr_pool_t *pool); + + +/** + * Accessor for svn_version_extended_t. + * + * @return The date when the libsvn_subr library was compiled, in the + * format defined by the C standard macro @c __DATE__. + * + * @since New in 1.8. + */ +const char * +svn_version_ext_build_date(const svn_version_extended_t *ext_info); + +/** + * Accessor for svn_version_extended_t. + * + * @return The time when the libsvn_subr library was compiled, in the + * format defined by the C standard macro @c __TIME__. + * + * @since New in 1.8. + */ +const char * +svn_version_ext_build_time(const svn_version_extended_t *ext_info); + +/** + * Accessor for svn_version_extended_t. + * + * @return The canonical host triplet (arch-vendor-osname) of the + * system where libsvn_subr was compiled. + * + * @note On Unix-like systems (includng Mac OS X), this string is the + * same as the output of the config.guess script. + * + * @since New in 1.8. + */ +const char * +svn_version_ext_build_host(const svn_version_extended_t *ext_info); + +/** + * Accessor for svn_version_extended_t. + * + * @return The localized copyright notice. + * + * @since New in 1.8. + */ +const char * +svn_version_ext_copyright(const svn_version_extended_t *ext_info); + +/** + * Accessor for svn_version_extended_t. + * + * @return The canonical host triplet (arch-vendor-osname) of the + * system where the current process is running. + * + * @note This string may not be the same as the output of config.guess + * on the same system. + * + * @since New in 1.8. + */ +const char * +svn_version_ext_runtime_host(const svn_version_extended_t *ext_info); + +/** + * Accessor for svn_version_extended_t. + * + * @return The "commercial" release name of the running operating + * system, if available. Not to be confused with, e.g., the output of + * "uname -v" or "uname -r". The returned value may be @c NULL. + * + * @since New in 1.8. + */ +const char * +svn_version_ext_runtime_osname(const svn_version_extended_t *ext_info); + +/** + * Dependent library information. + * Describes the name and versions of known dependencies + * used by libsvn_subr. + * + * @since New in 1.8. + */ +typedef struct svn_version_ext_linked_lib_t +{ + const char *name; /**< Library name */ + const char *compiled_version; /**< Compile-time version string */ + const char *runtime_version; /**< Run-time version string (optional) */ +} svn_version_ext_linked_lib_t; + +/** + * Accessor for svn_version_extended_t. + * + * @return Array of svn_version_ext_linked_lib_t describing dependent + * libraries. The returned value may be @c NULL. + * + * @since New in 1.8. + */ +const apr_array_header_t * +svn_version_ext_linked_libs(const svn_version_extended_t *ext_info); + + +/** + * Loaded shared library information. + * Describes the name and, where available, version of the shared libraries + * loaded by the running program. + * + * @since New in 1.8. + */ +typedef struct svn_version_ext_loaded_lib_t +{ + const char *name; /**< Library name */ + const char *version; /**< Library version (optional) */ +} svn_version_ext_loaded_lib_t; + + +/** + * Accessor for svn_version_extended_t. + * + * @return Array of svn_version_ext_loaded_lib_t describing loaded + * shared libraries. The returned value may be @c NULL. + * + * @note On Mac OS X, the loaded frameworks, private frameworks and + * system libraries will not be listed. + * + * @since New in 1.8. + */ +const apr_array_header_t * +svn_version_ext_loaded_libs(const svn_version_extended_t *ext_info); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_VERSION_H */ diff --git a/subversion/include/svn_wc.h b/subversion/include/svn_wc.h new file mode 100644 index 0000000..2a9741d --- /dev/null +++ b/subversion/include/svn_wc.h @@ -0,0 +1,8182 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_wc.h + * @brief Subversion's working copy library + * + * Requires: + * - A working copy + * + * Provides: + * - Ability to manipulate working copy's versioned data. + * - Ability to manipulate working copy's administrative files. + * + * Used By: + * - Clients. + * + * Notes: + * The 'path' parameters to most of the older functions can be + * absolute or relative (relative to current working + * directory). If there are any cases where they are + * relative to the path associated with the + * 'svn_wc_adm_access_t *adm_access' baton passed along with the + * path, those cases should be explicitly documented, and if they + * are not, please fix it. All new functions introduced since + * Subversion 1.7 require absolute paths, unless explicitly + * documented otherwise. + * + * Starting with Subversion 1.7, several arguments are re-ordered + * to be more consistent through the api. The common ordering used + * is: + * + * Firsts: + * - Output arguments + * Then: + * - Working copy context + * - Local abspath + * Followed by: + * - Function specific arguments + * - Specific callbacks with their batons + * Finally: + * - Generic callbacks (with baton) from directly functional to + * just observing: + * - svn_wc_conflict_resolver_func2_t + * - svn_wc_external_update_t + * - svn_cancel_func_t + * - svn_wc_notify_func2_t + * - Result pool + * - Scratch pool. + */ + +#ifndef SVN_WC_H +#define SVN_WC_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_tables.h> +#include <apr_hash.h> +#include <apr_time.h> +#include <apr_file_io.h> + +#include "svn_types.h" +#include "svn_string.h" +#include "svn_checksum.h" +#include "svn_io.h" +#include "svn_delta.h" /* for svn_stream_t */ +#include "svn_opt.h" +#include "svn_ra.h" /* for svn_ra_reporter_t type */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * Get libsvn_wc version information. + * + * @since New in 1.1. + */ +const svn_version_t * +svn_wc_version(void); + + +/** + * @defgroup svn_wc Working copy management + * @{ + */ + + +/** Flags for use with svn_wc_translated_file2() and svn_wc_translated_stream(). + * + * @defgroup translate_flags Translation flags + * @{ + */ + + /** Translate from Normal Form. + * + * The working copy text bases and repository files are stored + * in normal form. Some files' contents - or ever representation - + * differs between the working copy and the normal form. This flag + * specifies to take the latter form as input and transform it + * to the former. + * + * Either this flag or #SVN_WC_TRANSLATE_TO_NF should be specified, + * but not both. + */ +#define SVN_WC_TRANSLATE_FROM_NF 0x00000000 + + /** Translate to Normal Form. + * + * Either this flag or #SVN_WC_TRANSLATE_FROM_NF should be specified, + * but not both. + */ +#define SVN_WC_TRANSLATE_TO_NF 0x00000001 + + /** Force repair of eol styles, making sure the output file consistently + * contains the one eol style as specified by the svn:eol-style + * property and the required translation direction. + * + */ +#define SVN_WC_TRANSLATE_FORCE_EOL_REPAIR 0x00000002 + + /** Don't register a pool cleanup to delete the output file */ +#define SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP 0x00000004 + + /** Guarantee a new file is created on successful return. + * The default shortcuts translation by returning the path + * of the untranslated file when no translation is required. + */ +#define SVN_WC_TRANSLATE_FORCE_COPY 0x00000008 + + /** Use a non-wc-local tmp directory for creating output files, + * instead of in the working copy admin tmp area which is the default. + * + * @since New in 1.4. + */ +#define SVN_WC_TRANSLATE_USE_GLOBAL_TMP 0x00000010 + +/** @} */ + + +/** + * @defgroup svn_wc_context Working copy context + * @{ + */ + +/** The context for all working copy interactions. + * + * This is the client-facing datastructure API consumers are required + * to create and use when interacting with a working copy. Multiple + * contexts can be created for the same working copy simultaneously, within + * the same process or different processes. Context mutexing will be handled + * internally by the working copy library. + * + * @note: #svn_wc_context_t should be passed by non-const pointer in all + * APIs, even for read-only operations, as it contains mutable data (caching, + * etc.). + * + * @since New in 1.7. + */ +typedef struct svn_wc_context_t svn_wc_context_t; + +/** Create a context for the working copy, and return it in @a *wc_ctx. This + * context is not associated with a particular working copy, but as operations + * are performed, will load the appropriate working copy information. + * + * @a config should hold the various configuration options that may apply to + * this context. It should live at least as long as @a result_pool. It may + * be @c NULL. + * + * The context will be allocated in @a result_pool, and will use @a + * result_pool for any internal allocations requiring the same longevity as + * the context. The context will be automatically destroyed, and its + * resources released, when @a result_pool is cleared, or it may be manually + * destroyed by invoking svn_wc_context_destroy(). + * + * Use @a scratch_pool for temporary allocations. It may be cleared + * immediately upon returning from this function. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_context_create(svn_wc_context_t **wc_ctx, + const svn_config_t *config, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Destroy the working copy context described by @a wc_ctx, releasing any + * acquired resources. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_context_destroy(svn_wc_context_t *wc_ctx); + + +/** @} */ + + +/** + * Locking/Opening/Closing using adm access batons. + * + * @defgroup svn_wc_adm_access Adm access batons (deprecated) + * @{ + */ + +/** Baton for access to a working copy administrative area. + * + * Access batons can be grouped into sets, by passing an existing open + * baton when opening a new baton. Given one baton in a set, other batons + * may be retrieved. This allows an entire hierarchy to be locked, and + * then the set of batons can be passed around by passing a single baton. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use a #svn_wc_context_t object to access the working + * copy. + */ +typedef struct svn_wc_adm_access_t svn_wc_adm_access_t; + + +/** + * Return, in @a *adm_access, a pointer to a new access baton for the working + * copy administrative area associated with the directory @a path. If + * @a write_lock is TRUE the baton will include a write lock, otherwise the + * baton can only be used for read access. If @a path refers to a directory + * that is already write locked then the error #SVN_ERR_WC_LOCKED will be + * returned. The error #SVN_ERR_WC_NOT_DIRECTORY will be returned if + * @a path is not a versioned directory. + * + * If @a associated is an open access baton then @a adm_access will be added + * to the set containing @a associated. @a associated can be @c NULL, in + * which case @a adm_access is the start of a new set. + * + * @a levels_to_lock specifies how far to lock. Zero means just the specified + * directory. Any negative value means to lock the entire working copy + * directory hierarchy under @a path. A positive value indicates the number of + * levels of directories to lock -- 1 means just immediate subdirectories, 2 + * means immediate subdirectories and their subdirectories, etc. All the + * access batons will become part of the set containing @a adm_access. This + * is an all-or-nothing option, if it is not possible to lock all the + * requested directories then an error will be returned and @a adm_access will + * be invalid, with the exception that subdirectories of @a path that are + * missing from the physical filesystem will not be locked and will not cause + * an error. The error #SVN_ERR_WC_LOCKED will be returned if a + * subdirectory of @a path is already write locked. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client has canceled the operation. + * + * @a pool will be used to allocate memory for the baton and any subsequently + * cached items. If @a adm_access has not been closed when the pool is + * cleared, it will be closed automatically at that point, and removed from + * its set. A baton closed in this way will not remove physical locks from + * the working copy if cleanup is required. + * + * The first baton in a set, with @a associated passed as @c NULL, must have + * the longest lifetime of all the batons in the set. This implies it must be + * the root of the hierarchy. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + * Callers should use a #svn_wc_context_t object to access the working + * copy. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_open3(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_adm_open3(), but without cancellation support. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_open2(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + apr_pool_t *pool); + +/** + * Similar to svn_wc_adm_open2(), but with @a tree_lock instead of + * @a levels_to_lock. @a levels_to_lock is set to -1 if @a tree_lock + * is @c TRUE, else 0. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_open(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + svn_boolean_t tree_lock, + apr_pool_t *pool); + +/** + * Checks the working copy to determine the node type of @a path. If + * @a path is a versioned directory then the behaviour is like that of + * svn_wc_adm_open3(), otherwise, if @a path is a file or does not + * exist, then the behaviour is like that of svn_wc_adm_open3() with + * @a path replaced by the parent directory of @a path. If @a path is + * an unversioned directory, the behaviour is also like that of + * svn_wc_adm_open3() on the parent, except that if the open fails, + * then the returned #SVN_ERR_WC_NOT_DIRECTORY error refers to @a path, + * not to @a path's parent. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + * Callers should use a #svn_wc_context_t object to access the working + * copy. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_open3(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_adm_probe_open3() without the cancel + * functionality. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_open2(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + apr_pool_t *pool); + +/** + * Similar to svn_wc_adm_probe_open2(), but with @a tree_lock instead of + * @a levels_to_lock. @a levels_to_lock is set to -1 if @a tree_lock + * is @c TRUE, else 0. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_open(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + svn_boolean_t tree_lock, + apr_pool_t *pool); + +/** + * Open access batons for @a path and return in @a *anchor_access and + * @a *target the anchor and target required to drive an editor. Return + * in @a *target_access the access baton for the target, which may be the + * same as @a *anchor_access (in which case @a *target is the empty + * string, never NULL). All the access batons will be in the + * @a *anchor_access set. + * + * @a levels_to_lock determines the levels_to_lock used when opening + * @a path if @a path is a versioned directory, @a levels_to_lock is + * ignored otherwise. If @a write_lock is @c TRUE the access batons + * will hold write locks. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client has canceled the operation. + * + * This function is essentially a combination of svn_wc_adm_open3() and + * svn_wc_get_actual_target(), with the emphasis on reducing physical IO. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + * Callers should use a #svn_wc_context_t object to access the working + * copy. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_open_anchor(svn_wc_adm_access_t **anchor_access, + svn_wc_adm_access_t **target_access, + const char **target, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Return, in @a *adm_access, a pointer to an existing access baton associated + * with @a path. @a path must be a directory that is locked as part of the + * set containing the @a associated access baton. + * + * If the requested access baton is marked as missing in, or is simply + * absent from, @a associated, return #SVN_ERR_WC_NOT_LOCKED. + * + * @a pool is used only for local processing, it is not used for the batons. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_retrieve(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + apr_pool_t *pool); + +/** Check the working copy to determine the node type of @a path. If + * @a path is a versioned directory then the behaviour is like that of + * svn_wc_adm_retrieve(), otherwise, if @a path is a file, an unversioned + * directory, or does not exist, then the behaviour is like that of + * svn_wc_adm_retrieve() with @a path replaced by the parent directory of + * @a path. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_retrieve(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + apr_pool_t *pool); + +/** + * Try various ways to obtain an access baton for @a path. + * + * First, try to obtain @a *adm_access via svn_wc_adm_probe_retrieve(), + * but if this fails because @a associated can't give a baton for + * @a path or @a path's parent, then try svn_wc_adm_probe_open3(), + * this time passing @a write_lock and @a levels_to_lock. If there is + * still no access because @a path is not a versioned directory, then + * just set @a *adm_access to NULL and return success. But if it is + * because @a path is locked, then return the error #SVN_ERR_WC_LOCKED, + * and the effect on @a *adm_access is undefined. (Or if the attempt + * fails for any other reason, return the corresponding error, and the + * effect on @a *adm_access is also undefined.) + * + * If svn_wc_adm_probe_open3() succeeds, then add @a *adm_access to + * @a associated. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client has canceled the operation. + * + * Use @a pool only for local processing, not to allocate @a *adm_access. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_try3(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_adm_probe_try3() without the cancel + * functionality. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_try2(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + int levels_to_lock, + apr_pool_t *pool); + +/** + * Similar to svn_wc_adm_probe_try2(), but with @a tree_lock instead of + * @a levels_to_lock. @a levels_to_lock is set to -1 if @a tree_lock + * is @c TRUE, else 0. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_probe_try(svn_wc_adm_access_t **adm_access, + svn_wc_adm_access_t *associated, + const char *path, + svn_boolean_t write_lock, + svn_boolean_t tree_lock, + apr_pool_t *pool); + + +/** Give up the access baton @a adm_access, and its lock if any. This will + * recursively close any batons in the same set that are direct + * subdirectories of @a adm_access. Any physical locks will be removed from + * the working copy. Lock removal is unconditional, there is no check to + * determine if cleanup is required. + * + * Any temporary allocations are performed using @a scratch_pool. + * + * @since New in 1.6 + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_close2(svn_wc_adm_access_t *adm_access, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_adm_close2(), but with the internal pool of @a adm_access + * used for temporary allocations. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_adm_close(svn_wc_adm_access_t *adm_access); + +/** Return the path used to open the access baton @a adm_access. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +const char * +svn_wc_adm_access_path(const svn_wc_adm_access_t *adm_access); + +/** Return the pool used by access baton @a adm_access. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +apr_pool_t * +svn_wc_adm_access_pool(const svn_wc_adm_access_t *adm_access); + +/** Return @c TRUE is the access baton @a adm_access has a write lock, + * @c FALSE otherwise. Compared to svn_wc_locked() this is a cheap, fast + * function that doesn't access the filesystem. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * New code should use svn_wc_locked2() instead. + */ +SVN_DEPRECATED +svn_boolean_t +svn_wc_adm_locked(const svn_wc_adm_access_t *adm_access); + +/** @} */ + + +/** Gets up to two booleans indicating whether a path is locked for + * writing. + * + * @a locked_here is set to TRUE when a write lock on @a local_abspath + * exists in @a wc_ctx. @a locked is set to TRUE when there is a + * write_lock on @a local_abspath + * + * @a locked_here and/or @a locked can be NULL when you are not + * interested in a specific value + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_locked2(svn_boolean_t *locked_here, + svn_boolean_t *locked, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** Set @a *locked to non-zero if @a path is locked, else set it to zero. + * + * New code should use svn_wc_locked2() instead. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_locked(svn_boolean_t *locked, + const char *path, + apr_pool_t *pool); + + +/** + * @defgroup svn_wc_adm_dir_name Name of Subversion's admin dir + * @{ + */ + +/** The default name of the administrative subdirectory. + * + * Ideally, this would be completely private to wc internals (in fact, + * it used to be that adm_subdir() in adm_files.c was the only function + * who knew the adm subdir's name). However, import wants to protect + * against importing administrative subdirs, so now the name is a + * matter of public record. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +#define SVN_WC_ADM_DIR_NAME ".svn" + + +/** + * Return @c TRUE if @a name is the name of the WC administrative + * directory. Use @a pool for any temporary allocations. Only works + * with base directory names, not paths or URIs. + * + * For compatibility, the default name (.svn) will always be treated + * as an admin dir name, even if the working copy is actually using an + * alternative name. + * + * @since New in 1.3. + */ +svn_boolean_t +svn_wc_is_adm_dir(const char *name, apr_pool_t *pool); + + +/** + * Return the name of the administrative directory. + * Use @a pool for any temporary allocations. + * + * The returned pointer will refer to either a statically allocated + * string, or to a string allocated in @a pool. + * + * @since New in 1.3. + */ +const char * +svn_wc_get_adm_dir(apr_pool_t *pool); + + +/** + * Use @a name for the administrative directory in the working copy. + * Use @a pool for any temporary allocations. + * + * The list of valid names is limited. Currently only ".svn" (the + * default) and "_svn" are allowed. + * + * @note This function changes global (per-process) state and must be + * called in a single-threaded context during the initialization of a + * Subversion client. + * + * @since New in 1.3. + */ +svn_error_t * +svn_wc_set_adm_dir(const char *name, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_externals Externals + * @{ + */ + +/** Callback for external definitions updates + * + * @a local_abspath is the path on which the external definition was found. + * @a old_val and @a new_val are the before and after values of the + * SVN_PROP_EXTERNALS property. @a depth is the ambient depth of the + * working copy directory at @a local_abspath. + * + * @since New in 1.7. */ +typedef svn_error_t *(*svn_wc_external_update_t)(void *baton, + const char *local_abspath, + const svn_string_t *old_val, + const svn_string_t *new_val, + svn_depth_t depth, + apr_pool_t *scratch_pool); + +/** Traversal information is information gathered by a working copy + * crawl or update. For example, the before and after values of the + * svn:externals property are important after an update, and since + * we're traversing the working tree anyway (a complete traversal + * during the initial crawl, and a traversal of changed paths during + * the checkout/update/switch), it makes sense to gather the + * property's values then instead of making a second pass. + * + * New code should use the svn_wc_external_update_t callback instead. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef struct svn_wc_traversal_info_t svn_wc_traversal_info_t; + + +/** Return a new, empty traversal info object, allocated in @a pool. + * + * New code should use the svn_wc_external_update_t callback instead. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_wc_traversal_info_t * +svn_wc_init_traversal_info(apr_pool_t *pool); + +/** Set @a *externals_old and @a *externals_new to hash tables representing + * changes to values of the svn:externals property on directories + * traversed by @a traversal_info. + * + * @a traversal_info is obtained from svn_wc_init_traversal_info(), but is + * only useful after it has been passed through another function, such + * as svn_wc_crawl_revisions(), svn_wc_get_update_editor(), + * svn_wc_get_switch_editor(), etc. + * + * Each hash maps <tt>const char *</tt> directory names onto + * <tt>const char *</tt> values of the externals property for that directory. + * The dir names are full paths -- that is, anchor plus target, not target + * alone. The values are not parsed, they are simply copied raw, and are + * never NULL: directories that acquired or lost the property are + * simply omitted from the appropriate table. Directories whose value + * of the property did not change show the same value in each hash. + * + * The hashes, keys, and values have the same lifetime as @a traversal_info. + * + * New code should use the svn_wc_external_update_t callback instead. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +void +svn_wc_edited_externals(apr_hash_t **externals_old, + apr_hash_t **externals_new, + svn_wc_traversal_info_t *traversal_info); + + +/** Set @a *depths to a hash table mapping <tt>const char *</tt> + * directory names (directories traversed by @a traversal_info) to + * <tt>const char *</tt> values (the depths of those directories, as + * converted by svn_depth_to_word()). + * + * @a traversal_info is obtained from svn_wc_init_traversal_info(), but is + * only useful after it has been passed through another function, such + * as svn_wc_crawl_revisions(), svn_wc_get_update_editor(), + * svn_wc_get_switch_editor(), etc. + * + * The dir names are full paths -- that is, anchor plus target, not target + * alone. The values are not allocated, they are static constant strings. + * Although the values are never NULL, not all directories traversed + * are necessarily listed. For example, directories which did not + * have an svn:externals property set or modified are not included. + * + * The hashes and keys have the same lifetime as @a traversal_info. + * + * New code should use the svn_wc_external_update_t callback instead. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +void +svn_wc_traversed_depths(apr_hash_t **depths, + svn_wc_traversal_info_t *traversal_info); + + +/** One external item. This usually represents one line from an + * svn:externals description but with the path and URL + * canonicalized. + * + * In order to avoid backwards compatibility problems clients should use + * svn_wc_external_item2_create() to allocate and initialize this structure + * instead of doing so themselves. + * + * @since New in 1.5. + */ +typedef struct svn_wc_external_item2_t +{ + /** The name of the subdirectory into which this external should be + checked out. This is relative to the parent directory that + holds this external item. (Note that these structs are often + stored in hash tables with the target dirs as keys, so this + field will often be redundant.) */ + const char *target_dir; + + /** Where to check out from. This is possibly a relative external URL, as + * allowed in externals definitions, but without the peg revision. */ + const char *url; + + /** What revision to check out. The only valid kinds for this are + svn_opt_revision_number, svn_opt_revision_date, and + svn_opt_revision_head. */ + svn_opt_revision_t revision; + + /** The peg revision to use when checking out. The only valid kinds are + svn_opt_revision_number, svn_opt_revision_date, and + svn_opt_revision_head. */ + svn_opt_revision_t peg_revision; + +} svn_wc_external_item2_t; + +/** + * Initialize an external item. + * Set @a *item to an external item object, allocated in @a pool. + * + * In order to avoid backwards compatibility problems, this function + * is used to initialize and allocate the #svn_wc_external_item2_t + * structure rather than doing so explicitly, as the size of this + * structure may change in the future. + * + * The current implementation never returns error, but callers should + * still check for error, for compatibility with future versions. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc_external_item2_create(svn_wc_external_item2_t **item, + apr_pool_t *pool); + +/** Same as svn_wc_external_item2_create() except the pointer to the new + * empty item is 'const' which is stupid since the next thing you need to do + * is fill in its fields. + * + * @deprecated Provided for backward compatibility with the 1.7 API. + * @since New in 1.5. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_external_item_create(const svn_wc_external_item2_t **item, + apr_pool_t *pool); + +/** + * Return a duplicate of @a item, allocated in @a pool. No part of the new + * item will be shared with @a item. + * + * @since New in 1.5. + */ +svn_wc_external_item2_t * +svn_wc_external_item2_dup(const svn_wc_external_item2_t *item, + apr_pool_t *pool); + +/** + * One external item. Similar to svn_wc_external_item2_t, except + * @a revision is interpreted as both the operational revision and the + * peg revision. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +typedef struct svn_wc_external_item_t +{ + /** Same as #svn_wc_external_item2_t.target_dir */ + const char *target_dir; + + /** Same as #svn_wc_external_item2_t.url */ + const char *url; + + /** Same as #svn_wc_external_item2_t.revision */ + svn_opt_revision_t revision; + +} svn_wc_external_item_t; + +/** + * Return a duplicate of @a item, allocated in @a pool. No part of the new + * item will be shared with @a item. + * + * @since New in 1.3. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_wc_external_item_t * +svn_wc_external_item_dup(const svn_wc_external_item_t *item, + apr_pool_t *pool); + +/** + * If @a externals_p is non-NULL, set @a *externals_p to an array of + * #svn_wc_external_item2_t * objects based on @a desc. + * + * If the format of @a desc is invalid, don't touch @a *externals_p and + * return #SVN_ERR_CLIENT_INVALID_EXTERNALS_DESCRIPTION. Thus, if + * you just want to check the validity of an externals description, + * and don't care about the parsed result, pass NULL for @a externals_p. + * + * The format of @a desc is the same as for values of the directory + * property #SVN_PROP_EXTERNALS. Look there for more details. + * + * If @a canonicalize_url is @c TRUE, canonicalize the @a url member + * of those objects. If the @a url member refers to an absolute URL, + * it will be canonicalized as URL consistent with the way URLs are + * canonicalized throughout the Subversion API. If, however, the + * @a url member makes use of the recognized (SVN-specific) relative + * URL syntax for svn:externals, "canonicalization" is an ill-defined + * concept which may even result in munging the relative URL syntax + * beyond recognition. You've been warned. + * + * Allocate the table, keys, and values in @a pool. + * + * Use @a parent_directory only in constructing error strings. + * + * @since New in 1.5. + */ +svn_error_t * +svn_wc_parse_externals_description3(apr_array_header_t **externals_p, + const char *parent_directory, + const char *desc, + svn_boolean_t canonicalize_url, + apr_pool_t *pool); + +/** + * Similar to svn_wc_parse_externals_description3() with @a + * canonicalize_url set to @c TRUE, but returns an array of + * #svn_wc_external_item_t * objects instead of + * #svn_wc_external_item2_t * objects + * + * @since New in 1.1. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_parse_externals_description2(apr_array_header_t **externals_p, + const char *parent_directory, + const char *desc, + apr_pool_t *pool); + +/** + * Similar to svn_wc_parse_externals_description2(), but returns the + * parsed externals in a hash instead of an array. This function + * should not be used, as storing the externals in a hash causes their + * order of evaluation to be not easily identifiable. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_parse_externals_description(apr_hash_t **externals_p, + const char *parent_directory, + const char *desc, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_notifications Notification callback handling + * @{ + * + * In many cases, the WC library will scan a working copy and make + * changes. The caller usually wants to know when each of these changes + * has been made, so that it can display some kind of notification to + * the user. + * + * These notifications have a standard callback function type, which + * takes the path of the file that was affected, and a caller- + * supplied baton. + * + * @note The callback is a 'void' return -- this is a simple + * reporting mechanism, rather than an opportunity for the caller to + * alter the operation of the WC library. + * + * @note Some of the actions are used across several + * different Subversion commands. For example, the update actions are + * also used for checkouts, switches, and merges. + */ + +/** The type of action occurring. */ +typedef enum svn_wc_notify_action_t +{ + /** Adding a path to revision control. */ + svn_wc_notify_add = 0, + + /** Copying a versioned path. */ + svn_wc_notify_copy, + + /** Deleting a versioned path. */ + svn_wc_notify_delete, + + /** Restoring a missing path from the pristine text-base. */ + svn_wc_notify_restore, + + /** Reverting a modified path. */ + svn_wc_notify_revert, + + /** A revert operation has failed. */ + svn_wc_notify_failed_revert, + + /** Resolving a conflict. */ + svn_wc_notify_resolved, + + /** Skipping a path. */ + svn_wc_notify_skip, + + /** Got a delete in an update. */ + svn_wc_notify_update_delete, + + /** Got an add in an update. */ + svn_wc_notify_update_add, + + /** Got any other action in an update. */ + svn_wc_notify_update_update, + + /** The last notification in an update (including updates of externals). */ + svn_wc_notify_update_completed, + + /** Updating an external module. */ + svn_wc_notify_update_external, + + /** The last notification in a status (including status on externals). */ + svn_wc_notify_status_completed, + + /** Running status on an external module. */ + svn_wc_notify_status_external, + + /** Committing a modification. */ + svn_wc_notify_commit_modified, + + /** Committing an addition. */ + svn_wc_notify_commit_added, + + /** Committing a deletion. */ + svn_wc_notify_commit_deleted, + + /** Committing a replacement. */ + svn_wc_notify_commit_replaced, + + /** Transmitting post-fix text-delta data for a file. */ + svn_wc_notify_commit_postfix_txdelta, + + /** Processed a single revision's blame. */ + svn_wc_notify_blame_revision, + + /** Locking a path. @since New in 1.2. */ + svn_wc_notify_locked, + + /** Unlocking a path. @since New in 1.2. */ + svn_wc_notify_unlocked, + + /** Failed to lock a path. @since New in 1.2. */ + svn_wc_notify_failed_lock, + + /** Failed to unlock a path. @since New in 1.2. */ + svn_wc_notify_failed_unlock, + + /** Tried adding a path that already exists. @since New in 1.5. */ + svn_wc_notify_exists, + + /** Changelist name set. @since New in 1.5. */ + svn_wc_notify_changelist_set, + + /** Changelist name cleared. @since New in 1.5. */ + svn_wc_notify_changelist_clear, + + /** Warn user that a path has moved from one changelist to another. + @since New in 1.5. + @deprecated As of 1.7, separate clear and set notifications are sent. */ + svn_wc_notify_changelist_moved, + + /** A merge operation (to path) has begun. See #svn_wc_notify_t.merge_range. + @since New in 1.5. */ + svn_wc_notify_merge_begin, + + /** A merge operation (to path) from a foreign repository has begun. + See #svn_wc_notify_t.merge_range. @since New in 1.5. */ + svn_wc_notify_foreign_merge_begin, + + /** Replace notification. @since New in 1.5. */ + svn_wc_notify_update_replace, + + /** Property added. @since New in 1.6. */ + svn_wc_notify_property_added, + + /** Property updated. @since New in 1.6. */ + svn_wc_notify_property_modified, + + /** Property deleted. @since New in 1.6. */ + svn_wc_notify_property_deleted, + + /** Nonexistent property deleted. @since New in 1.6. */ + svn_wc_notify_property_deleted_nonexistent, + + /** Revprop set. @since New in 1.6. */ + svn_wc_notify_revprop_set, + + /** Revprop deleted. @since New in 1.6. */ + svn_wc_notify_revprop_deleted, + + /** The last notification in a merge. @since New in 1.6. */ + svn_wc_notify_merge_completed, + + /** The path is a tree-conflict victim of the intended action (*not* + * a persistent tree-conflict from an earlier operation, but *this* + * operation caused the tree-conflict). @since New in 1.6. */ + svn_wc_notify_tree_conflict, + + /** The path is a subdirectory referenced in an externals definition + * which is unable to be operated on. @since New in 1.6. */ + svn_wc_notify_failed_external, + + /** Starting an update operation. @since New in 1.7. */ + svn_wc_notify_update_started, + + /** An update tried to add a file or directory at a path where + * a separate working copy was found. @since New in 1.7. */ + svn_wc_notify_update_skip_obstruction, + + /** An explicit update tried to update a file or directory that + * doesn't live in the repository and can't be brought in. + * @since New in 1.7. */ + svn_wc_notify_update_skip_working_only, + + /** An update tried to update a file or directory to which access could + * not be obtained. @since New in 1.7. */ + svn_wc_notify_update_skip_access_denied, + + /** An update operation removed an external working copy. + * @since New in 1.7. */ + svn_wc_notify_update_external_removed, + + /** A node below an existing node was added during update. + * @since New in 1.7. */ + svn_wc_notify_update_shadowed_add, + + /** A node below an existing node was updated during update. + * @since New in 1.7. */ + svn_wc_notify_update_shadowed_update, + + /** A node below an existing node was deleted during update. + * @since New in 1.7. */ + svn_wc_notify_update_shadowed_delete, + + /** The mergeinfo on path was updated. @since New in 1.7. */ + svn_wc_notify_merge_record_info, + + /** A working copy directory was upgraded to the latest format. + * @since New in 1.7. */ + svn_wc_notify_upgraded_path, + + /** Mergeinfo describing a merge was recorded. + * @since New in 1.7. */ + svn_wc_notify_merge_record_info_begin, + + /** Mergeinfo was removed due to elision. + * @since New in 1.7. */ + svn_wc_notify_merge_elide_info, + + /** A file in the working copy was patched. + * @since New in 1.7. */ + svn_wc_notify_patch, + + /** A hunk from a patch was applied. + * @since New in 1.7. */ + svn_wc_notify_patch_applied_hunk, + + /** A hunk from a patch was rejected. + * @since New in 1.7. */ + svn_wc_notify_patch_rejected_hunk, + + /** A hunk from a patch was found to already be applied. + * @since New in 1.7. */ + svn_wc_notify_patch_hunk_already_applied, + + /** Committing a non-overwriting copy (path is the target of the + * copy, not the source). + * @since New in 1.7. */ + svn_wc_notify_commit_copied, + + /** Committing an overwriting (replace) copy (path is the target of + * the copy, not the source). + * @since New in 1.7. */ + svn_wc_notify_commit_copied_replaced, + + /** The server has instructed the client to follow a URL + * redirection. + * @since New in 1.7. */ + svn_wc_notify_url_redirect, + + /** The operation was attempted on a path which doesn't exist. + * @since New in 1.7. */ + svn_wc_notify_path_nonexistent, + + /** Removing a path by excluding it. + * @since New in 1.7. */ + svn_wc_notify_exclude, + + /** Operation failed because the node remains in conflict + * @since New in 1.7. */ + svn_wc_notify_failed_conflict, + + /** Operation failed because an added node is missing + * @since New in 1.7. */ + svn_wc_notify_failed_missing, + + /** Operation failed because a node is out of date + * @since New in 1.7. */ + svn_wc_notify_failed_out_of_date, + + /** Operation failed because an added parent is not selected + * @since New in 1.7. */ + svn_wc_notify_failed_no_parent, + + /** Operation failed because a node is locked by another user and/or + * working copy. @since New in 1.7. */ + svn_wc_notify_failed_locked, + + /** Operation failed because the operation was forbidden by the server. + * @since New in 1.7. */ + svn_wc_notify_failed_forbidden_by_server, + + /** The operation skipped the path because it was conflicted. + * @since New in 1.7. */ + svn_wc_notify_skip_conflicted, + + /** Just the lock on a file was removed during update. + * @since New in 1.8. */ + svn_wc_notify_update_broken_lock, + + /** Operation failed because a node is obstructed. + * @since New in 1.8. */ + svn_wc_notify_failed_obstruction, + + /** Conflict resolver is starting. + * This can be used by clients to detect when to display conflict summary + * information, for example. + * @since New in 1.8. */ + svn_wc_notify_conflict_resolver_starting, + + /** Conflict resolver is done. + * This can be used by clients to detect when to display conflict summary + * information, for example. + * @since New in 1.8. */ + svn_wc_notify_conflict_resolver_done, + + /** The current operation left local changes of something that was deleted + * The changes are available on (and below) the notified path + * @since New in 1.8. */ + svn_wc_notify_left_local_modifications, + + /** A copy from a foreign repository has started + * @since New in 1.8. */ + svn_wc_notify_foreign_copy_begin, + + /** A move in the working copy has been broken, i.e. degraded into a + * copy + delete. The notified path is the move source (the deleted path). + * ### TODO: Provide path to move destination as well? + * @since New in 1.8. */ + svn_wc_notify_move_broken + +} svn_wc_notify_action_t; + + +/** The type of notification that is occurring. */ +typedef enum svn_wc_notify_state_t +{ + svn_wc_notify_state_inapplicable = 0, + + /** Notifier doesn't know or isn't saying. */ + svn_wc_notify_state_unknown, + + /** The state did not change. */ + svn_wc_notify_state_unchanged, + + /** The item wasn't present. */ + svn_wc_notify_state_missing, + + /** An unversioned item obstructed work. */ + svn_wc_notify_state_obstructed, + + /** Pristine state was modified. */ + svn_wc_notify_state_changed, + + /** Modified state had mods merged in. */ + svn_wc_notify_state_merged, + + /** Modified state got conflicting mods. */ + svn_wc_notify_state_conflicted, + + /** The source to copy the file from is missing. */ + svn_wc_notify_state_source_missing + +} svn_wc_notify_state_t; + +/** + * What happened to a lock during an operation. + * + * @since New in 1.2. + */ +typedef enum svn_wc_notify_lock_state_t +{ + svn_wc_notify_lock_state_inapplicable = 0, + + svn_wc_notify_lock_state_unknown, + + /** The lock wasn't changed. */ + svn_wc_notify_lock_state_unchanged, + + /** The item was locked. */ + svn_wc_notify_lock_state_locked, + + /** The item was unlocked. */ + svn_wc_notify_lock_state_unlocked + +} svn_wc_notify_lock_state_t; + +/** + * Structure used in the #svn_wc_notify_func2_t function. + * + * @c kind, @c content_state, @c prop_state and @c lock_state are from + * after @c action, not before. + * + * @note If @c action is #svn_wc_notify_update_completed, then @c path has + * already been installed, so it is legitimate for an implementation of + * #svn_wc_notify_func2_t to examine @c path in the working copy. + * + * @note The purpose of the @c kind, @c mime_type, @c content_state, and + * @c prop_state fields is to provide "for free" information that an + * implementation is likely to want, and which it would otherwise be + * forced to deduce via expensive operations such as reading entries + * and properties. However, if the caller does not have this + * information, it will simply pass the corresponding `*_unknown' + * values, and it is up to the implementation how to handle that + * (i.e., whether to attempt deduction, or just to punt and + * give a less informative notification). + * + * @note Callers of notification functions should use svn_wc_create_notify() + * or svn_wc_create_notify_url() to create structures of this type to allow + * for extensibility. + * + * @since New in 1.2. + */ +typedef struct svn_wc_notify_t { + + /** Path, either absolute or relative to the current working directory + * (i.e., not relative to an anchor). @c path is "." or another valid path + * value for compatibility reasons when the real target is a url that + * is available in @c url. */ + const char *path; + + /** Action that describes what happened to #svn_wc_notify_t.path. */ + svn_wc_notify_action_t action; + + /** Node kind of @c path. */ + svn_node_kind_t kind; + + /** If non-NULL, indicates the mime-type of @c path. + * It is always @c NULL for directories. */ + const char *mime_type; + + /** Points to the lock structure received from the repository when + * @c action is #svn_wc_notify_locked. For other actions, it is + * @c NULL. */ + const svn_lock_t *lock; + + /** Points to an error describing the reason for the failure when @c + * action is one of the following: #svn_wc_notify_failed_lock, + * #svn_wc_notify_failed_unlock, #svn_wc_notify_failed_external. + * Is @c NULL otherwise. */ + svn_error_t *err; + + /** The type of notification that is occurring about node content. */ + svn_wc_notify_state_t content_state; + + /** The type of notification that is occurring about node properties. */ + svn_wc_notify_state_t prop_state; + + /** Reflects the addition or removal of a lock token in the working copy. */ + svn_wc_notify_lock_state_t lock_state; + + /** When @c action is #svn_wc_notify_update_completed, target revision + * of the update, or #SVN_INVALID_REVNUM if not available; when @c + * action is #svn_wc_notify_blame_revision, processed revision; Since + * Subversion 1.7 when action is #svn_wc_notify_update_update or + * #svn_wc_notify_update_add, the target revision. + * In all other cases, it is #SVN_INVALID_REVNUM. + */ + svn_revnum_t revision; + + /** If @c action pertains to a changelist, this is the changelist name. + * In all other cases, it is @c NULL. @since New in 1.5 */ + const char *changelist_name; + + /** When @c action is #svn_wc_notify_merge_begin or + * #svn_wc_notify_foreign_merge_begin or + * #svn_wc_notify_merge_record_info_begin, and both the + * left and right sides of the merge are from the same URL. In all + * other cases, it is @c NULL. @since New in 1.5 */ + svn_merge_range_t *merge_range; + + /** Similar to @c path, but if non-NULL the notification is about a url. + * @since New in 1.6 */ + const char *url; + + /** If non-NULL, specifies an absolute path prefix that can be subtracted + * from the start of the absolute path in @c path or @c url. Its purpose + * is to allow notification to remove a common prefix from all the paths + * displayed for an operation. @since New in 1.6 */ + const char *path_prefix; + + /** If @c action relates to properties, specifies the name of the property. + * @since New in 1.6 */ + const char *prop_name; + + /** If @c action is #svn_wc_notify_blame_revision, contains a list of + * revision properties for the specified revision + * @since New in 1.6 */ + apr_hash_t *rev_props; + + /** If @c action is #svn_wc_notify_update_update or + * #svn_wc_notify_update_add, contains the revision before the update. + * In all other cases, it is #SVN_INVALID_REVNUM. + * @since New in 1.7 */ + svn_revnum_t old_revision; + + /** These fields are used by svn patch to identify the + * hunk the notification is for. They are line-based + * offsets and lengths parsed from the unidiff hunk header. + * @since New in 1.7. */ + /* @{ */ + svn_linenum_t hunk_original_start; + svn_linenum_t hunk_original_length; + svn_linenum_t hunk_modified_start; + svn_linenum_t hunk_modified_length; + /* @} */ + + /** The line at which a hunk was matched (and applied). + * @since New in 1.7. */ + svn_linenum_t hunk_matched_line; + + /** The fuzz factor the hunk was applied with. + * @since New in 1.7 */ + svn_linenum_t hunk_fuzz; + + /* NOTE: Add new fields at the end to preserve binary compatibility. + Also, if you add fields here, you have to update svn_wc_create_notify + and svn_wc_dup_notify. */ +} svn_wc_notify_t; + +/** + * Allocate an #svn_wc_notify_t structure in @a pool, initialize and return + * it. + * + * Set the @c path field of the created struct to @a path, and @c action to + * @a action. Set all other fields to their @c _unknown, @c NULL or + * invalid value, respectively. Make only a shallow copy of the pointer + * @a path. + * + * @since New in 1.2. + */ +svn_wc_notify_t * +svn_wc_create_notify(const char *path, + svn_wc_notify_action_t action, + apr_pool_t *pool); + +/** + * Allocate an #svn_wc_notify_t structure in @a pool, initialize and return + * it. + * + * Set the @c url field of the created struct to @a url, @c path to "." and @c + * action to @a action. Set all other fields to their @c _unknown, @c NULL or + * invalid value, respectively. Make only a shallow copy of the pointer + * @a url. + * + * @since New in 1.6. + */ +svn_wc_notify_t * +svn_wc_create_notify_url(const char *url, + svn_wc_notify_action_t action, + apr_pool_t *pool); + +/** + * Return a deep copy of @a notify, allocated in @a pool. + * + * @since New in 1.2. + */ +svn_wc_notify_t * +svn_wc_dup_notify(const svn_wc_notify_t *notify, + apr_pool_t *pool); + +/** + * Notify the world that @a notify->action has happened to @a notify->path. + * + * Recommendation: callers of #svn_wc_notify_func2_t should avoid + * invoking it multiple times on the same path within a given + * operation, and implementations should not bother checking for such + * duplicate calls. For example, in an update, the caller should not + * invoke the notify func on receiving a prop change and then again + * on receiving a text change. Instead, wait until all changes have + * been received, and then invoke the notify func once (from within + * an #svn_delta_editor_t's close_file(), for example), passing + * the appropriate @a notify->content_state and @a notify->prop_state flags. + * + * @since New in 1.2. + */ +typedef void (*svn_wc_notify_func2_t)(void *baton, + const svn_wc_notify_t *notify, + apr_pool_t *pool); + +/** + * Similar to #svn_wc_notify_func2_t, but takes the information as arguments + * instead of struct fields. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef void (*svn_wc_notify_func_t)(void *baton, + const char *path, + svn_wc_notify_action_t action, + svn_node_kind_t kind, + const char *mime_type, + svn_wc_notify_state_t content_state, + svn_wc_notify_state_t prop_state, + svn_revnum_t revision); + +/** @} */ + + +/** + * Interactive conflict handling + * + * @defgroup svn_wc_conflict Conflict callback functionality + * @{ + * + * This API gives a Subversion client application the opportunity to + * define a callback that allows the user to resolve conflicts + * interactively during updates and merges. + * + * If a conflict is discovered, libsvn_wc invokes the callback with an + * #svn_wc_conflict_description_t. This structure describes the + * path in conflict, whether it's a text or property conflict, and may + * also present up to three files that can be used to resolve the + * conflict (perhaps by launching an editor or 3rd-party merging + * tool). The structure also provides a possible fourth file (@c + * merged_file) which, if not NULL, represents libsvn_wc's attempt to + * contextually merge the first three files. (Note that libsvn_wc + * will not attempt to merge a file that it believes is binary, and it + * will only attempt to merge property values it believes to be a + * series of multi-line text.) + * + * When the callback is finished interacting with the user, it + * responds by returning a #svn_wc_conflict_result_t. This + * structure indicates whether the user wants to postpone the conflict + * for later (allowing libsvn_wc to mark the path "conflicted" as + * usual), or whether the user wants libsvn_wc to use one of the four + * files as the "final" state for resolving the conflict immediately. + * + * Note that the callback is at liberty (and encouraged) to merge the + * three files itself. If it does so, it signals this to libsvn_wc by + * returning a choice of #svn_wc_conflict_choose_merged. To return + * the 'final' merged file to libsvn_wc, the callback has the option of + * either: + * + * - editing the original @c merged_file in-place + * + * or, if libsvn_wc never supplied a merged_file in the + * description structure (i.e. passed NULL for that field), + * + * - return the merged file in the #svn_wc_conflict_result_t. + * + */ + +/** The type of action being attempted on an object. + * + * @since New in 1.5. + */ +typedef enum svn_wc_conflict_action_t +{ + svn_wc_conflict_action_edit, /**< attempting to change text or props */ + svn_wc_conflict_action_add, /**< attempting to add object */ + svn_wc_conflict_action_delete, /**< attempting to delete object */ + svn_wc_conflict_action_replace /**< attempting to replace object, + @since New in 1.7 */ +} svn_wc_conflict_action_t; + + +/** The pre-existing condition which is causing a state of conflict. + * + * @since New in 1.5. + */ +typedef enum svn_wc_conflict_reason_t +{ + /** Local edits are already present */ + svn_wc_conflict_reason_edited, + /** Another object is in the way */ + svn_wc_conflict_reason_obstructed, + /** Object is already schedule-delete */ + svn_wc_conflict_reason_deleted, + /** Object is unknown or missing */ + svn_wc_conflict_reason_missing, + /** Object is unversioned */ + svn_wc_conflict_reason_unversioned, + /** Object is already added or schedule-add. @since New in 1.6. */ + svn_wc_conflict_reason_added, + /** Object is already replaced. @since New in 1.7. */ + svn_wc_conflict_reason_replaced, + /** Object is moved away. @since New in 1.8. */ + svn_wc_conflict_reason_moved_away, + /** Object is moved here. @since New in 1.8. */ + svn_wc_conflict_reason_moved_here + +} svn_wc_conflict_reason_t; + + +/** The type of conflict being described by an + * #svn_wc_conflict_description2_t (see below). + * + * @since New in 1.5. + */ +typedef enum svn_wc_conflict_kind_t +{ + /** textual conflict (on a file) */ + svn_wc_conflict_kind_text, + /** property conflict (on a file or dir) */ + svn_wc_conflict_kind_property, + /** tree conflict (on a dir) @since New in 1.6. */ + svn_wc_conflict_kind_tree +} svn_wc_conflict_kind_t; + + +/** The user operation that exposed a conflict. + * + * @since New in 1.6. + */ +typedef enum svn_wc_operation_t +{ + svn_wc_operation_none = 0, + svn_wc_operation_update, + svn_wc_operation_switch, + svn_wc_operation_merge + +} svn_wc_operation_t; + + +/** Info about one of the conflicting versions of a node. Each field may + * have its respective null/invalid/unknown value if the corresponding + * information is not relevant or not available. + * + * @todo Consider making some or all of the info mandatory, to reduce + * complexity. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type. + * + * @see svn_wc_conflict_version_create() + * @see svn_wc_conflict_version_dup() + * + * @since New in 1.6. +*/ +typedef struct svn_wc_conflict_version_t +{ + /** @name Where to find this node version in a repository */ + /**@{*/ + + /** URL of repository root */ + const char *repos_url; + + /** revision at which to look up path_in_repos */ + svn_revnum_t peg_rev; + + /** path within repos; must not start with '/' */ + /* ### should have been called repos_relpath, but we can't change this. */ + const char *path_in_repos; + /** @} */ + + /** The node kind. Can be any kind, including 'none' or 'unknown'. */ + svn_node_kind_t node_kind; + + /** UUID of the repository (or NULL if unknown.) + * @since New in 1.8. */ + const char *repos_uuid; + + /* @todo Add metadata about a local copy of the node, if and when + * we store one. */ + + /* Remember to update svn_wc_conflict_version_create() and + * svn_wc_conflict_version_dup() in case you add fields to this struct. */ +} svn_wc_conflict_version_t; + +/** + * Allocate an #svn_wc_conflict_version_t structure in @a pool, + * initialize to contain a conflict origin, and return it. + * + * Set the @c repos_url field of the created struct to @a repos_root_url, + * the @c path_in_repos field to @a repos_relpath, the @c peg_rev field to + * @a revision and the @c node_kind to @a kind. Make only shallow + * copies of the pointer arguments. + * + * @a repos_root_url, @a repos_relpath and @a revision must be valid, + * non-null values. @a repos_uuid should be a valid UUID, but can be + * NULL if unknown. @a kind can be any kind, even 'none' or 'unknown'. + * + * @since New in 1.8. + */ +svn_wc_conflict_version_t * +svn_wc_conflict_version_create2(const char *repos_root_url, + const char *repos_uuid, + const char *repos_relpath, + svn_revnum_t revision, + svn_node_kind_t kind, + apr_pool_t *result_pool); + +/** Similar to svn_wc_conflict_version_create2(), but doesn't set all + * required values. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_wc_conflict_version_t * +svn_wc_conflict_version_create(const char *repos_url, + const char *path_in_repos, + svn_revnum_t peg_rev, + svn_node_kind_t node_kind, + apr_pool_t *pool); + +/** Return a duplicate of @a version, allocated in @a pool. + * No part of the new version will be shared with @a version. + * + * @since New in 1.6. + */ +svn_wc_conflict_version_t * +svn_wc_conflict_version_dup(const svn_wc_conflict_version_t *version, + apr_pool_t *pool); + +/** A struct that describes a conflict that has occurred in the + * working copy. + * + * The conflict described by this structure is one of: + * - a conflict on the content of the file node @a local_abspath + * - a conflict on the property @a property_name of @a local_abspath + * - a tree conflict, of which @a local_abspath is the victim + * Be aware that the victim of a tree conflict can be a non-existent node. + * The three kinds of conflict are distinguished by @a kind. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type but should use + * svn_wc_conflict_description_create_text2() or + * svn_wc_conflict_description_create_prop2() or + * svn_wc_conflict_description_create_tree2() instead. + * + * @since New in 1.7. + */ +typedef struct svn_wc_conflict_description2_t +{ + /** The path that is in conflict (for a tree conflict, it is the victim) */ + const char *local_abspath; + + /** The node type of the path being operated on (for a tree conflict, + * ### which version?) */ + svn_node_kind_t node_kind; + + /** What sort of conflict are we describing? */ + svn_wc_conflict_kind_t kind; + + /** The name of the property whose conflict is being described. + * (Only if @a kind is 'property'; else undefined.) */ + const char *property_name; + + /** Whether svn thinks ('my' version of) @c path is a 'binary' file. + * (Only if @c kind is 'text', else undefined.) */ + svn_boolean_t is_binary; + + /** The svn:mime-type property of ('my' version of) @c path, if available, + * else NULL. + * (Only if @c kind is 'text', else undefined.) */ + const char *mime_type; + + /** The action being attempted on the conflicted node or property. + * (When @c kind is 'text', this action must be 'edit'.) */ + svn_wc_conflict_action_t action; + + /** The state of the target node or property, relative to its merge-left + * source, that is the reason for the conflict. + * (When @c kind is 'text', this reason must be 'edited'.) */ + svn_wc_conflict_reason_t reason; + + /** If this is text-conflict and involves the merging of two files + * descended from a common ancestor, here are the paths of up to + * four fulltext files that can be used to interactively resolve the + * conflict. + * + * @a base_abspath, @a their_abspath and @a my_abspath are absolute + * paths. + * + * ### Is @a merged_file relative to some directory, or absolute? + * + * All four files will be in repository-normal form -- LF + * line endings and contracted keywords. (If any of these files are + * not available, they default to NULL.) + * + * On the other hand, if this is a property-conflict, then these + * paths represent temporary files that contain the three different + * property-values in conflict. The fourth path (@c merged_file) + * may or may not be NULL; if set, it represents libsvn_wc's + * attempt to merge the property values together. (Remember that + * property values are technically binary values, and thus can't + * always be merged.) + */ + const char *base_abspath; /* common ancestor of the two files being merged */ + + /** their version of the file */ + /* ### BH: For properties this field contains the reference to + the property rejection (.prej) file */ + const char *their_abspath; + + /** my locally-edited version of the file */ + const char *my_abspath; + + /** merged version; may contain conflict markers */ + const char *merged_file; + + /** The operation that exposed the conflict. + * Used only for tree conflicts. + */ + svn_wc_operation_t operation; + + /** Info on the "merge-left source" or "older" version of incoming change. */ + const svn_wc_conflict_version_t *src_left_version; + + /** Info on the "merge-right source" or "their" version of incoming change. */ + const svn_wc_conflict_version_t *src_right_version; + + /* Remember to adjust svn_wc__conflict_description2_dup() + * if you add new fields to this struct. */ +} svn_wc_conflict_description2_t; + + +/** Similar to #svn_wc_conflict_description2_t, but with relative paths and + * adm_access batons. Passed to #svn_wc_conflict_resolver_func_t. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef struct svn_wc_conflict_description_t +{ + /** The path that is in conflict (for a tree conflict, it is the victim) */ + const char *path; + + /** The node type of the path being operated on (for a tree conflict, + * ### which version?) */ + svn_node_kind_t node_kind; + + /** What sort of conflict are we describing? */ + svn_wc_conflict_kind_t kind; + + /** The name of the property whose conflict is being described. + * (Only if @a kind is 'property'; else undefined.) */ + const char *property_name; + + /** Whether svn thinks ('my' version of) @c path is a 'binary' file. + * (Only if @c kind is 'text', else undefined.) */ + svn_boolean_t is_binary; + + /** The svn:mime-type property of ('my' version of) @c path, if available, + * else NULL. + * (Only if @c kind is 'text', else undefined.) */ + const char *mime_type; + + /** If not NULL, an open working copy access baton to either the + * path itself (if @c path is a directory), or to the parent + * directory (if @c path is a file.) + * For a tree conflict, this will always be an access baton + * to the parent directory of the path, even if the path is + * a directory. */ + svn_wc_adm_access_t *access; + + /** The action being attempted on the conflicted node or property. + * (When @c kind is 'text', this action must be 'edit'.) */ + svn_wc_conflict_action_t action; + + /** The state of the target node or property, relative to its merge-left + * source, that is the reason for the conflict. + * (When @c kind is 'text', this reason must be 'edited'.) */ + svn_wc_conflict_reason_t reason; + + /** If this is text-conflict and involves the merging of two files + * descended from a common ancestor, here are the paths of up to + * four fulltext files that can be used to interactively resolve the + * conflict. All four files will be in repository-normal form -- LF + * line endings and contracted keywords. (If any of these files are + * not available, they default to NULL.) + * + * On the other hand, if this is a property-conflict, then these + * paths represent temporary files that contain the three different + * property-values in conflict. The fourth path (@c merged_file) + * may or may not be NULL; if set, it represents libsvn_wc's + * attempt to merge the property values together. (Remember that + * property values are technically binary values, and thus can't + * always be merged.) + */ + const char *base_file; /* common ancestor of the two files being merged */ + + /** their version of the file */ + const char *their_file; + + /** my locally-edited version of the file */ + const char *my_file; + + /** merged version; may contain conflict markers */ + const char *merged_file; + + /** The operation that exposed the conflict. + * Used only for tree conflicts. + * + * @since New in 1.6. + */ + svn_wc_operation_t operation; + + /** Info on the "merge-left source" or "older" version of incoming change. + * @since New in 1.6. */ + svn_wc_conflict_version_t *src_left_version; + + /** Info on the "merge-right source" or "their" version of incoming change. + * @since New in 1.6. */ + svn_wc_conflict_version_t *src_right_version; + +} svn_wc_conflict_description_t; + +/** + * Allocate an #svn_wc_conflict_description_t structure in @a result_pool, + * initialize to represent a text conflict, and return it. + * + * Set the @c local_abspath field of the created struct to @a local_abspath + * (which must be an absolute path), the @c kind field to + * #svn_wc_conflict_kind_text, the @c node_kind to #svn_node_file, + * the @c action to #svn_wc_conflict_action_edit, and the @c reason to + * #svn_wc_conflict_reason_edited. + * + * @note It is the caller's responsibility to set the other required fields + * (such as the four file names and @c mime_type and @c is_binary). + * + * @since New in 1.7. + */ +svn_wc_conflict_description2_t * +svn_wc_conflict_description_create_text2(const char *local_abspath, + apr_pool_t *result_pool); + + +/** Similar to svn_wc_conflict_description_create_text2(), but returns + * a #svn_wc_conflict_description_t *. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_wc_conflict_description_t * +svn_wc_conflict_description_create_text(const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** + * Allocate an #svn_wc_conflict_description_t structure in @a result_pool, + * initialize to represent a property conflict, and return it. + * + * Set the @c local_abspath field of the created struct to @a local_abspath + * (which must be an absolute path), the @c kind field + * to #svn_wc_conflict_kind_property, the @c node_kind to @a node_kind, and + * the @c property_name to @a property_name. + * + * @note: It is the caller's responsibility to set the other required fields + * (such as the four file names and @c action and @c reason). + * + * @since New in 1.7. + */ +svn_wc_conflict_description2_t * +svn_wc_conflict_description_create_prop2(const char *local_abspath, + svn_node_kind_t node_kind, + const char *property_name, + apr_pool_t *result_pool); + +/** Similar to svn_wc_conflict_descriptor_create_prop(), but returns + * a #svn_wc_conflict_description_t *. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_wc_conflict_description_t * +svn_wc_conflict_description_create_prop(const char *path, + svn_wc_adm_access_t *adm_access, + svn_node_kind_t node_kind, + const char *property_name, + apr_pool_t *pool); + +/** + * Allocate an #svn_wc_conflict_description_t structure in @a pool, + * initialize to represent a tree conflict, and return it. + * + * Set the @c local_abspath field of the created struct to @a local_abspath + * (which must be an absolute path), the @c kind field to + * #svn_wc_conflict_kind_tree, the @c node_kind to @a node_kind, the @c + * operation to @a operation, the @c src_left_version field to + * @a src_left_version, and the @c src_right_version field to + * @a src_right_version. + * + * @note: It is the caller's responsibility to set the other required fields + * (such as the four file names and @c action and @c reason). + * + * @since New in 1.7. + */ +svn_wc_conflict_description2_t * +svn_wc_conflict_description_create_tree2( + const char *local_abspath, + svn_node_kind_t node_kind, + svn_wc_operation_t operation, + const svn_wc_conflict_version_t *src_left_version, + const svn_wc_conflict_version_t *src_right_version, + apr_pool_t *result_pool); + + +/** Similar to svn_wc_conflict_description_create_tree(), but returns + * a #svn_wc_conflict_description_t *. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_wc_conflict_description_t * +svn_wc_conflict_description_create_tree( + const char *path, + svn_wc_adm_access_t *adm_access, + svn_node_kind_t node_kind, + svn_wc_operation_t operation, + /* non-const */ svn_wc_conflict_version_t *src_left_version, + /* non-const */ svn_wc_conflict_version_t *src_right_version, + apr_pool_t *pool); + + +/** Return a duplicate of @a conflict, allocated in @a result_pool. + * A deep copy of all members will be made. + * + * @since New in 1.7. + */ +svn_wc_conflict_description2_t * +svn_wc__conflict_description2_dup( + const svn_wc_conflict_description2_t *conflict, + apr_pool_t *result_pool); + + +/** The way in which the conflict callback chooses a course of action. + * + * @since New in 1.5. + */ +typedef enum svn_wc_conflict_choice_t +{ + /** Don't resolve the conflict now. Let libsvn_wc mark the path + 'conflicted', so user can run 'svn resolved' later. */ + svn_wc_conflict_choose_postpone, + + /** If there were files to choose from, select one as a way of + resolving the conflict here and now. libsvn_wc will then do the + work of "installing" the chosen file. + */ + svn_wc_conflict_choose_base, /**< original version */ + svn_wc_conflict_choose_theirs_full, /**< incoming version */ + svn_wc_conflict_choose_mine_full, /**< own version */ + svn_wc_conflict_choose_theirs_conflict, /**< incoming (for conflicted hunks) */ + svn_wc_conflict_choose_mine_conflict, /**< own (for conflicted hunks) */ + svn_wc_conflict_choose_merged, /**< merged version */ + + /* @since New in 1.8. */ + svn_wc_conflict_choose_unspecified /**< undecided */ + +} svn_wc_conflict_choice_t; + + +/** The final result returned by #svn_wc_conflict_resolver_func_t. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type. Instead, + * construct this structure using svn_wc_create_conflict_result() + * below. + * + * @since New in 1.5. + */ +typedef struct svn_wc_conflict_result_t +{ + /** A choice to either delay the conflict resolution or select a + particular file to resolve the conflict. */ + svn_wc_conflict_choice_t choice; + + /** If not NULL, this is a path to a file which contains the client's + (or more likely, the user's) merging of the three values in + conflict. libsvn_wc accepts this file if (and only if) @c choice + is set to #svn_wc_conflict_choose_merged.*/ + const char *merged_file; + + /** If true, save a backup copy of merged_file (or the original + merged_file from the conflict description, if merged_file is + NULL) in the user's working copy. */ + svn_boolean_t save_merged; + +} svn_wc_conflict_result_t; + + +/** + * Allocate an #svn_wc_conflict_result_t structure in @a pool, + * initialize and return it. + * + * Set the @c choice field of the structure to @a choice, and @c + * merged_file to @a merged_file. Set all other fields to their @c + * _unknown, @c NULL or invalid value, respectively. Make only a shallow + * copy of the pointer argument @a merged_file. + * + * @since New in 1.5. + */ +svn_wc_conflict_result_t * +svn_wc_create_conflict_result(svn_wc_conflict_choice_t choice, + const char *merged_file, + apr_pool_t *pool); + + +/** A callback used in merge, update and switch for resolving conflicts + * during the application of a tree delta to a working copy. + * + * @a description describes the exact nature of the conflict, and + * provides information to help resolve it. @a baton is a closure + * object; it should be provided by the implementation, and passed by + * the caller. When finished, the callback signals its resolution by + * returning a structure in @a *result, which should be allocated in + * @a result_pool. (See #svn_wc_conflict_result_t.) @a scratch_pool + * should be used for any temporary allocations. + * + * The values #svn_wc_conflict_choose_mine_conflict and + * #svn_wc_conflict_choose_theirs_conflict are not legal for conflicts + * in binary files or binary properties. + * + * Implementations of this callback are free to present the conflict + * using any user interface. This may include simple contextual + * conflicts in a file's text or properties, or more complex + * 'tree'-based conflicts related to obstructed additions, deletions, + * and edits. The callback implementation is free to decide which + * sorts of conflicts to handle; it's also free to decide which types + * of conflicts are automatically resolvable and which require user + * interaction. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_wc_conflict_resolver_func2_t)( + svn_wc_conflict_result_t **result, + const svn_wc_conflict_description2_t *description, + void *baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Similar to #svn_wc_conflict_resolver_func2_t, but using + * #svn_wc_conflict_description_t instead of + * #svn_wc_conflict_description2_t + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef svn_error_t *(*svn_wc_conflict_resolver_func_t)( + svn_wc_conflict_result_t **result, + const svn_wc_conflict_description_t *description, + void *baton, + apr_pool_t *pool); + +/** @} */ + + + +/** + * A callback vtable invoked by our diff-editors, as they receive diffs + * from the server. 'svn diff' and 'svn merge' implement their own versions + * of this vtable. + * + * Common parameters: + * + * If @a state is non-NULL, set @a *state to the state of the item + * after the operation has been performed. (In practice, this is only + * useful with merge, not diff; diff callbacks will probably set + * @a *state to #svn_wc_notify_state_unknown, since they do not change + * the state and therefore do not bother to know the state after the + * operation.) By default, @a state refers to the item's content + * state. Functions concerned with property state have separate + * @a contentstate and @a propstate arguments. + * + * If @a tree_conflicted is non-NULL, set @a *tree_conflicted to true if + * this operation caused a tree conflict, else to false. (Like with @a + * state, this is only useful with merge, not diff; diff callbacks + * should set this to false.) + * + * @since New in 1.7. + */ +typedef struct svn_wc_diff_callbacks4_t +{ + /** + * This function is called before @a file_changed to allow callbacks to + * skip the most expensive processing of retrieving the file data. + * + */ + svn_error_t *(*file_opened)(svn_boolean_t *tree_conflicted, + svn_boolean_t *skip, + const char *path, + svn_revnum_t rev, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A file @a path has changed. If @a tmpfile2 is non-NULL, the + * contents have changed and those changes can be seen by comparing + * @a tmpfile1 and @a tmpfile2, which represent @a rev1 and @a rev2 of + * the file, respectively. + * + * If known, the @c svn:mime-type value of each file is passed into + * @a mimetype1 and @a mimetype2; either or both of the values can + * be NULL. The implementor can use this information to decide if + * (or how) to generate differences. + * + * @a propchanges is an array of (#svn_prop_t) structures. If it contains + * any elements, the original list of properties is provided in + * @a originalprops, which is a hash of #svn_string_t values, keyed on the + * property name. + * + */ + svn_error_t *(*file_changed)(svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + const apr_array_header_t *propchanges, + apr_hash_t *originalprops, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A file @a path was added. The contents can be seen by comparing + * @a tmpfile1 and @a tmpfile2, which represent @a rev1 and @a rev2 + * of the file, respectively. (If either file is empty, the rev + * will be 0.) + * + * If known, the @c svn:mime-type value of each file is passed into + * @a mimetype1 and @a mimetype2; either or both of the values can + * be NULL. The implementor can use this information to decide if + * (or how) to generate differences. + * + * @a propchanges is an array of (#svn_prop_t) structures. If it contains + * any elements, the original list of properties is provided in + * @a originalprops, which is a hash of #svn_string_t values, keyed on the + * property name. + * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a + * copy), and the origin of the copy may be recorded as + * @a copyfrom_path under @a copyfrom_revision. + */ + svn_error_t *(*file_added)(svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + const char *copyfrom_path, + svn_revnum_t copyfrom_revision, + const apr_array_header_t *propchanges, + apr_hash_t *originalprops, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A file @a path was deleted. The [loss of] contents can be seen by + * comparing @a tmpfile1 and @a tmpfile2. @a originalprops provides + * the properties of the file. + * ### Some existing callers include WC "entry props" in @a originalprops. + * + * If known, the @c svn:mime-type value of each file is passed into + * @a mimetype1 and @a mimetype2; either or both of the values can + * be NULL. The implementor can use this information to decide if + * (or how) to generate differences. + */ + svn_error_t *(*file_deleted)(svn_wc_notify_state_t *state, + svn_boolean_t *tree_conflicted, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + const char *mimetype1, + const char *mimetype2, + apr_hash_t *originalprops, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A directory @a path was deleted. + */ + svn_error_t *(*dir_deleted)(svn_wc_notify_state_t *state, + svn_boolean_t *tree_conflicted, + const char *path, + void *diff_baton, + apr_pool_t *scratch_pool); + /** + * A directory @a path has been opened. @a rev is the revision that the + * directory came from. + * + * This function is called for any existing directory @a path before any + * of the callbacks are called for a child of @a path. + * + * If the callback returns @c TRUE in @a *skip_children, children + * of this directory will be skipped. + */ + svn_error_t *(*dir_opened)(svn_boolean_t *tree_conflicted, + svn_boolean_t *skip, + svn_boolean_t *skip_children, + const char *path, + svn_revnum_t rev, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A directory @a path was added. @a rev is the revision that the + * directory came from. + * + * This function is called for any new directory @a path before any + * of the callbacks are called for a child of @a path. + * + * If @a copyfrom_path is non-@c NULL, this add has history (i.e., is a + * copy), and the origin of the copy may be recorded as + * @a copyfrom_path under @a copyfrom_revision. + */ + svn_error_t *(*dir_added)(svn_wc_notify_state_t *state, + svn_boolean_t *tree_conflicted, + svn_boolean_t *skip, + svn_boolean_t *skip_children, + const char *path, + svn_revnum_t rev, + const char *copyfrom_path, + svn_revnum_t copyfrom_revision, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A list of property changes (@a propchanges) was applied to the + * directory @a path. + * + * The array is a list of (#svn_prop_t) structures. + * + * @a dir_was_added is set to #TRUE if the directory was added, and + * to #FALSE if the directory pre-existed. + */ + svn_error_t *(*dir_props_changed)(svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + svn_boolean_t dir_was_added, + const apr_array_header_t *propchanges, + apr_hash_t *original_props, + void *diff_baton, + apr_pool_t *scratch_pool); + + /** + * A directory @a path which has been opened with @a dir_opened or @a + * dir_added has been closed. + * + * @a dir_was_added is set to #TRUE if the directory was added, and + * to #FALSE if the directory pre-existed. + */ + svn_error_t *(*dir_closed)(svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + svn_boolean_t dir_was_added, + void *diff_baton, + apr_pool_t *scratch_pool); + +} svn_wc_diff_callbacks4_t; + + +/** + * Similar to #svn_wc_diff_callbacks4_t, but without @a copyfrom_path and + * @a copyfrom_revision arguments to @c file_added and @c dir_added functions. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef struct svn_wc_diff_callbacks3_t +{ + /** The same as #svn_wc_diff_callbacks4_t.file_changed. */ + svn_error_t *(*file_changed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + const apr_array_header_t *propchanges, + apr_hash_t *originalprops, + void *diff_baton); + + /** Similar to #svn_wc_diff_callbacks4_t.file_added but without + * @a copyfrom_path and @a copyfrom_revision arguments. */ + svn_error_t *(*file_added)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + const apr_array_header_t *propchanges, + apr_hash_t *originalprops, + void *diff_baton); + + /** The same as #svn_wc_diff_callbacks4_t.file_deleted. */ + svn_error_t *(*file_deleted)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + svn_boolean_t *tree_conflicted, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + const char *mimetype1, + const char *mimetype2, + apr_hash_t *originalprops, + void *diff_baton); + + /** Similar to #svn_wc_diff_callbacks4_t.dir_added but without + * @a copyfrom_path and @a copyfrom_revision arguments. */ + svn_error_t *(*dir_added)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + svn_boolean_t *tree_conflicted, + const char *path, + svn_revnum_t rev, + void *diff_baton); + + /** The same as #svn_wc_diff_callbacks4_t.dir_deleted. */ + svn_error_t *(*dir_deleted)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + svn_boolean_t *tree_conflicted, + const char *path, + void *diff_baton); + + /** The same as #svn_wc_diff_callbacks4_t.dir_props_changed. */ + svn_error_t *(*dir_props_changed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + const apr_array_header_t *propchanges, + apr_hash_t *original_props, + void *diff_baton); + + /** The same as #svn_wc_diff_callbacks4_t.dir_opened. */ + svn_error_t *(*dir_opened)(svn_wc_adm_access_t *adm_access, + svn_boolean_t *tree_conflicted, + const char *path, + svn_revnum_t rev, + void *diff_baton); + + /** The same as #svn_wc_diff_callbacks4_t.dir_closed. */ + svn_error_t *(*dir_closed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + svn_boolean_t *tree_conflicted, + const char *path, + void *diff_baton); + +} svn_wc_diff_callbacks3_t; + +/** + * Similar to #svn_wc_diff_callbacks3_t, but without the @c dir_opened + * and @c dir_closed functions, and without the @a tree_conflicted argument + * to the functions. + * + * @deprecated Provided for backward compatibility with the 1.2 API. + */ +typedef struct svn_wc_diff_callbacks2_t +{ + /** The same as @c file_changed in #svn_wc_diff_callbacks3_t. */ + svn_error_t *(*file_changed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + const apr_array_header_t *propchanges, + apr_hash_t *originalprops, + void *diff_baton); + + /** The same as @c file_added in #svn_wc_diff_callbacks3_t. */ + svn_error_t *(*file_added)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *contentstate, + svn_wc_notify_state_t *propstate, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + const apr_array_header_t *propchanges, + apr_hash_t *originalprops, + void *diff_baton); + + /** The same as @c file_deleted in #svn_wc_diff_callbacks3_t. */ + svn_error_t *(*file_deleted)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + const char *mimetype1, + const char *mimetype2, + apr_hash_t *originalprops, + void *diff_baton); + + /** The same as @c dir_added in #svn_wc_diff_callbacks3_t. */ + svn_error_t *(*dir_added)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + svn_revnum_t rev, + void *diff_baton); + + /** The same as @c dir_deleted in #svn_wc_diff_callbacks3_t. */ + svn_error_t *(*dir_deleted)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + void *diff_baton); + + /** The same as @c dir_props_changed in #svn_wc_diff_callbacks3_t. */ + svn_error_t *(*dir_props_changed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + const apr_array_header_t *propchanges, + apr_hash_t *original_props, + void *diff_baton); + +} svn_wc_diff_callbacks2_t; + +/** + * Similar to #svn_wc_diff_callbacks2_t, but with file additions/content + * changes and property changes split into different functions. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef struct svn_wc_diff_callbacks_t +{ + /** Similar to @c file_changed in #svn_wc_diff_callbacks2_t, but without + * property change information. @a tmpfile2 is never NULL. @a state applies + * to the file contents. */ + svn_error_t *(*file_changed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + void *diff_baton); + + /** Similar to @c file_added in #svn_wc_diff_callbacks2_t, but without + * property change information. @a *state applies to the file contents. */ + svn_error_t *(*file_added)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + svn_revnum_t rev1, + svn_revnum_t rev2, + const char *mimetype1, + const char *mimetype2, + void *diff_baton); + + /** Similar to @c file_deleted in #svn_wc_diff_callbacks2_t, but without + * the properties. */ + svn_error_t *(*file_deleted)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + const char *tmpfile1, + const char *tmpfile2, + const char *mimetype1, + const char *mimetype2, + void *diff_baton); + + /** The same as @c dir_added in #svn_wc_diff_callbacks2_t. */ + svn_error_t *(*dir_added)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + svn_revnum_t rev, + void *diff_baton); + + /** The same as @c dir_deleted in #svn_wc_diff_callbacks2_t. */ + svn_error_t *(*dir_deleted)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + void *diff_baton); + + /** Similar to @c dir_props_changed in #svn_wc_diff_callbacks2_t, but this + * function is called for files as well as directories. */ + svn_error_t *(*props_changed)(svn_wc_adm_access_t *adm_access, + svn_wc_notify_state_t *state, + const char *path, + const apr_array_header_t *propchanges, + apr_hash_t *original_props, + void *diff_baton); + +} svn_wc_diff_callbacks_t; + + +/* Asking questions about a working copy. */ + +/** Set @a *wc_format to @a local_abspath's working copy format version + * number if @a local_abspath is a valid working copy directory, else set it + * to 0. + * + * Return error @c APR_ENOENT if @a local_abspath does not exist at all. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_check_wc2(int *wc_format, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_check_wc2(), but with a relative path and no supplied + * working copy context. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_check_wc(const char *path, + int *wc_format, + apr_pool_t *pool); + + +/** Set @a *has_binary_prop to @c TRUE iff @a path has been marked + * with a property indicating that it is non-text (in other words, binary). + * @a adm_access is an access baton set that contains @a path. + * + * @deprecated Provided for backward compatibility with the 1.6 API. As a + * replacement for this functionality, @see svn_mime_type_is_binary and + * #SVN_PROP_MIME_TYPE. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_has_binary_prop(svn_boolean_t *has_binary_prop, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + +/* Detecting modification. */ + +/** Set @a *modified_p to non-zero if @a local_abspath's text is modified + * with regard to the base revision, else set @a *modified_p to zero. + * @a local_abspath is the absolute path to the file. + * + * This function uses some heuristics to avoid byte-by-byte comparisons + * against the base text (eg. file size and its modification time). + * + * If @a local_abspath does not exist, consider it unmodified. If it exists + * but is not under revision control (not even scheduled for + * addition), return the error #SVN_ERR_ENTRY_NOT_FOUND. + * + * @a unused is ignored. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_text_modified_p2(svn_boolean_t *modified_p, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t unused, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_text_modified_p2(), but with a relative path and + * adm_access baton? + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_text_modified_p(svn_boolean_t *modified_p, + const char *filename, + svn_boolean_t force_comparison, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** Set @a *modified_p to non-zero if @a path's properties are modified + * with regard to the base revision, else set @a modified_p to zero. + * @a adm_access must be an access baton for @a path. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_props_modified_p2(svn_boolean_t *modified_p, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_props_modified_p2(), but with a relative path and + * adm_access baton. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_props_modified_p(svn_boolean_t *modified_p, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + +/** +* @defgroup svn_wc_entries Entries and status (deprecated) + * @{ + */ + +/** The schedule states an entry can be in. + * @deprecated Provided for backward compatibility with the 1.6 API. */ +typedef enum svn_wc_schedule_t +{ + /** Nothing special here */ + svn_wc_schedule_normal, + + /** Slated for addition */ + svn_wc_schedule_add, + + /** Slated for deletion */ + svn_wc_schedule_delete, + + /** Slated for replacement (delete + add) */ + svn_wc_schedule_replace + +} svn_wc_schedule_t; + + +/** + * Values for the working_size field in svn_wc_entry_t + * when it isn't set to the actual size value of the unchanged + * working file. + * + * The value of the working size is unknown (hasn't been + * calculated and stored in the past for whatever reason). + * + * @since New in 1.5 + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +#define SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN (-1) + +/** A working copy entry -- that is, revision control information about + * one versioned entity. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +/* SVN_DEPRECATED */ +typedef struct svn_wc_entry_t +{ + /* IMPORTANT: If you extend this structure, add new fields to the end. */ + + /* General Attributes */ + + /** entry's name */ + const char *name; + + /** base revision */ + svn_revnum_t revision; + + /** url in repository */ + const char *url; + + /** canonical repository URL or NULL if not known */ + const char *repos; + + /** repository uuid */ + const char *uuid; + + /** node kind (file, dir, ...) */ + svn_node_kind_t kind; + + /* State information */ + + /** scheduling (add, delete, replace ...) */ + svn_wc_schedule_t schedule; + + /** in a copied state (possibly because the entry is a child of a + * path that is #svn_wc_schedule_add or #svn_wc_schedule_replace, + * when the entry itself is #svn_wc_schedule_normal). + * COPIED is true for nodes under a directory that was copied, but + * COPYFROM_URL is null there. They are both set for the root + * destination of the copy. + */ + svn_boolean_t copied; + + /** The directory containing this entry had a versioned child of this + * name, but this entry represents a different revision or a switched + * path at which no item exists in the repository. This typically + * arises from committing or updating to a deletion of this entry + * without committing or updating the parent directory. + * + * The schedule can be 'normal' or 'add'. */ + svn_boolean_t deleted; + + /** absent -- we know an entry of this name exists, but that's all + (usually this happens because of authz restrictions) */ + svn_boolean_t absent; + + /** for THIS_DIR entry, implies whole entries file is incomplete */ + svn_boolean_t incomplete; + + /** copyfrom location */ + const char *copyfrom_url; + + /** copyfrom revision */ + svn_revnum_t copyfrom_rev; + + /** old version of conflicted file. A file basename, relative to the + * user's directory that the THIS_DIR entry refers to. */ + const char *conflict_old; + + /** new version of conflicted file. A file basename, relative to the + * user's directory that the THIS_DIR entry refers to. */ + const char *conflict_new; + + /** working version of conflicted file. A file basename, relative to the + * user's directory that the THIS_DIR entry refers to. */ + const char *conflict_wrk; + + /** property reject file. A file basename, relative to the user's + * directory that the THIS_DIR entry refers to. */ + const char *prejfile; + + /** last up-to-date time for text contents (0 means no information available) + */ + apr_time_t text_time; + + /** last up-to-date time for properties (0 means no information available) + * + * @deprecated This value will always be 0 in version 1.4 and later. + */ + apr_time_t prop_time; + + /** Hex MD5 checksum for the untranslated text base file, + * can be @c NULL for backwards compatibility. + */ + const char *checksum; + + /* "Entry props" */ + + /** last revision this was changed */ + svn_revnum_t cmt_rev; + + /** last date this was changed */ + apr_time_t cmt_date; + + /** last commit author of this item */ + const char *cmt_author; + + /** lock token or NULL if path not locked in this WC + * @since New in 1.2. + */ + const char *lock_token; + + /** lock owner, or NULL if not locked in this WC + * @since New in 1.2. + */ + const char *lock_owner; + + /** lock comment or NULL if not locked in this WC or no comment + * @since New in 1.2. + */ + const char *lock_comment; + + /** Lock creation date or 0 if not locked in this WC + * @since New in 1.2. + */ + apr_time_t lock_creation_date; + + /** Whether this entry has any working properties. + * False if this information is not stored in the entry. + * + * @since New in 1.4. */ + svn_boolean_t has_props; + + /** Whether this entry has property modifications. + * + * @note For working copies in older formats, this flag is not valid. + * + * @see svn_wc_props_modified_p(). + * + * @since New in 1.4. */ + svn_boolean_t has_prop_mods; + + /** A space-separated list of all properties whose presence/absence is cached + * in this entry. + * + * @see @c present_props. + * + * @since New in 1.4. + * @deprecated This value will always be "" in version 1.7 and later. */ + const char *cachable_props; + + /** Cached property existence for this entry. + * This is a space-separated list of property names. If a name exists in + * @c cachable_props but not in this list, this entry does not have that + * property. If a name exists in both lists, the property is present on this + * entry. + * + * @since New in 1.4. + * @deprecated This value will always be "" in version 1.7 and later. */ + const char *present_props; + + /** which changelist this item is part of, or NULL if not part of any. + * @since New in 1.5. + */ + const char *changelist; + + /** Size of the file after being translated into local + * representation, or #SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN if + * unknown. + * + * @since New in 1.5. + */ + apr_off_t working_size; + + /** Whether a local copy of this entry should be kept in the working copy + * after a deletion has been committed, Only valid for the this-dir entry + * when it is scheduled for deletion. + * + * @since New in 1.5. */ + svn_boolean_t keep_local; + + /** The depth of this entry. + * + * ### It's a bit annoying that we only use this on this_dir + * ### entries, yet it will exist (with value svn_depth_infinity) on + * ### all entries. Maybe some future extensibility would make this + * ### field meaningful on entries besides this_dir. + * + * @since New in 1.5. */ + svn_depth_t depth; + + /** Serialized data for all of the tree conflicts detected in this_dir. + * + * @since New in 1.6. */ + const char *tree_conflict_data; + + /** The entry is a intra-repository file external and this is the + * repository root relative path to the file specified in the + * externals definition, otherwise NULL if the entry is not a file + * external. + * + * @since New in 1.6. */ + const char *file_external_path; + + /** The entry is a intra-repository file external and this is the + * peg revision number specified in the externals definition. This + * field is only valid when the file_external_path field is + * non-NULL. The only permissible values are + * svn_opt_revision_unspecified if the entry is not an external, + * svn_opt_revision_head if the external revision is unspecified or + * specified with -r HEAD or svn_opt_revision_number for a specific + * revision number. + * + * @since New in 1.6. */ + svn_opt_revision_t file_external_peg_rev; + + /** The entry is an intra-repository file external and this is the + * operative revision number specified in the externals definition. + * This field is only valid when the file_external_path field is + * non-NULL. The only permissible values are + * svn_opt_revision_unspecified if the entry is not an external, + * svn_opt_revision_head if the external revision is unspecified or + * specified with -r HEAD or svn_opt_revision_number for a specific + * revision number. + * + * @since New in 1.6. */ + svn_opt_revision_t file_external_rev; + + /* IMPORTANT: If you extend this structure, check the following functions in + * subversion/libsvn_wc/entries.c, to see if you need to extend them as well. + * + * svn_wc__atts_to_entry() + * svn_wc_entry_dup() + * alloc_entry() + * read_entry() + * write_entry() + * fold_entry() + */ +} svn_wc_entry_t; + + +/** How an entries file's owner dir is named in the entries file. + * @deprecated Provided for backward compatibility with the 1.6 API. */ +#define SVN_WC_ENTRY_THIS_DIR "" + + +/** Set @a *entry to an entry for @a path, allocated in the access baton pool. + * If @a show_hidden is TRUE, return the entry even if it's in 'excluded', + * 'deleted' or 'absent' state. Excluded entries are those with their depth + * set to #svn_depth_exclude. If @a path is not under revision control, or + * if entry is hidden, not scheduled for re-addition, and @a show_hidden is @c + * FALSE, then set @a *entry to @c NULL. + * + * @a *entry should not be modified, since doing so modifies the entries + * cache in @a adm_access without changing the entries file on disk. + * + * If @a path is not a directory then @a adm_access must be an access baton + * for the parent directory of @a path. To avoid needing to know whether + * @a path is a directory or not, if @a path is a directory @a adm_access + * can still be an access baton for the parent of @a path so long as the + * access baton for @a path itself is in the same access baton set. + * + * @a path can be relative or absolute but must share the same base used + * to open @a adm_access. + * + * Note that it is possible for @a path to be absent from disk but still + * under revision control; and conversely, it is possible for @a path to + * be present, but not under revision control. + * + * Use @a pool only for local processing. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_entry(const svn_wc_entry_t **entry, + const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t show_hidden, + apr_pool_t *pool); + + +/** Parse the `entries' file for @a adm_access and return a hash @a entries, + * whose keys are (<tt>const char *</tt>) entry names and values are + * (<tt>svn_wc_entry_t *</tt>). The hash @a entries, and its keys and + * values, are allocated from the pool used to open the @a adm_access + * baton (that's how the entries caching works). @a pool is used for + * transient allocations. + * + * Entries that are in a 'excluded', 'deleted' or 'absent' state (and not + * scheduled for re-addition) are not returned in the hash, unless + * @a show_hidden is TRUE. Excluded entries are those with their depth set to + * #svn_depth_exclude. + * + * @par Important: + * The @a entries hash is the entries cache in @a adm_access + * and so usually the hash itself, the keys and the values should be treated + * as read-only. If any of these are modified then it is the caller's + * responsibility to ensure that the entries file on disk is updated. Treat + * the hash values as type (<tt>const svn_wc_entry_t *</tt>) if you wish to + * avoid accidental modification. Modifying the schedule member is a + * particularly bad idea, as the entries writing process relies on having + * access to the original schedule. Use a duplicate entry to modify the + * schedule. + * + * @par Important: + * Only the entry structures representing files and + * #SVN_WC_ENTRY_THIS_DIR contain complete information. The entry + * structures representing subdirs have only the `kind' and `state' + * fields filled in. If you want info on a subdir, you must use this + * routine to open its @a path and read the #SVN_WC_ENTRY_THIS_DIR + * structure, or call svn_wc_entry() on its @a path. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_entries_read(apr_hash_t **entries, + svn_wc_adm_access_t *adm_access, + svn_boolean_t show_hidden, + apr_pool_t *pool); + + +/** Return a duplicate of @a entry, allocated in @a pool. No part of the new + * entry will be shared with @a entry. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_wc_entry_t * +svn_wc_entry_dup(const svn_wc_entry_t *entry, + apr_pool_t *pool); + +/** @} */ + + +/** + * This struct contains information about a working copy node. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, users shouldn't allocate structures of this + * type, to preserve binary compatibility. + * + * @since New in 1.7. + */ +typedef struct svn_wc_info_t +{ + /** The schedule of this item + * ### Do we still need schedule? */ + svn_wc_schedule_t schedule; + + /** If copied, the URL from which the copy was made, else @c NULL. */ + const char *copyfrom_url; + + /** If copied, the revision from which the copy was made, + * else #SVN_INVALID_REVNUM. */ + svn_revnum_t copyfrom_rev; + + /** The checksum of the node, if it is a file. */ + const svn_checksum_t *checksum; + + /** A changelist the item is in, @c NULL if this node is not in a + * changelist. */ + const char *changelist; + + /** The depth of the item, see #svn_depth_t */ + svn_depth_t depth; + + /** + * The size of the file after being translated into its local + * representation, or #SVN_INVALID_FILESIZE if unknown. + * Not applicable for directories. + */ + svn_filesize_t recorded_size; + + /** + * The time at which the file had the recorded size recorded_size and was + * considered unmodified. */ + apr_time_t recorded_time; + + /** Array of const svn_wc_conflict_description2_t * which contains info + * on any conflict of which this node is a victim. Otherwise NULL. */ + const apr_array_header_t *conflicts; + + /** The local absolute path of the working copy root. */ + const char *wcroot_abspath; + + /** The path the node was moved from, if it was moved here. Else NULL. + * @since New in 1.8. */ + const char *moved_from_abspath; + + /** The path the node was moved to, if it was moved away. Else NULL. + * @since New in 1.8. */ + const char *moved_to_abspath; +} svn_wc_info_t; + +/** + * Return a duplicate of @a info, allocated in @a pool. No part of the new + * structure will be shared with @a info. + * + * @since New in 1.7. + */ +svn_wc_info_t * +svn_wc_info_dup(const svn_wc_info_t *info, + apr_pool_t *pool); + + +/** Given @a local_abspath in a dir under version control, decide if it is + * in a state of conflict; return the answers in @a *text_conflicted_p, @a + * *prop_conflicted_p, and @a *tree_conflicted_p. If one or two of the + * answers are uninteresting, simply pass @c NULL pointers for those. + * + * If @a local_abspath is unversioned or does not exist, return + * #SVN_ERR_WC_PATH_NOT_FOUND. + * + * If the @a local_abspath has corresponding text conflict files (with suffix + * .mine, .theirs, etc.) that cannot be found, assume that the text conflict + * has been resolved by the user and return @c FALSE in @a + * *text_conflicted_p. + * + * Similarly, if a property conflicts file (.prej suffix) is said to exist, + * but it cannot be found, assume that the property conflicts have been + * resolved by the user and return @c FALSE in @a *prop_conflicted_p. + * + * @a *tree_conflicted_p can't be auto-resolved in this fashion. An + * explicit `resolved' is needed. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_conflicted_p3(svn_boolean_t *text_conflicted_p, + svn_boolean_t *prop_conflicted_p, + svn_boolean_t *tree_conflicted_p, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_conflicted_p3(), but with a path/adm_access parameter + * pair in place of a wc_ctx/local_abspath pair. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_conflicted_p2(svn_boolean_t *text_conflicted_p, + svn_boolean_t *prop_conflicted_p, + svn_boolean_t *tree_conflicted_p, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** Given a @a dir_path under version control, decide if one of its entries + * (@a entry) is in a state of conflict; return the answers in @a + * text_conflicted_p and @a prop_conflicted_p. These pointers must not be + * null. + * + * If the @a entry mentions that text conflict files (with suffix .mine, + * .theirs, etc.) exist, but they cannot be found, assume the text conflict + * has been resolved by the user and return FALSE in @a *text_conflicted_p. + * + * Similarly, if the @a entry mentions that a property conflicts file (.prej + * suffix) exists, but it cannot be found, assume the property conflicts + * have been resolved by the user and return FALSE in @a *prop_conflicted_p. + * + * The @a entry is not updated. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_conflicted_p(svn_boolean_t *text_conflicted_p, + svn_boolean_t *prop_conflicted_p, + const char *dir_path, + const svn_wc_entry_t *entry, + apr_pool_t *pool); + + +/** Set @a *url and @a *rev to the ancestor URL and revision for @a path, + * allocating in @a pool. @a adm_access must be an access baton for @a path. + * + * If @a url or @a rev is NULL, then ignore it (just don't return the + * corresponding information). + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_ancestry(char **url, + svn_revnum_t *rev, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + +/** A callback vtable invoked by the generic entry-walker function. + * @since New in 1.5. + */ +typedef struct svn_wc_entry_callbacks2_t +{ + /** An @a entry was found at @a path. */ + svn_error_t *(*found_entry)(const char *path, + const svn_wc_entry_t *entry, + void *walk_baton, + apr_pool_t *pool); + + /** Handle the error @a err encountered while processing @a path. + * Wrap or squelch @a err as desired, and return an #svn_error_t + * *, or #SVN_NO_ERROR. + */ + svn_error_t *(*handle_error)(const char *path, + svn_error_t *err, + void *walk_baton, + apr_pool_t *pool); + +} svn_wc_entry_callbacks2_t; + +/** @deprecated Provided for backward compatibility with the 1.4 API. */ +typedef struct svn_wc_entry_callbacks_t +{ + /** An @a entry was found at @a path. */ + svn_error_t *(*found_entry)(const char *path, + const svn_wc_entry_t *entry, + void *walk_baton, + apr_pool_t *pool); + +} svn_wc_entry_callbacks_t; + +/** + * A generic entry-walker. + * + * Do a potentially recursive depth-first entry-walk beginning on + * @a path, which can be a file or dir. Call callbacks in + * @a walk_callbacks, passing @a walk_baton to each. Use @a pool for + * looping, recursion, and to allocate all entries returned. + * @a adm_access must be an access baton for @a path. The pool + * passed to @a walk_callbacks is a temporary subpool of @a pool. + * + * If @a depth is #svn_depth_empty, invoke the callbacks on @a path + * and return without recursing further. If #svn_depth_files, do + * the same and invoke the callbacks on file children (if any) of + * @a path, then return. If #svn_depth_immediates, do the preceding + * but also invoke callbacks on immediate subdirectories, then return. + * If #svn_depth_infinity, recurse fully starting from @a path. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client has canceled the operation. + * + * Like our other entries interfaces, entries that are in a 'excluded', + * 'deleted' or 'absent' state (and not scheduled for re-addition) are not + * discovered, unless @a show_hidden is TRUE. Excluded entries are those with + * their depth set to #svn_depth_exclude. + * + * When a new directory is entered, #SVN_WC_ENTRY_THIS_DIR will always + * be returned first. + * + * @note Callers should be aware that each directory will be + * returned *twice*: first as an entry within its parent, and + * subsequently as the '.' entry within itself. The two calls can be + * distinguished by looking for #SVN_WC_ENTRY_THIS_DIR in the 'name' + * field of the entry. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_walk_entries3(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_wc_entry_callbacks2_t *walk_callbacks, + void *walk_baton, + svn_depth_t depth, + svn_boolean_t show_hidden, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_walk_entries3(), but without cancellation support + * or error handling from @a walk_callbacks, and with @a depth always + * set to #svn_depth_infinity. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_walk_entries2(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_wc_entry_callbacks_t *walk_callbacks, + void *walk_baton, + svn_boolean_t show_hidden, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_walk_entries2(), but without cancellation support. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_walk_entries(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_wc_entry_callbacks_t *walk_callbacks, + void *walk_baton, + svn_boolean_t show_hidden, + apr_pool_t *pool); + + +/** Mark missing @a path as 'deleted' in its @a parent's list of + * entries. @a path should be a directory that is both deleted (via + * svn_wc_delete4) and removed (via a system call). This function + * should only be called during post-commit processing following a + * successful commit editor drive. + * + * Return #SVN_ERR_WC_PATH_FOUND if @a path isn't actually missing. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_mark_missing_deleted(const char *path, + svn_wc_adm_access_t *parent, + apr_pool_t *pool); + + +/** Ensure that an administrative area exists for @a local_abspath, so + * that @a local_abspath is a working copy subdir based on @a url at @a + * revision, with depth @a depth, and with repository UUID @a repos_uuid + * and repository root URL @a repos_root_url. + * + * @a depth must be a definite depth, it cannot be #svn_depth_unknown. + * @a repos_uuid and @a repos_root_url MUST NOT be @c NULL, and + * @a repos_root_url must be a prefix of @a url. + * + * If the administrative area does not exist, then create it and + * initialize it to an unlocked state. + * + * If the administrative area already exists then the given @a url + * must match the URL in the administrative area and the given + * @a revision must match the BASE of the working copy dir unless + * the admin directory is scheduled for deletion or the + * #SVN_ERR_WC_OBSTRUCTED_UPDATE error will be returned. + * + * Do not ensure existence of @a local_abspath itself; if @a local_abspath + * does not exist, return error. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_ensure_adm4(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *url, + const char *repos_root_url, + const char *repos_uuid, + svn_revnum_t revision, + svn_depth_t depth, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_ensure_adm4(), but without the wc context parameter. + * + * @note the @a uuid and @a repos parameters were documented as allowing + * @c NULL to be passed. Beginning with 1.7, this will return an error, + * contrary to prior documented behavior: see 'notes/api-errata/1.7/wc005.txt'. + * + * @since New in 1.5. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_ensure_adm3(const char *path, + const char *uuid, + const char *url, + const char *repos, + svn_revnum_t revision, + svn_depth_t depth, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_ensure_adm3(), but with @a depth set to + * #svn_depth_infinity. + * + * See the note on svn_wc_ensure_adm3() regarding the @a repos and @a uuid + * parameters. + * + * @since New in 1.3. + * @deprecated Provided for backwards compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_ensure_adm2(const char *path, + const char *uuid, + const char *url, + const char *repos, + svn_revnum_t revision, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_ensure_adm2(), but with @a repos set to @c NULL. + * + * @note as of 1.7, this function always returns #SVN_ERR_BAD_URL since + * the @a repos parameter may not be @c NULL. + * + * @deprecated Provided for backwards compatibility with the 1.2 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_ensure_adm(const char *path, + const char *uuid, + const char *url, + svn_revnum_t revision, + apr_pool_t *pool); + + +/** Set the repository root URL of @a path to @a repos, if possible. + * + * Before Subversion 1.7 there could be working copy directories that + * didn't have a stored repository root in some specific circumstances. + * This function allowed setting this root later. + * + * Since Subversion 1.7 this function just returns #SVN_NO_ERROR. + * + * @since New in 1.3. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_maybe_set_repos_root(svn_wc_adm_access_t *adm_access, + const char *path, + const char *repos, + apr_pool_t *pool); + + +/** + * @defgroup svn_wc_status Working copy status. + * @{ + * + * We have three functions for getting working copy status: one function + * for getting the status of exactly one thing, another for + * getting the statuses of (potentially) multiple things and a third for + * getting the working copy out-of-dateness with respect to the repository. + * + * Why do we have two different functions for getting working copy status? + * The concept of depth, as explained in the documentation for + * svn_depth_t, may be useful in understanding this. Suppose we're + * getting the status of directory D: + * + * To offer all three levels, we could have one unified function, + * taking a `depth' parameter. Unfortunately, because this function + * would have to handle multiple return values as well as the single + * return value case, getting the status of just one entity would + * become cumbersome: you'd have to roll through a hash to find one + * lone status. + * + * So we have svn_wc_status3() for depth-empty (just D itself), and + * svn_wc_walk_status() for depth-immediates and depth-infinity, + * since the latter two involve multiple return values. And for + * out-of-dateness information we have svn_wc_get_status_editor5(). + */ + +/** The type of status for the working copy. */ +enum svn_wc_status_kind +{ + /** does not exist */ + svn_wc_status_none = 1, + + /** is not a versioned thing in this wc */ + svn_wc_status_unversioned, + + /** exists, but uninteresting */ + svn_wc_status_normal, + + /** is scheduled for addition */ + svn_wc_status_added, + + /** under v.c., but is missing */ + svn_wc_status_missing, + + /** scheduled for deletion */ + svn_wc_status_deleted, + + /** was deleted and then re-added */ + svn_wc_status_replaced, + + /** text or props have been modified */ + svn_wc_status_modified, + + /** local mods received repos mods (### unused) */ + svn_wc_status_merged, + + /** local mods received conflicting repos mods */ + svn_wc_status_conflicted, + + /** is unversioned but configured to be ignored */ + svn_wc_status_ignored, + + /** an unversioned resource is in the way of the versioned resource */ + svn_wc_status_obstructed, + + /** an unversioned directory path populated by an svn:externals + property; this status is not used for file externals */ + svn_wc_status_external, + + /** a directory doesn't contain a complete entries list */ + svn_wc_status_incomplete +}; + +/** + * Structure for holding the "status" of a working copy item. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type. + * + * @since New in 1.7. + */ +typedef struct svn_wc_status3_t +{ + /** The kind of node as recorded in the working copy */ + svn_node_kind_t kind; + + /** The depth of the node as recorded in the working copy + * (#svn_depth_unknown for files or when no depth is set) */ + svn_depth_t depth; + + /** The actual size of the working file on disk, or SVN_INVALID_FILESIZE + * if unknown (or if the item isn't a file at all). */ + svn_filesize_t filesize; + + /** If the path is under version control, versioned is TRUE, otherwise + * FALSE. */ + svn_boolean_t versioned; + + /** Set to TRUE if the item is the victim of a conflict. */ + svn_boolean_t conflicted; + + /** The status of the node itself. In order of precedence: Obstructions, + * structural changes, text changes. */ + enum svn_wc_status_kind node_status; + + /** The status of the entry's text. */ + enum svn_wc_status_kind text_status; + + /** The status of the entry's properties. */ + enum svn_wc_status_kind prop_status; + + /** a file or directory can be 'copied' if it's scheduled for + * addition-with-history (or part of a subtree that is scheduled as such.). + */ + svn_boolean_t copied; + + /** Base revision. */ + svn_revnum_t revision; + + /** Last revision this was changed */ + svn_revnum_t changed_rev; + + /** Date of last commit. */ + apr_time_t changed_date; + + /** Last commit author of this item */ + const char *changed_author; + + /** The URL of the repository */ + const char *repos_root_url; + + /** The UUID of the repository */ + const char *repos_uuid; + + /** The in-repository path relative to the repository root. */ + const char *repos_relpath; + + /** a file or directory can be 'switched' if the switch command has been + * used. If this is TRUE, then file_external will be FALSE. + */ + svn_boolean_t switched; + + /** This directory has a working copy lock */ + svn_boolean_t locked; + + /** The repository file lock. (Values of path, token, owner, comment + * and are available if a lock is present) */ + const svn_lock_t *lock; + + /** Which changelist this item is part of, or NULL if not part of any. */ + const char *changelist; + + /** + * @defgroup svn_wc_status_ood WC out-of-date info from the repository + * @{ + * + * When the working copy item is out-of-date compared to the + * repository, the following fields represent the state of the + * youngest revision of the item in the repository. If the working + * copy is not out of date, the fields are initialized as described + * below. + */ + + /** Set to the node kind of the youngest commit, or #svn_node_none + * if not out of date. */ + svn_node_kind_t ood_kind; + + /** The status of the node, based on the text status if the node has no + * restructuring changes */ + enum svn_wc_status_kind repos_node_status; + + /** The entry's text status in the repository. */ + enum svn_wc_status_kind repos_text_status; + + /** The entry's property status in the repository. */ + enum svn_wc_status_kind repos_prop_status; + + /** The entry's lock in the repository, if any. */ + const svn_lock_t *repos_lock; + + /** Set to the youngest committed revision, or #SVN_INVALID_REVNUM + * if not out of date. */ + svn_revnum_t ood_changed_rev; + + /** Set to the most recent commit date, or @c 0 if not out of date. */ + apr_time_t ood_changed_date; + + /** Set to the user name of the youngest commit, or @c NULL if not + * out of date or non-existent. Because a non-existent @c + * svn:author property has the same behavior as an out-of-date + * working copy, examine @c ood_last_cmt_rev to determine whether + * the working copy is out of date. */ + const char *ood_changed_author; + + /** @} */ + + /** Set to the local absolute path that this node was moved from, if this + * file or directory has been moved here locally and is the root of that + * move. Otherwise set to NULL. + * + * This will be NULL for moved-here nodes that are just part of a subtree + * that was moved along (and are not themselves a root of a different move + * operation). + * + * @since New in 1.8. */ + const char *moved_from_abspath; + + /** Set to the local absolute path that this node was moved to, if this file + * or directory has been moved away locally and corresponds to the root + * of the destination side of the move. Otherwise set to NULL. + * + * Note: Saying just "root" here could be misleading. For example: + * svn mv A AA; + * svn mv AA/B BB; + * creates a situation where A/B is moved-to BB, but one could argue that + * the move source's root actually was AA/B. Note that, as far as the + * working copy is concerned, above case is exactly identical to: + * svn mv A/B BB; + * svn mv A AA; + * In both situations, @a moved_to_abspath would be set for nodes A (moved + * to AA) and A/B (moved to BB), only. + * + * This will be NULL for moved-away nodes that were just part of a subtree + * that was moved along (and are not themselves a root of a different move + * operation). + * + * @since New in 1.8. */ + const char *moved_to_abspath; + + /** @c TRUE iff the item is a file brought in by an svn:externals definition. + * @since New in 1.8. */ + svn_boolean_t file_external; + + /* NOTE! Please update svn_wc_dup_status3() when adding new fields here. */ +} svn_wc_status3_t; + +/** + * ### All diffs are not yet known. + * Same as svn_wc_status3_t, but without the #svn_boolean_t 'versioned' + * field. Instead an item that is not versioned has the 'entry' field set to + * @c NULL. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef struct svn_wc_status2_t +{ + /** Can be @c NULL if not under version control. */ + const svn_wc_entry_t *entry; + + /** The status of the entry itself, including its text if it is a file. */ + enum svn_wc_status_kind text_status; + + /** The status of the entry's properties. */ + enum svn_wc_status_kind prop_status; + + /** a directory can be 'locked' if a working copy update was interrupted. */ + svn_boolean_t locked; + + /** a file or directory can be 'copied' if it's scheduled for + * addition-with-history (or part of a subtree that is scheduled as such.). + */ + svn_boolean_t copied; + + /** a file or directory can be 'switched' if the switch command has been + * used. If this is TRUE, then file_external will be FALSE. + */ + svn_boolean_t switched; + + /** The entry's text status in the repository. */ + enum svn_wc_status_kind repos_text_status; + + /** The entry's property status in the repository. */ + enum svn_wc_status_kind repos_prop_status; + + /** The entry's lock in the repository, if any. */ + svn_lock_t *repos_lock; + + /** Set to the URI (actual or expected) of the item. + * @since New in 1.3 + */ + const char *url; + + /** + * @defgroup svn_wc_status_ood WC out-of-date info from the repository + * @{ + * + * When the working copy item is out-of-date compared to the + * repository, the following fields represent the state of the + * youngest revision of the item in the repository. If the working + * copy is not out of date, the fields are initialized as described + * below. + */ + + /** Set to the youngest committed revision, or #SVN_INVALID_REVNUM + * if not out of date. + * @since New in 1.3 + */ + svn_revnum_t ood_last_cmt_rev; + + /** Set to the most recent commit date, or @c 0 if not out of date. + * @since New in 1.3 + */ + apr_time_t ood_last_cmt_date; + + /** Set to the node kind of the youngest commit, or #svn_node_none + * if not out of date. + * @since New in 1.3 + */ + svn_node_kind_t ood_kind; + + /** Set to the user name of the youngest commit, or @c NULL if not + * out of date or non-existent. Because a non-existent @c + * svn:author property has the same behavior as an out-of-date + * working copy, examine @c ood_last_cmt_rev to determine whether + * the working copy is out of date. + * @since New in 1.3 + */ + const char *ood_last_cmt_author; + + /** @} */ + + /** Non-NULL if the entry is the victim of a tree conflict. + * @since New in 1.6 + */ + svn_wc_conflict_description_t *tree_conflict; + + /** If the item is a file that was added to the working copy with an + * svn:externals; if file_external is TRUE, then switched is always + * FALSE. + * @since New in 1.6 + */ + svn_boolean_t file_external; + + /** The actual status of the text compared to the pristine base of the + * file. This value isn't masked by other working copy statuses. + * @c pristine_text_status is #svn_wc_status_none if this value was + * not calculated during the status walk. + * @since New in 1.6 + */ + enum svn_wc_status_kind pristine_text_status; + + /** The actual status of the properties compared to the pristine base of + * the node. This value isn't masked by other working copy statuses. + * @c pristine_prop_status is #svn_wc_status_none if this value was + * not calculated during the status walk. + * @since New in 1.6 + */ + enum svn_wc_status_kind pristine_prop_status; + +} svn_wc_status2_t; + + + +/** + * Same as #svn_wc_status2_t, but without the #svn_lock_t 'repos_lock', const char 'url', #svn_revnum_t 'ood_last_cmt_rev', apr_time_t 'ood_last_cmt_date', #svn_node_kind_t 'ood_kind', const char 'ood_last_cmt_author', #svn_wc_conflict_description_t 'tree_conflict', #svn_boolean_t 'file_external', #svn_wc_status_kind 'pristine_text_status', and #svn_wc_status_kind 'pristine_prop_status' fields. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef struct svn_wc_status_t +{ + /** Can be @c NULL if not under version control. */ + const svn_wc_entry_t *entry; + + /** The status of the entries text. */ + enum svn_wc_status_kind text_status; + + /** The status of the entries properties. */ + enum svn_wc_status_kind prop_status; + + /** a directory can be 'locked' if a working copy update was interrupted. */ + svn_boolean_t locked; + + /** a file or directory can be 'copied' if it's scheduled for + * addition-with-history (or part of a subtree that is scheduled as such.). + */ + svn_boolean_t copied; + + /** a file or directory can be 'switched' if the switch command has been + * used. + */ + svn_boolean_t switched; + + /** The entry's text status in the repository. */ + enum svn_wc_status_kind repos_text_status; + + /** The entry's property status in the repository. */ + enum svn_wc_status_kind repos_prop_status; + +} svn_wc_status_t; + + +/** + * Return a deep copy of the @a orig_stat status structure, allocated + * in @a pool. + * + * @since New in 1.7. + */ +svn_wc_status3_t * +svn_wc_dup_status3(const svn_wc_status3_t *orig_stat, + apr_pool_t *pool); + +/** + * Same as svn_wc_dup_status3(), but for older svn_wc_status_t structures. + * + * @since New in 1.2 + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_wc_status2_t * +svn_wc_dup_status2(const svn_wc_status2_t *orig_stat, + apr_pool_t *pool); + + +/** + * Same as svn_wc_dup_status2(), but for older svn_wc_status_t structures. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_wc_status_t * +svn_wc_dup_status(const svn_wc_status_t *orig_stat, + apr_pool_t *pool); + + +/** + * Fill @a *status for @a local_abspath, allocating in @a result_pool. + * Use @a scratch_pool for temporary allocations. + * + * Here are some things to note about the returned structure. A quick + * examination of the @c status->text_status after a successful return of + * this function can reveal the following things: + * + * - #svn_wc_status_none : @a local_abspath is not versioned, and is + * not present on disk + * + * - #svn_wc_status_missing : @a local_abspath is versioned, but is + * missing from the working copy. + * + * - #svn_wc_status_unversioned : @a local_abspath is not versioned, + * but is present on disk and not being + * ignored (see above). + * + * The other available results for the @c text_status field are more + * straightforward in their meanings. See the comments on the + * #svn_wc_status_kind structure for some hints. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_status3(svn_wc_status3_t **status, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_status3(), but with a adm_access baton and absolute + * path. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_status2(svn_wc_status2_t **status, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + +/** + * Same as svn_wc_status2(), but for older svn_wc_status_t structures. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_status(svn_wc_status_t **status, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + + + +/** + * A callback for reporting a @a status about @a local_abspath. + * + * @a baton is a closure object; it should be provided by the + * implementation, and passed by the caller. + * + * @a scratch_pool will be cleared between invocations to the callback. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_wc_status_func4_t)(void *baton, + const char *local_abspath, + const svn_wc_status3_t *status, + apr_pool_t *scratch_pool); + +/** + * Same as svn_wc_status_func4_t, but with a non-const status and a relative + * path. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef svn_error_t *(*svn_wc_status_func3_t)(void *baton, + const char *path, + svn_wc_status2_t *status, + apr_pool_t *pool); + +/** + * Same as svn_wc_status_func3_t, but without a provided pool or + * the ability to propagate errors. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +typedef void (*svn_wc_status_func2_t)(void *baton, + const char *path, + svn_wc_status2_t *status); + +/** + * Same as svn_wc_status_func2_t, but for older svn_wc_status_t structures. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +typedef void (*svn_wc_status_func_t)(void *baton, + const char *path, + svn_wc_status_t *status); + +/** + * Walk the working copy status of @a local_abspath using @a wc_ctx, by + * creating #svn_wc_status3_t structures and sending these through + * @a status_func / @a status_baton. + * + * * Assuming the target is a directory, then: + * + * - If @a get_all is FALSE, then only locally-modified entries will be + * returned. If TRUE, then all entries will be returned. + * + * - If @a ignore_text_mods is TRUE, then the walk will not check for + * modified files. Any #svn_wc_status3_t structures returned for files + * will always have a text_status field set to svn_wc_status_normal. + * If @a ignore_text_mods is FALSE, the walk checks for text changes + * and returns #svn_wc_status3_t structures describing any changes. + * + * - If @a depth is #svn_depth_empty, a status structure will + * be returned for the target only; if #svn_depth_files, for the + * target and its immediate file children; if + * #svn_depth_immediates, for the target and its immediate + * children; if #svn_depth_infinity, for the target and + * everything underneath it, fully recursively. + * + * If @a depth is #svn_depth_unknown, take depths from the + * working copy and behave as above in each directory's case. + * + * If the given @a depth is incompatible with the depth found in a + * working copy directory, the found depth always governs. + * + * If @a no_ignore is set, statuses that would typically be ignored + * will instead be reported. + * + * @a ignore_patterns is an array of file patterns matching + * unversioned files to ignore for the purposes of status reporting, + * or @c NULL if the default set of ignorable file patterns should be used. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton while walking + * to determine if the client has canceled the operation. + * + * This function uses @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_walk_status(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + svn_boolean_t ignore_text_mods, + const apr_array_header_t *ignore_patterns, + svn_wc_status_func4_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * DEPRECATED -- please use APIs from svn_client.h + * + * --- + * + * Set @a *editor and @a *edit_baton to an editor that generates + * #svn_wc_status3_t structures and sends them through @a status_func / + * @a status_baton. @a anchor_abspath is a working copy directory + * directory which will be used as the root of our editor. If @a + * target_basename is not "", it represents a node in the @a anchor_abspath + * which is the subject of the editor drive (otherwise, the @a + * anchor_abspath is the subject). + * + * If @a set_locks_baton is non-@c NULL, it will be set to a baton that can + * be used in a call to the svn_wc_status_set_repos_locks() function. + * + * Callers drive this editor to describe working copy out-of-dateness + * with respect to the repository. If this information is not + * available or not desired, callers should simply call the + * close_edit() function of the @a editor vtable. + * + * If the editor driver calls @a editor's set_target_revision() vtable + * function, then when the edit drive is completed, @a *edit_revision + * will contain the revision delivered via that interface. + * + * Assuming the target is a directory, then: + * + * - If @a get_all is FALSE, then only locally-modified entries will be + * returned. If TRUE, then all entries will be returned. + * + * - If @a depth is #svn_depth_empty, a status structure will + * be returned for the target only; if #svn_depth_files, for the + * target and its immediate file children; if + * #svn_depth_immediates, for the target and its immediate + * children; if #svn_depth_infinity, for the target and + * everything underneath it, fully recursively. + * + * If @a depth is #svn_depth_unknown, take depths from the + * working copy and behave as above in each directory's case. + * + * If the given @a depth is incompatible with the depth found in a + * working copy directory, the found depth always governs. + * + * If @a no_ignore is set, statuses that would typically be ignored + * will instead be reported. + * + * @a ignore_patterns is an array of file patterns matching + * unversioned files to ignore for the purposes of status reporting, + * or @c NULL if the default set of ignorable file patterns should be used. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton while building + * the @a statushash to determine if the client has canceled the operation. + * + * If @a depth_as_sticky is set handle @a depth like when depth_is_sticky is + * passed for updating. This will show excluded nodes show up as added in the + * repository. + * + * If @a server_performs_filtering is TRUE, assume that the server handles + * the ambient depth filtering, so this doesn't have to be handled in the + * editor. + * + * Allocate the editor itself in @a result_pool, and use @a scratch_pool + * for temporary allocations. The editor will do its temporary allocations + * in a subpool of @a result_pool. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_status_editor5(const svn_delta_editor_t **editor, + void **edit_baton, + void **set_locks_baton, + svn_revnum_t *edit_revision, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target_basename, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + svn_boolean_t depth_as_sticky, + svn_boolean_t server_performs_filtering, + const apr_array_header_t *ignore_patterns, + svn_wc_status_func4_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Same as svn_wc_get_status_editor5, but using #svn_wc_status_func3_t + * instead of #svn_wc_status_func4_t. And @a server_performs_filtering + * always set to #TRUE. + * + * This also uses a single pool parameter, stating that all temporary + * allocations are performed in manually constructed/destroyed subpool. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_status_editor4(const svn_delta_editor_t **editor, + void **edit_baton, + void **set_locks_baton, + svn_revnum_t *edit_revision, + svn_wc_adm_access_t *anchor, + const char *target, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + const apr_array_header_t *ignore_patterns, + svn_wc_status_func3_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + +/** + * Same as svn_wc_get_status_editor4(), but using #svn_wc_status_func2_t + * instead of #svn_wc_status_func3_t. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_status_editor3(const svn_delta_editor_t **editor, + void **edit_baton, + void **set_locks_baton, + svn_revnum_t *edit_revision, + svn_wc_adm_access_t *anchor, + const char *target, + svn_depth_t depth, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + const apr_array_header_t *ignore_patterns, + svn_wc_status_func2_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + +/** + * Like svn_wc_get_status_editor3(), but with @a ignore_patterns + * provided from the corresponding value in @a config, and @a recurse + * instead of @a depth. If @a recurse is TRUE, behave as if for + * #svn_depth_infinity; else if @a recurse is FALSE, behave as if for + * #svn_depth_immediates. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_status_editor2(const svn_delta_editor_t **editor, + void **edit_baton, + void **set_locks_baton, + svn_revnum_t *edit_revision, + svn_wc_adm_access_t *anchor, + const char *target, + apr_hash_t *config, + svn_boolean_t recurse, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + svn_wc_status_func2_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + +/** + * Same as svn_wc_get_status_editor2(), but with @a set_locks_baton set + * to @c NULL, and taking a deprecated svn_wc_status_func_t argument. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_status_editor(const svn_delta_editor_t **editor, + void **edit_baton, + svn_revnum_t *edit_revision, + svn_wc_adm_access_t *anchor, + const char *target, + apr_hash_t *config, + svn_boolean_t recurse, + svn_boolean_t get_all, + svn_boolean_t no_ignore, + svn_wc_status_func_t status_func, + void *status_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + + +/** + * Associate @a locks, a hash table mapping <tt>const char*</tt> + * absolute repository paths to <tt>svn_lock_t</tt> objects, with a + * @a set_locks_baton returned by an earlier call to + * svn_wc_get_status_editor3(). @a repos_root is the repository root URL. + * Perform all allocations in @a pool. + * + * @note @a locks will not be copied, so it must be valid throughout the + * edit. @a pool must also not be destroyed or cleared before the edit is + * finished. + * + * @since New in 1.2. + */ +svn_error_t * +svn_wc_status_set_repos_locks(void *set_locks_baton, + apr_hash_t *locks, + const char *repos_root, + apr_pool_t *pool); + +/** @} */ + + +/** + * Copy @a src_abspath to @a dst_abspath, and schedule @a dst_abspath + * for addition to the repository, remembering the copy history. @a wc_ctx + * is used for accessing the working copy and must contain a write lock for + * the parent directory of @a dst_abspath, + * + * If @a metadata_only is TRUE then this is a database-only operation and + * the working directories and files are not copied. + * + * @a src_abspath must be a file or directory under version control; + * the parent of @a dst_abspath must be a directory under version control + * in the same working copy; @a dst_abspath will be the name of the copied + * item, and it must not exist already if @a metadata_only is FALSE. Note that + * when @a src points to a versioned file, the working file doesn't + * necessarily exist in which case its text-base is used instead. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the operation. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * If @a notify_func is non-NULL, call it with @a notify_baton and the path + * of the root node (only) of the destination. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_copy3(svn_wc_context_t *wc_ctx, + const char *src_abspath, + const char *dst_abspath, + svn_boolean_t metadata_only, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_copy3(), but takes access batons and a relative path + * and a basename instead of absolute paths and a working copy context. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_copy2(const char *src, + svn_wc_adm_access_t *dst_parent, + const char *dst_basename, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_copy2(), but takes an #svn_wc_notify_func_t instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_copy(const char *src, + svn_wc_adm_access_t *dst_parent, + const char *dst_basename, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Move @a src_abspath to @a dst_abspath, by scheduling @a dst_abspath + * for addition to the repository, remembering the history. Mark @a src_abspath + * as deleted after moving.@a wc_ctx is used for accessing the working copy and + * must contain a write lock for the parent directory of @a src_abspath and + * @a dst_abspath. + * + * If @a metadata_only is TRUE then this is a database-only operation and + * the working directories and files are not changed. + * + * @a src_abspath must be a file or directory under version control; + * the parent of @a dst_abspath must be a directory under version control + * in the same working copy; @a dst_abspath will be the name of the copied + * item, and it must not exist already if @a metadata_only is FALSE. Note that + * when @a src points to a versioned file, the working file doesn't + * necessarily exist in which case its text-base is used instead. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the operation. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * If @a notify_func is non-NULL, call it with @a notify_baton and the path + * of the root node (only) of the destination. + * + * Use @a scratch_pool for temporary allocations. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + * @see svn_client_move7() + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_move(svn_wc_context_t *wc_ctx, + const char *src_abspath, + const char *dst_abspath, + svn_boolean_t metadata_only, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** + * Schedule @a local_abspath for deletion. It will be deleted from the + * repository on the next commit. If @a local_abspath refers to a + * directory, then a recursive deletion will occur. @a wc_ctx must hold + * a write lock for the parent of @a local_abspath, @a local_abspath itself + * and everything below @a local_abspath. + * + * If @a keep_local is FALSE, this function immediately deletes all files, + * modified and unmodified, versioned and of @a delete_unversioned is TRUE, + * unversioned from the working copy. + * It also immediately deletes unversioned directories and directories that + * are scheduled to be added below @a local_abspath. Only versioned may + * remain in the working copy, these get deleted by the update following + * the commit. + * + * If @a keep_local is TRUE, all files and directories will be kept in the + * working copy (and will become unversioned on the next commit). + * + * If @a delete_unversioned_target is TRUE and @a local_abspath is not + * versioned, @a local_abspath will be handled as an added files without + * history. So it will be deleted if @a keep_local is FALSE. If @a + * delete_unversioned is FALSE and @a local_abspath is not versioned a + * #SVN_ERR_WC_PATH_NOT_FOUND error will be returned. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the operation. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * For each path marked for deletion, @a notify_func will be called with + * the @a notify_baton and that path. The @a notify_func callback may be + * @c NULL if notification is not needed. + * + * Use @a scratch_pool for temporary allocations. It may be cleared + * immediately upon returning from this function. + * + * @since New in 1.7. + */ + /* ### BH: Maybe add a delete_switched flag that allows deny switched + nodes like file externals? */ +svn_error_t * +svn_wc_delete4(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t keep_local, + svn_boolean_t delete_unversioned_target, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_delete4, but uses an access baton and relative path + * instead of a working copy context and absolute path. @a adm_access + * must hold a write lock for the parent of @a path. + * + * @c delete_unversioned_target will always be set to TRUE. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_delete3(const char *path, + svn_wc_adm_access_t *adm_access, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_boolean_t keep_local, + apr_pool_t *pool); + +/** + * Similar to svn_wc_delete3(), but with @a keep_local always set to FALSE. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_delete2(const char *path, + svn_wc_adm_access_t *adm_access, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_delete2(), but takes an #svn_wc_notify_func_t instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_delete(const char *path, + svn_wc_adm_access_t *adm_access, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + + +/** + * Schedule the single node that exists on disk at @a local_abspath for + * addition to the working copy. The added node will have the properties + * provided in @a props, or none if that is NULL. + * + * Check and canonicalize the properties in the same way as + * svn_wc_prop_set4(). Return an error and don't add the node if the + * properties are not valid on this node. Unlike svn_wc_prop_set4() + * there is no option to skip some of the checks and canonicalizations. + * + * ### The error code on validity check failure should be specified, and + * preferably should be a single code. + * + * The versioned state of the parent path must be a modifiable directory, + * and the versioned state of @a local_abspath must be either nonexistent or + * deleted; if deleted, the new node will be a replacement. + * + * If @a local_abspath does not exist as file, directory or symlink, return + * #SVN_ERR_WC_PATH_NOT_FOUND. + * + * ### TODO: Split into add_dir, add_file, add_symlink? + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc_add_from_disk2(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const apr_hash_t *props, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/** + * Similar to svn_wc_add_from_disk2(), but always passes NULL for @a + * props. + * + * This is a replacement for svn_wc_add4() case 2a (which see for + * details). + + * @see svn_wc_add4() + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add_from_disk(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/** + * Put @a local_abspath under version control by registering it as addition + * or copy in the database containing its parent. The new node is scheduled + * for addition to the repository below its parent node. + * + * 1) If the node is already versioned, it MUST BE the root of a separate + * working copy from the same repository as the parent WC. The new node + * and anything below it will be scheduled for addition inside the parent + * working copy as a copy of the original location. The separate working + * copy will be integrated by this step. In this case, which is only used + * by code like that of "svn cp URL@rev path" @a copyfrom_url and + * @a copyfrom_rev MUST BE the url and revision of @a local_abspath + * in the separate working copy. + * + * 2a) If the node was not versioned before it will be scheduled as a local + * addition or 2b) if @a copyfrom_url and @a copyfrom_rev are set as a copy + * of that location. In this last case the function doesn't set the pristine + * version (of a file) and/or pristine properties, which callers should + * handle via different APIs. Usually it is easier to call + * svn_wc_add_repos_file4() (### or a possible svn_wc_add_repos_dir()) than + * using this variant. + * + * If @a local_abspath does not exist as file, directory or symlink, return + * #SVN_ERR_WC_PATH_NOT_FOUND. + * + * If @a local_abspath is an unversioned directory, record @a depth on it; + * otherwise, ignore @a depth. (Use #svn_depth_infinity unless you exactly + * know what you are doing, or you may create an unexpected sparse working + * copy) + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the operation. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * When the @a local_abspath has been added, then @a notify_func will be + * called (if it is not @c NULL) with the @a notify_baton and the path. + * + * @note Case 1 is deprecated. Consider doing a WC-to-WC copy instead. + * @note For case 2a, prefer svn_wc_add_from_disk(). + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_add4(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_add4(), but with an access baton + * and relative path instead of a context and absolute path. + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add3(const char *path, + svn_wc_adm_access_t *parent_access, + svn_depth_t depth, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_add3(), but with the @a depth parameter always + * #svn_depth_infinity. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add2(const char *path, + svn_wc_adm_access_t *parent_access, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_add2(), but takes an #svn_wc_notify_func_t instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add(const char *path, + svn_wc_adm_access_t *parent_access, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** Add a file to a working copy at @a local_abspath, obtaining the + * text-base's contents from @a new_base_contents, the wc file's + * content from @a new_contents, its unmodified properties from @a + * new_base_props and its actual properties from @a new_props. Use + * @a wc_ctx for accessing the working copy. + * + * The unmodified text and props normally come from the repository + * file represented by the copyfrom args, see below. The new file + * will be marked as copy. + * + * @a new_contents and @a new_props may be NULL, in which case + * the working copy text and props are taken from the base files with + * appropriate translation of the file's content. + * + * @a new_contents must be provided in Normal Form. This is required + * in order to pass both special and non-special files through a stream. + * + * @a wc_ctx must contain a write lock for the parent of @a local_abspath. + * + * If @a copyfrom_url is non-NULL, then @a copyfrom_rev must be a + * valid revision number, and together they are the copyfrom history + * for the new file. + * + * The @a cancel_func and @a cancel_baton are a standard cancellation + * callback, or NULL if no callback is needed. @a notify_func and + * @a notify_baton are a notification callback, and (if not NULL) + * will be notified of the addition of this file. + * + * Use @a scratch_pool for temporary allocations. + * + * ### This function is very redundant with svn_wc_add(). Ideally, + * we'd merge them, so that svn_wc_add() would just take optional + * new_props and optional copyfrom information. That way it could be + * used for both 'svn add somefilesittingonmydisk' and for adding + * files from repositories, with or without copyfrom history. + * + * The problem with this Ideal Plan is that svn_wc_add() also takes + * care of recursive URL-rewriting. There's a whole comment in its + * doc string about how that's really weird, outside its core mission, + * etc, etc. So another part of the Ideal Plan is that that + * functionality of svn_wc_add() would move into a separate function. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_add_repos_file4(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_stream_t *new_base_contents, + svn_stream_t *new_contents, + apr_hash_t *new_base_props, + apr_hash_t *new_props, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_add_repos_file4, but uses access batons and a + * relative path instead of a working copy context and absolute path. + * + * ### NOTE: the notification callback/baton is not yet used. + * + * @since New in 1.6. + * @deprecated Provided for compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add_repos_file3(const char *dst_path, + svn_wc_adm_access_t *adm_access, + svn_stream_t *new_base_contents, + svn_stream_t *new_contents, + apr_hash_t *new_base_props, + apr_hash_t *new_props, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/** Same as svn_wc_add_repos_file3(), except that it has pathnames rather + * than streams for the text base, and actual text, and has no cancellation. + * + * @since New in 1.4. + * @deprecated Provided for compatibility with the 1.5 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add_repos_file2(const char *dst_path, + svn_wc_adm_access_t *adm_access, + const char *new_text_base_path, + const char *new_text_path, + apr_hash_t *new_base_props, + apr_hash_t *new_props, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + apr_pool_t *pool); + +/** Same as svn_wc_add_repos_file3(), except that it doesn't have the + * BASE arguments or cancellation. + * + * @deprecated Provided for compatibility with the 1.3 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add_repos_file(const char *dst_path, + svn_wc_adm_access_t *adm_access, + const char *new_text_path, + apr_hash_t *new_props, + const char *copyfrom_url, + svn_revnum_t copyfrom_rev, + apr_pool_t *pool); + + +/** Remove @a local_abspath from revision control. @a wc_ctx must + * hold a write lock on the parent of @a local_abspath, or if that is a + * WC root then on @a local_abspath itself. + * + * If @a local_abspath is a file, all its info will be removed from the + * administrative area. If @a local_abspath is a directory, then the + * administrative area will be deleted, along with *all* the administrative + * areas anywhere in the tree below @a adm_access. + * + * Normally, only administrative data is removed. However, if + * @a destroy_wf is TRUE, then all working file(s) and dirs are deleted + * from disk as well. When called with @a destroy_wf, any locally + * modified files will *not* be deleted, and the special error + * #SVN_ERR_WC_LEFT_LOCAL_MOD might be returned. (Callers only need to + * check for this special return value if @a destroy_wf is TRUE.) + * + * If @a instant_error is TRUE, then return + * #SVN_ERR_WC_LEFT_LOCAL_MOD the instant a locally modified file is + * encountered. Otherwise, leave locally modified files in place and + * return the error only after all the recursion is complete. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the removal. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * WARNING: This routine is exported for careful, measured use by + * libsvn_client. Do *not* call this routine unless you really + * understand what the heck you're doing. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_remove_from_revision_control2(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t destroy_wf, + svn_boolean_t instant_error, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_remove_from_revision_control2() but with a name + * and access baton. + * + * WARNING: This routine was exported for careful, measured use by + * libsvn_client. Do *not* call this routine unless you really + * understand what the heck you're doing. + * + * @deprecated Provided for compatibility with the 1.6 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_remove_from_revision_control(svn_wc_adm_access_t *adm_access, + const char *name, + svn_boolean_t destroy_wf, + svn_boolean_t instant_error, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Assuming @a local_abspath is under version control or a tree conflict + * victim and in a state of conflict, then take @a local_abspath *out* + * of this state. If @a resolve_text is TRUE then any text conflict is + * resolved, if @a resolve_tree is TRUE then any tree conflicts are + * resolved. If @a resolve_prop is set to "" all property conflicts are + * resolved, if it is set to any other string value, conflicts on that + * specific property are resolved and when resolve_prop is NULL, no + * property conflicts are resolved. + * + * If @a depth is #svn_depth_empty, act only on @a local_abspath; if + * #svn_depth_files, resolve @a local_abspath and its conflicted file + * children (if any); if #svn_depth_immediates, resolve @a local_abspath + * and all its immediate conflicted children (both files and directories, + * if any); if #svn_depth_infinity, resolve @a local_abspath and every + * conflicted file or directory anywhere beneath it. + * + * If @a conflict_choice is #svn_wc_conflict_choose_base, resolve the + * conflict with the old file contents; if + * #svn_wc_conflict_choose_mine_full, use the original working contents; + * if #svn_wc_conflict_choose_theirs_full, the new contents; and if + * #svn_wc_conflict_choose_merged, don't change the contents at all, + * just remove the conflict status, which is the pre-1.5 behavior. + * + * #svn_wc_conflict_choose_theirs_conflict and + * #svn_wc_conflict_choose_mine_conflict are not legal for binary + * files or properties. + * + * @a wc_ctx is a working copy context, with a write lock, for @a + * local_abspath. + * + * Needless to say, this function doesn't touch conflict markers or + * anything of that sort -- only a human can semantically resolve a + * conflict. Instead, this function simply marks a file as "having + * been resolved", clearing the way for a commit. + * + * The implementation details are opaque, as our "conflicted" criteria + * might change over time. (At the moment, this routine removes the + * three fulltext 'backup' files and any .prej file created in a conflict, + * and modifies @a local_abspath's entry.) + * + * If @a local_abspath is not under version control and not a tree + * conflict, return #SVN_ERR_ENTRY_NOT_FOUND. If @a path isn't in a + * state of conflict to begin with, do nothing, and return #SVN_NO_ERROR. + * + * If @c local_abspath was successfully taken out of a state of conflict, + * report this information to @c notify_func (if non-@c NULL.) If only + * text, only property, or only tree conflict resolution was requested, + * and it was successful, then success gets reported. + * + * Temporary allocations will be performed in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_resolved_conflict5(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + svn_boolean_t resolve_text, + const char *resolve_prop, + svn_boolean_t resolve_tree, + svn_wc_conflict_choice_t conflict_choice, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_resolved_conflict5, but takes an absolute path + * and an access baton. This version doesn't support resolving a specific + * property.conflict. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_resolved_conflict4(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t resolve_text, + svn_boolean_t resolve_props, + svn_boolean_t resolve_tree, + svn_depth_t depth, + svn_wc_conflict_choice_t conflict_choice, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_resolved_conflict4(), but without tree-conflict + * resolution support. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_resolved_conflict3(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t resolve_text, + svn_boolean_t resolve_props, + svn_depth_t depth, + svn_wc_conflict_choice_t conflict_choice, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_resolved_conflict3(), but without automatic conflict + * resolution support, and with @a depth set according to @a recurse: + * if @a recurse is TRUE, @a depth is #svn_depth_infinity, else it is + * #svn_depth_files. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_resolved_conflict2(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t resolve_text, + svn_boolean_t resolve_props, + svn_boolean_t recurse, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_resolved_conflict2(), but takes an + * svn_wc_notify_func_t and doesn't have cancellation support. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_resolved_conflict(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t resolve_text, + svn_boolean_t resolve_props, + svn_boolean_t recurse, + svn_wc_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + + +/* Commits. */ + + +/** + * Storage type for queued post-commit data. + * + * @since New in 1.5. + */ +typedef struct svn_wc_committed_queue_t svn_wc_committed_queue_t; + + +/** + * Create a queue for use with svn_wc_queue_committed() and + * svn_wc_process_committed_queue(). + * + * The returned queue and all further allocations required for queuing + * new items will also be done from @a pool. + * + * @since New in 1.5. + */ +svn_wc_committed_queue_t * +svn_wc_committed_queue_create(apr_pool_t *pool); + + +/** + * Queue committed items to be processed later by + * svn_wc_process_committed_queue2(). + * + * Record in @a queue that @a local_abspath will need to be bumped + * after a commit succeeds. + * + * If non-NULL, @a wcprop_changes is an array of <tt>svn_prop_t *</tt> + * changes to wc properties; if an #svn_prop_t->value is NULL, then + * that property is deleted. + * ### [JAF] No, a prop whose value is NULL is ignored, not deleted. This + * ### seems to be not a set of changes but rather the new complete set of + * ### props. And it's renamed to 'new_dav_cache' inside; why? + * + * If @a remove_lock is @c TRUE, any entryprops related to a repository + * lock will be removed. + * + * If @a remove_changelist is @c TRUE, any association with a + * changelist will be removed. + * + * + * If @a sha1_checksum is non-NULL, use it to identify the node's pristine + * text. + * + * If @a recurse is TRUE and @a local_abspath is a directory, then bump every + * versioned object at or under @a local_abspath. This is usually done for + * copied trees. + * + * ### In the present implementation, if a recursive directory item is in + * the queue, then any children (at any depth) of that directory that + * are also in the queue as separate items will get: + * 'wcprop_changes' = NULL; + * 'remove_lock' = FALSE; + * 'remove_changelist' from the recursive parent item; + * and any children (at any depth) of that directory that are NOT in + * the queue as separate items will get: + * 'wcprop_changes' = NULL; + * 'remove_lock' = FALSE; + * 'remove_changelist' from the recursive parent item; + * + * @note the @a recurse parameter should be used with extreme care since + * it will bump ALL nodes under the directory, regardless of their + * actual inclusion in the new revision. + * + * All pointer data passed to this function (@a local_abspath, + * @a wcprop_changes and the checksums) should remain valid until the + * queue has been processed by svn_wc_process_committed_queue2(). + * + * Temporary allocations will be performed in @a scratch_pool, and persistent + * allocations will use the same pool as @a queue used when it was created. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_queue_committed3(svn_wc_committed_queue_t *queue, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t recurse, + const apr_array_header_t *wcprop_changes, + svn_boolean_t remove_lock, + svn_boolean_t remove_changelist, + const svn_checksum_t *sha1_checksum, + apr_pool_t *scratch_pool); + +/** Same as svn_wc_queue_committed3() except @a path doesn't have to be an + * abspath and @a adm_access is unused and a SHA-1 checksum cannot be + * specified. + * + * @since New in 1.6. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_queue_committed2(svn_wc_committed_queue_t *queue, + const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t recurse, + const apr_array_header_t *wcprop_changes, + svn_boolean_t remove_lock, + svn_boolean_t remove_changelist, + const svn_checksum_t *md5_checksum, + apr_pool_t *scratch_pool); + + +/** Same as svn_wc_queue_committed2() but the @a queue parameter has an + * extra indirection and @a digest is supplied instead of a checksum type. + * + * @note despite the extra indirection, this function does NOT allocate + * the queue for you. svn_wc_committed_queue_create() must be called. + * + * @since New in 1.5 + * + * @deprecated Provided for backwards compatibility with 1.5 + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_queue_committed(svn_wc_committed_queue_t **queue, + const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t recurse, + const apr_array_header_t *wcprop_changes, + svn_boolean_t remove_lock, + svn_boolean_t remove_changelist, + const unsigned char *digest, + apr_pool_t *pool); + + +/** + * Bump all items in @a queue to @a new_revnum after a commit succeeds. + * @a rev_date and @a rev_author are the (server-side) date and author + * of the new revision; one or both may be @c NULL. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client wants to cancel the operation. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_process_committed_queue2(svn_wc_committed_queue_t *queue, + svn_wc_context_t *wc_ctx, + svn_revnum_t new_revnum, + const char *rev_date, + const char *rev_author, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** @see svn_wc_process_committed_queue2() + * + * @since New in 1.5. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_process_committed_queue(svn_wc_committed_queue_t *queue, + svn_wc_adm_access_t *adm_access, + svn_revnum_t new_revnum, + const char *rev_date, + const char *rev_author, + apr_pool_t *pool); + + +/** + * @note this function has improper expectations around the operation and + * execution of other parts of the Subversion WC library. The resulting + * coupling makes this interface near-impossible to support. Documentation + * has been removed, as a result. + * + * @deprecated Use the svn_wc_committed_queue_* functions instead. Provided + * for backwards compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_process_committed4(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t recurse, + svn_revnum_t new_revnum, + const char *rev_date, + const char *rev_author, + const apr_array_header_t *wcprop_changes, + svn_boolean_t remove_lock, + svn_boolean_t remove_changelist, + const unsigned char *digest, + apr_pool_t *pool); + +/** @see svn_wc_process_committed4() + * + * @deprecated Use the svn_wc_committed_queue_* functions instead. Provided + * for backwards compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_process_committed3(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t recurse, + svn_revnum_t new_revnum, + const char *rev_date, + const char *rev_author, + const apr_array_header_t *wcprop_changes, + svn_boolean_t remove_lock, + const unsigned char *digest, + apr_pool_t *pool); + +/** @see svn_wc_process_committed4() + * + * @deprecated Use the svn_wc_committed_queue_* functions instead. Provided + * for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_process_committed2(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t recurse, + svn_revnum_t new_revnum, + const char *rev_date, + const char *rev_author, + const apr_array_header_t *wcprop_changes, + svn_boolean_t remove_lock, + apr_pool_t *pool); + +/** @see svn_wc_process_committed4() + * + * @deprecated Use the svn_wc_committed_queue_* functions instead. Provided + * for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_process_committed(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t recurse, + svn_revnum_t new_revnum, + const char *rev_date, + const char *rev_author, + const apr_array_header_t *wcprop_changes, + apr_pool_t *pool); + + + + + +/** + * Do a depth-first crawl in a working copy, beginning at @a local_abspath, + * using @a wc_ctx for accessing the working copy. + * + * Communicate the `state' of the working copy's revisions and depths + * to @a reporter/@a report_baton. Obviously, if @a local_abspath is a + * file instead of a directory, this depth-first crawl will be a short one. + * + * No locks or logs are created, nor are any animals harmed in the + * process unless @a restore_files is TRUE. No cleanup is necessary. + * + * After all revisions are reported, @a reporter->finish_report() is + * called, which immediately causes the RA layer to update the working + * copy. Thus the return value may very well reflect the result of + * the update! + * + * If @a depth is #svn_depth_empty, then report state only for + * @a path itself. If #svn_depth_files, do the same and include + * immediate file children of @a path. If #svn_depth_immediates, + * then behave as if for #svn_depth_files but also report the + * property states of immediate subdirectories. If @a depth is + * #svn_depth_infinity, then report state fully recursively. All + * descents are only as deep as @a path's own depth permits, of + * course. If @a depth is #svn_depth_unknown, then just use + * #svn_depth_infinity, which in practice means depth of @a path. + * + * Iff @a honor_depth_exclude is TRUE, the crawler will report paths + * whose ambient depth is #svn_depth_exclude as being excluded, and + * thus prevent the server from pushing update data for those paths; + * therefore, don't set this flag if you wish to pull in excluded paths. + * Note that #svn_depth_exclude on the target @a path is never + * honored, even if @a honor_depth_exclude is TRUE, because we need to + * be able to explicitly pull in a target. For example, if this is + * the working copy... + * + * svn co greek_tree_repos wc_dir + * svn up --set-depth exclude wc_dir/A/B/E # now A/B/E is excluded + * + * ...then 'svn up wc_dir/A/B' would report E as excluded (assuming + * @a honor_depth_exclude is TRUE), but 'svn up wc_dir/A/B/E' would + * not, because the latter is trying to explicitly pull in E. In + * general, we never report the update target as excluded. + * + * Iff @a depth_compatibility_trick is TRUE, then set the @c start_empty + * flag on @a reporter->set_path() and @a reporter->link_path() calls + * as necessary to trick a pre-1.5 (i.e., depth-unaware) server into + * sending back all the items the client might need to upgrade a + * working copy from a shallower depth to a deeper one. + * + * If @a restore_files is TRUE, then unexpectedly missing working files + * will be restored from the administrative directory's cache. For each + * file restored, the @a notify_func function will be called with the + * @a notify_baton and the path of the restored file. @a notify_func may + * be @c NULL if this notification is not required. If @a + * use_commit_times is TRUE, then set restored files' timestamps to + * their last-commit-times. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_crawl_revisions5(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const svn_ra_reporter3_t *reporter, + void *report_baton, + svn_boolean_t restore_files, + svn_depth_t depth, + svn_boolean_t honor_depth_exclude, + svn_boolean_t depth_compatibility_trick, + svn_boolean_t use_commit_times, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_crawl_revisions5, but with a relative path and + * access baton instead of an absolute path and wc_ctx. + * + * Passes NULL for @a cancel_func and @a cancel_baton. + * + * @since New in 1.6. + * @deprecated Provided for compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_crawl_revisions4(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_ra_reporter3_t *reporter, + void *report_baton, + svn_boolean_t restore_files, + svn_depth_t depth, + svn_boolean_t honor_depth_exclude, + svn_boolean_t depth_compatibility_trick, + svn_boolean_t use_commit_times, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_crawl_revisions4, but with @a honor_depth_exclude always + * set to false. + * + * @deprecated Provided for compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_crawl_revisions3(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_ra_reporter3_t *reporter, + void *report_baton, + svn_boolean_t restore_files, + svn_depth_t depth, + svn_boolean_t depth_compatibility_trick, + svn_boolean_t use_commit_times, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + +/** + * Similar to svn_wc_crawl_revisions3, but taking svn_ra_reporter2_t + * instead of svn_ra_reporter3_t, and therefore only able to report + * #svn_depth_infinity for depths; and taking @a recurse instead of @a + * depth; and with @a depth_compatibility_trick always false. + * + * @deprecated Provided for compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_crawl_revisions2(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_ra_reporter2_t *reporter, + void *report_baton, + svn_boolean_t restore_files, + svn_boolean_t recurse, + svn_boolean_t use_commit_times, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + +/** + * Similar to svn_wc_crawl_revisions2(), but takes an #svn_wc_notify_func_t + * and a #svn_ra_reporter_t instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_crawl_revisions(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_ra_reporter_t *reporter, + void *report_baton, + svn_boolean_t restore_files, + svn_boolean_t recurse, + svn_boolean_t use_commit_times, + svn_wc_notify_func_t notify_func, + void *notify_baton, + svn_wc_traversal_info_t *traversal_info, + apr_pool_t *pool); + + +/** + * @defgroup svn_wc_roots Working copy roots + * @{ + */ + +/** If @a is_wcroot is not @c NULL, set @a *is_wcroot to @c TRUE if @a + * local_abspath is the root of the working copy, otherwise to @c FALSE. + * + * If @a is_switched is not @c NULL, set @a *is_switched to @c TRUE if @a + * local_abspath is not the root of the working copy, and switched against its + * parent. + * + * If @a kind is not @c NULL, set @a *kind to the node kind of @a + * local_abspath. + * + * Use @a scratch_pool for any temporary allocations. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc_check_root(svn_boolean_t *is_wcroot, + svn_boolean_t *is_switched, + svn_node_kind_t *kind, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** Set @a *wc_root to @c TRUE if @a local_abspath represents a "working copy + * root", @c FALSE otherwise. Here, @a local_abspath is a "working copy root" + * if its parent directory is not a WC or if it is switched. Also, a deleted + * tree-conflict victim is considered a "working copy root" because it has no + * URL. + * + * If @a local_abspath is not found, return the error #SVN_ERR_ENTRY_NOT_FOUND. + * + * Use @a scratch_pool for any temporary allocations. + * + * @note For legacy reasons only a directory can be a wc-root. However, this + * function will also set wc_root to @c TRUE for a switched file. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. Consider + * using svn_wc_check_root() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_is_wc_root2(svn_boolean_t *wc_root, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + + +/** + * Similar to svn_wc_is_wc_root2(), but with an access baton and relative + * path. + * + * @note If @a path is '', this function will always return @c TRUE. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_is_wc_root(svn_boolean_t *wc_root, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** @} */ + + +/* Updates. */ + +/** Conditionally split @a path into an @a anchor and @a target for the + * purpose of updating and committing. + * + * @a anchor is the directory at which the update or commit editor + * should be rooted. + * + * @a target is the actual subject (relative to the @a anchor) of the + * update/commit, or "" if the @a anchor itself is the subject. + * + * Allocate @a anchor and @a target in @a result_pool; @a scratch_pool + * is used for temporary allocations. + * + * @note Even though this API uses a #svn_wc_context_t, it accepts a + * (possibly) relative path and returns a (possibly) relative path in + * @a *anchor. The reason being that the outputs are generally used to + * open access batons, and such opening currently requires relative paths. + * In the long-run, I expect this API to be removed from 1.7, due to the + * remove of access batons, but for the time being, the #svn_wc_context_t + * parameter allows us to avoid opening a duplicate database, just for this + * function. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_get_actual_target2(const char **anchor, + const char **target, + svn_wc_context_t *wc_ctx, + const char *path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Similar to svn_wc_get_actual_target2(), but without the wc context, and + * with a absolute path. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_actual_target(const char *path, + const char **anchor, + const char **target, + apr_pool_t *pool); + + +/** + * @defgroup svn_wc_update_switch Update and switch (update-like functionality) + * @{ + */ + +/** + * A simple callback type to wrap svn_ra_get_file(); see that + * docstring for more information. + * + * This technique allows libsvn_client to 'wrap' svn_ra_get_file() and + * pass it down into libsvn_wc functions, thus allowing the WC layer + * to legally call the RA function via (blind) callback. + * + * @since New in 1.5 + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +typedef svn_error_t *(*svn_wc_get_file_t)(void *baton, + const char *path, + svn_revnum_t revision, + svn_stream_t *stream, + svn_revnum_t *fetched_rev, + apr_hash_t **props, + apr_pool_t *pool); + +/** + * A simple callback type to wrap svn_ra_get_dir2() for avoiding issue #3569, + * where a directory is updated to a revision without some of its children + * recorded in the working copy. A future update won't bring these files in + * because the repository assumes they are already there. + * + * We really only need the names of the dirents for a not-present marking, + * but we also store the node-kind if we receive one. + * + * @a *dirents should be set to a hash mapping <tt>const char *</tt> child + * names, to <tt>const svn_dirent_t *</tt> instances. + * + * @since New in 1.7. + */ +typedef svn_error_t *(*svn_wc_dirents_func_t)(void *baton, + apr_hash_t **dirents, + const char *repos_root_url, + const char *repos_relpath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * DEPRECATED -- please use APIs from svn_client.h + * + * --- + * + * Set @a *editor and @a *edit_baton to an editor and baton for updating a + * working copy. + * + * @a anchor_abspath is a local working copy directory, with a fully recursive + * write lock in @a wc_ctx, which will be used as the root of our editor. + * + * @a target_basename is the entry in @a anchor_abspath that will actually be + * updated, or the empty string if all of @a anchor_abspath should be updated. + * + * The editor invokes @a notify_func with @a notify_baton as the update + * progresses, if @a notify_func is non-NULL. + * + * If @a cancel_func is non-NULL, the editor will invoke @a cancel_func with + * @a cancel_baton as the update progresses to see if it should continue. + * + * If @a conflict_func is non-NULL, then invoke it with @a + * conflict_baton whenever a conflict is encountered, giving the + * callback a chance to resolve the conflict before the editor takes + * more drastic measures (such as marking a file conflicted, or + * bailing out of the update). + * + * If @a external_func is non-NULL, then invoke it with @a external_baton + * whenever external changes are encountered, giving the callback a chance + * to store the external information for processing. + * + * If @a diff3_cmd is non-NULL, then use it as the diff3 command for + * any merging; otherwise, use the built-in merge code. + * + * @a preserved_exts is an array of filename patterns which, when + * matched against the extensions of versioned files, determine for + * which such files any related generated conflict files will preserve + * the original file's extension as their own. If a file's extension + * does not match any of the patterns in @a preserved_exts (which is + * certainly the case if @a preserved_exts is @c NULL or empty), + * generated conflict files will carry Subversion's custom extensions. + * + * @a target_revision is a pointer to a revision location which, after + * successful completion of the drive of this editor, will be + * populated with the revision to which the working copy was updated. + * + * If @a use_commit_times is TRUE, then all edited/added files will + * have their working timestamp set to the last-committed-time. If + * FALSE, the working files will be touched with the 'now' time. + * + * If @a allow_unver_obstructions is TRUE, then allow unversioned + * obstructions when adding a path. + * + * If @a adds_as_modification is TRUE, a local addition at the same path + * as an incoming addition of the same node kind results in a normal node + * with a possible local modification, instead of a tree conflict. + * + * If @a depth is #svn_depth_infinity, update fully recursively. + * Else if it is #svn_depth_immediates, update the uppermost + * directory, its file entries, and the presence or absence of + * subdirectories (but do not descend into the subdirectories). + * Else if it is #svn_depth_files, update the uppermost directory + * and its immediate file entries, but not subdirectories. + * Else if it is #svn_depth_empty, update exactly the uppermost + * target, and don't touch its entries. + * + * If @a depth_is_sticky is set and @a depth is not + * #svn_depth_unknown, then in addition to updating PATHS, also set + * their sticky ambient depth value to @a depth. + * + * If @a server_performs_filtering is TRUE, assume that the server handles + * the ambient depth filtering, so this doesn't have to be handled in the + * editor. + * + * If @a clean_checkout is TRUE, assume that we are checking out into an + * empty directory, and so bypass a number of conflict checks that are + * unnecessary in this case. + * + * If @a fetch_dirents_func is not NULL, the update editor may call this + * callback, when asked to perform a depth restricted update. It will do this + * before returning the editor to allow using the primary ra session for this. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_update_editor4(const svn_delta_editor_t **editor, + void **edit_baton, + svn_revnum_t *target_revision, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target_basename, + svn_boolean_t use_commit_times, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t allow_unver_obstructions, + svn_boolean_t adds_as_modification, + svn_boolean_t server_performs_filtering, + svn_boolean_t clean_checkout, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + svn_wc_dirents_func_t fetch_dirents_func, + void *fetch_dirents_baton, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_wc_external_update_t external_func, + void *external_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_get_update_editor4, but uses access batons and relative + * path instead of a working copy context-abspath pair and + * svn_wc_traversal_info_t instead of an externals callback. Also, + * @a fetch_func and @a fetch_baton are ignored. + * + * If @a ti is non-NULL, record traversal info in @a ti, for use by + * post-traversal accessors such as svn_wc_edited_externals(). + * + * All locks, both those in @a anchor and newly acquired ones, will be + * released when the editor driver calls @c close_edit. + * + * Always sets @a adds_as_modification to TRUE, @a server_performs_filtering + * and @a clean_checkout to FALSE. + * + * Uses a svn_wc_conflict_resolver_func_t conflict resolver instead of a + * svn_wc_conflict_resolver_func2_t. + * + * This function assumes that @a diff3_cmd is path encoded. Later versions + * assume utf-8. + * + * Always passes a null dirent function. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_update_editor3(svn_revnum_t *target_revision, + svn_wc_adm_access_t *anchor, + const char *target, + svn_boolean_t use_commit_times, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t allow_unver_obstructions, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_conflict_resolver_func_t conflict_func, + void *conflict_baton, + svn_wc_get_file_t fetch_func, + void *fetch_baton, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_traversal_info_t *ti, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_get_update_editor3() but with the @a + * allow_unver_obstructions parameter always set to FALSE, @a + * conflict_func and baton set to NULL, @a fetch_func and baton set to + * NULL, @a preserved_exts set to NULL, @a depth_is_sticky set to + * FALSE, and @a depth set according to @a recurse: if @a recurse is + * TRUE, pass #svn_depth_infinity, if FALSE, pass #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_update_editor2(svn_revnum_t *target_revision, + svn_wc_adm_access_t *anchor, + const char *target, + svn_boolean_t use_commit_times, + svn_boolean_t recurse, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const char *diff3_cmd, + const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_traversal_info_t *ti, + apr_pool_t *pool); + +/** + * Similar to svn_wc_get_update_editor2(), but takes an svn_wc_notify_func_t + * instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_update_editor(svn_revnum_t *target_revision, + svn_wc_adm_access_t *anchor, + const char *target, + svn_boolean_t use_commit_times, + svn_boolean_t recurse, + svn_wc_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const char *diff3_cmd, + const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_traversal_info_t *ti, + apr_pool_t *pool); + +/** + * DEPRECATED -- please use APIs from svn_client.h + * + * --- + * + * A variant of svn_wc_get_update_editor4(). + * + * Set @a *editor and @a *edit_baton to an editor and baton for "switching" + * a working copy to a new @a switch_url. (Right now, this URL must be + * within the same repository that the working copy already comes + * from.) @a switch_url must not be @c NULL. + * + * All other parameters behave as for svn_wc_get_update_editor4(). + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_switch_editor4(const svn_delta_editor_t **editor, + void **edit_baton, + svn_revnum_t *target_revision, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target_basename, + const char *switch_url, + svn_boolean_t use_commit_times, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t allow_unver_obstructions, + svn_boolean_t server_performs_filtering, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + svn_wc_dirents_func_t fetch_dirents_func, + void *fetch_dirents_baton, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_wc_external_update_t external_func, + void *external_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_get_switch_editor4, but uses access batons and relative + * path instead of a working copy context and svn_wc_traversal_info_t instead + * of an externals callback. + * + * If @a ti is non-NULL, record traversal info in @a ti, for use by + * post-traversal accessors such as svn_wc_edited_externals(). + * + * All locks, both those in @a anchor and newly acquired ones, will be + * released when the editor driver calls @c close_edit. + * + * Always sets @a server_performs_filtering to FALSE. + * + * Uses a svn_wc_conflict_resolver_func_t conflict resolver instead of a + * svn_wc_conflict_resolver_func2_t. + * + * This function assumes that @a diff3_cmd is path encoded. Later versions + * assume utf-8. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_switch_editor3(svn_revnum_t *target_revision, + svn_wc_adm_access_t *anchor, + const char *target, + const char *switch_url, + svn_boolean_t use_commit_times, + svn_depth_t depth, + svn_boolean_t depth_is_sticky, + svn_boolean_t allow_unver_obstructions, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_conflict_resolver_func_t conflict_func, + void *conflict_baton, + const char *diff3_cmd, + const apr_array_header_t *preserved_exts, + const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_traversal_info_t *ti, + apr_pool_t *pool); + +/** + * Similar to svn_wc_get_switch_editor3() but with the + * @a allow_unver_obstructions parameter always set to FALSE, + * @a preserved_exts set to NULL, @a conflict_func and baton set to NULL, + * @a depth_is_sticky set to FALSE, and @a depth set according to @a + * recurse: if @a recurse is TRUE, pass #svn_depth_infinity, if + * FALSE, pass #svn_depth_files. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_switch_editor2(svn_revnum_t *target_revision, + svn_wc_adm_access_t *anchor, + const char *target, + const char *switch_url, + svn_boolean_t use_commit_times, + svn_boolean_t recurse, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const char *diff3_cmd, + const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_traversal_info_t *ti, + apr_pool_t *pool); + +/** + * Similar to svn_wc_get_switch_editor2(), but takes an + * #svn_wc_notify_func_t instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_switch_editor(svn_revnum_t *target_revision, + svn_wc_adm_access_t *anchor, + const char *target, + const char *switch_url, + svn_boolean_t use_commit_times, + svn_boolean_t recurse, + svn_wc_notify_func_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const char *diff3_cmd, + const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_traversal_info_t *ti, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_properties Properties + * @{ + */ + +/** Set @a *props to a hash table mapping <tt>char *</tt> names onto + * <tt>svn_string_t *</tt> values for all the regular properties of + * @a local_abspath. Allocate the table, names, and values in + * @a result_pool. If the node has no properties, then an empty hash + * is returned. Use @a wc_ctx to access the working copy, and @a + * scratch_pool for temporary allocations. + * + * If the node does not exist, #SVN_ERR_WC_PATH_NOT_FOUND is returned. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_prop_list2(apr_hash_t **props, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_prop_list2() but with a #svn_wc_adm_access_t / + * relative path parameter pair. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_prop_list(apr_hash_t **props, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + +/** Return the set of "pristine" properties for @a local_abspath. + * + * There are node states where properties do not make sense. For these + * cases, NULL will be returned in @a *props. Otherwise, a hash table + * will always be returned (but may be empty, indicating no properties). + * + * If the node is locally-added, then @a *props will be set to NULL since + * pristine properties are undefined. Note: if this addition is replacing a + * previously-deleted node, then the replaced node's properties are not + * available until the addition is reverted. + * + * If the node has been copied (from another node in the repository), then + * the pristine properties will correspond to those original properties. + * + * If the node is locally-deleted, these properties will correspond to + * the BASE node's properties, as checked-out from the repository. Note: if + * this deletion is a child of a copy, then the pristine properties will + * correspond to that copy's properties, not any potential BASE node. The + * BASE node's properties will not be accessible until the copy is reverted. + * + * Nodes that are incomplete, excluded, absent, or not present at the + * node's revision will return NULL in @a props. + * + * If the node is not versioned, SVN_ERR_WC_PATH_NOT_FOUND will be returned. + * + * @a props will be allocated in @a result_pool, and all temporary + * allocations will be performed in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_get_pristine_props(apr_hash_t **props, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Set @a *value to the value of property @a name for @a local_abspath, + * allocating @a *value in @a result_pool. If no such prop, set @a *value + * to @c NULL. @a name may be a regular or wc property; if it is an + * entry property, return the error #SVN_ERR_BAD_PROP_KIND. @a wc_ctx + * is used to access the working copy. + * + * If @a local_abspath is not a versioned path, return + * #SVN_ERR_WC_PATH_NOT_FOUND + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_prop_get2(const svn_string_t **value, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *name, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_prop_get2(), but with a #svn_wc_adm_access_t / + * relative path parameter pair. + * + * When @a path is not versioned, set @a *value to NULL. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_prop_get(const svn_string_t **value, + const char *name, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** + * Set property @a name to @a value for @a local_abspath, or if @a value is + * NULL, remove property @a name from @a local_abspath. Use @a wc_ctx to + * access @a local_abspath. + * + * @a name may be a regular property or a "wc property". If @a name is + * an "entry property", return the error #SVN_ERR_BAD_PROP_KIND (even if + * @a skip_checks is TRUE). + * + * If @a name is a "wc property", then just update the WC DAV cache for + * @a local_abspath with @a name and @a value. In this case, @a depth + * must be #svn_depth_empty. + * + * The rest of this description applies when @a name is a regular property. + * + * If @a name is a name in the reserved "svn:" name space, and @a value is + * non-null, then canonicalize the property value and check the property + * name and value as documented for svn_wc_canonicalize_svn_prop(). + * @a skip_checks controls the level of checking as documented there. + * + * Return an error if the canonicalization or the check fails. + * The error will be either #SVN_ERR_ILLEGAL_TARGET (if the + * property is not appropriate for @a path), or + * #SVN_ERR_BAD_MIME_TYPE (if @a name is "svn:mime-type", but @a value + * is not a valid mime-type). + * ### That is not currently right -- several other errors can be raised. + * + * @a depth follows the usual semantics for depth. + * + * @a changelist_filter is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose properties are + * set; that is, don't set properties on any item unless it's a member + * of one of those changelists. If @a changelist_filter is empty (or + * altogether @c NULL), no changelist filtering occurs. + * + * If @a cancel_func is non-NULL, then it will be invoked (with the + * @a cancel_baton value passed) during the processing of the property + * set (i.e. when @a depth indicates some amount of recursion). + * + * For each file or directory operated on, @a notify_func will be called + * with its path and the @a notify_baton. @a notify_func may be @c NULL + * if you are not interested in this information. + * + * Use @a scratch_pool for temporary allocation. + * + * @note If the caller is setting both svn:mime-type and svn:eol-style in + * separate calls, and @a skip_checks is false, there is an ordering + * dependency between them, as the validity check for svn:eol-style makes + * use of the current value of svn:mime-type. + * + * ### The error code on validity check failure should be specified, and + * should be a single code or a very small set of possibilities. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_prop_set4(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *name, + const svn_string_t *value, + svn_depth_t depth, + svn_boolean_t skip_checks, + const apr_array_header_t *changelist_filter, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_prop_set4(), but with a #svn_wc_adm_access_t / + * relative path parameter pair, no @a depth parameter, no changelist + * filtering (for the depth-based property setting), and no cancellation. + * + * @since New in 1.6. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_prop_set3(const char *name, + const svn_string_t *value, + const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t skip_checks, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + + +/** + * Like svn_wc_prop_set3(), but without the notification callbacks. + * + * @since New in 1.2. + * @deprecated Provided for backwards compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_prop_set2(const char *name, + const svn_string_t *value, + const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t skip_checks, + apr_pool_t *pool); + + +/** + * Like svn_wc_prop_set2(), but with @a skip_checks always FALSE. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_prop_set(const char *name, + const svn_string_t *value, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + + +/** Return TRUE iff @a name is a 'normal' property name. 'Normal' is + * defined as a user-visible and user-tweakable property that shows up + * when you fetch a proplist. + * + * The function currently parses the namespace like so: + * + * - 'svn:wc:' ==> a wcprop, stored/accessed separately via different API. + * + * - 'svn:entry:' ==> an "entry" prop, shunted into the 'entries' file. + * + * If these patterns aren't found, then the property is assumed to be + * Normal. + */ +svn_boolean_t +svn_wc_is_normal_prop(const char *name); + + + +/** Return TRUE iff @a name is a 'wc' property name. */ +svn_boolean_t +svn_wc_is_wc_prop(const char *name); + +/** Return TRUE iff @a name is a 'entry' property name. */ +svn_boolean_t +svn_wc_is_entry_prop(const char *name); + +/** Callback type used by #svn_wc_canonicalize_svn_prop. + * + * If @a mime_type is non-null, it sets @a *mime_type to the value of + * #SVN_PROP_MIME_TYPE for the path passed to + * #svn_wc_canonicalize_svn_prop (allocated from @a pool). If @a + * stream is non-null, it writes the contents of the file to @a + * stream. + * + * (Currently, this is used if you are attempting to set the + * #SVN_PROP_EOL_STYLE property, to make sure that the value matches + * the mime type and contents.) + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_wc_canonicalize_svn_prop_get_file_t)( + const svn_string_t **mime_type, + svn_stream_t *stream, + void *baton, + apr_pool_t *pool); + + +/** Canonicalize the value of an svn:* property @a propname with + * value @a propval. + * + * If the property is not appropriate for a node of kind @a kind, or + * is otherwise invalid, throw an error. Otherwise, set @a *propval_p + * to a canonicalized version of the property value. + * + * The exact set of canonicalizations and checks may vary across different + * versions of this API. Currently: + * + * - svn:executable + * - svn:needs-lock + * - svn:special + * - set the value to '*' + * + * - svn:keywords + * - strip leading and trailing white space + * + * - svn:ignore + * - svn:global-ignores + * - svn:auto-props + * - add a final a newline character if missing + * + * - svn:externals + * - add a final a newline character if missing + * - check for valid syntax + * - check for no duplicate entries + * + * - svn:mergeinfo + * - canonicalize + * - check for validity + * + * Also, unless @a skip_some_checks is TRUE: + * + * - svn:eol-style + * - strip leading and trailing white space + * - check value is recognized + * - check file content has a self-consistent EOL style + * (but not necessarily that it matches @a propval) + * + * - svn:mime-type + * - strip white space + * - check for reasonable syntax + * + * The EOL-style check (if not skipped) requires access to the contents and + * MIME type of the target if it is a file. It will call @a prop_getter with + * @a getter_baton. The callback must set the MIME type and/or write the + * contents of the file to the given stream. If @a skip_some_checks is true, + * then @a prop_getter is not used and may be NULL. + * + * @a path should be the path of the file in question; it is only used + * for error messages. + * + * ### The error code on validity check failure should be specified, and + * should be a single code or a very small set of possibilities. + * + * ### This is not actually related to the WC, but it does need to call + * ### svn_wc_parse_externals_description3. + * + * @since New in 1.5. + */ +svn_error_t * +svn_wc_canonicalize_svn_prop(const svn_string_t **propval_p, + const char *propname, + const svn_string_t *propval, + const char *path, + svn_node_kind_t kind, + svn_boolean_t skip_some_checks, + svn_wc_canonicalize_svn_prop_get_file_t prop_getter, + void *getter_baton, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_diffs Diffs + * @{ + */ + +/** + * DEPRECATED -- please use APIs from svn_client.h + * + * --- + * + * Return an @a editor/@a edit_baton for diffing a working copy against the + * repository. The editor is allocated in @a result_pool; temporary + * calculations are performed in @a scratch_pool. + * + * This editor supports diffing either the actual files and properties in the + * working copy (when @a use_text_base is #FALSE), or the current pristine + * information (when @a use_text_base is #TRUE) against the editor driver. + * + * @a anchor_abspath/@a target represent the base of the hierarchy to be + * compared. The diff callback paths will be relative to this path. + * + * Diffs will be reported as valid relpaths, with @a anchor_abspath being + * the root (""). + * + * @a callbacks/@a callback_baton is the callback table to use. + * + * If @a depth is #svn_depth_empty, just diff exactly @a target or + * @a anchor_path if @a target is empty. If #svn_depth_files then do the same + * and for top-level file entries as well (if any). If + * #svn_depth_immediates, do the same as #svn_depth_files but also diff + * top-level subdirectories at #svn_depth_empty. If #svn_depth_infinity, + * then diff fully recursively. + * + * @a ignore_ancestry determines whether paths that have discontinuous node + * ancestry are treated as delete/add or as simple modifications. If + * @a ignore_ancestry is @c FALSE, then any discontinuous node ancestry will + * result in the diff given as a full delete followed by an add. + * + * @a show_copies_as_adds determines whether paths added with history will + * appear as a diff against their copy source, or whether such paths will + * appear as if they were newly added in their entirety. + * @a show_copies_as_adds implies not @a ignore_ancestry. + * + * If @a use_git_diff_format is TRUE, copied paths will be treated as added + * if they weren't modified after being copied. This allows the callbacks + * to generate appropriate --git diff headers for such files. + * @a use_git_diff_format implies @a show_copies_as_adds, and as such implies + * not @a ignore_ancestry. + * + * Normally, the difference from repository->working_copy is shown. + * If @a reverse_order is TRUE, then show working_copy->repository diffs. + * + * If @a cancel_func is non-NULL, it will be used along with @a cancel_baton + * to periodically check if the client has canceled the operation. + * + * @a changelist_filter is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose differences are + * reported; that is, don't generate diffs about any item unless + * it's a member of one of those changelists. If @a changelist_filter is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * If @a server_performs_filtering is TRUE, assume that the server handles + * the ambient depth filtering, so this doesn't have to be handled in the + * editor. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_diff_editor6(const svn_delta_editor_t **editor, + void **edit_baton, + svn_wc_context_t *wc_ctx, + const char *anchor_abspath, + const char *target, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t show_copies_as_adds, + svn_boolean_t use_git_diff_format, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_boolean_t server_performs_filtering, + const apr_array_header_t *changelist_filter, + const svn_wc_diff_callbacks4_t *callbacks, + void *callback_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_get_diff_editor6(), but with an access baton and relative + * path. @a server_performs_filtering always true and with a + * #svn_wc_diff_callbacks3_t instead of #svn_wc_diff_callbacks4_t, + * @a show_copies_as_adds, and @a use_git_diff_format set to @c FALSE. + * + * Diffs will be reported as below the relative path stored in @a anchor. + * + * @since New in 1.6. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_diff_editor5(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks3_t *callbacks, + void *callback_baton, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const apr_array_header_t *changelist_filter, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_get_diff_editor5(), but with an + * #svn_wc_diff_callbacks2_t instead of #svn_wc_diff_callbacks3_t. + * + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_diff_editor4(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks2_t *callbacks, + void *callback_baton, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const apr_array_header_t *changelist_filter, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_get_diff_editor4(), but with @a changelist_filter + * passed as @c NULL, and @a depth set to #svn_depth_infinity if @a + * recurse is TRUE, or #svn_depth_files if @a recurse is FALSE. + * + * @deprecated Provided for backward compatibility with the 1.4 API. + + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_diff_editor3(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks2_t *callbacks, + void *callback_baton, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_get_diff_editor3(), but with an + * #svn_wc_diff_callbacks_t instead of #svn_wc_diff_callbacks2_t. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_diff_editor2(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks_t *callbacks, + void *callback_baton, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_get_diff_editor2(), but with @a ignore_ancestry + * always set to @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_diff_editor(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks_t *callbacks, + void *callback_baton, + svn_boolean_t recurse, + svn_boolean_t use_text_base, + svn_boolean_t reverse_order, + svn_cancel_func_t cancel_func, + void *cancel_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_pool_t *pool); + + +/** + * Compare working copy against the text-base. + * + * @a target_abspath represents the base of the hierarchy to be compared. + * + * @a callbacks/@a callback_baton is the callback table to use when two + * files are to be compared. + * + * If @a depth is #svn_depth_empty, just diff exactly @a target_path. + * If #svn_depth_files then do the same + * and for top-level file entries as well (if any). If + * #svn_depth_immediates, do the same as #svn_depth_files but also diff + * top-level subdirectories at #svn_depth_empty. If #svn_depth_infinity, + * then diff fully recursively. + * + * @a ignore_ancestry determines whether paths that have discontinuous node + * ancestry are treated as delete/add or as simple modifications. If + * @a ignore_ancestry is @c FALSE, then any discontinuous node ancestry will + * result in the diff given as a full delete followed by an add. + * + * @a show_copies_as_adds determines whether paths added with history will + * appear as a diff against their copy source, or whether such paths will + * appear as if they were newly added in their entirety. + * + * If @a use_git_diff_format is TRUE, copied paths will be treated as added + * if they weren't modified after being copied. This allows the callbacks + * to generate appropriate --git diff headers for such files. + * + * @a changelist_filter is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose differences are + * reported; that is, don't generate diffs about any item unless + * it's a member of one of those changelists. If @a changelist_filter is + * empty (or altogether @c NULL), no changelist filtering occurs. + * + * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at various + * points during the operation. If it returns an error (typically + * #SVN_ERR_CANCELLED), return that error immediately. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_diff6(svn_wc_context_t *wc_ctx, + const char *target_abspath, + const svn_wc_diff_callbacks4_t *callbacks, + void *callback_baton, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + svn_boolean_t show_copies_as_adds, + svn_boolean_t use_git_diff_format, + const apr_array_header_t *changelist_filter, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_diff6(), but with a #svn_wc_diff_callbacks3_t argument + * instead of #svn_wc_diff_callbacks4_t, @a show_copies_as_adds, + * and @a use_git_diff_format set to * @c FALSE. + * It also doesn't allow specifying a cancel function. + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_diff5(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks3_t *callbacks, + void *callback_baton, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + const apr_array_header_t *changelist_filter, + apr_pool_t *pool); + +/** + * Similar to svn_wc_diff5(), but with a #svn_wc_diff_callbacks2_t argument + * instead of #svn_wc_diff_callbacks3_t. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.5 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_diff4(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks2_t *callbacks, + void *callback_baton, + svn_depth_t depth, + svn_boolean_t ignore_ancestry, + const apr_array_header_t *changelist_filter, + apr_pool_t *pool); + +/** + * Similar to svn_wc_diff4(), but with @a changelist_filter passed @c NULL, + * and @a depth set to #svn_depth_infinity if @a recurse is TRUE, or + * #svn_depth_files if @a recurse is FALSE. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_diff3(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks2_t *callbacks, + void *callback_baton, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + apr_pool_t *pool); + +/** + * Similar to svn_wc_diff3(), but with a #svn_wc_diff_callbacks_t argument + * instead of #svn_wc_diff_callbacks2_t. + * + * @since New in 1.1. + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_diff2(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks_t *callbacks, + void *callback_baton, + svn_boolean_t recurse, + svn_boolean_t ignore_ancestry, + apr_pool_t *pool); + +/** + * Similar to svn_wc_diff2(), but with @a ignore_ancestry always set + * to @c FALSE. + * + * @deprecated Provided for backward compatibility with the 1.0 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_diff(svn_wc_adm_access_t *anchor, + const char *target, + const svn_wc_diff_callbacks_t *callbacks, + void *callback_baton, + svn_boolean_t recurse, + apr_pool_t *pool); + + +/** Given a @a local_abspath to a file or directory under version control, + * discover any local changes made to properties and/or the set of 'pristine' + * properties. @a wc_ctx will be used to access the working copy. + * + * If @a propchanges is non-@c NULL, return these changes as an array of + * #svn_prop_t structures stored in @a *propchanges. The structures and + * array will be allocated in @a result_pool. If there are no local property + * modifications on @a local_abspath, then set @a *propchanges will be empty. + * + * If @a original_props is non-@c NULL, then set @a *original_props to + * hashtable (<tt>const char *name</tt> -> <tt>const svn_string_t *value</tt>) + * that represents the 'pristine' property list of @a path. This hashtable is + * allocated in @a result_pool. + * + * Use @a scratch_pool for temporary allocations. + */ +svn_error_t * +svn_wc_get_prop_diffs2(apr_array_header_t **propchanges, + apr_hash_t **original_props, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_get_prop_diffs2(), but with a #svn_wc_adm_access_t / + * relative path parameter pair. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_prop_diffs(apr_array_header_t **propchanges, + apr_hash_t **original_props, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_merging Merging + * @{ + */ + +/** The outcome of a merge carried out (or tried as a dry-run) by + * svn_wc_merge() + */ +typedef enum svn_wc_merge_outcome_t +{ + /** The working copy is (or would be) unchanged. The changes to be + * merged were already present in the working copy + */ + svn_wc_merge_unchanged, + + /** The working copy has been (or would be) changed. */ + svn_wc_merge_merged, + + /** The working copy has been (or would be) changed, but there was (or + * would be) a conflict + */ + svn_wc_merge_conflict, + + /** No merge was performed, probably because the target file was + * either absent or not under version control. + */ + svn_wc_merge_no_merge + +} svn_wc_merge_outcome_t; + +/** Given absolute paths to three fulltexts, merge the differences between + * @a left_abspath and @a right_abspath into @a target_abspath. + * It may help to know that @a left_abspath, @a right_abspath and @a + * target_abspath correspond to "OLDER", "YOURS", and "MINE", + * respectively, in the diff3 documentation. + * + * @a wc_ctx should contain a write lock for the directory containing @a + * target_abspath. + * + * This function assumes that @a left_abspath and @a right_abspath are + * in repository-normal form (linefeeds, with keywords contracted); if + * necessary, @a target_abspath is temporarily converted to this form to + * receive the changes, then translated back again. + * + * If @a target_abspath is absent, or present but not under version + * control, then set @a *merge_content_outcome to #svn_wc_merge_no_merge and + * return success without merging anything. (The reasoning is that if + * the file is not versioned, then it is probably unrelated to the + * changes being considered, so they should not be merged into it. + * Furthermore, merging into an unversioned file is a lossy operation.) + * + * @a dry_run determines whether the working copy is modified. When it + * is @c FALSE the merge will cause @a target_abspath to be modified, when + * it is @c TRUE the merge will be carried out to determine the result but + * @a target_abspath will not be modified. + * + * If @a diff3_cmd is non-NULL, then use it as the diff3 command for + * any merging; otherwise, use the built-in merge code. If @a + * merge_options is non-NULL, either pass its elements to @a diff3_cmd or + * parse it and use as options to the internal merge code (see + * svn_diff_file_options_parse()). @a merge_options must contain + * <tt>const char *</tt> elements. + * + * If @a merge_props_state is non-NULL, merge @a prop_diff into the + * working properties before merging the text. (If @a merge_props_state + * is NULL, do not merge any property changes; in this case, @a prop_diff + * is only used to help determine the text merge result.) Handle any + * conflicts as described for svn_wc_merge_props3(), with the parameters + * @a dry_run, @a conflict_func and @a conflict_baton. Return the + * outcome of the property merge in @a *merge_props_state. + * + * The outcome of the text merge is returned in @a *merge_content_outcome. If + * there is a conflict and @a dry_run is @c FALSE, then attempt to call @a + * conflict_func with @a conflict_baton (if non-NULL). If the + * conflict callback cannot resolve the conflict, then: + * + * * Put conflict markers around the conflicting regions in + * @a target_abspath, labeled with @a left_label, @a right_label, and + * @a target_label. (If any of these labels are @c NULL, default + * values will be used.) + * + * * Copy @a left_abspath, @a right_abspath, and the original @a + * target_abspath to unique names in the same directory as @a + * target_abspath, ending with the suffixes ".LEFT_LABEL", ".RIGHT_LABEL", + * and ".TARGET_LABEL" respectively. + * + * * Mark @a target_abspath as "text-conflicted", and track the above + * mentioned backup files as well. + * + * * If @a left_version and/or @a right_version are not NULL, provide + * these values to the conflict handler and track these while the conflict + * exists. + * + * Binary case: + * + * If @a target_abspath is a binary file, then no merging is attempted, + * the merge is deemed to be a conflict. If @a dry_run is @c FALSE the + * working @a target_abspath is untouched, and copies of @a left_abspath and + * @a right_abspath are created next to it using @a left_label and + * @a right_label. @a target_abspath is marked as "text-conflicted", and + * begins tracking the two backup files and the version information. + * + * If @a dry_run is @c TRUE no files are changed. The outcome of the merge + * is returned in @a *merge_content_outcome. + * ### (and what about @a *merge_props_state?) + * + * ### BH: Two kinds of outcome is not how it should be. + * + * ### For text, we report the outcome as 'merged' if there was some + * incoming change that we dealt with (even if we decided to no-op?) + * but the callers then convert this outcome into a notification + * of 'merged' only if there was already a local modification; + * otherwise they notify it as simply 'updated'. But for props + * we report a notify state of 'merged' here if there was an + * incoming change regardless of the local-mod state. Inconsistent. + * + * Use @a scratch_pool for any temporary allocation. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc_merge5(enum svn_wc_merge_outcome_t *merge_content_outcome, + enum svn_wc_notify_state_t *merge_props_state, + svn_wc_context_t *wc_ctx, + const char *left_abspath, + const char *right_abspath, + const char *target_abspath, + const char *left_label, + const char *right_label, + const char *target_label, + const svn_wc_conflict_version_t *left_version, + const svn_wc_conflict_version_t *right_version, + svn_boolean_t dry_run, + const char *diff3_cmd, + const apr_array_header_t *merge_options, + apr_hash_t *original_props, + const apr_array_header_t *prop_diff, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_merge5() but with @a merge_props_state and @a + * original_props always passed as NULL. + * + * Unlike svn_wc_merge5(), this function doesn't merge property + * changes. Callers of this function must first use + * svn_wc_merge_props3() to get this functionality. + * + * @since New in 1.7. + * @deprecated Provided for backwards compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge4(enum svn_wc_merge_outcome_t *merge_outcome, + svn_wc_context_t *wc_ctx, + const char *left_abspath, + const char *right_abspath, + const char *target_abspath, + const char *left_label, + const char *right_label, + const char *target_label, + const svn_wc_conflict_version_t *left_version, + const svn_wc_conflict_version_t *right_version, + svn_boolean_t dry_run, + const char *diff3_cmd, + const apr_array_header_t *merge_options, + const apr_array_header_t *prop_diff, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + + +/** Similar to svn_wc_merge4() but takes relative paths and an access + * baton. It doesn't support a cancel function or tracking origin version + * information. + * + * Uses a svn_wc_conflict_resolver_func_t conflict resolver instead of a + * svn_wc_conflict_resolver_func2_t. + * + * This function assumes that @a diff3_cmd is path encoded. Later versions + * assume utf-8. + * + * @since New in 1.5. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge3(enum svn_wc_merge_outcome_t *merge_outcome, + const char *left, + const char *right, + const char *merge_target, + svn_wc_adm_access_t *adm_access, + const char *left_label, + const char *right_label, + const char *target_label, + svn_boolean_t dry_run, + const char *diff3_cmd, + const apr_array_header_t *merge_options, + const apr_array_header_t *prop_diff, + svn_wc_conflict_resolver_func_t conflict_func, + void *conflict_baton, + apr_pool_t *pool); + + +/** Similar to svn_wc_merge3(), but with @a prop_diff, @a + * conflict_func, @a conflict_baton set to NULL. + * + * @deprecated Provided for backwards compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge2(enum svn_wc_merge_outcome_t *merge_outcome, + const char *left, + const char *right, + const char *merge_target, + svn_wc_adm_access_t *adm_access, + const char *left_label, + const char *right_label, + const char *target_label, + svn_boolean_t dry_run, + const char *diff3_cmd, + const apr_array_header_t *merge_options, + apr_pool_t *pool); + + +/** Similar to svn_wc_merge2(), but with @a merge_options set to NULL. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge(const char *left, + const char *right, + const char *merge_target, + svn_wc_adm_access_t *adm_access, + const char *left_label, + const char *right_label, + const char *target_label, + svn_boolean_t dry_run, + enum svn_wc_merge_outcome_t *merge_outcome, + const char *diff3_cmd, + apr_pool_t *pool); + + +/** Given a @a local_abspath under version control, merge an array of @a + * propchanges into the path's existing properties. @a propchanges is + * an array of #svn_prop_t objects, and @a baseprops is a hash + * representing the original set of properties that @a propchanges is + * working against. @a wc_ctx contains a lock for @a local_abspath. + * + * Only the working properties will be changed. + * + * If @a state is non-NULL, set @a *state to the state of the properties + * after the merge. + * + * If a conflict is found when merging a property, and @a dry_run is + * false and @a conflict_func is not null, then call @a conflict_func + * with @a conflict_baton and a description of the conflict. If any + * conflicts are not resolved by such callbacks, describe the unresolved + * conflicts in a temporary .prej file (or append to an already-existing + * .prej file) and mark the path as conflicted in the WC DB. + * + * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at various + * points during the operation. If it returns an error (typically + * #SVN_ERR_CANCELLED), return that error immediately. + * + * If @a local_abspath is not under version control, return the error + * #SVN_ERR_WC_PATH_NOT_FOUND and don't touch anyone's properties. + * + * If @a local_abspath has a status in which it doesn't have properties + * (E.g. deleted) return the error SVN_ERR_WC_PATH_UNEXPECTED_STATUS. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_merge_props3(svn_wc_notify_state_t *state, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const svn_wc_conflict_version_t *left_version, + const svn_wc_conflict_version_t *right_version, + apr_hash_t *baseprops, + const apr_array_header_t *propchanges, + svn_boolean_t dry_run, + svn_wc_conflict_resolver_func2_t conflict_func, + void *conflict_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + + +/** Similar to svn_wc_merge_props3, but takes an access baton and relative + * path, no cancel_function, and no left and right version. + * + * This function has the @a base_merge parameter which (when TRUE) will + * apply @a propchanges to this node's pristine set of properties. This + * functionality is not supported since API version 1.7 and will give an + * error if requested (unless @a dry_run is TRUE). For details see + * 'notes/api-errata/1.7/wc006.txt'. + * + * Uses a svn_wc_conflict_resolver_func_t conflict resolver instead of a + * svn_wc_conflict_resolver_func2_t. + * + * For compatibility reasons this function returns + * #SVN_ERR_UNVERSIONED_RESOURCE, when svn_wc_merge_props3 would return either + * #SVN_ERR_WC_PATH_NOT_FOUND or #SVN_ERR_WC_PATH_UNEXPECTED_STATUS. + * + * @since New in 1.5. The base_merge option is not supported since 1.7. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge_props2(svn_wc_notify_state_t *state, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_hash_t *baseprops, + const apr_array_header_t *propchanges, + svn_boolean_t base_merge, + svn_boolean_t dry_run, + svn_wc_conflict_resolver_func_t conflict_func, + void *conflict_baton, + apr_pool_t *pool); + + +/** + * Same as svn_wc_merge_props2(), but with a @a conflict_func (and + * baton) of NULL. + * + * @since New in 1.3. The base_merge option is not supported since 1.7. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge_props(svn_wc_notify_state_t *state, + const char *path, + svn_wc_adm_access_t *adm_access, + apr_hash_t *baseprops, + const apr_array_header_t *propchanges, + svn_boolean_t base_merge, + svn_boolean_t dry_run, + apr_pool_t *pool); + + +/** + * Similar to svn_wc_merge_props(), but no baseprops are given. + * Instead, it's assumed that the incoming propchanges are based + * against the working copy's own baseprops. While this assumption is + * correct for 'svn update', it's incorrect for 'svn merge', and can + * cause flawed behavior. (See issue #2035.) + * + * @since The base_merge option is not supported since 1.7. + * @deprecated Provided for backward compatibility with the 1.2 API. + * Replaced by svn_wc_merge_props(). + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_merge_prop_diffs(svn_wc_notify_state_t *state, + const char *path, + svn_wc_adm_access_t *adm_access, + const apr_array_header_t *propchanges, + svn_boolean_t base_merge, + svn_boolean_t dry_run, + apr_pool_t *pool); + +/** @} */ + + +/** Given a @a path to a wc file, return in @a *contents a readonly stream to + * the pristine contents of the file that would serve as base content for the + * next commit. That means: + * + * When there is no change in node history scheduled, i.e. when there are only + * local text-mods, prop-mods or a delete, return the last checked-out or + * updated-/switched-to contents of the file. + * + * If the file is simply added or replaced (no copy-/move-here involved), + * set @a *contents to @c NULL. + * + * When the file has been locally copied-/moved-here, return the contents of + * the copy/move source (even if the copy-/move-here replaces a locally + * deleted file). + * + * If @a local_abspath refers to an unversioned or non-existing path, return + * @c SVN_ERR_WC_PATH_NOT_FOUND. Use @a wc_ctx to access the working copy. + * @a contents may not be @c NULL (unlike @a *contents). + * + * @since New in 1.7. */ +svn_error_t * +svn_wc_get_pristine_contents2(svn_stream_t **contents, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_get_pristine_contents2, but takes no working copy + * context and a path that can be relative + * + * @since New in 1.6. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_pristine_contents(svn_stream_t **contents, + const char *path, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Set @a *pristine_path to the path of the "normal" pristine text file for + * the versioned file @a path. + * + * If @a path does not have a pristine text, set @a *pristine_path to a path where + * nothing exists on disk (in a directory that does exist). + * + * @note: Before version 1.7, the behaviour in that case was to provide the + * path where the pristine text *would be* if it were present. The new + * behaviour is intended to provide backward compatibility for callers that + * open or test the provided path immediately, and not for callers that + * store the path for later use. + * + * @deprecated Provided for backwards compatibility with the 1.5 API. + * Callers should use svn_wc_get_pristine_contents() instead. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_pristine_copy_path(const char *path, + const char **pristine_path, + apr_pool_t *pool); + + +/** + * Recurse from @a local_abspath, cleaning up unfinished log business. Perform + * any temporary allocations in @a scratch_pool. Any working copy locks under + * @a local_abspath will be taken over and then cleared by this function. + * + * WARNING: there is no mechanism that will protect locks that are still being + * used. + * + * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at various + * points during the operation. If it returns an error (typically + * #SVN_ERR_CANCELLED), return that error immediately. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_cleanup3(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_cleanup3() but uses relative paths and creates its own + * #svn_wc_context_t. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_cleanup2(const char *path, + const char *diff3_cmd, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_cleanup2(). @a optional_adm_access is an historic + * relic and not used, it may be NULL. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_cleanup(const char *path, + svn_wc_adm_access_t *optional_adm_access, + const char *diff3_cmd, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Callback for retrieving a repository root for a url from upgrade. + * + * Called by svn_wc_upgrade() when no repository root and/or repository + * uuid are recorded in the working copy. For normal Subversion 1.5 and + * later working copies, this callback will not be used. + * + * @since New in 1.7. + */ +typedef svn_error_t * (*svn_wc_upgrade_get_repos_info_t)( + const char **repos_root, + const char **repos_uuid, + void *baton, + const char *url, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** + * Upgrade the working copy at @a local_abspath to the latest metadata + * storage format. @a local_abspath should be an absolute path to the + * root of the working copy. + * + * If @a cancel_func is non-NULL, invoke it with @a cancel_baton at + * various points during the operation. If it returns an error + * (typically #SVN_ERR_CANCELLED), return that error immediately. + * + * For each directory converted, @a notify_func will be called with + * in @a notify_baton action #svn_wc_notify_upgraded_path and as path + * the path of the upgraded directory. @a notify_func may be @c NULL + * if this notification is not needed. + * + * If the old working copy doesn't contain a repository root and/or + * repository uuid, @a repos_info_func (if non-NULL) will be called + * with @a repos_info_baton to provide the missing information. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_upgrade(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_wc_upgrade_get_repos_info_t repos_info_func, + void *repos_info_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/** Relocation validation callback typedef. + * + * Called for each relocated file/directory. @a uuid, if non-NULL, contains + * the expected repository UUID, @a url contains the tentative URL. + * + * @a baton is a closure object; it should be provided by the + * implementation, and passed by the caller. + * + * If @a root_url is passed, then the implementation should make sure that + * @a url is the repository root. + * @a pool may be used for temporary allocations. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_wc_relocation_validator3_t)(void *baton, + const char *uuid, + const char *url, + const char *root_url, + apr_pool_t *pool); + +/** Similar to #svn_wc_relocation_validator3_t, but with + * the @a root argument. + * + * If @a root is TRUE, then the implementation should make sure that @a url + * is the repository root. Else, it can be a URL inside the repository. + * + * @deprecated Provided for backwards compatibility with the 1.4 API. + */ +typedef svn_error_t *(*svn_wc_relocation_validator2_t)(void *baton, + const char *uuid, + const char *url, + svn_boolean_t root, + apr_pool_t *pool); + +/** Similar to #svn_wc_relocation_validator2_t, but without + * the @a root and @a pool arguments. @a uuid will not be NULL in this version + * of the function. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +typedef svn_error_t *(*svn_wc_relocation_validator_t)(void *baton, + const char *uuid, + const char *url); + +/** Recursively change repository references at @a wcroot_abspath + * (which is the root directory of a working copy). The pre-change + * URL should begin with @a from, and the post-change URL will begin + * with @a to. @a validator (and its baton, @a validator_baton), will + * be called for the newly generated base URL and calculated repo + * root. + * + * @a wc_ctx is an working copy context. + * + * @a scratch_pool will be used for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_relocate4(svn_wc_context_t *wc_ctx, + const char *wcroot_abspath, + const char *from, + const char *to, + svn_wc_relocation_validator3_t validator, + void *validator_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_relocate4(), but with a #svn_wc_adm_access_t / + * relative path parameter pair. + * + * @note As of the 1.7 API, @a path is required to be a working copy + * root directory, and @a recurse is required to be TRUE. + * + * @since New in 1.5. + * @deprecated Provided for limited backwards compatibility with the + * 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_relocate3(const char *path, + svn_wc_adm_access_t *adm_access, + const char *from, + const char *to, + svn_boolean_t recurse, + svn_wc_relocation_validator3_t validator, + void *validator_baton, + apr_pool_t *pool); + +/** Similar to svn_wc_relocate3(), but uses #svn_wc_relocation_validator2_t. + * + * @since New in 1.4. + * @deprecated Provided for backwards compatibility with the 1.4 API. */ +SVN_DEPRECATED +svn_error_t * +svn_wc_relocate2(const char *path, + svn_wc_adm_access_t *adm_access, + const char *from, + const char *to, + svn_boolean_t recurse, + svn_wc_relocation_validator2_t validator, + void *validator_baton, + apr_pool_t *pool); + +/** Similar to svn_wc_relocate2(), but uses #svn_wc_relocation_validator_t. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. */ +SVN_DEPRECATED +svn_error_t * +svn_wc_relocate(const char *path, + svn_wc_adm_access_t *adm_access, + const char *from, + const char *to, + svn_boolean_t recurse, + svn_wc_relocation_validator_t validator, + void *validator_baton, + apr_pool_t *pool); + + +/** + * Revert changes to @a local_abspath. Perform necessary allocations in + * @a scratch_pool. + * + * @a wc_ctx contains the necessary locks required for performing the + * operation. + * + * If @a depth is #svn_depth_empty, revert just @a path (if a + * directory, then revert just the properties on that directory). + * Else if #svn_depth_files, revert @a path and any files + * directly under @a path if it is directory. Else if + * #svn_depth_immediates, revert all of the preceding plus + * properties on immediate subdirectories; else if #svn_depth_infinity, + * revert path and everything under it fully recursively. + * + * @a changelist_filter is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items reverted; that is, + * don't revert any item unless it's a member of one of those + * changelists. If @a changelist_filter is empty (or altogether @c NULL), + * no changelist filtering occurs. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton at + * various points during the reversion process. If it returns an + * error (typically #SVN_ERR_CANCELLED), return that error + * immediately. + * + * If @a use_commit_times is TRUE, then all reverted working-files + * will have their timestamp set to the last-committed-time. If + * FALSE, the reverted working-files will be touched with the 'now' time. + * + * For each item reverted, @a notify_func will be called with @a notify_baton + * and the path of the reverted item. @a notify_func may be @c NULL if this + * notification is not needed. + * + * If @a path is not under version control, return the error + * #SVN_ERR_UNVERSIONED_RESOURCE. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_revert4(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + svn_boolean_t use_commit_times, + const apr_array_header_t *changelist_filter, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_revert4() but takes a relative path and access baton. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_revert3(const char *path, + svn_wc_adm_access_t *parent_access, + svn_depth_t depth, + svn_boolean_t use_commit_times, + const apr_array_header_t *changelist_filter, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_revert3(), but with @a changelist_filter passed as @c + * NULL, and @a depth set according to @a recursive: if @a recursive + * is TRUE, @a depth is #svn_depth_infinity; if FALSE, @a depth is + * #svn_depth_empty. + * + * @note Most APIs map @a recurse==FALSE to @a depth==svn_depth_files; + * revert is deliberately different. + * + * @since New in 1.2. + * @deprecated Provided for backward compatibility with the 1.4 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_revert2(const char *path, + svn_wc_adm_access_t *parent_access, + svn_boolean_t recursive, + svn_boolean_t use_commit_times, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Similar to svn_wc_revert2(), but takes an #svn_wc_notify_func_t instead. + * + * @deprecated Provided for backward compatibility with the 1.1 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_revert(const char *path, + svn_wc_adm_access_t *parent_access, + svn_boolean_t recursive, + svn_boolean_t use_commit_times, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool); + +/** + * Restores a missing node, @a local_abspath using the @a wc_ctx. Records + * the new last modified time of the file for status processing. + * + * If @a use_commit_times is TRUE, then set restored files' timestamps + * to their last-commit-times. + * + * Returns SVN_ERROR_WC_PATH_NOT_FOUND if LOCAL_ABSPATH is not versioned and + * SVN_ERROR_WC_PATH_UNEXPECTED_STATUS if LOCAL_ABSPATH is in a status where + * it can't be restored. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_restore(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t use_commit_times, + apr_pool_t *scratch_pool); + + +/* Tmp files */ + +/** Create a unique temporary file in administrative tmp/ area of + * directory @a path. Return a handle in @a *fp and the path + * in @a *new_name. Either @a fp or @a new_name can be NULL. + * + * The flags will be <tt>APR_WRITE | APR_CREATE | APR_EXCL</tt> and + * optionally @c APR_DELONCLOSE (if the @a delete_when argument is + * set to #svn_io_file_del_on_close). + * + * This means that as soon as @a fp is closed, the tmp file will vanish. + * + * @since New in 1.4 + * @deprecated For compatibility with 1.6 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_create_tmp_file2(apr_file_t **fp, + const char **new_name, + const char *path, + svn_io_file_del_t delete_when, + apr_pool_t *pool); + + +/** Same as svn_wc_create_tmp_file2(), but with @a new_name set to @c NULL, + * and without the ability to delete the file on pool cleanup. + * + * @deprecated For compatibility with 1.3 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_create_tmp_file(apr_file_t **fp, + const char *path, + svn_boolean_t delete_on_close, + apr_pool_t *pool); + + +/** + * @defgroup svn_wc_translate EOL conversion and keyword expansion + * @{ + */ + + +/** Set @a xlated_path to a translated copy of @a src + * or to @a src itself if no translation is necessary. + * That is, if @a versioned_file's properties indicate newline conversion or + * keyword expansion, point @a *xlated_path to a copy of @a src + * whose newlines and keywords are converted using the translation + * as requested by @a flags. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client has canceled the operation. + * + * When translating to the normal form, inconsistent eol styles will be + * repaired when appropriate for the given setting. When translating + * from normal form, no EOL repair is performed (consistency is assumed). + * This behaviour can be overridden by specifying + * #SVN_WC_TRANSLATE_FORCE_EOL_REPAIR. + * + * The caller can explicitly request a new file to be returned by setting the + * #SVN_WC_TRANSLATE_FORCE_COPY flag in @a flags. + * + * This function is generally used to get a file that can be compared + * meaningfully against @a versioned_file's text base, if + * @c SVN_WC_TRANSLATE_TO_NF is specified, against @a versioned_file itself + * if @c SVN_WC_TRANSLATE_FROM_NF is specified. + * + * If a new output file is created, it is created in the temp file area + * belonging to @a versioned_file. By default it will be deleted at pool + * cleanup. If @c SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP is specified, the + * default pool cleanup handler to remove @a *xlated_path is not registered. + * If the input file is returned as the output, its lifetime is not + * specified. + * + * If an error is returned, the effect on @a *xlated_path is undefined. + * + * @since New in 1.4 + * @deprecated Provided for compatibility with the 1.6 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_translated_file2(const char **xlated_path, + const char *src, + const char *versioned_file, + svn_wc_adm_access_t *adm_access, + apr_uint32_t flags, + apr_pool_t *pool); + + +/** Same as svn_wc_translated_file2, but will never clean up + * temporary files. + * + * @deprecated Provided for compatibility with the 1.3 API + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_translated_file(const char **xlated_p, + const char *vfile, + svn_wc_adm_access_t *adm_access, + svn_boolean_t force_repair, + apr_pool_t *pool); + + +/** Returns a @a stream allocated in @a pool with access to the given + * @a path taking the file properties from @a versioned_file using + * @a adm_access. + * + * If @a flags includes #SVN_WC_TRANSLATE_FROM_NF, the stream will + * translate from Normal Form to working copy form while writing to + * @a path; stream read operations are not supported. + * Conversely, if @a flags includes #SVN_WC_TRANSLATE_TO_NF, the stream will + * translate from working copy form to Normal Form while reading from + * @a path; stream write operations are not supported. + * + * The @a flags are the same constants as those used for + * svn_wc_translated_file2(). + * + * @since New in 1.5. + * @deprecated Provided for compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_translated_stream(svn_stream_t **stream, + const char *path, + const char *versioned_file, + svn_wc_adm_access_t *adm_access, + apr_uint32_t flags, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_deltas Text/Prop Deltas Using an Editor + * @{ + */ + +/** Send the local modifications for versioned file @a local_abspath (with + * matching @a file_baton) through @a editor, then close @a file_baton + * afterwards. Use @a scratch_pool for any temporary allocation. + * + * If @a new_text_base_md5_checksum is non-NULL, set + * @a *new_text_base_md5_checksum to the MD5 checksum of (@a local_abspath + * translated to repository-normal form), allocated in @a result_pool. + * + * If @a new_text_base_sha1_checksum in non-NULL, store a copy of (@a + * local_abspath translated to repository-normal form) in the pristine text + * store, and set @a *new_text_base_sha1_checksum to its SHA-1 checksum. + * + * If @a fulltext, send the untranslated copy of @a local_abspath through + * @a editor as full-text; else send it as svndiff against the current text + * base. + * + * If sending a diff, and the recorded checksum for @a local_abspath's + * text-base does not match the current actual checksum, then remove the tmp + * copy (and set @a *tempfile to NULL if appropriate), and return the + * error #SVN_ERR_WC_CORRUPT_TEXT_BASE. + * + * @note This is intended for use with both infix and postfix + * text-delta styled editor drivers. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_transmit_text_deltas3(const svn_checksum_t **new_text_base_md5_checksum, + const svn_checksum_t **new_text_base_sha1_checksum, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t fulltext, + const svn_delta_editor_t *editor, + void *file_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_transmit_text_deltas3(), but with a relative path + * and adm_access baton, and the checksum output is an MD5 digest instead of + * two svn_checksum_t objects. + * + * If @a tempfile is non-NULL, make a copy of @a path with keywords + * and eol translated to repository-normal form, and set @a *tempfile to the + * absolute path to this copy, allocated in @a result_pool. The copy will + * be in the temporary-text-base directory. Do not clean up the copy; + * caller can do that. (The purpose of handing back the tmp copy is that it + * is usually about to become the new text base anyway, but the installation + * of the new text base is outside the scope of this function.) + * + * @since New in 1.4. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_transmit_text_deltas2(const char **tempfile, + unsigned char digest[], + const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t fulltext, + const svn_delta_editor_t *editor, + void *file_baton, + apr_pool_t *pool); + +/** Similar to svn_wc_transmit_text_deltas2(), but with @a digest set to NULL. + * + * @deprecated Provided for backwards compatibility with the 1.3 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_transmit_text_deltas(const char *path, + svn_wc_adm_access_t *adm_access, + svn_boolean_t fulltext, + const svn_delta_editor_t *editor, + void *file_baton, + const char **tempfile, + apr_pool_t *pool); + + +/** Given a @a local_abspath, transmit all local property + * modifications using the appropriate @a editor method (in conjunction + * with @a baton). Use @a scratch_pool for any temporary allocation. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_transmit_prop_deltas2(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const svn_delta_editor_t *editor, + void *baton, + apr_pool_t *scratch_pool); + + +/** Similar to svn_wc_transmit_prop_deltas2(), but with a relative path, + * adm_access baton and tempfile. + * + * If a temporary file remains after this function is finished, the + * path to that file is returned in @a *tempfile (so the caller can + * clean this up if it wishes to do so). + * + * @note Starting version 1.5, no tempfile will ever be returned + * anymore. If @a *tempfile is passed, its value is set to @c NULL. + * + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_transmit_prop_deltas(const char *path, + svn_wc_adm_access_t *adm_access, + const svn_wc_entry_t *entry, + const svn_delta_editor_t *editor, + void *baton, + const char **tempfile, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_ignore Ignoring unversioned files and directories + * @{ + */ + +/** Get the run-time configured list of ignore patterns from the + * #svn_config_t's in the @a config hash, and store them in @a *patterns. + * Allocate @a *patterns and its contents in @a pool. + */ +svn_error_t * +svn_wc_get_default_ignores(apr_array_header_t **patterns, + apr_hash_t *config, + apr_pool_t *pool); + +/** Get the list of ignore patterns from the #svn_config_t's in the + * @a config hash and the local ignore patterns from the directory + * at @a local_abspath, using @a wc_ctx, and store them in @a *patterns. + * Allocate @a *patterns and its contents in @a result_pool, use @a + * scratch_pool for temporary allocations. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_get_ignores2(apr_array_header_t **patterns, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_hash_t *config, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_get_ignores2(), but with a #svn_wc_adm_access_t + * parameter in place of #svn_wc_context_t and @c local_abspath parameters. + * + * @since New in 1.3. + * @deprecated Provided for backwards compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_get_ignores(apr_array_header_t **patterns, + apr_hash_t *config, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** Return TRUE iff @a str matches any of the elements of @a list, a + * list of zero or more ignore patterns. + * + * @since New in 1.5. + */ +svn_boolean_t +svn_wc_match_ignore_list(const char *str, + const apr_array_header_t *list, + apr_pool_t *pool); + +/** @} */ + + +/** + * @defgroup svn_wc_repos_locks Repository locks + * @{ + */ + +/** Add @a lock to the working copy for @a local_abspath. If @a + * local_abspath is read-only, due to locking properties, make it writable. + * Perform temporary allocations in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_add_lock2(svn_wc_context_t *wc_ctx, + const char *abspath, + const svn_lock_t *lock, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_add_lock2(), but with a #svn_wc_adm_access_t / + * relative path parameter pair. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_add_lock(const char *path, + const svn_lock_t *lock, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** Remove any lock from @a local_abspath. If @a local_abspath has a + * lock and the locking so specifies, make the file read-only. Don't + * return an error if @a local_abspath didn't have a lock. Perform temporary + * allocations in @a scratch_pool. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_remove_lock2(svn_wc_context_t *wc_ctx, + const char *local_abspath, + apr_pool_t *scratch_pool); + +/** + * Similar to svn_wc_remove_lock2(), but with a #svn_wc_adm_access_t / + * relative path parameter pair. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + * @since New in 1.2. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_remove_lock(const char *path, + svn_wc_adm_access_t *adm_access, + apr_pool_t *pool); + +/** @} */ + + +/** A structure to report a summary of a working copy, including the + * mix of revisions found within it, whether any parts are switched or + * locally modified, and whether it is a sparse checkout. + * + * @note Fields may be added to the end of this structure in future + * versions. Therefore, to preserve binary compatibility, users + * should not directly allocate structures of this type. + * + * @since New in 1.4 + */ +typedef struct svn_wc_revision_status_t +{ + svn_revnum_t min_rev; /**< Lowest revision found */ + svn_revnum_t max_rev; /**< Highest revision found */ + + svn_boolean_t switched; /**< Is anything switched? */ + svn_boolean_t modified; /**< Is anything modified? */ + + /** Whether any WC paths are at a depth other than #svn_depth_infinity. + * @since New in 1.5. + */ + svn_boolean_t sparse_checkout; +} svn_wc_revision_status_t; + +/** Set @a *result_p to point to a new #svn_wc_revision_status_t structure + * containing a summary of the revision range and status of the working copy + * at @a local_abspath (not including "externals"). @a local_abspath must + * be absolute. Return SVN_ERR_WC_PATH_NOT_FOUND if @a local_abspath is not + * a working copy path. + * + * Set @a (*result_p)->min_rev and @a (*result_p)->max_rev respectively to the + * lowest and highest revision numbers in the working copy. If @a committed + * is TRUE, summarize the last-changed revisions, else the base revisions. + * + * Set @a (*result_p)->switched to indicate whether any item in the WC is + * switched relative to its parent. If @a trail_url is non-NULL, use it to + * determine if @a local_abspath itself is switched. It should be any trailing + * portion of @a local_abspath's expected URL, long enough to include any parts + * that the caller considers might be changed by a switch. If it does not + * match the end of @a local_abspath's actual URL, then report a "switched" + * status. + * + * Set @a (*result_p)->modified to indicate whether any item is locally + * modified. + * + * If @a cancel_func is non-NULL, call it with @a cancel_baton to determine + * if the client has canceled the operation. + * + * Allocate *result_p in @a result_pool, use @a scratch_pool for temporary + * allocations. + * + * @a wc_ctx should be a valid working copy context. + * + * @since New in 1.7 + */ +svn_error_t * +svn_wc_revision_status2(svn_wc_revision_status_t **result_p, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *trail_url, + svn_boolean_t committed, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + +/** Similar to svn_wc_revision_status2(), but with a (possibly) local + * path and no wc_ctx parameter. + * + * @since New in 1.4. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_revision_status(svn_wc_revision_status_t **result_p, + const char *wc_path, + const char *trail_url, + svn_boolean_t committed, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + + +/** + * Set @a local_abspath's 'changelist' attribute to @a changelist iff + * @a changelist is not @c NULL; otherwise, remove any current + * changelist assignment from @a local_abspath. @a changelist may not + * be the empty string. Recurse to @a depth. + * + * @a changelist_filter is an array of <tt>const char *</tt> changelist + * names, used as a restrictive filter on items whose changelist + * assignments are adjusted; that is, don't tweak the changeset of any + * item unless it's currently a member of one of those changelists. + * If @a changelist_filter is empty (or altogether @c NULL), no changelist + * filtering occurs. + * + * If @a cancel_func is not @c NULL, call it with @a cancel_baton to + * determine if the client has canceled the operation. + * + * If @a notify_func is not @c NULL, call it with @a notify_baton to + * report the change (using notification types + * #svn_wc_notify_changelist_set and #svn_wc_notify_changelist_clear). + * + * Use @a scratch_pool for temporary allocations. + * + * @note For now, directories are NOT allowed to be associated with + * changelists; there is confusion about whether they should behave + * as depth-0 or depth-infinity objects. If @a local_abspath is a directory, + * return an error. + * + * @note This metadata is purely a client-side "bookkeeping" + * convenience, and is entirely managed by the working copy. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_set_changelist2(svn_wc_context_t *wc_ctx, + const char *local_abspath, + const char *changelist, + svn_depth_t depth, + const apr_array_header_t *changelist_filter, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_set_changelist2(), but with an access baton and + * relative path. + * + * @since New in 1.5. + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_set_changelist(const char *path, + const char *changelist, + svn_wc_adm_access_t *adm_access, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *pool); + + + +/** + * The callback type used by svn_wc_get_changelists() and + * svn_client_get_changelists(). + * + * On each invocation, @a path is a newly discovered member of the + * changelist, and @a baton is a private function closure. + * + * @since New in 1.5. + */ +typedef svn_error_t *(*svn_changelist_receiver_t) (void *baton, + const char *path, + const char *changelist, + apr_pool_t *pool); + + +/** + * ### TODO: Doc string, please. + * + * @since New in 1.7. + */ +svn_error_t * +svn_wc_get_changelists(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + const apr_array_header_t *changelist_filter, + svn_changelist_receiver_t callback_func, + void *callback_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); + + +/** Crop @a local_abspath according to @a depth. + * + * Remove any item that exceeds the boundary of @a depth (relative to + * @a local_abspath) from revision control. Leave modified items behind + * (unversioned), while removing unmodified ones completely. + * + * @a depth can be svn_depth_empty, svn_depth_files or svn_depth_immediates. + * Excluding nodes is handled by svn_wc_exclude(). + * + * If @a local_abspath starts out with a shallower depth than @a depth, + * do not upgrade it to @a depth (that would not be cropping); however, do + * check children and crop them appropriately according to @a depth. + * + * Returns immediately with an #SVN_ERR_UNSUPPORTED_FEATURE error if @a + * local_abspath is not a directory, or if @a depth is not restrictive + * (e.g., #svn_depth_infinity). + * + * @a wc_ctx contains a tree lock, for the local path to the working copy + * which will be used as the root of this operation. + * + * If @a cancel_func is not @c NULL, call it with @a cancel_baton at + * various points to determine if the client has canceled the operation. + * + * If @a notify_func is not @c NULL, call it with @a notify_baton to + * report changes as they are made. + * + * @since New in 1.7 + */ +svn_error_t * +svn_wc_crop_tree2(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_depth_t depth, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_crop_tree2(), but uses an access baton and target. + * + * svn_wc_crop_tree() also allows #svn_depth_exclude, which is now + * handled via svn_wc_exclude() + * + * @a target is a basename in @a anchor or "" for @a anchor itself. + * + * @since New in 1.6 + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_crop_tree(svn_wc_adm_access_t *anchor, + const char *target, + svn_depth_t depth, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *pool); + +/** Remove the local node for @a local_abspath from the working copy and + * add an excluded node placeholder in its place. + * + * This feature is only supported for unmodified nodes. An + * #SVN_ERR_UNSUPPORTED_FEATURE error is returned if the node can't be + * excluded in its current state. + * + * @a wc_ctx contains a tree lock, for the local path to the working copy + * which will be used as the root of this operation + * + * If @a notify_func is not @c NULL, call it with @a notify_baton to + * report changes as they are made. + * + * If @a cancel_func is not @c NULL, call it with @a cancel_baton at + * various points to determine if the client has canceled the operation. + * + * + * @since New in 1.7 + */ +svn_error_t * +svn_wc_exclude(svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_cancel_func_t cancel_func, + void *cancel_baton, + svn_wc_notify_func2_t notify_func, + void *notify_baton, + apr_pool_t *scratch_pool); + + +/** @} */ + +/** + * Set @a kind to the #svn_node_kind_t of @a abspath. Use @a wc_ctx to access + * the working copy, and @a scratch_pool for all temporary allocations. + * + * If @a abspath is not under version control, set @a kind to #svn_node_none. + * + * If @a show_hidden and @a show_deleted are both @c FALSE, the kind of + * scheduled for delete, administrative only 'not present' and excluded + * nodes is reported as #svn_node_none. This is recommended as a check + * for 'is there a versioned file or directory here?' + * + * If @a show_deleted is FALSE, but @a show_hidden is @c TRUE then only + * scheduled for delete and administrative only 'not present' nodes are + * reported as #svn_node_none. This is recommended as check for + * 'Can I add a node here?' + * + * If @a show_deleted is TRUE, but @a show_hidden is FALSE, then only + * administrative only 'not present' nodes and excluded nodes are reported as + * #svn_node_none. This behavior is the behavior bescribed as 'hidden' + * before Subversion 1.7. + * + * If @a show_hidden and @a show_deleted are both @c TRUE all nodes are + * reported. + * + * @since New in 1.8. + */ +svn_error_t * +svn_wc_read_kind2(svn_node_kind_t *kind, + svn_wc_context_t *wc_ctx, + const char *local_abspath, + svn_boolean_t show_deleted, + svn_boolean_t show_hidden, + apr_pool_t *scratch_pool); + +/** Similar to svn_wc_read_kind2() but with @a show_deleted always + * passed as TRUE. + * + * @since New in 1.7. + * @deprecated Provided for backward compatibility with the 1.7 API. + */ +SVN_DEPRECATED +svn_error_t * +svn_wc_read_kind(svn_node_kind_t *kind, + svn_wc_context_t *wc_ctx, + const char *abspath, + svn_boolean_t show_hidden, + apr_pool_t *scratch_pool); + + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_WC_H */ diff --git a/subversion/include/svn_xml.h b/subversion/include/svn_xml.h new file mode 100644 index 0000000..90969be --- /dev/null +++ b/subversion/include/svn_xml.h @@ -0,0 +1,381 @@ +/** + * @copyright + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * @endcopyright + * + * @file svn_xml.h + * @brief XML code shared by various Subversion libraries. + */ + +#ifndef SVN_XML_H +#define SVN_XML_H + +#include <apr.h> +#include <apr_pools.h> +#include <apr_hash.h> + +#include "svn_types.h" +#include "svn_string.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** The namespace all Subversion XML uses. */ +#define SVN_XML_NAMESPACE "svn:" + +/** Used as style argument to svn_xml_make_open_tag() and friends. */ +enum svn_xml_open_tag_style { + /** <tag ...> */ + svn_xml_normal = 1, + + /** <tag ...>, no cosmetic newline */ + svn_xml_protect_pcdata, + + /** <tag .../> */ + svn_xml_self_closing +}; + + + +/** Determine if a string of character @a data of length @a len is a + * safe bet for use with the svn_xml_escape_* functions found in this + * header. + * + * Return @c TRUE if it is, @c FALSE otherwise. + * + * Essentially, this function exists to determine whether or not + * simply running a string of bytes through the Subversion XML escape + * routines will produce legitimate XML. It should only be necessary + * for data which might contain bytes that cannot be safely encoded + * into XML (certain control characters, for example). + */ +svn_boolean_t +svn_xml_is_xml_safe(const char *data, + apr_size_t len); + +/** Create or append in @a *outstr an xml-escaped version of @a string, + * suitable for output as character data. + * + * If @a *outstr is @c NULL, set @a *outstr to a new stringbuf allocated + * in @a pool, else append to the existing stringbuf there. + */ +void +svn_xml_escape_cdata_stringbuf(svn_stringbuf_t **outstr, + const svn_stringbuf_t *string, + apr_pool_t *pool); + +/** Same as svn_xml_escape_cdata_stringbuf(), but @a string is an + * @c svn_string_t. + */ +void +svn_xml_escape_cdata_string(svn_stringbuf_t **outstr, + const svn_string_t *string, + apr_pool_t *pool); + +/** Same as svn_xml_escape_cdata_stringbuf(), but @a string is a + * NULL-terminated C string. + */ +void +svn_xml_escape_cdata_cstring(svn_stringbuf_t **outstr, + const char *string, + apr_pool_t *pool); + + +/** Create or append in @a *outstr an xml-escaped version of @a string, + * suitable for output as an attribute value. + * + * If @a *outstr is @c NULL, set @a *outstr to a new stringbuf allocated + * in @a pool, else append to the existing stringbuf there. + */ +void +svn_xml_escape_attr_stringbuf(svn_stringbuf_t **outstr, + const svn_stringbuf_t *string, + apr_pool_t *pool); + +/** Same as svn_xml_escape_attr_stringbuf(), but @a string is an + * @c svn_string_t. + */ +void +svn_xml_escape_attr_string(svn_stringbuf_t **outstr, + const svn_string_t *string, + apr_pool_t *pool); + +/** Same as svn_xml_escape_attr_stringbuf(), but @a string is a + * NULL-terminated C string. + */ +void +svn_xml_escape_attr_cstring(svn_stringbuf_t **outstr, + const char *string, + apr_pool_t *pool); + +/** + * Return UTF-8 string @a string if it contains no characters that are + * unrepresentable in XML. Else, return a copy of @a string, + * allocated in @a pool, with each unrepresentable character replaced + * by "?\uuu", where "uuu" is the three-digit unsigned decimal value + * of that character. + * + * Neither the input nor the output need be valid XML; however, the + * output can always be safely XML-escaped. + * + * @note The current implementation treats all Unicode characters as + * representable, except for most ASCII control characters (the + * exceptions being CR, LF, and TAB, which are valid in XML). There + * may be other UTF-8 characters that are invalid in XML; see + * http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=90591 + * and its thread for details. + * + * @since New in 1.2. + */ +const char * +svn_xml_fuzzy_escape(const char *string, + apr_pool_t *pool); + + +/*---------------------------------------------------------------*/ + +/* Generalized Subversion XML Parsing */ + +/** A generalized Subversion XML parser object */ +typedef struct svn_xml_parser_t svn_xml_parser_t; + +typedef void (*svn_xml_start_elem)(void *baton, + const char *name, + const char **atts); + +typedef void (*svn_xml_end_elem)(void *baton, const char *name); + +/* data is not NULL-terminated. */ +typedef void (*svn_xml_char_data)(void *baton, + const char *data, + apr_size_t len); + + +/** Create a general Subversion XML parser */ +svn_xml_parser_t * +svn_xml_make_parser(void *baton, + svn_xml_start_elem start_handler, + svn_xml_end_elem end_handler, + svn_xml_char_data data_handler, + apr_pool_t *pool); + + +/** Free a general Subversion XML parser */ +void +svn_xml_free_parser(svn_xml_parser_t *svn_parser); + + +/** Push @a len bytes of xml data in @a buf at @a svn_parser. + * + * If this is the final push, @a is_final must be set. + * + * An error will be returned if there was a syntax problem in the XML, + * or if any of the callbacks set an error using + * svn_xml_signal_bailout(). + * + * If an error is returned, the @c svn_xml_parser_t will have been freed + * automatically, so the caller should not call svn_xml_free_parser(). + */ +svn_error_t * +svn_xml_parse(svn_xml_parser_t *svn_parser, + const char *buf, + apr_size_t len, + svn_boolean_t is_final); + + + +/** The way to officially bail out of xml parsing. + * + * Store @a error in @a svn_parser and set all expat callbacks to @c NULL. + */ +void +svn_xml_signal_bailout(svn_error_t *error, + svn_xml_parser_t *svn_parser); + + + + + +/*** Helpers for dealing with the data Expat gives us. ***/ + +/** Return the value associated with @a name in expat attribute array @a atts, + * else return @c NULL. + * + * (There could never be a @c NULL attribute value in the XML, + * although the empty string is possible.) + * + * @a atts is an array of c-strings: even-numbered indexes are names, + * odd-numbers hold values. If all is right, it should end on an + * even-numbered index pointing to @c NULL. + */ +const char * +svn_xml_get_attr_value(const char *name, + const char *const *atts); + + + +/* Converting between Expat attribute lists and APR hash tables. */ + + +/** Create an attribute hash from @c va_list @a ap. + * + * The contents of @a ap are alternating <tt>char *</tt> keys and + * <tt>char *</tt> vals, terminated by a final @c NULL falling on an + * even index (zero-based). + */ +apr_hash_t * +svn_xml_ap_to_hash(va_list ap, + apr_pool_t *pool); + +/** Create a hash that corresponds to Expat xml attribute list @a atts. + * + * The hash's keys and values are <tt>char *</tt>'s. + * + * @a atts may be NULL, in which case you just get an empty hash back + * (this makes life more convenient for some callers). + */ +apr_hash_t * +svn_xml_make_att_hash(const char **atts, + apr_pool_t *pool); + + +/** Like svn_xml_make_att_hash(), but takes a hash and preserves any + * key/value pairs already in it. + */ +void +svn_xml_hash_atts_preserving(const char **atts, + apr_hash_t *ht, + apr_pool_t *pool); + +/** Like svn_xml_make_att_hash(), but takes a hash and overwrites + * key/value pairs already in it that also appear in @a atts. + */ +void +svn_xml_hash_atts_overlaying(const char **atts, + apr_hash_t *ht, + apr_pool_t *pool); + + + +/* Printing XML */ + +/** Create an XML header and return it in @a *str. + * + * Fully-formed XML documents should start out with a header, + * something like <pre> + * \<?xml version="1.0" encoding="UTF-8"?\> + * </pre> + * + * This function returns such a header. @a *str must either be @c NULL, in + * which case a new string is created, or it must point to an existing + * string to be appended to. @a encoding must either be NULL, in which case + * encoding information is omitted from the header, or must be the name of + * the encoding of the XML document, such as "UTF-8". + * + * @since New in 1.7. + */ +void +svn_xml_make_header2(svn_stringbuf_t **str, + const char *encoding, + apr_pool_t *pool); + +/** Like svn_xml_make_header2(), but does not emit encoding information. + * + * @deprecated Provided for backward compatibility with the 1.6 API. + */ +SVN_DEPRECATED +void +svn_xml_make_header(svn_stringbuf_t **str, + apr_pool_t *pool); + + +/** Store a new xml tag @a tagname in @a *str. + * + * If @a *str is @c NULL, set @a *str to a new stringbuf allocated + * in @a pool, else append to the existing stringbuf there. + * + * Take the tag's attributes from varargs, a NULL-terminated list of + * alternating <tt>char *</tt> key and <tt>char *</tt> val. Do xml-escaping + * on each val. + * + * @a style is one of the enumerated styles in @c svn_xml_open_tag_style. + */ +void +svn_xml_make_open_tag(svn_stringbuf_t **str, + apr_pool_t *pool, + enum svn_xml_open_tag_style style, + const char *tagname, + ...); + + +/** Like svn_xml_make_open_tag(), but takes a @c va_list instead of being + * variadic. + */ +void +svn_xml_make_open_tag_v(svn_stringbuf_t **str, + apr_pool_t *pool, + enum svn_xml_open_tag_style style, + const char *tagname, + va_list ap); + + +/** Like svn_xml_make_open_tag(), but takes a hash table of attributes + * (<tt>char *</tt> keys mapping to <tt>char *</tt> values). + * + * You might ask, why not just provide svn_xml_make_tag_atts()? + * + * The reason is that a hash table is the most natural interface to an + * attribute list; the fact that Expat uses <tt>char **</tt> atts instead is + * certainly a defensible implementation decision, but since we'd have + * to have special code to support such lists throughout Subversion + * anyway, we might as well write that code for the natural interface + * (hashes) and then convert in the few cases where conversion is + * needed. Someday it might even be nice to change expat-lite to work + * with apr hashes. + * + * See conversion functions svn_xml_make_att_hash() and + * svn_xml_make_att_hash_overlaying(). Callers should use those to + * convert Expat attr lists into hashes when necessary. + */ +void +svn_xml_make_open_tag_hash(svn_stringbuf_t **str, + apr_pool_t *pool, + enum svn_xml_open_tag_style style, + const char *tagname, + apr_hash_t *attributes); + + +/** Store an xml close tag @a tagname in @a str. + * + * If @a *str is @c NULL, set @a *str to a new stringbuf allocated + * in @a pool, else append to the existing stringbuf there. + */ +void +svn_xml_make_close_tag(svn_stringbuf_t **str, + apr_pool_t *pool, + const char *tagname); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_XML_H */ |