fs.h revision 299742
12116Sjkh/* fs.h : interface to Subversion filesystem, private to libsvn_fs 22116Sjkh * 38870Srgrimes * ==================================================================== 42116Sjkh * Licensed to the Apache Software Foundation (ASF) under one 52116Sjkh * or more contributor license agreements. See the NOTICE file 62116Sjkh * distributed with this work for additional information 72116Sjkh * regarding copyright ownership. The ASF licenses this file 878172Sru * to you under the Apache License, Version 2.0 (the 978172Sru * "License"); you may not use this file except in compliance 1078172Sru * with the License. You may obtain a copy of the License at 1178172Sru * 1278172Sru * http://www.apache.org/licenses/LICENSE-2.0 1378172Sru * 1478172Sru * Unless required by applicable law or agreed to in writing, 152116Sjkh * software distributed under the License is distributed on an 162116Sjkh * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 172116Sjkh * KIND, either express or implied. See the License for the 182116Sjkh * specific language governing permissions and limitations 1978172Sru * under the License. 202116Sjkh * ==================================================================== 2178172Sru */ 2278172Sru 232116Sjkh#ifndef SVN_LIBSVN_FS_BASE_H 24#define SVN_LIBSVN_FS_BASE_H 25 26#define SVN_WANT_BDB 27#include "svn_private_config.h" 28 29#include <apr_pools.h> 30#include <apr_hash.h> 31#include "svn_fs.h" 32 33#include "bdb/env.h" 34 35#ifdef __cplusplus 36extern "C" { 37#endif /* __cplusplus */ 38 39 40/*** Filesystem schema versions ***/ 41 42/* The format number of this filesystem. This is independent of the 43 repository format number, and independent of any other FS back 44 ends. See the SVN_FS_BASE__MIN_*_FORMAT defines to get a sense of 45 what changes and features were added in which versions of this 46 back-end's format. 47 48 Note: If you bump this, please update the switch statement in 49 base_create() as well. 50 */ 51#define SVN_FS_BASE__FORMAT_NUMBER 4 52 53/* Minimum format number that supports representation sharing. This 54 also brings in the support for storing SHA1 checksums. */ 55#define SVN_FS_BASE__MIN_REP_SHARING_FORMAT 4 56 57/* Minimum format number that supports the 'miscellaneous' table */ 58#define SVN_FS_BASE__MIN_MISCELLANY_FORMAT 4 59 60/* Minimum format number that supports forward deltas */ 61#define SVN_FS_BASE__MIN_FORWARD_DELTAS_FORMAT 4 62 63/* Minimum format number that supports node-origins tracking */ 64#define SVN_FS_BASE__MIN_NODE_ORIGINS_FORMAT 3 65 66/* Minimum format number that supports mergeinfo */ 67#define SVN_FS_BASE__MIN_MERGEINFO_FORMAT 3 68 69/* Minimum format number that supports svndiff version 1. */ 70#define SVN_FS_BASE__MIN_SVNDIFF1_FORMAT 2 71 72/* Return SVN_ERR_UNSUPPORTED_FEATURE if the version of filesystem FS does 73 not indicate support for FEATURE (which REQUIRES a newer version). */ 74svn_error_t * 75svn_fs_base__test_required_feature_format(svn_fs_t *fs, 76 const char *feature, 77 int requires); 78 79 80 81/*** Miscellany keys. ***/ 82 83/* Revision at which the repo started using forward deltas. */ 84#define SVN_FS_BASE__MISC_FORWARD_DELTA_UPGRADE "forward-delta-rev" 85 86 87 88/*** The filesystem structure. ***/ 89 90typedef struct base_fs_data_t 91{ 92 /* A Berkeley DB environment for all the filesystem's databases. 93 This establishes the scope of the filesystem's transactions. */ 94 bdb_env_baton_t *bdb; 95 96 /* The filesystem's various tables. See `structure' for details. */ 97 DB *changes; 98 DB *copies; 99 DB *nodes; 100 DB *representations; 101 DB *revisions; 102 DB *strings; 103 DB *transactions; 104 DB *uuids; 105 DB *locks; 106 DB *lock_tokens; 107 DB *node_origins; 108 DB *miscellaneous; 109 DB *checksum_reps; 110 111 /* A boolean for tracking when we have a live Berkeley DB 112 transaction trail alive. */ 113 svn_boolean_t in_txn_trail; 114 115 /* The format number of this FS. */ 116 int format; 117 118} base_fs_data_t; 119 120 121/*** Filesystem Revision ***/ 122typedef struct revision_t 123{ 124 /* id of the transaction that was committed to create this 125 revision. */ 126 const char *txn_id; 127 128} revision_t; 129 130 131/*** Transaction Kind ***/ 132typedef enum transaction_kind_t 133{ 134 transaction_kind_normal = 1, /* normal, uncommitted */ 135 transaction_kind_committed, /* committed */ 136 transaction_kind_dead /* uncommitted and dead */ 137 138} transaction_kind_t; 139 140 141/*** Filesystem Transaction ***/ 142typedef struct transaction_t 143{ 144 /* kind of transaction. */ 145 transaction_kind_t kind; 146 147 /* revision which this transaction was committed to create, or an 148 invalid revision number if this transaction was never committed. */ 149 svn_revnum_t revision; 150 151 /* property list (const char * name, svn_string_t * value). 152 may be NULL if there are no properties. */ 153 apr_hash_t *proplist; 154 155 /* node revision id of the root node. */ 156 const svn_fs_id_t *root_id; 157 158 /* node revision id of the node which is the root of the revision 159 upon which this txn is base. (unfinished only) */ 160 const svn_fs_id_t *base_id; 161 162 /* copies list (const char * copy_ids), or NULL if there have been 163 no copies in this transaction. */ 164 apr_array_header_t *copies; 165 166} transaction_t; 167 168 169/*** Node-Revision ***/ 170typedef struct node_revision_t 171{ 172 /* node kind */ 173 svn_node_kind_t kind; 174 175 /* predecessor node revision id, or NULL if there is no predecessor 176 for this node revision */ 177 const svn_fs_id_t *predecessor_id; 178 179 /* number of predecessors this node revision has (recursively), or 180 -1 if not known (for backward compatibility). */ 181 int predecessor_count; 182 183 /* representation key for this node's properties. may be NULL if 184 there are no properties. */ 185 const char *prop_key; 186 187 /* representation key for this node's text data (files) or entries 188 list (dirs). may be NULL if there are no contents. */ 189 const char *data_key; 190 191 /* data representation instance identifier. Sounds fancy, but is 192 really just a way to distinguish between "I use the same rep key 193 as another node because we share ancestry and haven't had our 194 text touched at all" and "I use the same rep key as another node 195 only because one or both of us decided to pick up a shared 196 representation after-the-fact." May be NULL (if this node 197 revision isn't using a shared rep, or isn't the original 198 "assignee" of a shared rep). */ 199 const char *data_key_uniquifier; 200 201 /* representation key for this node's text-data-in-progess (files 202 only). NULL if no edits are currently in-progress. This field 203 is always NULL for kinds other than "file". */ 204 const char *edit_key; 205 206 /* path at which this node first came into existence. */ 207 const char *created_path; 208 209 /* does this node revision have the mergeinfo tracking property set 210 on it? (only valid for FS schema 3 and newer) */ 211 svn_boolean_t has_mergeinfo; 212 213 /* number of children of this node which have the mergeinfo tracking 214 property set (0 for files; valid only for FS schema 3 and newer). */ 215 apr_int64_t mergeinfo_count; 216 217} node_revision_t; 218 219 220/*** Representation Kind ***/ 221typedef enum rep_kind_t 222{ 223 rep_kind_fulltext = 1, /* fulltext */ 224 rep_kind_delta /* delta */ 225 226} rep_kind_t; 227 228 229/*** "Delta" Offset/Window Chunk ***/ 230typedef struct rep_delta_chunk_t 231{ 232 /* diff format version number ### at this point, "svndiff" is the 233 only format used. */ 234 apr_byte_t version; 235 236 /* starting offset of the data represented by this chunk */ 237 svn_filesize_t offset; 238 239 /* string-key to which this representation points. */ 240 const char *string_key; 241 242 /* size of the fulltext data represented by this delta window. */ 243 apr_size_t size; 244 245 /* representation-key to use when needed source data for 246 undeltification. */ 247 const char *rep_key; 248 249 /* apr_off_t rep_offset; ### not implemented */ 250 251} rep_delta_chunk_t; 252 253 254/*** Representation ***/ 255typedef struct representation_t 256{ 257 /* representation kind */ 258 rep_kind_t kind; 259 260 /* transaction ID under which representation was created (used as a 261 mutability flag when compared with a current editing 262 transaction). */ 263 const char *txn_id; 264 265 /* Checksums for the contents produced by this representation. 266 These checksum is for the contents the rep shows to consumers, 267 regardless of how the rep stores the data under the hood. It is 268 independent of the storage (fulltext, delta, whatever). 269 270 If this is NULL, then for compatibility behave as though 271 this checksum matches the expected checksum. */ 272 svn_checksum_t *md5_checksum; 273 svn_checksum_t *sha1_checksum; 274 275 /* kind-specific stuff */ 276 union 277 { 278 /* fulltext stuff */ 279 struct 280 { 281 /* string-key which holds the fulltext data */ 282 const char *string_key; 283 284 } fulltext; 285 286 /* delta stuff */ 287 struct 288 { 289 /* an array of rep_delta_chunk_t * chunks of delta 290 information */ 291 apr_array_header_t *chunks; 292 293 } delta; 294 } contents; 295} representation_t; 296 297 298/*** Copy Kind ***/ 299typedef enum copy_kind_t 300{ 301 copy_kind_real = 1, /* real copy */ 302 copy_kind_soft /* soft copy */ 303 304} copy_kind_t; 305 306 307/*** Copy ***/ 308typedef struct copy_t 309{ 310 /* What kind of copy occurred. */ 311 copy_kind_t kind; 312 313 /* Path of copy source. */ 314 const char *src_path; 315 316 /* Transaction id of copy source. */ 317 const char *src_txn_id; 318 319 /* Node-revision of copy destination. */ 320 const svn_fs_id_t *dst_noderev_id; 321 322} copy_t; 323 324 325/*** Change ***/ 326typedef struct change_t 327{ 328 /* Path of the change. */ 329 const char *path; 330 331 /* Node revision ID of the change. */ 332 const svn_fs_id_t *noderev_id; 333 334 /* The kind of change. */ 335 svn_fs_path_change_kind_t kind; 336 337 /* Text or property mods? */ 338 svn_boolean_t text_mod; 339 svn_boolean_t prop_mod; 340 341} change_t; 342 343 344/*** Lock node ***/ 345typedef struct lock_node_t 346{ 347 /* entries list, maps (const char *) name --> (const char *) lock-node-id */ 348 apr_hash_t *entries; 349 350 /* optional lock-token, might be NULL. */ 351 const char *lock_token; 352 353} lock_node_t; 354 355 356 357#ifdef __cplusplus 358} 359#endif /* __cplusplus */ 360 361#endif /* SVN_LIBSVN_FS_BASE_H */ 362