1 /*
2  * entries.h :  manipulating entries
3  *
4  * ====================================================================
5  *    Licensed to the Apache Software Foundation (ASF) under one
6  *    or more contributor license agreements.  See the NOTICE file
7  *    distributed with this work for additional information
8  *    regarding copyright ownership.  The ASF licenses this file
9  *    to you under the Apache License, Version 2.0 (the
10  *    "License"); you may not use this file except in compliance
11  *    with the License.  You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *    Unless required by applicable law or agreed to in writing,
16  *    software distributed under the License is distributed on an
17  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  *    KIND, either express or implied.  See the License for the
19  *    specific language governing permissions and limitations
20  *    under the License.
21  * ====================================================================
22  */
23 
24 
25 #ifndef SVN_LIBSVN_WC_ENTRIES_H
26 #define SVN_LIBSVN_WC_ENTRIES_H
27 
28 #include <apr_pools.h>
29 
30 #include "svn_types.h"
31 
32 #include "wc_db.h"
33 #include "private/svn_sqlite.h"
34 
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
40 /** Get an ENTRY for the given LOCAL_ABSPATH.
41  *
42  * This API does not require an access baton, just a wc_db handle (DB).
43  * The requested entry MUST be present and version-controlled when
44  * ALLOW_UNVERSIONED is FALSE; otherwise, SVN_ERR_WC_PATH_NOT_FOUND is
45  * returned. When ALLOW_UNVERSIONED is TRUE, and the node is not under
46  * version control, *ENTRY will be set to NULL (this is easier for callers
47  * to handle, than detecting the error and clearing it).
48  *
49  * If you know the entry is a FILE or DIR, then specify that in KIND. If you
50  * are unsure, then specify 'svn_node_unknown' for KIND. This value will be
51  * used to optimize the access to the entry, so it is best to know the kind.
52  * If you specify FILE/DIR, and the entry is *something else*, then
53  * SVN_ERR_NODE_UNEXPECTED_KIND will be returned.
54  *
55  * If KIND == UNKNOWN, and you request the parent stub, and the node turns
56  * out to NOT be a directory, then SVN_ERR_NODE_UNEXPECTED_KIND is returned.
57  *
58  * NOTE: if SVN_ERR_NODE_UNEXPECTED_KIND is returned, then the ENTRY *IS*
59  * valid and may be examined. For any other error, ENTRY *IS NOT* valid.
60  *
61  * NOTE: if an access baton is available, then it will be examined for
62  * cached entries (and this routine may even cache them for you). It is
63  * not required, however, to do any access baton management for this API.
64  *
65  * ENTRY will be allocated in RESULT_POOL, and all temporary allocations
66  * will be performed in SCRATCH_POOL.
67  */
68 svn_error_t *
69 svn_wc__get_entry(const svn_wc_entry_t **entry,
70                   svn_wc__db_t *db,
71                   const char *local_abspath,
72                   svn_boolean_t allow_unversioned,
73                   svn_node_kind_t kind,
74                   apr_pool_t *result_pool,
75                   apr_pool_t *scratch_pool);
76 
77 /* Is ENTRY in a 'hidden' state in the sense of the 'show_hidden'
78  * switches on svn_wc_entries_read(), svn_wc_walk_entries*(), etc.? */
79 svn_error_t *
80 svn_wc__entry_is_hidden(svn_boolean_t *hidden, const svn_wc_entry_t *entry);
81 
82 
83 /* The checksums of one pre-1.7 text-base file.  If the text-base file
84  * exists, both checksums are filled in, otherwise both fields are NULL. */
85 typedef struct svn_wc__text_base_file_info_t
86 {
87   svn_checksum_t *sha1_checksum;
88   svn_checksum_t *md5_checksum;
89 } svn_wc__text_base_file_info_t;
90 
91 /* The text-base checksums of the normal base and/or the revert-base of one
92  * pre-1.7 versioned text file. */
93 typedef struct svn_wc__text_base_info_t
94 {
95   svn_wc__text_base_file_info_t normal_base;
96   svn_wc__text_base_file_info_t revert_base;
97 } svn_wc__text_base_info_t;
98 
99 /* For internal use by upgrade.c to write entries in the wc-ng format.
100    Return in DIR_BATON the baton to be passed as PARENT_BATON when
101    upgrading child directories. Pass a NULL PARENT_BATON when upgrading
102    the root directory.
103 
104    TEXT_BASES_INFO is a hash of information about all the text bases found
105    in this directory's admin area, keyed on (const char *) name of the
106    versioned file, with (svn_wc__text_base_info_t *) values. */
107 svn_error_t *
108 svn_wc__write_upgraded_entries(void **dir_baton,
109                                void *parent_baton,
110                                svn_wc__db_t *db,
111                                svn_sqlite__db_t *sdb,
112                                apr_int64_t repos_id,
113                                apr_int64_t wc_id,
114                                const char *dir_abspath,
115                                const char *new_root_abspath,
116                                apr_hash_t *entries,
117                                apr_hash_t *text_bases_info,
118                                apr_pool_t *result_pool,
119                                apr_pool_t *scratch_pool);
120 
121 /* Parse a file external specification in the NULL terminated STR and
122    place the path in PATH_RESULT, the peg revision in PEG_REV_RESULT
123    and revision number in REV_RESULT.  STR may be NULL, in which case
124    PATH_RESULT will be set to NULL and both PEG_REV_RESULT and
125    REV_RESULT set to svn_opt_revision_unspecified.
126 
127    The format that is read is the same as a working-copy path with a
128    peg revision; see svn_opt_parse_path(). */
129 svn_error_t *
130 svn_wc__unserialize_file_external(const char **path_result,
131                                   svn_opt_revision_t *peg_rev_result,
132                                   svn_opt_revision_t *rev_result,
133                                   const char *str,
134                                   apr_pool_t *pool);
135 
136 /* Serialize into STR the file external path, peg revision number and
137    the operative revision number into a format that
138    unserialize_file_external() can parse.  The format is
139      %{peg_rev}:%{rev}:%{path}
140    where a rev will either be HEAD or the string revision number.  If
141    PATH is NULL then STR will be set to NULL.  This method writes to a
142    string instead of a svn_stringbuf_t so that the string can be
143    protected by write_str(). */
144 svn_error_t *
145 svn_wc__serialize_file_external(const char **str,
146                                 const char *path,
147                                 const svn_opt_revision_t *peg_rev,
148                                 const svn_opt_revision_t *rev,
149                                 apr_pool_t *pool);
150 
151 /* Non-deprecated wrapper variant of svn_wc_entries_read used implement
152    legacy API functions. See svn_wc_entries_read for a detailed description.
153  */
154 svn_error_t *
155 svn_wc__entries_read_internal(apr_hash_t **entries,
156                               svn_wc_adm_access_t *adm_access,
157                               svn_boolean_t show_hidden,
158                               apr_pool_t *pool);
159 
160 #ifdef __cplusplus
161 }
162 #endif /* __cplusplus */
163 
164 #endif /* SVN_LIBSVN_WC_ENTRIES_H */
165