]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/libsvn_fs_base/fs.h
MFV r298691:
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / libsvn_fs_base / fs.h
1 /* fs.h : interface to Subversion filesystem, private to libsvn_fs
2  *
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  */
22
23 #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
36 extern "C" {
37 #endif /* __cplusplus */
38
39 \f
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). */
74 svn_error_t *
75 svn_fs_base__test_required_feature_format(svn_fs_t *fs,
76                                           const char *feature,
77                                           int requires);
78
79
80 \f
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 \f
88 /*** The filesystem structure.  ***/
89
90 typedef 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 ***/
122 typedef 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 ***/
132 typedef 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 ***/
142 typedef 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 ***/
170 typedef 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
200      This is no longer used by the 1.9 code but we have to keep
201      reading and writing it to remain compatible with 1.8, and
202      earlier, that require it. */
203   const char *data_key_uniquifier;
204
205   /* representation key for this node's text-data-in-progess (files
206      only).  NULL if no edits are currently in-progress.  This field
207      is always NULL for kinds other than "file".  */
208   const char *edit_key;
209
210   /* path at which this node first came into existence.  */
211   const char *created_path;
212
213   /* does this node revision have the mergeinfo tracking property set
214      on it?  (only valid for FS schema 3 and newer) */
215   svn_boolean_t has_mergeinfo;
216
217   /* number of children of this node which have the mergeinfo tracking
218      property set  (0 for files; valid only for FS schema 3 and newer). */
219   apr_int64_t mergeinfo_count;
220
221 } node_revision_t;
222
223
224 /*** Representation Kind ***/
225 typedef enum rep_kind_t
226 {
227   rep_kind_fulltext = 1, /* fulltext */
228   rep_kind_delta         /* delta */
229
230 } rep_kind_t;
231
232
233 /*** "Delta" Offset/Window Chunk ***/
234 typedef struct rep_delta_chunk_t
235 {
236   /* diff format version number ### at this point, "svndiff" is the
237      only format used. */
238   apr_byte_t version;
239
240   /* starting offset of the data represented by this chunk */
241   svn_filesize_t offset;
242
243   /* string-key to which this representation points. */
244   const char *string_key;
245
246   /* size of the fulltext data represented by this delta window. */
247   apr_size_t size;
248
249   /* representation-key to use when needed source data for
250      undeltification. */
251   const char *rep_key;
252
253   /* apr_off_t rep_offset;  ### not implemented */
254
255 } rep_delta_chunk_t;
256
257
258 /*** Representation ***/
259 typedef struct representation_t
260 {
261   /* representation kind */
262   rep_kind_t kind;
263
264   /* transaction ID under which representation was created (used as a
265      mutability flag when compared with a current editing
266      transaction). */
267   const char *txn_id;
268
269   /* Checksums for the contents produced by this representation.
270      These checksum is for the contents the rep shows to consumers,
271      regardless of how the rep stores the data under the hood.  It is
272      independent of the storage (fulltext, delta, whatever).
273
274      If this is NULL, then for compatibility behave as though
275      this checksum matches the expected checksum. */
276   svn_checksum_t *md5_checksum;
277   svn_checksum_t *sha1_checksum;
278
279   /* kind-specific stuff */
280   union
281   {
282     /* fulltext stuff */
283     struct
284     {
285       /* string-key which holds the fulltext data */
286       const char *string_key;
287
288     } fulltext;
289
290     /* delta stuff */
291     struct
292     {
293       /* an array of rep_delta_chunk_t * chunks of delta
294          information */
295       apr_array_header_t *chunks;
296
297     } delta;
298   } contents;
299 } representation_t;
300
301
302 /*** Copy Kind ***/
303 typedef enum copy_kind_t
304 {
305   copy_kind_real = 1, /* real copy */
306   copy_kind_soft      /* soft copy */
307
308 } copy_kind_t;
309
310
311 /*** Copy ***/
312 typedef struct copy_t
313 {
314   /* What kind of copy occurred. */
315   copy_kind_t kind;
316
317   /* Path of copy source. */
318   const char *src_path;
319
320   /* Transaction id of copy source. */
321   const char *src_txn_id;
322
323   /* Node-revision of copy destination. */
324   const svn_fs_id_t *dst_noderev_id;
325
326 } copy_t;
327
328
329 /*** Change ***/
330 typedef struct change_t
331 {
332   /* Path of the change. */
333   const char *path;
334
335   /* Node revision ID of the change. */
336   const svn_fs_id_t *noderev_id;
337
338   /* The kind of change. */
339   svn_fs_path_change_kind_t kind;
340
341   /* Text or property mods? */
342   svn_boolean_t text_mod;
343   svn_boolean_t prop_mod;
344
345 } change_t;
346
347
348 /*** Lock node ***/
349 typedef struct lock_node_t
350 {
351   /* entries list, maps (const char *) name --> (const char *) lock-node-id */
352   apr_hash_t *entries;
353
354   /* optional lock-token, might be NULL. */
355   const char *lock_token;
356
357 } lock_node_t;
358
359
360 \f
361 #ifdef __cplusplus
362 }
363 #endif /* __cplusplus */
364
365 #endif /* SVN_LIBSVN_FS_BASE_H */