svn_mergeinfo_private.h revision 251881
1/** 2 * @copyright 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 * @endcopyright 22 * 23 * @file svn_mergeinfo_private.h 24 * @brief Subversion-internal mergeinfo APIs. 25 */ 26 27#ifndef SVN_MERGEINFO_PRIVATE_H 28#define SVN_MERGEINFO_PRIVATE_H 29 30#include <apr_pools.h> 31 32#include "svn_types.h" 33#include "svn_error.h" 34#include "svn_mergeinfo.h" 35 36#ifdef __cplusplus 37extern "C" { 38#endif /* __cplusplus */ 39 40 41/* Set inheritability of all ranges in RANGELIST to INHERITABLE. 42 If RANGELIST is NULL do nothing. */ 43void 44svn_rangelist__set_inheritance(svn_rangelist_t *rangelist, 45 svn_boolean_t inheritable); 46 47/* Parse a rangelist from the string STR. Set *RANGELIST to the result, 48 * allocated in RESULT_POOL. Return an error if the rangelist is not 49 * well-formed (for example, if it contains invalid characters or if 50 * R1 >= R2 in a "R1-R2" range element). 51 * 52 * Unlike svn_mergeinfo_parse(), this does not sort the ranges into order 53 * or combine adjacent and overlapping ranges. 54 * 55 * The compaction can be done with svn_rangelist__combine_adjacent_ranges(). 56 */ 57svn_error_t * 58svn_rangelist__parse(svn_rangelist_t **rangelist, 59 const char *str, 60 apr_pool_t *result_pool); 61 62/* In-place combines adjacent ranges in a rangelist. 63 SCRATCH_POOL is just used for providing error messages. */ 64svn_error_t * 65svn_rangelist__combine_adjacent_ranges(svn_rangelist_t *rangelist, 66 apr_pool_t *scratch_pool); 67 68/* Set inheritability of all rangelists in MERGEINFO to INHERITABLE. 69 If MERGEINFO is NULL do nothing. If a rangelist in MERGEINFO is 70 NULL leave it alone. */ 71void 72svn_mergeinfo__set_inheritance(svn_mergeinfo_t mergeinfo, 73 svn_boolean_t inheritable, 74 apr_pool_t *scratch_pool); 75 76/* Return whether INFO1 and INFO2 are equal in *IS_EQUAL. 77 78 CONSIDER_INHERITANCE determines how the rangelists in the two 79 hashes are compared for equality. If CONSIDER_INHERITANCE is FALSE, 80 then the start and end revisions of the svn_merge_range_t's being 81 compared are the only factors considered when determining equality. 82 83 e.g. '/trunk: 1,3-4*,5' == '/trunk: 1,3-5' 84 85 If CONSIDER_INHERITANCE is TRUE, then the inheritability of the 86 svn_merge_range_t's is also considered and must be the same for two 87 otherwise identical ranges to be judged equal. 88 89 e.g. '/trunk: 1,3-4*,5' != '/trunk: 1,3-5' 90 '/trunk: 1,3-4*,5' == '/trunk: 1,3-4*,5' 91 '/trunk: 1,3-4,5' == '/trunk: 1,3-4,5' 92 93 Use POOL for temporary allocations. */ 94svn_error_t * 95svn_mergeinfo__equals(svn_boolean_t *is_equal, 96 svn_mergeinfo_t info1, 97 svn_mergeinfo_t info2, 98 svn_boolean_t consider_inheritance, 99 apr_pool_t *pool); 100 101/* Examine MERGEINFO, removing all paths from the hash which map to 102 empty rangelists. POOL is used only to allocate the apr_hash_index_t 103 iterator. Returns TRUE if any paths were removed and FALSE if none were 104 removed or MERGEINFO is NULL. */ 105svn_boolean_t 106svn_mergeinfo__remove_empty_rangelists(svn_mergeinfo_t mergeinfo, 107 apr_pool_t *pool); 108 109/* Make a shallow (ie, mergeinfos are not duped, or altered at all; 110 keys share storage) copy of IN_CATALOG in *OUT_CATALOG, removing 111 PREFIX_PATH from the beginning of each key in the catalog. 112 PREFIX_PATH and the keys of IN_CATALOG are absolute 'fspaths', 113 starting with '/'. It is illegal for any key to not start with 114 PREFIX_PATH. The keys of *OUT_CATALOG are relpaths. The new hash 115 and temporary values are allocated in POOL. (This is useful for 116 making the return value from svn_ra_get_mergeinfo relative to the 117 session root, say.) */ 118svn_error_t * 119svn_mergeinfo__remove_prefix_from_catalog(svn_mergeinfo_catalog_t *out_catalog, 120 svn_mergeinfo_catalog_t in_catalog, 121 const char *prefix_path, 122 apr_pool_t *pool); 123 124/* Make a shallow (ie, mergeinfos are not duped, or altered at all; 125 though keys are reallocated) copy of IN_CATALOG in *OUT_CATALOG, 126 adding PREFIX_PATH to the beginning of each key in the catalog. 127 128 The new hash keys are allocated in RESULT_POOL. SCRATCH_POOL 129 is used for any temporary allocations.*/ 130svn_error_t * 131svn_mergeinfo__add_prefix_to_catalog(svn_mergeinfo_catalog_t *out_catalog, 132 svn_mergeinfo_catalog_t in_catalog, 133 const char *prefix_path, 134 apr_pool_t *result_pool, 135 apr_pool_t *scratch_pool); 136 137/* Set *OUT_MERGEINFO to a shallow copy of MERGEINFO with the relpath 138 SUFFIX_RELPATH added to the end of each key path. 139 140 Allocate *OUT_MERGEINFO and the new keys in RESULT_POOL. Use 141 SCRATCH_POOL for any temporary allocations. */ 142svn_error_t * 143svn_mergeinfo__add_suffix_to_mergeinfo(svn_mergeinfo_t *out_mergeinfo, 144 svn_mergeinfo_t mergeinfo, 145 const char *suffix_relpath, 146 apr_pool_t *result_pool, 147 apr_pool_t *scratch_pool); 148 149/* Create a string representation of CATALOG in *OUTPUT, allocated in POOL. 150 The hash keys of CATALOG and the merge source paths of each key's mergeinfo 151 are represented in sorted order as per svn_sort_compare_items_as_paths. 152 If CATALOG is empty or NULL then *OUTPUT->DATA is set to "\n". If SVN_DEBUG 153 is true, then a NULL or empty CATALOG causes *OUTPUT to be set to an 154 appropriate newline terminated string. If KEY_PREFIX is not NULL then 155 prepend KEY_PREFIX to each key (path) in *OUTPUT. if VAL_PREFIX is not 156 NULL then prepend VAL_PREFIX to each merge source:rangelist line in 157 *OUTPUT. 158 159 Any relative merge source paths in the mergeinfo in CATALOG are converted 160 to absolute paths in *OUTPUT. */ 161svn_error_t * 162svn_mergeinfo__catalog_to_formatted_string(svn_string_t **output, 163 svn_mergeinfo_catalog_t catalog, 164 const char *key_prefix, 165 const char *val_prefix, 166 apr_pool_t *pool); 167 168/* Set *YOUNGEST_REV and *OLDEST_REV to the youngest and oldest revisions 169 found in the rangelists within MERGEINFO. Note that *OLDEST_REV is 170 exclusive and *YOUNGEST_REV is inclusive. If MERGEINFO is NULL or empty 171 set *YOUNGEST_REV and *OLDEST_REV to SVN_INVALID_REVNUM. */ 172svn_error_t * 173svn_mergeinfo__get_range_endpoints(svn_revnum_t *youngest_rev, 174 svn_revnum_t *oldest_rev, 175 svn_mergeinfo_t mergeinfo, 176 apr_pool_t *pool); 177 178/* Set *FILTERED_MERGEINFO to a deep copy of MERGEINFO, allocated in 179 RESULT_POOL, less any revision ranges that fall outside of the range 180 OLDEST_REV:YOUNGEST_REV (exclusive:inclusive) if INCLUDE_RANGE is true, 181 or less any ranges within OLDEST_REV:YOUNGEST_REV if INCLUDE_RANGE 182 is false. If all the rangelists mapped to a given path are filtered 183 then filter that path as well. If all paths are filtered or MERGEINFO is 184 empty or NULL then *FILTERED_MERGEINFO is set to an empty hash. 185 186 Use SCRATCH_POOL for any temporary allocations. */ 187svn_error_t * 188svn_mergeinfo__filter_mergeinfo_by_ranges(svn_mergeinfo_t *filtered_mergeinfo, 189 svn_mergeinfo_t mergeinfo, 190 svn_revnum_t youngest_rev, 191 svn_revnum_t oldest_rev, 192 svn_boolean_t include_range, 193 apr_pool_t *result_pool, 194 apr_pool_t *scratch_pool); 195 196/* Filter each mergeinfo in CATALOG as per 197 svn_mergeinfo__filter_mergeinfo_by_ranges() and put a deep copy of the 198 result in *FILTERED_CATALOG, allocated in RESULT_POOL. If any mergeinfo 199 is filtered to an empty hash then filter that path/mergeinfo as well. 200 If all mergeinfo is filtered or CATALOG is NULL then set *FILTERED_CATALOG 201 to an empty hash. 202 203 Use SCRATCH_POOL for any temporary allocations. */ 204svn_error_t* 205svn_mergeinfo__filter_catalog_by_ranges( 206 svn_mergeinfo_catalog_t *filtered_catalog, 207 svn_mergeinfo_catalog_t catalog, 208 svn_revnum_t youngest_rev, 209 svn_revnum_t oldest_rev, 210 svn_boolean_t include_range, 211 apr_pool_t *result_pool, 212 apr_pool_t *scratch_pool); 213 214/* If MERGEINFO is non-inheritable return TRUE, return FALSE otherwise. 215 MERGEINFO may be NULL or empty. */ 216svn_boolean_t 217svn_mergeinfo__is_noninheritable(svn_mergeinfo_t mergeinfo, 218 apr_pool_t *scratch_pool); 219 220/* Return a rangelist with one svn_merge_range_t * element defined by START, 221 END, and INHERITABLE. The rangelist and its contents are allocated in 222 RESULT_POOL. */ 223svn_rangelist_t * 224svn_rangelist__initialize(svn_revnum_t start, 225 svn_revnum_t end, 226 svn_boolean_t inheritable, 227 apr_pool_t *result_pool); 228 229/* Adjust in-place MERGEINFO's rangelists by OFFSET. If OFFSET is negative 230 and would adjust any part of MERGEINFO's source revisions to 0 or less, 231 then those revisions are dropped. If all the source revisions for a merge 232 source path are dropped, then the path itself is dropped. If all merge 233 source paths are dropped, then *ADJUSTED_MERGEINFO is set to an empty 234 hash. *ADJUSTED_MERGEINFO is allocated in RESULT_POOL. SCRATCH_POOL is 235 used for any temporary allocations. */ 236svn_error_t * 237svn_mergeinfo__adjust_mergeinfo_rangelists(svn_mergeinfo_t *adjusted_mergeinfo, 238 svn_mergeinfo_t mergeinfo, 239 svn_revnum_t offset, 240 apr_pool_t *result_pool, 241 apr_pool_t *scratch_pool); 242 243/* Translates an array SEGMENTS (of svn_location_segment_t *), like the one 244 returned from svn_client__repos_location_segments, into a mergeinfo 245 *MERGEINFO_P, allocated in POOL. 246 247 Note: A svn_location_segment_t segment may legitimately describe only revision 0, 248 but there is no way to describe that using svn_mergeinfo_t. Any such 249 segment in SEGMENTS are ignored. */ 250svn_error_t * 251svn_mergeinfo__mergeinfo_from_segments(svn_mergeinfo_t *mergeinfo_p, 252 const apr_array_header_t *segments, 253 apr_pool_t *pool); 254 255/* Merge every rangelist in MERGEINFO into the given MERGED_RANGELIST, 256 * ignoring the source paths of MERGEINFO. MERGED_RANGELIST may 257 * initially be empty. New elements added to RANGELIST are allocated in 258 * RESULT_POOL. See svn_rangelist_merge2() for details of inheritability 259 * etc. */ 260svn_error_t * 261svn_rangelist__merge_many(svn_rangelist_t *merged_rangelist, 262 svn_mergeinfo_t mergeinfo, 263 apr_pool_t *result_pool, 264 apr_pool_t *scratch_pool); 265 266#ifdef __cplusplus 267} 268#endif /* __cplusplus */ 269 270#endif /* SVN_MERGEINFO_PRIVATE_H */ 271