summaryrefslogtreecommitdiff
path: root/subversion/libsvn_fs_base/fs.h
blob: cc89116836a76506ba1a893bc829dc9dd2aca44f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/* fs.h : interface to Subversion filesystem, private to libsvn_fs
 *
 * ====================================================================
 *    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_LIBSVN_FS_BASE_H
#define SVN_LIBSVN_FS_BASE_H

#define SVN_WANT_BDB
#include "svn_private_config.h"

#include <apr_pools.h>
#include <apr_hash.h>
#include "svn_fs.h"

#include "bdb/env.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


/*** Filesystem schema versions ***/

/* The format number of this filesystem.  This is independent of the
   repository format number, and independent of any other FS back
   ends.  See the SVN_FS_BASE__MIN_*_FORMAT defines to get a sense of
   what changes and features were added in which versions of this
   back-end's format.

   Note: If you bump this, please update the switch statement in
         base_create() as well.
 */
#define SVN_FS_BASE__FORMAT_NUMBER                4

/* Minimum format number that supports representation sharing.  This
   also brings in the support for storing SHA1 checksums.   */
#define SVN_FS_BASE__MIN_REP_SHARING_FORMAT       4

/* Minimum format number that supports the 'miscellaneous' table */
#define SVN_FS_BASE__MIN_MISCELLANY_FORMAT        4

/* Minimum format number that supports forward deltas */
#define SVN_FS_BASE__MIN_FORWARD_DELTAS_FORMAT    4

/* Minimum format number that supports node-origins tracking */
#define SVN_FS_BASE__MIN_NODE_ORIGINS_FORMAT      3

/* Minimum format number that supports mergeinfo */
#define SVN_FS_BASE__MIN_MERGEINFO_FORMAT         3

/* Minimum format number that supports svndiff version 1.  */
#define SVN_FS_BASE__MIN_SVNDIFF1_FORMAT          2

/* Return SVN_ERR_UNSUPPORTED_FEATURE if the version of filesystem FS does
   not indicate support for FEATURE (which REQUIRES a newer version). */
svn_error_t *
svn_fs_base__test_required_feature_format(svn_fs_t *fs,
                                          const char *feature,
                                          int requires);



/*** Miscellany keys. ***/

/* Revision at which the repo started using forward deltas. */
#define SVN_FS_BASE__MISC_FORWARD_DELTA_UPGRADE  "forward-delta-rev"



/*** The filesystem structure.  ***/

typedef struct base_fs_data_t
{
  /* A Berkeley DB environment for all the filesystem's databases.
     This establishes the scope of the filesystem's transactions.  */
  bdb_env_baton_t *bdb;

  /* The filesystem's various tables.  See `structure' for details.  */
  DB *changes;
  DB *copies;
  DB *nodes;
  DB *representations;
  DB *revisions;
  DB *strings;
  DB *transactions;
  DB *uuids;
  DB *locks;
  DB *lock_tokens;
  DB *node_origins;
  DB *miscellaneous;
  DB *checksum_reps;

  /* A boolean for tracking when we have a live Berkeley DB
     transaction trail alive. */
  svn_boolean_t in_txn_trail;

  /* The format number of this FS. */
  int format;

} base_fs_data_t;


/*** Filesystem Revision ***/
typedef struct revision_t
{
  /* id of the transaction that was committed to create this
     revision. */
  const char *txn_id;

} revision_t;


/*** Transaction Kind ***/
typedef enum transaction_kind_t
{
  transaction_kind_normal = 1,  /* normal, uncommitted */
  transaction_kind_committed,   /* committed */
  transaction_kind_dead         /* uncommitted and dead */

} transaction_kind_t;


/*** Filesystem Transaction ***/
typedef struct transaction_t
{
  /* kind of transaction. */
  transaction_kind_t kind;

  /* revision which this transaction was committed to create, or an
     invalid revision number if this transaction was never committed. */
  svn_revnum_t revision;

  /* property list (const char * name, svn_string_t * value).
     may be NULL if there are no properties.  */
  apr_hash_t *proplist;

  /* node revision id of the root node.  */
  const svn_fs_id_t *root_id;

  /* node revision id of the node which is the root of the revision
     upon which this txn is base.  (unfinished only) */
  const svn_fs_id_t *base_id;

  /* copies list (const char * copy_ids), or NULL if there have been
     no copies in this transaction.  */
  apr_array_header_t *copies;

} transaction_t;


/*** Node-Revision ***/
typedef struct node_revision_t
{
  /* node kind */
  svn_node_kind_t kind;

  /* predecessor node revision id, or NULL if there is no predecessor
     for this node revision */
  const svn_fs_id_t *predecessor_id;

  /* number of predecessors this node revision has (recursively), or
     -1 if not known (for backward compatibility). */
  int predecessor_count;

  /* representation key for this node's properties.  may be NULL if
     there are no properties.  */
  const char *prop_key;

  /* representation key for this node's text data (files) or entries
     list (dirs).  may be NULL if there are no contents.  */
  const char *data_key;

  /* data representation instance identifier.  Sounds fancy, but is
     really just a way to distinguish between "I use the same rep key
     as another node because we share ancestry and haven't had our
     text touched at all" and "I use the same rep key as another node
     only because one or both of us decided to pick up a shared
     representation after-the-fact."  May be NULL (if this node
     revision isn't using a shared rep, or isn't the original
     "assignee" of a shared rep). */
  const char *data_key_uniquifier;

  /* representation key for this node's text-data-in-progess (files
     only).  NULL if no edits are currently in-progress.  This field
     is always NULL for kinds other than "file".  */
  const char *edit_key;

  /* path at which this node first came into existence.  */
  const char *created_path;

  /* does this node revision have the mergeinfo tracking property set
     on it?  (only valid for FS schema 3 and newer) */
  svn_boolean_t has_mergeinfo;

  /* number of children of this node which have the mergeinfo tracking
     property set  (0 for files; valid only for FS schema 3 and newer). */
  apr_int64_t mergeinfo_count;

} node_revision_t;


/*** Representation Kind ***/
typedef enum rep_kind_t
{
  rep_kind_fulltext = 1, /* fulltext */
  rep_kind_delta         /* delta */

} rep_kind_t;


/*** "Delta" Offset/Window Chunk ***/
typedef struct rep_delta_chunk_t
{
  /* diff format version number ### at this point, "svndiff" is the
     only format used. */
  apr_byte_t version;

  /* starting offset of the data represented by this chunk */
  svn_filesize_t offset;

  /* string-key to which this representation points. */
  const char *string_key;

  /* size of the fulltext data represented by this delta window. */
  apr_size_t size;

  /* representation-key to use when needed source data for
     undeltification. */
  const char *rep_key;

  /* apr_off_t rep_offset;  ### not implemented */

} rep_delta_chunk_t;


/*** Representation ***/
typedef struct representation_t
{
  /* representation kind */
  rep_kind_t kind;

  /* transaction ID under which representation was created (used as a
     mutability flag when compared with a current editing
     transaction). */
  const char *txn_id;

  /* Checksums for the contents produced by this representation.
     These checksum is for the contents the rep shows to consumers,
     regardless of how the rep stores the data under the hood.  It is
     independent of the storage (fulltext, delta, whatever).

     If this is NULL, then for compatibility behave as though
     this checksum matches the expected checksum. */
  svn_checksum_t *md5_checksum;
  svn_checksum_t *sha1_checksum;

  /* kind-specific stuff */
  union
  {
    /* fulltext stuff */
    struct
    {
      /* string-key which holds the fulltext data */
      const char *string_key;

    } fulltext;

    /* delta stuff */
    struct
    {
      /* an array of rep_delta_chunk_t * chunks of delta
         information */
      apr_array_header_t *chunks;

    } delta;
  } contents;
} representation_t;


/*** Copy Kind ***/
typedef enum copy_kind_t
{
  copy_kind_real = 1, /* real copy */
  copy_kind_soft      /* soft copy */

} copy_kind_t;


/*** Copy ***/
typedef struct copy_t
{
  /* What kind of copy occurred. */
  copy_kind_t kind;

  /* Path of copy source. */
  const char *src_path;

  /* Transaction id of copy source. */
  const char *src_txn_id;

  /* Node-revision of copy destination. */
  const svn_fs_id_t *dst_noderev_id;

} copy_t;


/*** Change ***/
typedef struct change_t
{
  /* Path of the change. */
  const char *path;

  /* Node revision ID of the change. */
  const svn_fs_id_t *noderev_id;

  /* The kind of change. */
  svn_fs_path_change_kind_t kind;

  /* Text or property mods? */
  svn_boolean_t text_mod;
  svn_boolean_t prop_mod;

} change_t;


/*** Lock node ***/
typedef struct lock_node_t
{
  /* entries list, maps (const char *) name --> (const char *) lock-node-id */
  apr_hash_t *entries;

  /* optional lock-token, might be NULL. */
  const char *lock_token;

} lock_node_t;



#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* SVN_LIBSVN_FS_BASE_H */