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