]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/include/svn_fs.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / include / svn_fs.h
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_fs.h
24  * @brief Interface to the Subversion filesystem.
25  */
26
27 #ifndef SVN_FS_H
28 #define SVN_FS_H
29
30 #include <apr.h>
31 #include <apr_pools.h>
32 #include <apr_hash.h>
33 #include <apr_tables.h>
34 #include <apr_time.h>    /* for apr_time_t */
35
36 #include "svn_types.h"
37 #include "svn_string.h"
38 #include "svn_delta.h"
39 #include "svn_io.h"
40 #include "svn_mergeinfo.h"
41 #include "svn_checksum.h"
42
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif /* __cplusplus */
47
48 \f
49 /**
50  * Get libsvn_fs version information.
51  *
52  * @since New in 1.1.
53  */
54 const svn_version_t *
55 svn_fs_version(void);
56
57 /**
58  * @defgroup fs_handling Filesystem interaction subsystem
59  * @{
60  */
61
62 /* Opening and creating filesystems.  */
63
64
65 /** An object representing a Subversion filesystem.  */
66 typedef struct svn_fs_t svn_fs_t;
67
68 /**
69  * @defgroup svn_fs_backend_names Built-in back-ends
70  * Constants defining the currently supported built-in filesystem backends.
71  *
72  * @see svn_fs_type
73  * @{
74  */
75 /** @since New in 1.1. */
76 #define SVN_FS_TYPE_BDB                         "bdb"
77 /** @since New in 1.1. */
78 #define SVN_FS_TYPE_FSFS                        "fsfs"
79
80 /**
81  * EXPERIMENTAL filesystem backend.
82  *
83  * It is not ready for general production use.  Please consult the
84  * respective release notes on suggested usage scenarios.
85  *
86  * @since New in 1.9.
87  */
88 #define SVN_FS_TYPE_FSX                         "fsx"
89
90 /** @} */
91
92
93 /**
94  * @name Filesystem configuration options
95  * @{
96  */
97 #define SVN_FS_CONFIG_BDB_TXN_NOSYNC            "bdb-txn-nosync"
98 #define SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE        "bdb-log-autoremove"
99
100 /** Enable / disable text delta caching for a FSFS repository.
101  *
102  * @since New in 1.7.
103  */
104 #define SVN_FS_CONFIG_FSFS_CACHE_DELTAS         "fsfs-cache-deltas"
105
106 /** Enable / disable full-text caching for a FSFS repository.
107  *
108  * @since New in 1.7.
109  */
110 #define SVN_FS_CONFIG_FSFS_CACHE_FULLTEXTS      "fsfs-cache-fulltexts"
111
112 /** Enable / disable revprop caching for a FSFS repository.
113  *
114  * "2" is allowed, too and means "enable if efficient",
115  * i.e. this will not create warning at runtime if there
116  * if no efficient support for revprop caching.
117  *
118  * @since New in 1.8.
119  */
120 #define SVN_FS_CONFIG_FSFS_CACHE_REVPROPS       "fsfs-cache-revprops"
121
122 /** Select the cache namespace.  If you potentially share the cache with
123  * another FS object for the same repository, objects read through one FS
124  * will not need to be read again for the other.  In most cases, that is
125  * a very desirable behavior and the default is, therefore, an empty
126  * namespace.
127  *
128  * If you want to be sure that your FS instance will actually read all
129  * requested data at least once, you need to specify a separate namespace
130  * for it.  All repository verification code, for instance, should use
131  * some GUID here that is different each time you open an FS instance.
132  *
133  * @since New in 1.8.
134  */
135 #define SVN_FS_CONFIG_FSFS_CACHE_NS             "fsfs-cache-namespace"
136
137 /** Enable / disable the FSFS format 7 "block read" feature.
138  *
139  * @since New in 1.9.
140  */
141 #define SVN_FS_CONFIG_FSFS_BLOCK_READ           "fsfs-block-read"
142
143 /** String with a decimal representation of the FSFS format shard size.
144  * Zero ("0") means that a repository with linear layout should be created.
145  *
146  * This option will only be used during the creation of new repositories
147  * and is otherwise ignored.
148  *
149  * @since New in 1.9.
150  */
151 #define SVN_FS_CONFIG_FSFS_SHARD_SIZE           "fsfs-shard-size"
152
153 /** Enable / disable the FSFS format 7 logical addressing feature for a
154  * newly created repository.
155  *
156  * This option will only be used during the creation of new repositories
157  * and is otherwise ignored.
158  *
159  * @since New in 1.9.
160  */
161 #define SVN_FS_CONFIG_FSFS_LOG_ADDRESSING       "fsfs-log-addressing"
162
163 /* Note to maintainers: if you add further SVN_FS_CONFIG_FSFS_CACHE_* knobs,
164    update fs_fs.c:verify_as_revision_before_current_plus_plus(). */
165
166 /** Select the filesystem type. See also #svn_fs_type().
167  *
168  * @since New in 1.1. */
169 #define SVN_FS_CONFIG_FS_TYPE                   "fs-type"
170
171 /** Create repository format compatible with Subversion versions
172  * earlier than 1.4.
173  *
174  *  @since New in 1.4.
175  */
176 #define SVN_FS_CONFIG_PRE_1_4_COMPATIBLE        "pre-1.4-compatible"
177
178 /** Create repository format compatible with Subversion versions
179  * earlier than 1.5.
180  *
181  * @since New in 1.5.
182  */
183 #define SVN_FS_CONFIG_PRE_1_5_COMPATIBLE        "pre-1.5-compatible"
184
185 /** Create repository format compatible with Subversion versions
186  * earlier than 1.6.
187  *
188  * @since New in 1.6.
189  */
190 #define SVN_FS_CONFIG_PRE_1_6_COMPATIBLE        "pre-1.6-compatible"
191
192 /** Create repository format compatible with Subversion versions
193  * earlier than 1.8.
194  *
195  * @since New in 1.8.
196  */
197 #define SVN_FS_CONFIG_PRE_1_8_COMPATIBLE        "pre-1.8-compatible"
198
199 /** Create repository format compatible with the specified Subversion
200  * release.  The value must be a version in the same format as
201  * #SVN_VER_NUMBER and cannot exceed the current version.
202  *
203  * @note The @c patch component would often be ignored, due to our forward
204  * compatibility promises within minor release lines.  It should therefore
205  * usually be set to @c 0.
206  *
207  * @since New in 1.9.
208  */
209 #define SVN_FS_CONFIG_COMPATIBLE_VERSION        "compatible-version"
210 /** @} */
211
212
213 /**
214  * Callers should invoke this function to initialize global state in
215  * the FS library before creating FS objects.  If this function is
216  * invoked, no FS objects may be created in another thread at the same
217  * time as this invocation, and the provided @a pool must last longer
218  * than any FS object created subsequently.
219  *
220  * If this function is not called, the FS library will make a best
221  * effort to bootstrap a mutex for protecting data common to FS
222  * objects; however, there is a small window of failure.  Also, a
223  * small amount of data will be leaked if the Subversion FS library is
224  * dynamically unloaded, and using the bdb FS can potentially segfault
225  * or invoke other undefined behavior if this function is not called
226  * with an appropriate pool (such as the pool the module was loaded into)
227  * when loaded dynamically.
228  *
229  * If this function is called multiple times before the pool passed to
230  * the first call is destroyed or cleared, the later calls will have
231  * no effect.
232  *
233  * @since New in 1.2.
234  */
235 svn_error_t *
236 svn_fs_initialize(apr_pool_t *pool);
237 \f
238
239 /** The type of a warning callback function.  @a baton is the value specified
240  * in the call to svn_fs_set_warning_func(); the filesystem passes it through
241  * to the callback.  @a err contains the warning message.
242  *
243  * The callback function should not clear the error that is passed to it;
244  * its caller should do that.
245  */
246 typedef void (*svn_fs_warning_callback_t)(void *baton, svn_error_t *err);
247
248
249 /** Provide a callback function, @a warning, that @a fs should use to
250  * report (non-fatal) errors.  To print an error, the filesystem will call
251  * @a warning, passing it @a warning_baton and the error.
252  *
253  * By default, this is set to a function that will crash the process.
254  * Dumping to @c stderr or <tt>/dev/tty</tt> is not acceptable default
255  * behavior for server processes, since those may both be equivalent to
256  * <tt>/dev/null</tt>.
257  */
258 void
259 svn_fs_set_warning_func(svn_fs_t *fs,
260                         svn_fs_warning_callback_t warning,
261                         void *warning_baton);
262
263 \f
264
265 /**
266  * Create a new, empty Subversion filesystem, stored in the directory
267  * @a path, and return a pointer to it in @a *fs_p.  @a path must not
268  * currently exist, but its parent must exist.  If @a fs_config is not
269  * @c NULL, the options it contains modify the behavior of the
270  * filesystem.  The interpretation of @a fs_config is specific to the
271  * filesystem back-end.  The new filesystem may be closed by
272  * destroying @a pool.
273  *
274  * @note The lifetime of @a fs_config must not be shorter than @a
275  * pool's. It's a good idea to allocate @a fs_config from @a pool or
276  * one of its ancestors.
277  *
278  * If @a fs_config contains a value for #SVN_FS_CONFIG_FS_TYPE, that
279  * value determines the filesystem type for the new filesystem.
280  * Currently defined values are:
281  *
282  *   SVN_FS_TYPE_BDB   Berkeley-DB implementation
283  *   SVN_FS_TYPE_FSFS  Native-filesystem implementation
284  *   SVN_FS_TYPE_FSX   Experimental filesystem implementation
285  *
286  * If @a fs_config is @c NULL or does not contain a value for
287  * #SVN_FS_CONFIG_FS_TYPE then the default filesystem type will be used.
288  * This will typically be BDB for version 1.1 and FSFS for later versions,
289  * though the caller should not rely upon any particular default if they
290  * wish to ensure that a filesystem of a specific type is created.
291  *
292  * @since New in 1.1.
293  */
294 svn_error_t *
295 svn_fs_create(svn_fs_t **fs_p,
296               const char *path,
297               apr_hash_t *fs_config,
298               apr_pool_t *pool);
299
300 /**
301  * Open a Subversion filesystem located in the directory @a path, and
302  * return a pointer to it in @a *fs_p.  If @a fs_config is not @c
303  * NULL, the options it contains modify the behavior of the
304  * filesystem.  The interpretation of @a fs_config is specific to the
305  * filesystem back-end.  The opened filesystem will be allocated in
306  * @a result_pool may be closed by clearing or destroying that pool.
307  * Use @a scratch_pool for temporary allocations.
308  *
309  * @note The lifetime of @a fs_config must not be shorter than @a
310  * result_pool's. It's a good idea to allocate @a fs_config from
311  * @a result_pool or one of its ancestors.
312  *
313  * Only one thread may operate on any given filesystem object at once.
314  * Two threads may access the same filesystem simultaneously only if
315  * they open separate filesystem objects.
316  *
317  * @note You probably don't want to use this directly.  Take a look at
318  * svn_repos_open3() instead.
319  *
320  * @since New in 1.9.
321  */
322 svn_error_t *
323 svn_fs_open2(svn_fs_t **fs_p,
324              const char *path,
325              apr_hash_t *fs_config,
326              apr_pool_t *result_pool,
327              apr_pool_t *scratch_pool);
328
329 /**
330  * Like svn_fs_open2(), but without @a scratch_pool.
331  *
332  * @deprecated Provided for backward compatibility with the 1.8 API.
333  * @since New in 1.1.
334  */
335 SVN_DEPRECATED
336 svn_error_t *
337 svn_fs_open(svn_fs_t **fs_p,
338             const char *path,
339             apr_hash_t *fs_config,
340             apr_pool_t *pool);
341
342 /** The kind of action being taken by 'upgrade'.
343  *
344  * @since New in 1.9.
345  */
346 typedef enum svn_fs_upgrade_notify_action_t
347 {
348   /** Packing of the revprop shard has completed.
349    *  The number parameter is the shard being processed. */
350   svn_fs_upgrade_pack_revprops = 0,
351
352   /** Removal of the non-packed revprop shard is completed.
353    *  The number parameter is the shard being processed */
354   svn_fs_upgrade_cleanup_revprops,
355
356   /** DB format has been set to the new value.
357    *  The number parameter is the new format number. */
358   svn_fs_upgrade_format_bumped
359 } svn_fs_upgrade_notify_action_t;
360
361 /** The type of an upgrade notification function.  @a number is specifc
362  * to @a action (see #svn_fs_upgrade_notify_action_t); @a action is the
363  * type of action being performed.  @a baton is the corresponding baton
364  * for the notification function, and @a scratch_pool can be used for
365  * temporary allocations, but will be cleared between invocations.
366  *
367  * @since New in 1.9.
368  */
369 typedef svn_error_t *(*svn_fs_upgrade_notify_t)(void *baton,
370                                       apr_uint64_t number,
371                                       svn_fs_upgrade_notify_action_t action,
372                                       apr_pool_t *scratch_pool);
373
374 /**
375  * Upgrade the Subversion filesystem located in the directory @a path
376  * to the latest version supported by this library.  Return
377  * #SVN_ERR_FS_UNSUPPORTED_UPGRADE and make no changes to the
378  * filesystem if the requested upgrade is not supported.  Use
379  * @a scratch_pool for temporary allocations.
380  *
381  * The optional @a notify_func callback is only a general feedback that
382  * the operation is still in process but may be called in e.g. random shard
383  * order and more than once for the same shard.
384  *
385  * The optional @a cancel_func callback will be invoked as usual to allow
386  * the user to preempt this potentially lengthy operation.
387  *
388  * @note You probably don't want to use this directly.  Take a look at
389  * svn_repos_upgrade2() instead.
390  *
391  * @note Canceling an upgrade is legal but may leave remnants of previous
392  * format data that may not be cleaned up automatically by later calls.
393  *
394  * @since New in 1.9.
395  */
396 svn_error_t *
397 svn_fs_upgrade2(const char *path,
398                 svn_fs_upgrade_notify_t notify_func,
399                 void *notify_baton,
400                 svn_cancel_func_t cancel_func,
401                 void *cancel_baton,
402                 apr_pool_t *scratch_pool);
403
404 /**
405  * Like svn_fs_upgrade2 but with notify_func, notify_baton, cancel_func
406  * and cancel_baton being set to NULL.
407  *
408  * @deprecated Provided for backward compatibility with the 1.8 API.
409  * @since New in 1.5.
410  */
411 SVN_DEPRECATED
412 svn_error_t *
413 svn_fs_upgrade(const char *path,
414                apr_pool_t *pool);
415
416 /**
417  * Callback function type for progress notification.
418  *
419  * @a revision is the number of the revision currently being processed,
420  * #SVN_INVALID_REVNUM if the current stage is not linked to any specific
421  * revision. @a baton is the callback baton.
422  *
423  * @since New in 1.8.
424  */
425 typedef void (*svn_fs_progress_notify_func_t)(svn_revnum_t revision,
426                                               void *baton,
427                                               apr_pool_t *pool);
428
429 /**
430  * Return, in @a *fs_type, a string identifying the back-end type of
431  * the Subversion filesystem located in @a path.  Allocate @a *fs_type
432  * in @a pool.
433  *
434  * The string should be equal to one of the @c SVN_FS_TYPE_* defined
435  * constants, unless the filesystem is a new back-end type added in
436  * a later version of Subversion.
437  *
438  * In general, the type should make no difference in the filesystem's
439  * semantics, but there are a few situations (such as backups) where
440  * it might matter.
441  *
442  * @since New in 1.3.
443  */
444 svn_error_t *
445 svn_fs_type(const char **fs_type,
446             const char *path,
447             apr_pool_t *pool);
448
449 /**
450  * Return the path to @a fs's repository, allocated in @a pool.
451  * @note This is just what was passed to svn_fs_create() or
452  * svn_fs_open() -- might be absolute, might not.
453  *
454  * @since New in 1.1.
455  */
456 const char *
457 svn_fs_path(svn_fs_t *fs,
458             apr_pool_t *pool);
459
460 /**
461  * Return a shallow copy of the configuration parameters used to open
462  * @a fs, allocated in @a pool.  It may be @c NULL.  The contents of the
463  * hash contents remains valid only for @a fs's lifetime.
464  *
465  * @note This is just what was passed to svn_fs_create() or svn_fs_open().
466  * You may not modify it.
467  *
468  * @since New in 1.8.
469  */
470 apr_hash_t *
471 svn_fs_config(svn_fs_t *fs,
472               apr_pool_t *pool);
473
474 /**
475  * Delete the filesystem at @a path.
476  *
477  * @note: Deleting a filesystem that has an open svn_fs_t is not
478  * supported.  Clear/destroy all pools used to create/open @a path.
479  * See issue 4264.
480  *
481  * @since New in 1.1.
482  */
483 svn_error_t *
484 svn_fs_delete_fs(const char *path,
485                  apr_pool_t *pool);
486
487 /** The type of a hotcopy notification function.  @a start_revision and
488  * @a end_revision indicate the copied revision range.  @a baton is the
489  * corresponding baton for the notification function, and @a scratch_pool
490  * can be used for temporary allocations, but will be cleared between
491  * invocations.
492  */
493 typedef void (*svn_fs_hotcopy_notify_t)(void *baton,
494                                         svn_revnum_t start_revision,
495                                         svn_revnum_t end_revision,
496                                         apr_pool_t *scratch_pool);
497
498 /**
499  * Copy a possibly live Subversion filesystem from @a src_path to
500  * @a dest_path.  If @a clean is @c TRUE, perform cleanup on the
501  * source filesystem as part of the copy operation; currently, this
502  * means deleting copied, unused logfiles for a Berkeley DB source
503  * filesystem.
504  *
505  * If @a incremental is TRUE, make an effort to avoid re-copying
506  * information already present in the destination where possible.  If
507  * incremental hotcopy is not implemented, raise
508  * #SVN_ERR_UNSUPPORTED_FEATURE.
509  *
510  * For each revision range copied, @a notify_func will be called with
511  * staring and ending revision numbers (both inclusive and not necessarily
512  * different) and with the @a notify_baton.  Currently, this notification
513  * is not triggered by the BDB backend.  @a notify_func may be @c NULL
514  * if this notification is not required.
515  *
516  * The optional @a cancel_func callback will be invoked with
517  * @a cancel_baton as usual to allow the user to preempt this potentially
518  * lengthy operation.
519  *
520  * Use @a scratch_pool for temporary allocations.
521  *
522  * @since New in 1.9.
523  */
524 svn_error_t *
525 svn_fs_hotcopy3(const char *src_path,
526                 const char *dest_path,
527                 svn_boolean_t clean,
528                 svn_boolean_t incremental,
529                 svn_fs_hotcopy_notify_t notify_func,
530                 void *notify_baton,
531                 svn_cancel_func_t cancel_func,
532                 void *cancel_baton,
533                 apr_pool_t *scratch_pool);
534
535 /**
536  * Like svn_fs_hotcopy3(), but with @a notify_func and @a notify_baton
537  * always passed as @c NULL.
538  *
539  * @deprecated Provided for backward compatibility with the 1.8 API.
540  * @since New in 1.8.
541  */
542 SVN_DEPRECATED
543 svn_error_t *
544 svn_fs_hotcopy2(const char *src_path,
545                 const char *dest_path,
546                 svn_boolean_t clean,
547                 svn_boolean_t incremental,
548                 svn_cancel_func_t cancel_func,
549                 void *cancel_baton,
550                 apr_pool_t *scratch_pool);
551
552 /**
553  * Like svn_fs_hotcopy2(), but with @a incremental always passed as @c
554  * TRUE and without cancellation support.
555  *
556  * @deprecated Provided for backward compatibility with the 1.7 API.
557  * @since New in 1.1.
558  */
559 SVN_DEPRECATED
560 svn_error_t *
561 svn_fs_hotcopy(const char *src_path,
562                const char *dest_path,
563                svn_boolean_t clean,
564                apr_pool_t *pool);
565
566 /** Perform any necessary non-catastrophic recovery on the Subversion
567  * filesystem located at @a path.
568  *
569  * If @a cancel_func is not @c NULL, it is called periodically with
570  * @a cancel_baton as argument to see if the client wishes to cancel
571  * recovery.  BDB filesystems do not currently support cancellation.
572  *
573  * Do any necessary allocation within @a pool.
574  *
575  * For FSFS filesystems, recovery is currently limited to recreating
576  * the db/current file, and does not require exclusive access.
577  *
578  * For BDB filesystems, recovery requires exclusive access, and is
579  * described in detail below.
580  *
581  * After an unexpected server exit, due to a server crash or a system
582  * crash, a Subversion filesystem based on Berkeley DB needs to run
583  * recovery procedures to bring the database back into a consistent
584  * state and release any locks that were held by the deceased process.
585  * The recovery procedures require exclusive access to the database
586  * --- while they execute, no other process or thread may access the
587  * database.
588  *
589  * In a server with multiple worker processes, like Apache, if a
590  * worker process accessing the filesystem dies, you must stop the
591  * other worker processes, and run recovery.  Then, the other worker
592  * processes can re-open the database and resume work.
593  *
594  * If the server exited cleanly, there is no need to run recovery, but
595  * there is no harm in it, either, and it take very little time.  So
596  * it's a fine idea to run recovery when the server process starts,
597  * before it begins handling any requests.
598  *
599  * @since New in 1.5.
600  */
601 svn_error_t *
602 svn_fs_recover(const char *path,
603                svn_cancel_func_t cancel_func,
604                void *cancel_baton,
605                apr_pool_t *pool);
606
607
608 /**
609  * Callback for svn_fs_freeze().
610  *
611  * @since New in 1.8.
612  */
613 typedef svn_error_t *(*svn_fs_freeze_func_t)(void *baton, apr_pool_t *pool);
614
615 /**
616  * Take an exclusive lock on @a fs to prevent commits and then invoke
617  * @a freeze_func passing @a freeze_baton.
618  *
619  * @note @a freeze_func must not, directly or indirectly, call any function
620  * that attempts to take out a lock on the underlying repository.  These
621  * include functions for packing, hotcopying, setting revprops and commits.
622  * Attempts to do so may result in a deadlock.
623  *
624  * @note The BDB backend doesn't implement this feature so most
625  * callers should not call this function directly but should use the
626  * higher level svn_repos_freeze() instead.
627  *
628  * @see svn_repos_freeze()
629  *
630  * @since New in 1.8.
631  */
632 svn_error_t *
633 svn_fs_freeze(svn_fs_t *fs,
634               svn_fs_freeze_func_t freeze_func,
635               void *freeze_baton,
636               apr_pool_t *pool);
637
638
639 /** Subversion filesystems based on Berkeley DB.
640  *
641  * The following functions are specific to Berkeley DB filesystems.
642  *
643  * @defgroup svn_fs_bdb Berkeley DB filesystems
644  * @{
645  */
646
647 /** Register an error handling function for Berkeley DB error messages.
648  *
649  * @deprecated Provided for backward compatibility with the 1.2 API.
650  *
651  * Despite being first declared deprecated in Subversion 1.3, this API
652  * is redundant in versions 1.1 and 1.2 as well.
653  *
654  * Berkeley DB's error codes are seldom sufficiently informative to allow
655  * adequate troubleshooting.  Berkeley DB provides extra messages through
656  * a callback function - if an error occurs, the @a handler will be called
657  * with two strings: an error message prefix, which will be zero, and
658  * an error message.  @a handler might print it out, log it somewhere,
659  * etc.
660  *
661  * Subversion 1.1 and later install their own handler internally, and
662  * wrap the messages from Berkeley DB into the standard svn_error_t object,
663  * making any information gained through this interface redundant.
664  *
665  * It is only worth using this function if your program will be used
666  * with Subversion 1.0.
667  *
668  * This function connects to the Berkeley DB @c DBENV->set_errcall interface.
669  * Since that interface supports only a single callback, Subversion's internal
670  * callback is registered with Berkeley DB, and will forward notifications to
671  * a user provided callback after performing its own processing.
672  */
673 SVN_DEPRECATED
674 svn_error_t *
675 svn_fs_set_berkeley_errcall(svn_fs_t *fs,
676                             void (*handler)(const char *errpfx,
677                                             char *msg));
678
679 /** Set @a *logfiles to an array of <tt>const char *</tt> log file names
680  * of Berkeley DB-based Subversion filesystem.
681  *
682  * If @a only_unused is @c TRUE, set @a *logfiles to an array which
683  * contains only the names of Berkeley DB log files no longer in use
684  * by the filesystem.  Otherwise, all log files (used and unused) are
685  * returned.
686
687  * This function wraps the Berkeley DB 'log_archive' function
688  * called by the db_archive binary.  Repository administrators may
689  * want to run this function periodically and delete the unused log
690  * files, as a way of reclaiming disk space.
691  */
692 svn_error_t *
693 svn_fs_berkeley_logfiles(apr_array_header_t **logfiles,
694                          const char *path,
695                          svn_boolean_t only_unused,
696                          apr_pool_t *pool);
697
698
699 /**
700  * The following functions are similar to their generic counterparts.
701  *
702  * In Subversion 1.2 and earlier, they only work on Berkeley DB filesystems.
703  * In Subversion 1.3 and later, they perform largely as aliases for their
704  * generic counterparts (with the exception of recover, which only gained
705  * a generic counterpart in 1.5).
706  *
707  * @defgroup svn_fs_bdb_deprecated Berkeley DB filesystem compatibility
708  * @{
709  */
710
711 /** @deprecated Provided for backward compatibility with the 1.0 API. */
712 SVN_DEPRECATED
713 svn_fs_t *
714 svn_fs_new(apr_hash_t *fs_config,
715            apr_pool_t *pool);
716
717 /** @deprecated Provided for backward compatibility with the 1.0 API. */
718 SVN_DEPRECATED
719 svn_error_t *
720 svn_fs_create_berkeley(svn_fs_t *fs,
721                        const char *path);
722
723 /** @deprecated Provided for backward compatibility with the 1.0 API. */
724 SVN_DEPRECATED
725 svn_error_t *
726 svn_fs_open_berkeley(svn_fs_t *fs,
727                      const char *path);
728
729 /** @deprecated Provided for backward compatibility with the 1.0 API. */
730 SVN_DEPRECATED
731 const char *
732 svn_fs_berkeley_path(svn_fs_t *fs,
733                      apr_pool_t *pool);
734
735 /** @deprecated Provided for backward compatibility with the 1.0 API. */
736 SVN_DEPRECATED
737 svn_error_t *
738 svn_fs_delete_berkeley(const char *path,
739                        apr_pool_t *pool);
740
741 /** @deprecated Provided for backward compatibility with the 1.0 API. */
742 SVN_DEPRECATED
743 svn_error_t *
744 svn_fs_hotcopy_berkeley(const char *src_path,
745                         const char *dest_path,
746                         svn_boolean_t clean_logs,
747                         apr_pool_t *pool);
748
749 /** @deprecated Provided for backward compatibility with the 1.4 API. */
750 SVN_DEPRECATED
751 svn_error_t *
752 svn_fs_berkeley_recover(const char *path,
753                         apr_pool_t *pool);
754 /** @} */
755
756 /** @} */
757
758 \f
759 /** Filesystem Access Contexts.
760  *
761  * @since New in 1.2.
762  *
763  * At certain times, filesystem functions need access to temporary
764  * user data.  For example, which user is changing a file?  If the
765  * file is locked, has an appropriate lock-token been supplied?
766  *
767  * This temporary user data is stored in an "access context" object,
768  * and the access context is then connected to the filesystem object.
769  * Whenever a filesystem function requires information, it can pull
770  * things out of the context as needed.
771  *
772  * @defgroup svn_fs_access_ctx Filesystem access contexts
773  * @{
774  */
775
776 /** An opaque object representing temporary user data. */
777 typedef struct svn_fs_access_t svn_fs_access_t;
778
779
780 /** Set @a *access_ctx to a new #svn_fs_access_t object representing
781  *  @a username, allocated in @a pool.  @a username is presumed to
782  *  have been authenticated by the caller.
783  *
784  *  Make a deep copy of @a username.
785  */
786 svn_error_t *
787 svn_fs_create_access(svn_fs_access_t **access_ctx,
788                      const char *username,
789                      apr_pool_t *pool);
790
791
792 /** Associate @a access_ctx with an open @a fs.
793  *
794  * This function can be run multiple times on the same open
795  * filesystem, in order to change the filesystem access context for
796  * different filesystem operations.  Pass a NULL value for @a
797  * access_ctx to disassociate the current access context from the
798  * filesystem.
799  */
800 svn_error_t *
801 svn_fs_set_access(svn_fs_t *fs,
802                   svn_fs_access_t *access_ctx);
803
804
805 /** Set @a *access_ctx to the current @a fs access context, or NULL if
806  * there is no current fs access context.
807  */
808 svn_error_t *
809 svn_fs_get_access(svn_fs_access_t **access_ctx,
810                   svn_fs_t *fs);
811
812
813 /** Accessors for the access context: */
814
815 /** Set @a *username to the name represented by @a access_ctx. */
816 svn_error_t *
817 svn_fs_access_get_username(const char **username,
818                            svn_fs_access_t *access_ctx);
819
820
821 /** Push a lock-token @a token associated with path @a path into the
822  * context @a access_ctx.  The context remembers all tokens it
823  * receives, and makes them available to fs functions.  The token and
824  * path are not duplicated into @a access_ctx's pool; make sure the
825  * token's lifetime is at least as long as @a access_ctx.
826  *
827  * @since New in 1.6. */
828 svn_error_t *
829 svn_fs_access_add_lock_token2(svn_fs_access_t *access_ctx,
830                               const char *path,
831                               const char *token);
832
833 /**
834  * Same as svn_fs_access_add_lock_token2(), but with @a path set to value 1.
835  *
836  * @deprecated Provided for backward compatibility with the 1.5 API.
837  */
838 SVN_DEPRECATED
839 svn_error_t *
840 svn_fs_access_add_lock_token(svn_fs_access_t *access_ctx,
841                              const char *token);
842
843 /** @} */
844
845 \f
846 /** Filesystem Nodes and Node-Revisions.
847  *
848  * In a Subversion filesystem, a `node' corresponds roughly to an
849  * `inode' in a Unix filesystem:
850  * - A node is either a file or a directory.
851  * - A node's contents change over time.
852  * - When you change a node's contents, it's still the same node; it's
853  *   just been changed.  So a node's identity isn't bound to a specific
854  *   set of contents.
855  * - If you rename a node, it's still the same node, just under a
856  *   different name.  So a node's identity isn't bound to a particular
857  *   filename.
858  *
859  * A `node revision' refers to one particular version of a node's contents,
860  * that existed over a specific period of time (one or more repository
861  * revisions).  Changing a node's contents always creates a new revision of
862  * that node, which is to say creates a new `node revision'.  Once created,
863  * a node revision's contents never change.
864  *
865  * When we create a node, its initial contents are the initial revision of
866  * the node.  As users make changes to the node over time, we create new
867  * revisions of that same node.  When a user commits a change that deletes
868  * a file from the filesystem, we don't delete the node, or any revision
869  * of it --- those stick around to allow us to recreate prior revisions of
870  * the filesystem.  Instead, we just remove the reference to the node
871  * from the directory.
872  *
873  * Each node revision is a part of exactly one node, and appears only once
874  * in the history of that node.  It is uniquely identified by a node
875  * revision id, #svn_fs_id_t.  Its node revision id also identifies which
876  * node it is a part of.
877  *
878  * @note: Often when we talk about `the node' within the context of a single
879  * revision (or transaction), we implicitly mean `the node as it appears in
880  * this revision (or transaction)', or in other words `the node revision'.
881  *
882  * @note: Commonly, a node revision will have the same content as some other
883  * node revisions in the same node and in different nodes.  The FS libraries
884  * allow different node revisions to share the same data without storing a
885  * separate copy of the data.
886  *
887  * @defgroup svn_fs_nodes Filesystem nodes
888  * @{
889  */
890
891 /** Defines the possible ways two arbitrary (root, path)-pairs may be
892  * related.
893  *
894  * @since New in 1.9.
895  */
896 typedef enum svn_fs_node_relation_t
897 {
898   /** The (root, path)-pairs are not related, i.e. none of the other cases
899    * apply.  If the roots refer to different @c svn_fs_t instances, then
900    * they are always considered unrelated - even if the underlying
901    * repository is the same.
902    */
903   svn_fs_node_unrelated = 0,
904
905   /** No changes have been made between the (root, path)-pairs, i.e. they
906    * have the same (relative) nodes in their sub-trees, corresponding sub-
907    * tree nodes have the same contents as well as properties and report the
908    * same "created-path" and "created-rev" data.  This implies having a
909    * common ancestor.
910    *
911    * However, due to efficiency considerations, the FS implementation may
912    * report some combinations as merely having a common ancestor
913    * (@a svn_fs_node_common_ancestor) instead of actually being unchanged.
914    */
915   svn_fs_node_unchanged,
916
917   /** The (root, path)-pairs have a common ancestor (which may be one of
918    * them) but there are changes between them, i.e. they don't fall into
919    * the @c svn_fs_node_unchanged category.
920    *
921    * Due to efficiency considerations, the FS implementation may falsely
922    * classify some combinations as merely having a common ancestor that
923    * are, in fact, unchanged (@a svn_fs_node_unchanged).
924    */
925   svn_fs_node_common_ancestor
926
927 } svn_fs_node_relation_t;
928
929 /** An object representing a node-revision id.  */
930 typedef struct svn_fs_id_t svn_fs_id_t;
931
932
933 /** Return -1, 0, or 1 if node revisions @a a and @a b are respectively
934  * unrelated, equivalent, or otherwise related (part of the same node).
935  *
936  * @note Consider using the more expressive #svn_fs_node_relation() instead.
937  *
938  * @see #svn_fs_node_relation
939  */
940 int
941 svn_fs_compare_ids(const svn_fs_id_t *a,
942                    const svn_fs_id_t *b);
943
944
945
946 /** Return TRUE if node revisions @a id1 and @a id2 are related (part of the
947  * same node), else return FALSE.
948  *
949  * @note Consider using the more expressive #svn_fs_node_relation() instead.
950  *
951  * @see #svn_fs_node_relation
952  */
953 svn_boolean_t
954 svn_fs_check_related(const svn_fs_id_t *id1,
955                      const svn_fs_id_t *id2);
956
957
958 /**
959  * @note This function is not guaranteed to work with all filesystem
960  * types.  There is currently no un-deprecated equivalent; contact the
961  * Subversion developers if you have a need for it.
962  *
963  * @deprecated Provided for backward compatibility with the 1.0 API.
964  */
965 SVN_DEPRECATED
966 svn_fs_id_t *
967 svn_fs_parse_id(const char *data,
968                 apr_size_t len,
969                 apr_pool_t *pool);
970
971
972 /** Return a Subversion string containing the unparsed form of the
973  * node revision id @a id.  Allocate the string containing the
974  * unparsed form in @a pool.
975  */
976 svn_string_t *
977 svn_fs_unparse_id(const svn_fs_id_t *id,
978                   apr_pool_t *pool);
979
980 /** @} */
981
982 \f
983 /** Filesystem Transactions.
984  *
985  * To make a change to a Subversion filesystem:
986  * - Create a transaction object, using svn_fs_begin_txn().
987  * - Call svn_fs_txn_root(), to get the transaction's root directory.
988  * - Make whatever changes you like in that tree.
989  * - Commit the transaction, using svn_fs_commit_txn().
990  *
991  * The filesystem implementation guarantees that your commit will
992  * either:
993  * - succeed completely, so that all of the changes are committed to
994  *   create a new revision of the filesystem, or
995  * - fail completely, leaving the filesystem unchanged.
996  *
997  * Until you commit the transaction, any changes you make are
998  * invisible.  Only when your commit succeeds do they become visible
999  * to the outside world, as a new revision of the filesystem.
1000  *
1001  * If you begin a transaction, and then decide you don't want to make
1002  * the change after all (say, because your net connection with the
1003  * client disappeared before the change was complete), you can call
1004  * svn_fs_abort_txn(), to cancel the entire transaction; this
1005  * leaves the filesystem unchanged.
1006  *
1007  * The only way to change the contents of files or directories, or
1008  * their properties, is by making a transaction and creating a new
1009  * revision, as described above.  Once a revision has been committed, it
1010  * never changes again; the filesystem interface provides no means to
1011  * go back and edit the contents of an old revision.  Once history has
1012  * been recorded, it is set in stone.  Clients depend on this property
1013  * to do updates and commits reliably; proxies depend on this property
1014  * to cache changes accurately; and so on.
1015  *
1016  * There are two kinds of nodes in the filesystem: mutable, and
1017  * immutable.  Revisions in the filesystem consist entirely of
1018  * immutable nodes, whose contents never change.  A transaction in
1019  * progress, which the user is still constructing, uses mutable nodes
1020  * for those nodes which have been changed so far, and refers to
1021  * immutable nodes from existing revisions for portions of the tree
1022  * which haven't been changed yet in that transaction.
1023  *
1024  * Immutable nodes, as part of revisions, never refer to mutable
1025  * nodes, which are part of uncommitted transactions.  Mutable nodes
1026  * may refer to immutable nodes, or other mutable nodes.
1027  *
1028  * Note that the terms "immutable" and "mutable" describe whether or
1029  * not the nodes have been changed as part of a transaction --- not
1030  * the permissions on the nodes they refer to.  Even if you aren't
1031  * authorized to modify the filesystem's root directory, you might be
1032  * authorized to change some descendant of the root; doing so would
1033  * create a new mutable copy of the root directory.  Mutability refers
1034  * to the role of the node: part of an existing revision, or part of a
1035  * new one.  This is independent of your authorization to make changes
1036  * to a given node.
1037  *
1038  * Transactions are actually persistent objects, stored in the
1039  * database.  You can open a filesystem, begin a transaction, and
1040  * close the filesystem, and then a separate process could open the
1041  * filesystem, pick up the same transaction, and continue work on it.
1042  * When a transaction is successfully committed, it is removed from
1043  * the database.
1044  *
1045  * Every transaction is assigned a name.  You can open a transaction
1046  * by name, and resume work on it, or find out the name of a
1047  * transaction you already have open.  You can also list all the
1048  * transactions currently present in the database.
1049  *
1050  * You may assign properties to transactions; these are name/value
1051  * pairs.  When you commit a transaction, all of its properties become
1052  * unversioned revision properties of the new revision.  (There is one
1053  * exception: the svn:date property will be automatically set on new
1054  * transactions to the date that the transaction was created, and can
1055  * be overwritten when the transaction is committed by the current
1056  * time; see svn_fs_commit_txn.)
1057  *
1058  * Transaction names are guaranteed to contain only letters (upper-
1059  * and lower-case), digits, `-', and `.', from the ASCII character
1060  * set.
1061  *
1062  * The Subversion filesystem will make a best effort to not reuse
1063  * transaction names.  The Berkeley DB backend generates transaction
1064  * names using a sequence, or a counter, which is stored in the BDB
1065  * database.  Each new transaction increments the counter.  The
1066  * current value of the counter is not serialized into a filesystem
1067  * dump file, so dumping and restoring the repository will reset the
1068  * sequence and reuse transaction names.  The FSFS backend generates a
1069  * transaction name using the hostname, process ID and current time in
1070  * microseconds since 00:00:00 January 1, 1970 UTC.  So it is
1071  * extremely unlikely that a transaction name will be reused.
1072  *
1073  * @defgroup svn_fs_txns Filesystem transactions
1074  * @{
1075  */
1076
1077 /** The type of a Subversion transaction object.  */
1078 typedef struct svn_fs_txn_t svn_fs_txn_t;
1079
1080
1081 /** @defgroup svn_fs_begin_txn2_flags Bitmask flags for svn_fs_begin_txn2()
1082  * @since New in 1.2.
1083  * @{ */
1084
1085 /** Do on-the-fly out-of-dateness checks.  That is, an fs routine may
1086  * throw error if a caller tries to edit an out-of-date item in the
1087  * transaction.
1088  *
1089  * @warning ### Not yet implemented.
1090  */
1091 #define SVN_FS_TXN_CHECK_OOD                     0x00001
1092
1093 /** Do on-the-fly lock checks.  That is, an fs routine may throw error
1094  * if a caller tries to edit a locked item without having rights to the lock.
1095  */
1096 #define SVN_FS_TXN_CHECK_LOCKS                   0x00002
1097
1098 /** Allow the client to specify the final svn:date of the revision by
1099  * setting or deleting the corresponding transaction property rather
1100  * than have it set automatically when the transaction is committed.
1101  *
1102  * @since New in 1.9.
1103  */
1104 #define SVN_FS_TXN_CLIENT_DATE                   0x00004
1105
1106 /** @} */
1107
1108 /**
1109  * Begin a new transaction on the filesystem @a fs, based on existing
1110  * revision @a rev.  Set @a *txn_p to a pointer to the new transaction.
1111  * When committed, this transaction will create a new revision.
1112  *
1113  * Allocate the new transaction in @a pool; when @a pool is freed, the new
1114  * transaction will be closed (neither committed nor aborted).
1115  *
1116  * @a flags determines transaction enforcement behaviors, and is composed
1117  * from the constants SVN_FS_TXN_* (#SVN_FS_TXN_CHECK_OOD etc.).
1118  *
1119  * @note If you're building a txn for committing, you probably
1120  * don't want to call this directly.  Instead, call
1121  * svn_repos_fs_begin_txn_for_commit(), which honors the
1122  * repository's hook configurations.
1123  *
1124  * @since New in 1.2.
1125  */
1126 svn_error_t *
1127 svn_fs_begin_txn2(svn_fs_txn_t **txn_p,
1128                   svn_fs_t *fs,
1129                   svn_revnum_t rev,
1130                   apr_uint32_t flags,
1131                   apr_pool_t *pool);
1132
1133
1134 /**
1135  * Same as svn_fs_begin_txn2(), but with @a flags set to 0.
1136  *
1137  * @deprecated Provided for backward compatibility with the 1.1 API.
1138  */
1139 SVN_DEPRECATED
1140 svn_error_t *
1141 svn_fs_begin_txn(svn_fs_txn_t **txn_p,
1142                  svn_fs_t *fs,
1143                  svn_revnum_t rev,
1144                  apr_pool_t *pool);
1145
1146
1147
1148 /** Commit @a txn.
1149  *
1150  * @note You usually don't want to call this directly.
1151  * Instead, call svn_repos_fs_commit_txn(), which honors the
1152  * repository's hook configurations.
1153  *
1154  * If the transaction conflicts with other changes committed to the
1155  * repository, return an #SVN_ERR_FS_CONFLICT error.  Otherwise, create
1156  * a new filesystem revision containing the changes made in @a txn,
1157  * storing that new revision number in @a *new_rev, and return zero.
1158  *
1159  * If #SVN_FS_TXN_CLIENT_DATE was passed to #svn_fs_begin_txn2 any
1160  * svn:date on the transaction will be become the unversioned property
1161  * svn:date on the revision.  svn:date can have any value, it does not
1162  * have to be a timestamp.  If the transaction has no svn:date the
1163  * revision will have no svn:date.
1164  *
1165  * If #SVN_FS_TXN_CLIENT_DATE was not passed to #svn_fs_begin_txn2 the
1166  * new revision will have svn:date set to the current time at some
1167  * point during the commit and any svn:date on the transaction will be
1168  * lost.
1169  *
1170  * If @a conflict_p is non-zero, use it to provide details on any
1171  * conflicts encountered merging @a txn with the most recent committed
1172  * revisions.  If a conflict occurs, set @a *conflict_p to the path of
1173  * the conflict in @a txn, allocated within @a pool;
1174  * otherwise, set @a *conflict_p to NULL.
1175  *
1176  * If the commit succeeds, @a txn is invalid.
1177  *
1178  * If the commit fails for any reason, @a *new_rev is an invalid
1179  * revision number, an error other than #SVN_NO_ERROR is returned and
1180  * @a txn is still valid; you can make more operations to resolve the
1181  * conflict, or call svn_fs_abort_txn() to abort the transaction.
1182  *
1183  * @note Success or failure of the commit of @a txn is determined by
1184  * examining the value of @a *new_rev upon this function's return.  If
1185  * the value is a valid revision number, the commit was successful,
1186  * even though a non-@c NULL function return value may indicate that
1187  * something else went wrong in post commit FS processing.
1188  *
1189  * @note See api-errata/1.8/fs001.txt for information on how this
1190  * function was documented in versions prior to 1.8.
1191  *
1192  * ### need to document this better. there are four combinations of
1193  * ### return values:
1194  * ### 1) err=NULL. conflict=NULL. new_rev is valid
1195  * ### 2) err=SVN_ERR_FS_CONFLICT. conflict is set. new_rev=SVN_INVALID_REVNUM
1196  * ### 3) err=!NULL. conflict=NULL. new_rev is valid
1197  * ### 4) err=!NULL. conflict=NULL. new_rev=SVN_INVALID_REVNUM
1198  * ###
1199  * ### some invariants:
1200  * ###   *conflict_p will be non-NULL IFF SVN_ERR_FS_CONFLICT
1201  * ###   if *conflict_p is set (and SVN_ERR_FS_CONFLICT), then new_rev
1202  * ###     will always be SVN_INVALID_REVNUM
1203  * ###   *conflict_p will always be initialized to NULL, or to a valid
1204  * ###     conflict string
1205  * ###   *new_rev will always be initialized to SVN_INVALID_REVNUM, or
1206  * ###     to a valid, committed revision number
1207  *
1208  */
1209 svn_error_t *
1210 svn_fs_commit_txn(const char **conflict_p,
1211                   svn_revnum_t *new_rev,
1212                   svn_fs_txn_t *txn,
1213                   apr_pool_t *pool);
1214
1215
1216 /** Abort the transaction @a txn.  Any changes made in @a txn are
1217  * discarded, and the filesystem is left unchanged.  Use @a pool for
1218  * any necessary allocations.
1219  *
1220  * @note This function first sets the state of @a txn to "dead", and
1221  * then attempts to purge it and any related data from the filesystem.
1222  * If some part of the cleanup process fails, @a txn and some portion
1223  * of its data may remain in the database after this function returns.
1224  * Use svn_fs_purge_txn() to retry the transaction cleanup.
1225  */
1226 svn_error_t *
1227 svn_fs_abort_txn(svn_fs_txn_t *txn,
1228                  apr_pool_t *pool);
1229
1230
1231 /** Cleanup the dead transaction in @a fs whose ID is @a txn_id.  Use
1232  * @a pool for all allocations.  If the transaction is not yet dead,
1233  * the error #SVN_ERR_FS_TRANSACTION_NOT_DEAD is returned.  (The
1234  * caller probably forgot to abort the transaction, or the cleanup
1235  * step of that abort failed for some reason.)
1236  */
1237 svn_error_t *
1238 svn_fs_purge_txn(svn_fs_t *fs,
1239                  const char *txn_id,
1240                  apr_pool_t *pool);
1241
1242
1243 /** Set @a *name_p to the name of the transaction @a txn, as a
1244  * NULL-terminated string.  Allocate the name in @a pool.
1245  */
1246 svn_error_t *
1247 svn_fs_txn_name(const char **name_p,
1248                 svn_fs_txn_t *txn,
1249                 apr_pool_t *pool);
1250
1251 /** Return @a txn's base revision. */
1252 svn_revnum_t
1253 svn_fs_txn_base_revision(svn_fs_txn_t *txn);
1254
1255
1256
1257 /** Open the transaction named @a name in the filesystem @a fs.  Set @a *txn
1258  * to the transaction.
1259  *
1260  * If there is no such transaction, #SVN_ERR_FS_NO_SUCH_TRANSACTION is
1261  * the error returned.
1262  *
1263  * Allocate the new transaction in @a pool; when @a pool is freed, the new
1264  * transaction will be closed (neither committed nor aborted).
1265  */
1266 svn_error_t *
1267 svn_fs_open_txn(svn_fs_txn_t **txn,
1268                 svn_fs_t *fs,
1269                 const char *name,
1270                 apr_pool_t *pool);
1271
1272
1273 /** Set @a *names_p to an array of <tt>const char *</tt> ids which are the
1274  * names of all the currently active transactions in the filesystem @a fs.
1275  * Allocate the array in @a pool.
1276  */
1277 svn_error_t *
1278 svn_fs_list_transactions(apr_array_header_t **names_p,
1279                          svn_fs_t *fs,
1280                          apr_pool_t *pool);
1281
1282 /* Transaction properties */
1283
1284 /** Set @a *value_p to the value of the property named @a propname on
1285  * transaction @a txn.  If @a txn has no property by that name, set
1286  * @a *value_p to zero.  Allocate the result in @a pool.
1287  */
1288 svn_error_t *
1289 svn_fs_txn_prop(svn_string_t **value_p,
1290                 svn_fs_txn_t *txn,
1291                 const char *propname,
1292                 apr_pool_t *pool);
1293
1294
1295 /** Set @a *table_p to the entire property list of transaction @a txn, as
1296  * an APR hash table allocated in @a pool.  The resulting table maps property
1297  * names to pointers to #svn_string_t objects containing the property value.
1298  */
1299 svn_error_t *
1300 svn_fs_txn_proplist(apr_hash_t **table_p,
1301                     svn_fs_txn_t *txn,
1302                     apr_pool_t *pool);
1303
1304
1305 /** Change a transactions @a txn's property's value, or add/delete a
1306  * property.  @a name is the name of the property to change, and @a value
1307  * is the new value of the property, or zero if the property should be
1308  * removed altogether.  Do any necessary temporary allocation in @a pool.
1309  */
1310 svn_error_t *
1311 svn_fs_change_txn_prop(svn_fs_txn_t *txn,
1312                        const char *name,
1313                        const svn_string_t *value,
1314                        apr_pool_t *pool);
1315
1316
1317 /** Change, add, and/or delete transaction property values in
1318  * transaction @a txn.  @a props is an array of <tt>svn_prop_t</tt>
1319  * elements.  This is equivalent to calling svn_fs_change_txn_prop()
1320  * multiple times with the @c name and @c value fields of each
1321  * successive <tt>svn_prop_t</tt>, but may be more efficient.
1322  * (Properties not mentioned are left alone.)  Do any necessary
1323  * temporary allocation in @a pool.
1324  *
1325  * @since New in 1.5.
1326  */
1327 svn_error_t *
1328 svn_fs_change_txn_props(svn_fs_txn_t *txn,
1329                         const apr_array_header_t *props,
1330                         apr_pool_t *pool);
1331
1332 /** @} */
1333
1334 \f
1335 /** Roots.
1336  *
1337  * An #svn_fs_root_t object represents the root directory of some
1338  * revision or transaction in a filesystem.  To refer to particular
1339  * node or node revision, you provide a root, and a directory path
1340  * relative to that root.
1341  *
1342  * @defgroup svn_fs_roots Filesystem roots
1343  * @{
1344  */
1345
1346 /** The Filesystem Root object. */
1347 typedef struct svn_fs_root_t svn_fs_root_t;
1348
1349
1350 /** Set @a *root_p to the root directory of revision @a rev in filesystem @a fs.
1351  * Allocate @a *root_p in a private subpool of @a pool; the root can be
1352  * destroyed earlier than @a pool by calling #svn_fs_close_root.
1353  */
1354 svn_error_t *
1355 svn_fs_revision_root(svn_fs_root_t **root_p,
1356                      svn_fs_t *fs,
1357                      svn_revnum_t rev,
1358                      apr_pool_t *pool);
1359
1360
1361 /** Set @a *root_p to the root directory of @a txn.  Allocate @a *root_p in a
1362  * private subpool of @a pool; the root can be destroyed earlier than @a pool by
1363  * calling #svn_fs_close_root.
1364  */
1365 svn_error_t *
1366 svn_fs_txn_root(svn_fs_root_t **root_p,
1367                 svn_fs_txn_t *txn,
1368                 apr_pool_t *pool);
1369
1370
1371 /** Free the root directory @a root; this only needs to be used if you want to
1372  * free the memory associated with @a root earlier than the time you destroy
1373  * the pool passed to the function that created it (svn_fs_revision_root() or
1374  * svn_fs_txn_root()).
1375  */
1376 void
1377 svn_fs_close_root(svn_fs_root_t *root);
1378
1379
1380 /** Return the filesystem to which @a root belongs.  */
1381 svn_fs_t *
1382 svn_fs_root_fs(svn_fs_root_t *root);
1383
1384
1385 /** Return @c TRUE iff @a root is a transaction root.  */
1386 svn_boolean_t
1387 svn_fs_is_txn_root(svn_fs_root_t *root);
1388
1389 /** Return @c TRUE iff @a root is a revision root.  */
1390 svn_boolean_t
1391 svn_fs_is_revision_root(svn_fs_root_t *root);
1392
1393
1394 /** If @a root is the root of a transaction, return the name of the
1395  * transaction, allocated in @a pool; otherwise, return NULL.
1396  */
1397 const char *
1398 svn_fs_txn_root_name(svn_fs_root_t *root,
1399                      apr_pool_t *pool);
1400
1401 /** If @a root is the root of a transaction, return the number of the
1402  * revision on which is was based when created.  Otherwise, return
1403  * #SVN_INVALID_REVNUM.
1404  *
1405  * @since New in 1.5.
1406  */
1407 svn_revnum_t
1408 svn_fs_txn_root_base_revision(svn_fs_root_t *root);
1409
1410 /** If @a root is the root of a revision, return the revision number.
1411  * Otherwise, return #SVN_INVALID_REVNUM.
1412  */
1413 svn_revnum_t
1414 svn_fs_revision_root_revision(svn_fs_root_t *root);
1415
1416 /** @} */
1417
1418 \f
1419 /** Directory entry names and directory paths.
1420  *
1421  * Here are the rules for directory entry names, and directory paths:
1422  *
1423  * A directory entry name is a Unicode string encoded in UTF-8, and
1424  * may not contain the NULL character (U+0000).  The name should be in
1425  * Unicode canonical decomposition and ordering.  No directory entry
1426  * may be named '.', '..', or the empty string.  Given a directory
1427  * entry name which fails to meet these requirements, a filesystem
1428  * function returns an SVN_ERR_FS_PATH_SYNTAX error.
1429  *
1430  * A directory path is a sequence of zero or more directory entry
1431  * names, separated by slash characters (U+002f), and possibly ending
1432  * with slash characters.  Sequences of two or more consecutive slash
1433  * characters are treated as if they were a single slash.  If a path
1434  * ends with a slash, it refers to the same node it would without the
1435  * slash, but that node must be a directory, or else the function
1436  * returns an SVN_ERR_FS_NOT_DIRECTORY error.
1437  *
1438  * A path consisting of the empty string, or a string containing only
1439  * slashes, refers to the root directory.
1440  *
1441  * @defgroup svn_fs_directories Filesystem directories
1442  * @{
1443  */
1444
1445
1446 \f
1447 /** The kind of change that occurred on the path. */
1448 typedef enum svn_fs_path_change_kind_t
1449 {
1450   /** path modified in txn */
1451   svn_fs_path_change_modify = 0,
1452
1453   /** path added in txn */
1454   svn_fs_path_change_add,
1455
1456   /** path removed in txn */
1457   svn_fs_path_change_delete,
1458
1459   /** path removed and re-added in txn */
1460   svn_fs_path_change_replace,
1461
1462   /** ignore all previous change items for path (internal-use only) */
1463   svn_fs_path_change_reset
1464 } svn_fs_path_change_kind_t;
1465
1466 /** Change descriptor.
1467  *
1468  * @note Fields may be added to the end of this structure in future
1469  * versions.  Therefore, to preserve binary compatibility, users
1470  * should not directly allocate structures of this type.
1471  *
1472  * @note The @c text_mod, @c prop_mod and @c mergeinfo_mod flags mean the
1473  * text, properties and mergeinfo property (respectively) were "touched"
1474  * by the commit API; this does not mean the new value is different from
1475  * the old value.
1476  *
1477  * @since New in 1.6. */
1478 typedef struct svn_fs_path_change2_t
1479 {
1480   /** node revision id of changed path */
1481   const svn_fs_id_t *node_rev_id;
1482
1483   /** kind of change */
1484   svn_fs_path_change_kind_t change_kind;
1485
1486   /** was the text touched?
1487    * For node_kind=dir: always false. For node_kind=file:
1488    *   modify:      true iff text touched.
1489    *   add (copy):  true iff text touched.
1490    *   add (plain): always true.
1491    *   delete:      always false.
1492    *   replace:     as for the add/copy part of the replacement.
1493    */
1494   svn_boolean_t text_mod;
1495
1496   /** were the properties touched?
1497    *   modify:      true iff props touched.
1498    *   add (copy):  true iff props touched.
1499    *   add (plain): true iff props touched.
1500    *   delete:      always false.
1501    *   replace:     as for the add/copy part of the replacement.
1502    */
1503   svn_boolean_t prop_mod;
1504
1505   /** what node kind is the path?
1506       (Note: it is legal for this to be #svn_node_unknown.) */
1507   svn_node_kind_t node_kind;
1508
1509   /** Copyfrom revision and path; this is only valid if copyfrom_known
1510    * is true. */
1511   svn_boolean_t copyfrom_known;
1512   svn_revnum_t copyfrom_rev;
1513   const char *copyfrom_path;
1514
1515   /** was the mergeinfo property touched?
1516    *   modify:      } true iff svn:mergeinfo property add/del/mod
1517    *   add (copy):  }          and fs format supports this flag.
1518    *   add (plain): }
1519    *   delete:      always false.
1520    *   replace:     as for the add/copy part of the replacement.
1521    * (Note: Pre-1.9 repositories will report #svn_tristate_unknown.)
1522    * @since New in 1.9. */
1523   svn_tristate_t mergeinfo_mod;
1524   /* NOTE! Please update svn_fs_path_change2_create() when adding new
1525      fields here. */
1526 } svn_fs_path_change2_t;
1527
1528
1529 /** Similar to #svn_fs_path_change2_t, but without kind and copyfrom
1530  * information.
1531  *
1532  * @deprecated Provided for backwards compatibility with the 1.5 API.
1533  */
1534
1535 typedef struct svn_fs_path_change_t
1536 {
1537   /** node revision id of changed path */
1538   const svn_fs_id_t *node_rev_id;
1539
1540   /** kind of change */
1541   svn_fs_path_change_kind_t change_kind;
1542
1543   /** were there text mods? */
1544   svn_boolean_t text_mod;
1545
1546   /** were there property mods? */
1547   svn_boolean_t prop_mod;
1548
1549 } svn_fs_path_change_t;
1550
1551 /**
1552  * Allocate an #svn_fs_path_change2_t structure in @a pool, initialize and
1553  * return it.
1554  *
1555  * Set the @c node_rev_id field of the created struct to @a node_rev_id, and
1556  * @c change_kind to @a change_kind.  Set all other fields to their
1557  * @c _unknown, @c NULL or invalid value, respectively.
1558  *
1559  * @since New in 1.6.
1560  */
1561 svn_fs_path_change2_t *
1562 svn_fs_path_change2_create(const svn_fs_id_t *node_rev_id,
1563                            svn_fs_path_change_kind_t change_kind,
1564                            apr_pool_t *pool);
1565
1566 /** Determine what has changed under a @a root.
1567  *
1568  * Allocate and return a hash @a *changed_paths2_p containing descriptions
1569  * of the paths changed under @a root.  The hash is keyed with
1570  * <tt>const char *</tt> paths, and has #svn_fs_path_change2_t * values.
1571  *
1572  * Callers can assume that this function takes time proportional to
1573  * the amount of data output, and does not need to do tree crawls;
1574  * however, it is possible that some of the @c node_kind fields in the
1575  * #svn_fs_path_change2_t * values will be #svn_node_unknown or
1576  * that and some of the @c copyfrom_known fields will be FALSE.
1577  *
1578  * Use @a pool for all allocations, including the hash and its values.
1579  *
1580  * @since New in 1.6.
1581  */
1582 svn_error_t *
1583 svn_fs_paths_changed2(apr_hash_t **changed_paths2_p,
1584                       svn_fs_root_t *root,
1585                       apr_pool_t *pool);
1586
1587
1588 /** Same as svn_fs_paths_changed2(), only with #svn_fs_path_change_t * values
1589  * in the hash (and thus no kind or copyfrom data).
1590  *
1591  * @deprecated Provided for backward compatibility with the 1.5 API.
1592  */
1593 SVN_DEPRECATED
1594 svn_error_t *
1595 svn_fs_paths_changed(apr_hash_t **changed_paths_p,
1596                      svn_fs_root_t *root,
1597                      apr_pool_t *pool);
1598
1599 /** @} */
1600
1601 \f
1602 /* Operations appropriate to all kinds of nodes.  */
1603
1604 /** Set @a *kind_p to the type of node present at @a path under @a
1605  * root.  If @a path does not exist under @a root, set @a *kind_p to
1606  * #svn_node_none.  Use @a pool for temporary allocation.
1607  */
1608 svn_error_t *
1609 svn_fs_check_path(svn_node_kind_t *kind_p,
1610                   svn_fs_root_t *root,
1611                   const char *path,
1612                   apr_pool_t *pool);
1613
1614
1615 /** An opaque node history object. */
1616 typedef struct svn_fs_history_t svn_fs_history_t;
1617
1618
1619 /** Set @a *history_p to an opaque node history object which
1620  * represents @a path under @a root.  @a root must be a revision root.
1621  * Allocate the result in @a result_pool and use @a scratch_pool for
1622  * temporary allocations.
1623  *
1624  * @since New in 1.9.
1625  */
1626 svn_error_t *
1627 svn_fs_node_history2(svn_fs_history_t **history_p,
1628                      svn_fs_root_t *root,
1629                      const char *path,
1630                      apr_pool_t *result_pool,
1631                      apr_pool_t *scratch_pool);
1632
1633 /** Same as svn_fs_node_history2() but using a single @a pool for all
1634  * allocations.
1635  *
1636  * @deprecated Provided for backward compatibility with the 1.8 API.
1637  */
1638 SVN_DEPRECATED
1639 svn_error_t *
1640 svn_fs_node_history(svn_fs_history_t **history_p,
1641                     svn_fs_root_t *root,
1642                     const char *path,
1643                     apr_pool_t *pool);
1644
1645
1646 /** Set @a *prev_history_p to an opaque node history object which
1647  * represents the previous (or "next oldest") interesting history
1648  * location for the filesystem node represented by @a history, or @c
1649  * NULL if no such previous history exists.  If @a cross_copies is @c
1650  * FALSE, also return @c NULL if stepping backwards in history to @a
1651  * *prev_history_p would cross a filesystem copy operation.
1652  *
1653  * @note If this is the first call to svn_fs_history_prev() for the @a
1654  * history object, it could return a history object whose location is
1655  * the same as the original.  This will happen if the original
1656  * location was an interesting one (where the node was modified, or
1657  * took place in a copy event).  This behavior allows looping callers
1658  * to avoid the calling svn_fs_history_location() on the object
1659  * returned by svn_fs_node_history(), and instead go ahead and begin
1660  * calling svn_fs_history_prev().
1661  *
1662  * @note This function uses node-id ancestry alone to determine
1663  * modifiedness, and therefore does NOT claim that in any of the
1664  * returned revisions file contents changed, properties changed,
1665  * directory entries lists changed, etc.
1666  *
1667  * @note The revisions returned for @a path will be older than or
1668  * the same age as the revision of that path in @a root.  That is, if
1669  * @a root is a revision root based on revision X, and @a path was
1670  * modified in some revision(s) younger than X, those revisions
1671  * younger than X will not be included for @a path.
1672  *
1673  * Allocate the result in @a result_pool and use @a scratch_pool for
1674  * temporary allocations.
1675  *
1676  * @since New in 1.9. */
1677 svn_error_t *
1678 svn_fs_history_prev2(svn_fs_history_t **prev_history_p,
1679                      svn_fs_history_t *history,
1680                      svn_boolean_t cross_copies,
1681                      apr_pool_t *result_pool,
1682                      apr_pool_t *scratch_pool);
1683
1684 /** Same as svn_fs_history_prev2() but using a single @a pool for all
1685  * allocations.
1686  *
1687  * @deprecated Provided for backward compatibility with the 1.8 API.
1688  */
1689 SVN_DEPRECATED
1690 svn_error_t *
1691 svn_fs_history_prev(svn_fs_history_t **prev_history_p,
1692                     svn_fs_history_t *history,
1693                     svn_boolean_t cross_copies,
1694                     apr_pool_t *pool);
1695
1696
1697 /** Set @a *path and @a *revision to the path and revision,
1698  * respectively, of the @a history object.  Use @a pool for all
1699  * allocations.
1700  */
1701 svn_error_t *
1702 svn_fs_history_location(const char **path,
1703                         svn_revnum_t *revision,
1704                         svn_fs_history_t *history,
1705                         apr_pool_t *pool);
1706
1707
1708 /** Set @a *is_dir to @c TRUE iff @a path in @a root is a directory.
1709  * Do any necessary temporary allocation in @a pool.
1710  */
1711 svn_error_t *
1712 svn_fs_is_dir(svn_boolean_t *is_dir,
1713               svn_fs_root_t *root,
1714               const char *path,
1715               apr_pool_t *pool);
1716
1717
1718 /** Set @a *is_file to @c TRUE iff @a path in @a root is a file.
1719  * Do any necessary temporary allocation in @a pool.
1720  */
1721 svn_error_t *
1722 svn_fs_is_file(svn_boolean_t *is_file,
1723                svn_fs_root_t *root,
1724                const char *path,
1725                apr_pool_t *pool);
1726
1727
1728 /** Get the id of a node.
1729  *
1730  * Set @a *id_p to the node revision ID of @a path in @a root, allocated in
1731  * @a pool.
1732  *
1733  * If @a root is the root of a transaction, keep in mind that other
1734  * changes to the transaction can change which node @a path refers to,
1735  * and even whether the path exists at all.
1736  */
1737 svn_error_t *
1738 svn_fs_node_id(const svn_fs_id_t **id_p,
1739                svn_fs_root_t *root,
1740                const char *path,
1741                apr_pool_t *pool);
1742
1743 /** Determine how @a path_a under @a root_a and @a path_b under @a root_b
1744  * are related and return the result in @a relation.  There is no restriction
1745  * concerning the roots: They may refer to different repositories, be in
1746  * arbitrary revision order and any of them may pertain to a transaction.
1747  * @a scratch_pool is used for temporary allocations.
1748  *
1749  * @note Paths from different svn_fs_t will be reported as unrelated even
1750  * if the underlying physical repository is the same.
1751  *
1752  * @since New in 1.9.
1753  */
1754 svn_error_t *
1755 svn_fs_node_relation(svn_fs_node_relation_t *relation,
1756                      svn_fs_root_t *root_a,
1757                      const char *path_a,
1758                      svn_fs_root_t *root_b,
1759                      const char *path_b,
1760                      apr_pool_t *scratch_pool);
1761
1762 /** Set @a *revision to the revision in which the node-revision identified
1763  * by @a path under @a root was created; that is, to the revision in which
1764  * @a path under @a root was last modified.  @a *revision will
1765  * be set to #SVN_INVALID_REVNUM for uncommitted nodes (i.e. modified nodes
1766  * under a transaction root).  Note that the root of an unmodified transaction
1767  * is not itself considered to be modified; in that case, return the revision
1768  * upon which the transaction was based.
1769  *
1770  * Use @a pool for any temporary allocations.
1771  */
1772 svn_error_t *
1773 svn_fs_node_created_rev(svn_revnum_t *revision,
1774                         svn_fs_root_t *root,
1775                         const char *path,
1776                         apr_pool_t *pool);
1777
1778 /** Set @a *revision to the revision in which the line of history
1779  * represented by @a path under @a root originated.  Use @a pool for
1780  * any temporary allocations.  If @a root is a transaction root, @a
1781  * *revision will be set to #SVN_INVALID_REVNUM for any nodes newly
1782  * added in that transaction (brand new files or directories created
1783  * using #svn_fs_make_dir or #svn_fs_make_file).
1784  *
1785  * @since New in 1.5.
1786  */
1787 svn_error_t *
1788 svn_fs_node_origin_rev(svn_revnum_t *revision,
1789                        svn_fs_root_t *root,
1790                        const char *path,
1791                        apr_pool_t *pool);
1792
1793 /** Set @a *created_path to the path at which @a path under @a root was
1794  * created.  Use @a pool for all allocations.  Callers may use this
1795  * function in conjunction with svn_fs_node_created_rev() to perform a
1796  * reverse lookup of the mapping of (path, revision) -> node-id that
1797  * svn_fs_node_id() performs.
1798  */
1799 svn_error_t *
1800 svn_fs_node_created_path(const char **created_path,
1801                          svn_fs_root_t *root,
1802                          const char *path,
1803                          apr_pool_t *pool);
1804
1805
1806 /** Set @a *value_p to the value of the property named @a propname of
1807  * @a path in @a root.  If the node has no property by that name, set
1808  * @a *value_p to zero.  Allocate the result in @a pool.
1809  */
1810 svn_error_t *
1811 svn_fs_node_prop(svn_string_t **value_p,
1812                  svn_fs_root_t *root,
1813                  const char *path,
1814                  const char *propname,
1815                  apr_pool_t *pool);
1816
1817
1818 /** Set @a *table_p to the entire property list of @a path in @a root,
1819  * as an APR hash table allocated in @a pool.  The resulting table maps
1820  * property names to pointers to #svn_string_t objects containing the
1821  * property value.
1822  */
1823 svn_error_t *
1824 svn_fs_node_proplist(apr_hash_t **table_p,
1825                      svn_fs_root_t *root,
1826                      const char *path,
1827                      apr_pool_t *pool);
1828
1829 /** Set @a *has_props to TRUE if the node @a path in @a root has properties
1830  * and to FALSE if it doesn't have properties. Perform temporary allocations
1831  * in @a scratch_pool.
1832  *
1833  * @since New in 1.9.
1834  */
1835 svn_error_t *
1836 svn_fs_node_has_props(svn_boolean_t *has_props,
1837                       svn_fs_root_t *root,
1838                       const char *path,
1839                       apr_pool_t *scratch_pool);
1840
1841
1842 /** Change a node's property's value, or add/delete a property.
1843  *
1844  * - @a root and @a path indicate the node whose property should change.
1845  *   @a root must be the root of a transaction, not the root of a revision.
1846  * - @a name is the name of the property to change.
1847  * - @a value is the new value of the property, or zero if the property should
1848  *   be removed altogether.
1849  * Do any necessary temporary allocation in @a pool.
1850  */
1851 svn_error_t *
1852 svn_fs_change_node_prop(svn_fs_root_t *root,
1853                         const char *path,
1854                         const char *name,
1855                         const svn_string_t *value,
1856                         apr_pool_t *pool);
1857
1858
1859 /** Determine if the properties of two path/root combinations are different.
1860  *
1861  * Set @a *different_p to #TRUE if the properties at @a path1 under @a root1
1862  * differ from those at @a path2 under @a root2, or set it to #FALSE if they
1863  * are the same.  Both paths must exist under their respective roots, and
1864  * both roots must be in the same filesystem.
1865  * Do any necessary temporary allocation in @a scratch_pool.
1866  *
1867  * @note For the purposes of preserving accurate history, certain bits of
1868  * code (such as the repository dump code) need to care about the distinction
1869  * between situations when the properties are "different" and "have changed
1870  * across two points in history".  We have a pair of functions that can
1871  * answer both of these questions, svn_fs_props_different() and
1872  * svn_fs_props_changed().  See issue 4598 for more details.
1873  *
1874  * @see svn_fs_props_changed
1875  *
1876  * @since New in 1.9.
1877  */
1878 svn_error_t *
1879 svn_fs_props_different(svn_boolean_t *different_p,
1880                        svn_fs_root_t *root1,
1881                        const char *path1,
1882                        svn_fs_root_t *root2,
1883                        const char *path2,
1884                        apr_pool_t *scratch_pool);
1885
1886
1887 /** Determine if the properties of two path/root combinations have changed.
1888  *
1889  * Set @a *changed_p to #TRUE if the properties at @a path1 under @a root1
1890  * differ from those at @a path2 under @a root2, or set it to #FALSE if they
1891  * are the same.  Both paths must exist under their respective roots, and
1892  * both roots must be in the same filesystem.
1893  * Do any necessary temporary allocation in @a pool.
1894  *
1895  * @note For the purposes of preserving accurate history, certain bits of
1896  * code (such as the repository dump code) need to care about the distinction
1897  * between situations when the properties are "different" and "have changed
1898  * across two points in history".  We have a pair of functions that can
1899  * answer both of these questions, svn_fs_props_different() and
1900  * svn_fs_props_changed().  See issue 4598 for more details.
1901  *
1902  * @note This function can currently return false negatives for FSFS:
1903  * If @a root1 and @a root2 were both transaction roots and the proplists
1904  * of both paths had been changed in their respective transactions,
1905  * @a changed_p would be set to #FALSE.
1906  *
1907  * @see svn_fs_props_different
1908  */
1909 svn_error_t *
1910 svn_fs_props_changed(svn_boolean_t *changed_p,
1911                      svn_fs_root_t *root1,
1912                      const char *path1,
1913                      svn_fs_root_t *root2,
1914                      const char *path2,
1915                      apr_pool_t *pool);
1916
1917
1918 /** Discover a node's copy ancestry, if any.
1919  *
1920  * If the node at @a path in @a root was copied from some other node, set
1921  * @a *rev_p and @a *path_p to the revision and path (expressed as an
1922  * absolute filesystem path) of the other node, allocating @a *path_p
1923  * in @a pool.
1924  *
1925  * Else if there is no copy ancestry for the node, set @a *rev_p to
1926  * #SVN_INVALID_REVNUM and @a *path_p to NULL.
1927  *
1928  * If an error is returned, the values of @a *rev_p and @a *path_p are
1929  * undefined, but otherwise, if one of them is set as described above,
1930  * you may assume the other is set correspondingly.
1931  *
1932  * @a root may be a revision root or a transaction root.
1933  *
1934  * Notes:
1935  *    - Copy ancestry does not descend.  After copying directory D to
1936  *      E, E will have copy ancestry referring to D, but E's children
1937  *      may not.  See also svn_fs_copy().
1938  *
1939  *    - Copy ancestry *under* a copy is preserved.  That is, if you
1940  *      copy /A/D/G/pi to /A/D/G/pi2, and then copy /A/D/G to /G, then
1941  *      /G/pi2 will still have copy ancestry pointing to /A/D/G/pi.
1942  *      We don't know if this is a feature or a bug yet; if it turns
1943  *      out to be a bug, then the fix is to make svn_fs_copied_from()
1944  *      observe the following logic, which currently callers may
1945  *      choose to follow themselves: if node X has copy history, but
1946  *      its ancestor A also has copy history, then you may ignore X's
1947  *      history if X's revision-of-origin is earlier than A's --
1948  *      because that would mean that X's copy history was preserved in
1949  *      a copy-under-a-copy scenario.  If X's revision-of-origin is
1950  *      the same as A's, then it was copied under A during the same
1951  *      transaction that created A.  (X's revision-of-origin cannot be
1952  *      greater than A's, if X has copy history.)  @todo See how
1953  *      people like this, it can always be hidden behind the curtain
1954  *      if necessary.
1955  *
1956  *    - Copy ancestry is not stored as a regular subversion property
1957  *      because it is not inherited.  Copying foo to bar results in a
1958  *      revision of bar with copy ancestry; but committing a text
1959  *      change to bar right after that results in a new revision of
1960  *      bar without copy ancestry.
1961  */
1962 svn_error_t *
1963 svn_fs_copied_from(svn_revnum_t *rev_p,
1964                    const char **path_p,
1965                    svn_fs_root_t *root,
1966                    const char *path,
1967                    apr_pool_t *pool);
1968
1969
1970 /** Set @a *root_p and @a *path_p to the revision root and path of the
1971  * destination of the most recent copy event that caused @a path to
1972  * exist where it does in @a root, or to NULL if no such copy exists.
1973  *
1974  * @a *path_p might be a parent of @a path, rather than @a path
1975  * itself.  However, it will always be the deepest relevant path.
1976  * That is, if a copy occurs underneath another copy in the same txn,
1977  * this function makes sure to set @a *path_p to the longest copy
1978  * destination path that is still a parent of or equal to @a path.
1979  *
1980  * Values returned in @a *root_p and @a *path_p will be allocated
1981  * from @a pool.
1982  *
1983  * @since New in 1.3.
1984  */
1985 svn_error_t *
1986 svn_fs_closest_copy(svn_fs_root_t **root_p,
1987                     const char **path_p,
1988                     svn_fs_root_t *root,
1989                     const char *path,
1990                     apr_pool_t *pool);
1991
1992
1993 /** Retrieve mergeinfo for multiple nodes.
1994  *
1995  * @a *catalog is a catalog for @a paths.  It will never be @c NULL,
1996  * but may be empty.
1997  *
1998  * @a root is revision root to use when looking up paths.
1999  *
2000  * @a paths are the paths you are requesting information for.
2001  *
2002  * @a inherit indicates whether to retrieve explicit,
2003  * explicit-or-inherited, or only inherited mergeinfo.
2004  *
2005  * If @a adjust_inherited_mergeinfo is @c TRUE, then any inherited
2006  * mergeinfo returned in @a *catalog is normalized to represent the
2007  * inherited mergeinfo on the path which inherits it.  This adjusted
2008  * mergeinfo is keyed by the path which inherits it.  If
2009  * @a adjust_inherited_mergeinfo is @c FALSE, then any inherited
2010  * mergeinfo is the raw explicit mergeinfo from the nearest parent
2011  * of the path with explicit mergeinfo, unadjusted for the path-wise
2012  * difference between the path and its parent.  This may include
2013  * non-inheritable mergeinfo.  This unadjusted mergeinfo is keyed by
2014  * the path at which it was found.
2015  *
2016  * If @a include_descendants is TRUE, then additionally return the
2017  * mergeinfo for any descendant of any element of @a paths which has
2018  * the #SVN_PROP_MERGEINFO property explicitly set on it.  (Note
2019  * that inheritance is only taken into account for the elements in @a
2020  * paths; descendants of the elements in @a paths which get their
2021  * mergeinfo via inheritance are not included in @a *catalog.)
2022  *
2023  * Allocate @a *catalog in result_pool.  Do any necessary temporary
2024  * allocations in @a scratch_pool.
2025  *
2026  * @since New in 1.8.
2027  */
2028 svn_error_t *
2029 svn_fs_get_mergeinfo2(svn_mergeinfo_catalog_t *catalog,
2030                       svn_fs_root_t *root,
2031                       const apr_array_header_t *paths,
2032                       svn_mergeinfo_inheritance_t inherit,
2033                       svn_boolean_t include_descendants,
2034                       svn_boolean_t adjust_inherited_mergeinfo,
2035                       apr_pool_t *result_pool,
2036                       apr_pool_t *scratch_pool);
2037
2038 /**
2039  * Same as svn_fs_get_mergeinfo2(), but with @a adjust_inherited_mergeinfo
2040  * set always set to @c TRUE and with only one pool.
2041  *
2042  * @deprecated Provided for backward compatibility with the 1.5 API.
2043  */
2044 SVN_DEPRECATED
2045 svn_error_t *
2046 svn_fs_get_mergeinfo(svn_mergeinfo_catalog_t *catalog,
2047                      svn_fs_root_t *root,
2048                      const apr_array_header_t *paths,
2049                      svn_mergeinfo_inheritance_t inherit,
2050                      svn_boolean_t include_descendants,
2051                      apr_pool_t *pool);
2052
2053 /** Merge changes between two nodes into a third node.
2054  *
2055  * Given nodes @a source and @a target, and a common ancestor @a ancestor,
2056  * modify @a target to contain all the changes made between @a ancestor and
2057  * @a source, as well as the changes made between @a ancestor and @a target.
2058  * @a target_root must be the root of a transaction, not a revision.
2059  *
2060  * @a source, @a target, and @a ancestor are generally directories; this
2061  * function recursively merges the directories' contents.  If they are
2062  * files, this function simply returns an error whenever @a source,
2063  * @a target, and @a ancestor are all distinct node revisions.
2064  *
2065  * If there are differences between @a ancestor and @a source that conflict
2066  * with changes between @a ancestor and @a target, this function returns an
2067  * #SVN_ERR_FS_CONFLICT error.
2068  *
2069  * If the merge is successful, @a target is left in the merged state, and
2070  * the base root of @a target's txn is set to the root node of @a source.
2071  * If an error is returned (whether for conflict or otherwise), @a target
2072  * is left unaffected.
2073  *
2074  * If @a conflict_p is non-NULL, then: a conflict error sets @a *conflict_p
2075  * to the name of the node in @a target which couldn't be merged,
2076  * otherwise, success sets @a *conflict_p to NULL.
2077  *
2078  * Do any necessary temporary allocation in @a pool.
2079  */
2080 svn_error_t *
2081 svn_fs_merge(const char **conflict_p,
2082              svn_fs_root_t *source_root,
2083              const char *source_path,
2084              svn_fs_root_t *target_root,
2085              const char *target_path,
2086              svn_fs_root_t *ancestor_root,
2087              const char *ancestor_path,
2088              apr_pool_t *pool);
2089
2090
2091 \f
2092 /* Directories.  */
2093
2094
2095 /** The type of a Subversion directory entry.  */
2096 typedef struct svn_fs_dirent_t
2097 {
2098
2099   /** The name of this directory entry.  */
2100   const char *name;
2101
2102   /** The node revision ID it names.  */
2103   const svn_fs_id_t *id;
2104
2105   /** The node kind. */
2106   svn_node_kind_t kind;
2107
2108 } svn_fs_dirent_t;
2109
2110
2111 /** Set @a *entries_p to a newly allocated APR hash table containing the
2112  * entries of the directory at @a path in @a root.  The keys of the table
2113  * are entry names, as byte strings, excluding the final NULL
2114  * character; the table's values are pointers to #svn_fs_dirent_t
2115  * structures.  Allocate the table and its contents in @a pool.
2116  */
2117 svn_error_t *
2118 svn_fs_dir_entries(apr_hash_t **entries_p,
2119                    svn_fs_root_t *root,
2120                    const char *path,
2121                    apr_pool_t *pool);
2122
2123 /** Take the #svn_fs_dirent_t structures in @a entries as returned by
2124  * #svn_fs_dir_entries for @a root and determine an optimized ordering
2125  * in which data access would most likely be efficient.  Set @a *ordered_p
2126  * to a newly allocated APR array of pointers to these #svn_fs_dirent_t
2127  * structures.  Allocate the array (but not its contents) in @a result_pool
2128  * and use @a scratch_pool for temporaries.
2129  *
2130  * @since New in 1.9.
2131  */
2132 svn_error_t *
2133 svn_fs_dir_optimal_order(apr_array_header_t **ordered_p,
2134                          svn_fs_root_t *root,
2135                          apr_hash_t *entries,
2136                          apr_pool_t *result_pool,
2137                          apr_pool_t *scratch_pool);
2138
2139 /** Create a new directory named @a path in @a root.  The new directory has
2140  * no entries, and no properties.  @a root must be the root of a transaction,
2141  * not a revision.
2142  *
2143  * Do any necessary temporary allocation in @a pool.
2144  */
2145 svn_error_t *
2146 svn_fs_make_dir(svn_fs_root_t *root,
2147                 const char *path,
2148                 apr_pool_t *pool);
2149
2150
2151 /** Delete the node named @a path in @a root.  If the node being deleted is
2152  * a directory, its contents will be deleted recursively.  @a root must be
2153  * the root of a transaction, not of a revision.  Use @a pool for
2154  * temporary allocation.
2155  *
2156  * If return #SVN_ERR_FS_NO_SUCH_ENTRY, then the basename of @a path is
2157  * missing from its parent, that is, the final target of the deletion
2158  * is missing.
2159  *
2160  * Attempting to remove the root dir also results in an error,
2161  * #SVN_ERR_FS_ROOT_DIR, even if the dir is empty.
2162  */
2163 svn_error_t *
2164 svn_fs_delete(svn_fs_root_t *root,
2165               const char *path,
2166               apr_pool_t *pool);
2167
2168
2169 /** Create a copy of @a from_path in @a from_root named @a to_path in
2170  * @a to_root.  If @a from_path in @a from_root is a directory, copy the
2171  * tree it refers to recursively.
2172  *
2173  * The copy will remember its source; use svn_fs_copied_from() to
2174  * access this information.
2175  *
2176  * @a to_root must be the root of a transaction; @a from_root must be the
2177  * root of a revision.  (Requiring @a from_root to be the root of a
2178  * revision makes the implementation trivial: there is no detectable
2179  * difference (modulo node revision ID's) between copying @a from and
2180  * simply adding a reference to it.  So the operation takes place in
2181  * constant time.  However, there's no reason not to extend this to
2182  * mutable nodes --- it's just more code.)  Further, @a to_root and @a
2183  * from_root must represent the same filesystem.
2184  *
2185  * @note To do a copy without preserving copy history, use
2186  * svn_fs_revision_link().
2187  *
2188  * Do any necessary temporary allocation in @a pool.
2189  */
2190 svn_error_t *
2191 svn_fs_copy(svn_fs_root_t *from_root,
2192             const char *from_path,
2193             svn_fs_root_t *to_root,
2194             const char *to_path,
2195             apr_pool_t *pool);
2196
2197
2198 /** Like svn_fs_copy(), but doesn't record copy history, and preserves
2199  * the PATH.  You cannot use svn_fs_copied_from() later to find out
2200  * where this copy came from.
2201  *
2202  * Use svn_fs_revision_link() in situations where you don't care
2203  * about the copy history, and where @a to_path and @a from_path are
2204  * the same, because it is cheaper than svn_fs_copy().
2205  */
2206 svn_error_t *
2207 svn_fs_revision_link(svn_fs_root_t *from_root,
2208                      svn_fs_root_t *to_root,
2209                      const char *path,
2210                      apr_pool_t *pool);
2211
2212 \f
2213 /* Files.  */
2214
2215 /** Set @a *length_p to the length of the file @a path in @a root, in bytes.
2216  * Do any necessary temporary allocation in @a pool.
2217  */
2218 svn_error_t *
2219 svn_fs_file_length(svn_filesize_t *length_p,
2220                    svn_fs_root_t *root,
2221                    const char *path,
2222                    apr_pool_t *pool);
2223
2224
2225 /** Set @a *checksum to the checksum of type @a kind for the file @a path.
2226  * @a *checksum will be allocated out of @a pool, which will also be used
2227  * for temporary allocations.
2228  *
2229  * If the filesystem does not have a prerecorded checksum of @a kind for
2230  * @a path, and @a force is not TRUE, do not calculate a checksum
2231  * dynamically, just put NULL into @a checksum.  (By convention, the NULL
2232  * checksum is considered to match any checksum.)
2233  *
2234  * Notes:
2235  *
2236  * You might wonder, why do we only provide this interface for file
2237  * contents, and not for properties or directories?
2238  *
2239  * The answer is that property lists and directory entry lists are
2240  * essentially data structures, not text.  We serialize them for
2241  * transmission, but there is no guarantee that the consumer will
2242  * parse them into the same form, or even the same order, as the
2243  * producer.  It's difficult to find a checksumming method that
2244  * reaches the same result given such variation in input.  (I suppose
2245  * we could calculate an independent MD5 sum for each propname and
2246  * value, and XOR them together; same with directory entry names.
2247  * Maybe that's the solution?)  Anyway, for now we punt.  The most
2248  * important data, and the only data that goes through svndiff
2249  * processing, is file contents, so that's what we provide
2250  * checksumming for.
2251  *
2252  * Internally, of course, the filesystem checksums everything, because
2253  * it has access to the lowest level storage forms: strings behind
2254  * representations.
2255  *
2256  * @since New in 1.6.
2257  */
2258 svn_error_t *
2259 svn_fs_file_checksum(svn_checksum_t **checksum,
2260                      svn_checksum_kind_t kind,
2261                      svn_fs_root_t *root,
2262                      const char *path,
2263                      svn_boolean_t force,
2264                      apr_pool_t *pool);
2265
2266 /**
2267  * Same as svn_fs_file_checksum(), only always put the MD5 checksum of file
2268  * @a path into @a digest, which should point to @c APR_MD5_DIGESTSIZE bytes
2269  * of storage.  If the checksum doesn't exist, put all 0's into @a digest.
2270  *
2271  * @deprecated Provided for backward compatibility with the 1.5 API.
2272  */
2273 SVN_DEPRECATED
2274 svn_error_t *
2275 svn_fs_file_md5_checksum(unsigned char digest[],
2276                          svn_fs_root_t *root,
2277                          const char *path,
2278                          apr_pool_t *pool);
2279
2280
2281 /** Set @a *contents to a readable generic stream that will yield the
2282  * contents of the file @a path in @a root.  Allocate the stream in
2283  * @a pool.  You can only use @a *contents for as long as the underlying
2284  * filesystem is open.  If @a path is not a file, return
2285  * #SVN_ERR_FS_NOT_FILE.
2286  *
2287  * If @a root is the root of a transaction, it is possible that the
2288  * contents of the file @a path will change between calls to
2289  * svn_fs_file_contents().  In that case, the result of reading from
2290  * @a *contents is undefined.
2291  *
2292  * ### @todo kff: I am worried about lifetime issues with this pool vs
2293  * the trail created farther down the call stack.  Trace this function
2294  * to investigate...
2295  */
2296 svn_error_t *
2297 svn_fs_file_contents(svn_stream_t **contents,
2298                      svn_fs_root_t *root,
2299                      const char *path,
2300                      apr_pool_t *pool);
2301
2302 /**
2303  * Callback function type used with svn_fs_try_process_file_contents()
2304  * that delivers the immutable, non-NULL @a contents of @a len bytes.
2305  * @a baton is an implementation-specific closure.
2306  *
2307  * Use @a scratch_pool for allocations.
2308  *
2309  * @since New in 1.8.
2310  */
2311 typedef svn_error_t *
2312 (*svn_fs_process_contents_func_t)(const unsigned char *contents,
2313                                   apr_size_t len,
2314                                   void *baton,
2315                                   apr_pool_t *scratch_pool);
2316
2317 /** Efficiently deliver the contents of the file @a path in @a root
2318  * via @a processor (with @a baton), setting @a *success to @c TRUE
2319  * upon doing so.  Use @a pool for allocations.
2320  *
2321  * This function is intended to support zero copy data processing.  It may
2322  * not be implemented for all data backends or not be applicable for certain
2323  * content.  In those cases, @a *success will always be @c FALSE.  Also,
2324  * this is a best-effort function which means that there is no guarantee
2325  * that @a processor gets called at all.
2326  *
2327  * @note @a processor is expected to be a relatively simple function with
2328  * a runtime of O(content size) or less.
2329  *
2330  * @since New in 1.8.
2331  */
2332 svn_error_t *
2333 svn_fs_try_process_file_contents(svn_boolean_t *success,
2334                                  svn_fs_root_t *root,
2335                                  const char *path,
2336                                  svn_fs_process_contents_func_t processor,
2337                                  void* baton,
2338                                  apr_pool_t *pool);
2339
2340 /** Create a new file named @a path in @a root.  The file's initial contents
2341  * are the empty string, and it has no properties.  @a root must be the
2342  * root of a transaction, not a revision.
2343  *
2344  * Do any necessary temporary allocation in @a pool.
2345  */
2346 svn_error_t *
2347 svn_fs_make_file(svn_fs_root_t *root,
2348                  const char *path,
2349                  apr_pool_t *pool);
2350
2351
2352 /** Apply a text delta to the file @a path in @a root.  @a root must be the
2353  * root of a transaction, not a revision.
2354  *
2355  * Set @a *contents_p to a function ready to receive text delta windows
2356  * describing how to change the file's contents, relative to its
2357  * current contents.  Set @a *contents_baton_p to a baton to pass to
2358  * @a *contents_p.
2359  *
2360  * If @a path does not exist in @a root, return an error.  (You cannot use
2361  * this routine to create new files;  use svn_fs_make_file() to create
2362  * an empty file first.)
2363  *
2364  * @a base_checksum is the hex MD5 digest for the base text against
2365  * which the delta is to be applied; it is ignored if NULL, and may be
2366  * ignored even if not NULL.  If it is not ignored, it must match the
2367  * checksum of the base text against which svndiff data is being
2368  * applied; if not, svn_fs_apply_textdelta() or the @a *contents_p call
2369  * which detects the mismatch will return the error
2370  * #SVN_ERR_CHECKSUM_MISMATCH (if there is no base text, there may
2371  * still be an error if @a base_checksum is neither NULL nor the
2372  * checksum of the empty string).
2373  *
2374  * @a result_checksum is the hex MD5 digest for the fulltext that
2375  * results from this delta application.  It is ignored if NULL, but if
2376  * not NULL, it must match the checksum of the result; if it does not,
2377  * then the @a *contents_p call which detects the mismatch will return
2378  * the error #SVN_ERR_CHECKSUM_MISMATCH.
2379  *
2380  * The caller must send all delta windows including the terminating
2381  * NULL window to @a *contents_p before making further changes to the
2382  * transaction.
2383  *
2384  * Do temporary allocation in @a pool.
2385  */
2386 svn_error_t *
2387 svn_fs_apply_textdelta(svn_txdelta_window_handler_t *contents_p,
2388                        void **contents_baton_p,
2389                        svn_fs_root_t *root,
2390                        const char *path,
2391                        const char *base_checksum,
2392                        const char *result_checksum,
2393                        apr_pool_t *pool);
2394
2395
2396 /** Write data directly to the file @a path in @a root.  @a root must be the
2397  * root of a transaction, not a revision.
2398  *
2399  * Set @a *contents_p to a stream ready to receive full textual data.
2400  * When the caller closes this stream, the data replaces the previous
2401  * contents of the file.  The caller must write all file data and close
2402  * the stream before making further changes to the transaction.
2403  *
2404  * If @a path does not exist in @a root, return an error.  (You cannot use
2405  * this routine to create new files;  use svn_fs_make_file() to create
2406  * an empty file first.)
2407  *
2408  * @a result_checksum is the hex MD5 digest for the final fulltext
2409  * written to the stream.  It is ignored if NULL, but if not null, it
2410  * must match the checksum of the result; if it does not, then the @a
2411  * *contents_p call which detects the mismatch will return the error
2412  * #SVN_ERR_CHECKSUM_MISMATCH.
2413  *
2414  * Do any necessary temporary allocation in @a pool.
2415  *
2416  * @note This is like svn_fs_apply_textdelta(), but takes the text
2417  * straight.
2418  */
2419 svn_error_t *
2420 svn_fs_apply_text(svn_stream_t **contents_p,
2421                   svn_fs_root_t *root,
2422                   const char *path,
2423                   const char *result_checksum,
2424                   apr_pool_t *pool);
2425
2426
2427 /** Check if the contents of two root/path combos are different.
2428  *
2429  * Set @a *different_p to #TRUE if the file contents at @a path1 under
2430  * @a root1 differ from those at @a path2 under @a root2, or set it to
2431  * #FALSE if they are the same.  Both paths must exist under their
2432  * respective roots, and both roots must be in the same filesystem.
2433  * Do any necessary temporary allocation in @a scratch_pool.
2434  *
2435  * @note For the purposes of preserving accurate history, certain bits of
2436  * code (such as the repository dump code) need to care about the distinction
2437  * between situations when two files have "different" content and when the
2438  * contents of a given file "have changed" across two points in its history.
2439  * We have a pair of functions that can answer both of these questions,
2440  * svn_fs_contents_different() and svn_fs_contents_changed().  See issue
2441  * 4598 for more details.
2442  *
2443  * @see svn_fs_contents_changed
2444  *
2445  * @since New in 1.9.
2446  */
2447 svn_error_t *
2448 svn_fs_contents_different(svn_boolean_t *different_p,
2449                           svn_fs_root_t *root1,
2450                           const char *path1,
2451                           svn_fs_root_t *root2,
2452                           const char *path2,
2453                           apr_pool_t *scratch_pool);
2454
2455 /** Check if the contents of two root/path combos have changed.
2456  *
2457  * Set @a *changed_p to #TRUE if the file contents at @a path1 under
2458  * @a root1 differ from those at @a path2 under @a root2, or set it to
2459  * #FALSE if they are the same.  Both paths must exist under their
2460  * respective roots, and both roots must be in the same filesystem.
2461  * Do any necessary temporary allocation in @a pool.
2462  *
2463  * @note svn_fs_contents_changed() was not designed to be used to detect
2464  * when two files have different content, but really to detect when the
2465  * contents of a given file have changed across two points in its history.
2466  * For the purposes of preserving accurate history, certain bits of code
2467  * (such as the repository dump code) need to care about this distinction.
2468  * For example, it's not an error from the FS API point of view to call
2469  * svn_fs_apply_textdelta() and explicitly set a file's contents to exactly
2470  * what they were before the edit was made.  We have a pair of functions
2471  * that can answer both of these questions, svn_fs_contents_changed() and
2472  * svn_fs_contents_different().  See issue 4598 for more details.
2473  *
2474  * @see svn_fs_contents_different
2475  */
2476 svn_error_t *
2477 svn_fs_contents_changed(svn_boolean_t *changed_p,
2478                         svn_fs_root_t *root1,
2479                         const char *path1,
2480                         svn_fs_root_t *root2,
2481                         const char *path2,
2482                         apr_pool_t *pool);
2483
2484
2485 \f
2486 /* Filesystem revisions.  */
2487
2488
2489 /** Set @a *youngest_p to the number of the youngest revision in filesystem
2490  * @a fs.  Use @a pool for all temporary allocation.
2491  *
2492  * The oldest revision in any filesystem is numbered zero.
2493  */
2494 svn_error_t *
2495 svn_fs_youngest_rev(svn_revnum_t *youngest_p,
2496                     svn_fs_t *fs,
2497                     apr_pool_t *pool);
2498
2499
2500 /**
2501  * Return filesystem format information for @a fs.
2502  *
2503  * Set @a *fs_format to the filesystem format number of @a fs, which is
2504  * an integer that increases when incompatible changes are made (such as
2505  * by #svn_fs_upgrade).
2506  *
2507  * Set @a *supports_version to the version number of the minimum Subversion GA
2508  * release that can read and write @a fs.
2509  *
2510  * @see svn_repos_info_format
2511  *
2512  * @since New in 1.9.
2513  */
2514 svn_error_t *
2515 svn_fs_info_format(int *fs_format,
2516                    svn_version_t **supports_version,
2517                    svn_fs_t *fs,
2518                    apr_pool_t *result_pool,
2519                    apr_pool_t *scratch_pool);
2520
2521 /**
2522  * Return a list of admin-serviceable config files for @a fs.  @a *files
2523  * will be set to an array containing paths as C strings.
2524  *
2525  * @since New in 1.9.
2526  */
2527 svn_error_t *
2528 svn_fs_info_config_files(apr_array_header_t **files,
2529                          svn_fs_t *fs,
2530                          apr_pool_t *result_pool,
2531                          apr_pool_t *scratch_pool);
2532
2533
2534
2535 /** Provide filesystem @a fs the opportunity to compress storage relating to
2536  * associated with  @a revision in filesystem @a fs.  Use @a pool for all
2537  * allocations.
2538  *
2539  * @note This can be a time-consuming process, depending the breadth
2540  * of the changes made in @a revision, and the depth of the history of
2541  * those changed paths.  This may also be a no op.
2542  */
2543 svn_error_t *
2544 svn_fs_deltify_revision(svn_fs_t *fs,
2545                         svn_revnum_t revision,
2546                         apr_pool_t *pool);
2547
2548
2549 /** Set @a *value_p to the value of the property named @a propname on
2550  * revision @a rev in the filesystem @a fs.  If @a rev has no property by
2551  * that name, set @a *value_p to zero.  Allocate the result in @a pool.
2552  */
2553 svn_error_t *
2554 svn_fs_revision_prop(svn_string_t **value_p,
2555                      svn_fs_t *fs,
2556                      svn_revnum_t rev,
2557                      const char *propname,
2558                      apr_pool_t *pool);
2559
2560
2561 /** Set @a *table_p to the entire property list of revision @a rev in
2562  * filesystem @a fs, as an APR hash table allocated in @a pool.  The table
2563  * maps <tt>char *</tt> property names to #svn_string_t * values; the names
2564  * and values are allocated in @a pool.
2565  */
2566 svn_error_t *
2567 svn_fs_revision_proplist(apr_hash_t **table_p,
2568                          svn_fs_t *fs,
2569                          svn_revnum_t rev,
2570                          apr_pool_t *pool);
2571
2572
2573 /** Change a revision's property's value, or add/delete a property.
2574  *
2575  * - @a fs is a filesystem, and @a rev is the revision in that filesystem
2576  *   whose property should change.
2577  * - @a name is the name of the property to change.
2578  * - if @a old_value_p is not @c NULL, then changing the property will fail with
2579  *   error #SVN_ERR_FS_PROP_BASEVALUE_MISMATCH if the present value of the
2580  *   property is not @a *old_value_p.  (This is an atomic test-and-set).
2581  *   @a *old_value_p may be @c NULL, representing that the property must be not
2582  *   already set.
2583  * - @a value is the new value of the property, or zero if the property should
2584  *   be removed altogether.
2585  *
2586  * Note that revision properties are non-historied --- you can change
2587  * them after the revision has been committed.  They are not protected
2588  * via transactions.
2589  *
2590  * Do any necessary temporary allocation in @a pool.
2591  *
2592  * @since New in 1.7.
2593  */
2594 svn_error_t *
2595 svn_fs_change_rev_prop2(svn_fs_t *fs,
2596                         svn_revnum_t rev,
2597                         const char *name,
2598                         const svn_string_t *const *old_value_p,
2599                         const svn_string_t *value,
2600                         apr_pool_t *pool);
2601
2602
2603 /**
2604  * Similar to svn_fs_change_rev_prop2(), but with @a old_value_p passed as
2605  * @c NULL.
2606  *
2607  * @deprecated Provided for backward compatibility with the 1.6 API.
2608  */
2609 SVN_DEPRECATED
2610 svn_error_t *
2611 svn_fs_change_rev_prop(svn_fs_t *fs,
2612                        svn_revnum_t rev,
2613                        const char *name,
2614                        const svn_string_t *value,
2615                        apr_pool_t *pool);
2616
2617
2618 \f
2619 /* Computing deltas.  */
2620
2621
2622 /** Set @a *stream_p to a pointer to a delta stream that will turn the
2623  * contents of the file @a source into the contents of the file @a target.
2624  * If @a source_root is zero, use a file with zero length as the source.
2625  *
2626  * This function does not compare the two files' properties.
2627  *
2628  * Allocate @a *stream_p, and do any necessary temporary allocation, in
2629  * @a pool.
2630  */
2631 svn_error_t *
2632 svn_fs_get_file_delta_stream(svn_txdelta_stream_t **stream_p,
2633                              svn_fs_root_t *source_root,
2634                              const char *source_path,
2635                              svn_fs_root_t *target_root,
2636                              const char *target_path,
2637                              apr_pool_t *pool);
2638
2639
2640 \f
2641 /* UUID manipulation. */
2642
2643 /** Populate @a *uuid with the UUID associated with @a fs.  Allocate
2644     @a *uuid in @a pool.  */
2645 svn_error_t *
2646 svn_fs_get_uuid(svn_fs_t *fs,
2647                 const char **uuid,
2648                 apr_pool_t *pool);
2649
2650
2651 /** If not @c NULL, associate @a *uuid with @a fs.  Otherwise (if @a
2652  * uuid is @c NULL), generate a new UUID for @a fs.  Use @a pool for
2653  * any scratch work.
2654  */
2655 svn_error_t *
2656 svn_fs_set_uuid(svn_fs_t *fs,
2657                 const char *uuid,
2658                 apr_pool_t *pool);
2659
2660 \f
2661 /** @defgroup svn_fs_locks Filesystem locks
2662  * @{
2663  * @since New in 1.2. */
2664
2665 /** A lock represents one user's exclusive right to modify a path in a
2666  * filesystem.  In order to create or destroy a lock, a username must
2667  * be associated with the filesystem's access context (see
2668  * #svn_fs_access_t).
2669  *
2670  * When a lock is created, a 'lock-token' is returned.  The lock-token
2671  * is a unique URI that represents the lock (treated as an opaque
2672  * string by the client), and is required to make further use of the
2673  * lock (including removal of the lock.)  A lock-token can also be
2674  * queried to return a svn_lock_t structure that describes the details
2675  * of the lock.  lock-tokens must not contain any newline character,
2676  * mainly due to the serialization for tokens for pre-commit hook.
2677  *
2678  * Locks are not secret; anyone can view existing locks in a
2679  * filesystem.  Locks are not omnipotent: they can be broken and stolen
2680  * by people who don't "own" the lock.  (Though admins can tailor a
2681  * custom break/steal policy via libsvn_repos pre-lock hook script.)
2682  *
2683  * Locks can be created with an optional expiration date.  If a lock
2684  * has an expiration date, then the act of fetching/reading it might
2685  * cause it to automatically expire, returning either nothing or an
2686  * expiration error (depending on the API).
2687  */
2688
2689 /** Lock information for use with svn_fs_lock_many() [and svn_repos_fs_...].
2690  *
2691  * @see svn_fs_lock_target_create
2692  *
2693  * @since New in 1.9.
2694  */
2695 typedef struct svn_fs_lock_target_t svn_fs_lock_target_t;
2696
2697 /** Create an <tt>svn_fs_lock_target_t</tt> allocated in @a result_pool.
2698  * @a token can be NULL and @a current_rev can be SVN_INVALID_REVNUM.
2699  *
2700  * The @a token is not duplicated and so must have a lifetime at least as
2701  * long as the returned target object.
2702  *
2703  * @since New in 1.9.
2704  */
2705 svn_fs_lock_target_t *svn_fs_lock_target_create(const char *token,
2706                                                 svn_revnum_t current_rev,
2707                                                 apr_pool_t *result_pool);
2708
2709 /** Update @a target changing the token to @a token, @a token can be NULL.
2710  *
2711  * The @a token is not duplicated and so must have a lifetime at least as
2712  * long as @a target.
2713  *
2714  * @since New in 1.9.
2715  */
2716 void svn_fs_lock_target_set_token(svn_fs_lock_target_t *target,
2717                                   const char *token);
2718
2719 /** The callback invoked by svn_fs_lock_many() and svn_fs_unlock_many().
2720  *
2721  * @a path and @a lock are allocated in the result_pool passed to
2722  * svn_fs_lock_many/svn_fs_unlock_many and so will persist beyond the
2723  * callback invocation. @a fs_err will be cleared after the callback
2724  * returns, use svn_error_dup() to preserve the error.
2725  *
2726  * If the callback returns an error no further callbacks will be made
2727  * and svn_fs_lock_many/svn_fs_unlock_many will return an error.  The
2728  * caller cannot rely on any particular order for these callbacks and
2729  * cannot rely on interrupting the underlying operation by returning
2730  * an error.  Returning an error stops the callbacks but any locks
2731  * that would have been reported in further callbacks may, or may not,
2732  * still be created/released.
2733  *
2734  * @since New in 1.9.
2735  */
2736 typedef svn_error_t *(*svn_fs_lock_callback_t)(void *baton,
2737                                                const char *path,
2738                                                const svn_lock_t *lock,
2739                                                svn_error_t *fs_err,
2740                                                apr_pool_t *scratch_pool);
2741
2742 /** Lock the paths in @a lock_targets in @a fs.
2743  *
2744  * @a fs must have a username associated with it (see
2745  * #svn_fs_access_t), else return #SVN_ERR_FS_NO_USER.  Set the
2746  * 'owner' field in each new lock to the fs username.
2747  *
2748  * @a comment is optional: it's either an xml-escapable UTF8 string
2749  * which describes the lock, or it is @c NULL.
2750  *
2751  * @a is_dav_comment describes whether the comment was created by a
2752  * generic DAV client; only mod_dav_svn's autoversioning feature needs
2753  * to use it.  If in doubt, pass 0.
2754  *
2755  * The paths to be locked are passed as the <tt>const char *</tt> keys
2756  * of the @a lock_targets hash.  The hash values are
2757  * <tt>svn_fs_lock_target_t *</tt> and provide the token and
2758  * @a current_rev for each path.  The token is a lock token such as can
2759  * be generated using svn_fs_generate_lock_token() (indicating that
2760  * the caller wants to dictate the lock token used), or it is @c NULL
2761  * (indicating that the caller wishes to have a new token generated by
2762  * this function).  If the token is not @c NULL, and represents an
2763  * existing lock, then the path must match the path associated with
2764  * that existing lock.  If @a current_rev is a valid revnum, then do an
2765  * out-of-dateness check.  If the revnum is less than the
2766  * last-changed-revision of the path (or if the path doesn't exist in
2767  * HEAD), yield an #SVN_ERR_FS_OUT_OF_DATE error for this path.
2768  *
2769  * If a path is already locked, then yield #SVN_ERR_FS_PATH_ALREADY_LOCKED,
2770  * unless @a steal_lock is TRUE, in which case "steal" the existing
2771  * lock, even if the FS access-context's username does not match the
2772  * current lock's owner: delete the existing lock on the path, and
2773  * create a new one.
2774  *
2775  * If @a expiration_date is zero, then create a non-expiring lock.
2776  * Else, the lock will expire at @a expiration_date.
2777  *
2778  * For each path in @a lock_targets @a lock_callback will be invoked
2779  * passing @a lock_baton and the lock and error that apply to path.
2780  * @a lock_callback can be NULL in which case it is not called and any
2781  * errors that would have been passed to the callback are not reported.
2782  *
2783  * The lock and path passed to @a lock_callback will be allocated in
2784  * @a result_pool.  Use @a scratch_pool for temporary allocations.
2785  *
2786  * @note At this time, only files can be locked.
2787  *
2788  * @note This function is not atomic.  If it returns an error, some targets
2789  * may remain unlocked while others may have been locked.
2790  *
2791  * @note You probably don't want to use this directly.  Take a look at
2792  * svn_repos_fs_lock_many() instead.
2793  *
2794  * @since New in 1.9.
2795  */
2796 svn_error_t *
2797 svn_fs_lock_many(svn_fs_t *fs,
2798                  apr_hash_t *lock_targets,
2799                  const char *comment,
2800                  svn_boolean_t is_dav_comment,
2801                  apr_time_t expiration_date,
2802                  svn_boolean_t steal_lock,
2803                  svn_fs_lock_callback_t lock_callback,
2804                  void *lock_baton,
2805                  apr_pool_t *result_pool,
2806                  apr_pool_t *scratch_pool);
2807
2808 /** Similar to svn_fs_lock_many() but locks only a single @a path and
2809  * returns the lock in @a *lock, allocated in @a pool, or an error.
2810  *
2811  * @since New in 1.2.
2812  */
2813 svn_error_t *
2814 svn_fs_lock(svn_lock_t **lock,
2815             svn_fs_t *fs,
2816             const char *path,
2817             const char *token,
2818             const char *comment,
2819             svn_boolean_t is_dav_comment,
2820             apr_time_t expiration_date,
2821             svn_revnum_t current_rev,
2822             svn_boolean_t steal_lock,
2823             apr_pool_t *pool);
2824
2825
2826 /** Generate a unique lock-token using @a fs. Return in @a *token,
2827  * allocated in @a pool.
2828  *
2829  * This can be used in to populate lock->token before calling
2830  * svn_fs_attach_lock().
2831  */
2832 svn_error_t *
2833 svn_fs_generate_lock_token(const char **token,
2834                            svn_fs_t *fs,
2835                            apr_pool_t *pool);
2836
2837
2838 /** Remove the locks on the paths in @a unlock_targets in @a fs.
2839  *
2840  * The paths to be unlocked are passed as <tt>const char *</tt> keys
2841  * of the @a unlock_targets hash with the corresponding lock tokens as
2842  * <tt>const char *</tt> values.  If the token doesn't point to a
2843  * lock, yield an #SVN_ERR_FS_BAD_LOCK_TOKEN error for this path.  If
2844  * the token points to an expired lock, yield an
2845  * #SVN_ERR_FS_LOCK_EXPIRED error for this path.  If @a fs has no
2846  * username associated with it, yield an #SVN_ERR_FS_NO_USER unless @a
2847  * break_lock is specified.
2848  *
2849  * If the token points to a lock, but the username of @a fs's access
2850  * context doesn't match the lock's owner, yield an
2851  * #SVN_ERR_FS_LOCK_OWNER_MISMATCH.  If @a break_lock is TRUE,
2852  * however, don't return error; allow the lock to be "broken" in any
2853  * case.  In the latter case, the token shall be @c NULL.
2854  *
2855  * For each path in @a unlock_targets @a lock_callback will be invoked
2856  * passing @a lock_baton and error that apply to path.  The @a lock
2857  * passed to the callback will be NULL.  @a lock_callback can be NULL
2858  * in which case it is not called and any errors that would have been
2859  * passed to the callback are not reported.
2860  *
2861  * The path passed to lock_callback will be allocated in @a result_pool.
2862  * Use @a scratch_pool for temporary allocations.
2863  *
2864  * @note This function is not atomic.  If it returns an error, some targets
2865  * may remain locked while others may have been unlocked.
2866  *
2867  * @note You probably don't want to use this directly.  Take a look at
2868  * svn_repos_fs_unlock_many() instead.
2869  *
2870  * @since New in 1.9.
2871  */
2872 svn_error_t *
2873 svn_fs_unlock_many(svn_fs_t *fs,
2874                    apr_hash_t *unlock_targets,
2875                    svn_boolean_t break_lock,
2876                    svn_fs_lock_callback_t lock_callback,
2877                    void *lock_baton,
2878                    apr_pool_t *result_pool,
2879                    apr_pool_t *scratch_pool);
2880
2881 /** Similar to svn_fs_unlock_many() but only unlocks a single path.
2882  *
2883  * @since New in 1.2.
2884  */
2885 svn_error_t *
2886 svn_fs_unlock(svn_fs_t *fs,
2887               const char *path,
2888               const char *token,
2889               svn_boolean_t break_lock,
2890               apr_pool_t *pool);
2891
2892
2893 /** If @a path is locked in @a fs, set @a *lock to an svn_lock_t which
2894  *  represents the lock, allocated in @a pool.
2895  *
2896  * If @a path is not locked or does not exist in HEAD, set @a *lock to NULL.
2897  */
2898 svn_error_t *
2899 svn_fs_get_lock(svn_lock_t **lock,
2900                 svn_fs_t *fs,
2901                 const char *path,
2902                 apr_pool_t *pool);
2903
2904
2905 /** The type of a lock discovery callback function.  @a baton is the
2906  * value specified in the call to svn_fs_get_locks(); the filesystem
2907  * passes it through to the callback.  @a lock is a lock structure.
2908  * @a pool is a temporary subpool for use by the callback
2909  * implementation -- it is cleared after invocation of the callback.
2910  */
2911 typedef svn_error_t *(*svn_fs_get_locks_callback_t)(void *baton,
2912                                                     svn_lock_t *lock,
2913                                                     apr_pool_t *pool);
2914
2915
2916 /** Report locks on or below @a path in @a fs using the @a
2917  * get_locks_func / @a get_locks_baton.  Use @a pool for necessary
2918  * allocations.
2919  *
2920  * @a depth limits the reported locks to those associated with paths
2921  * within the specified depth of @a path, and must be one of the
2922  * following values:  #svn_depth_empty, #svn_depth_files,
2923  * #svn_depth_immediates, or #svn_depth_infinity.
2924  *
2925  * If the @a get_locks_func callback implementation returns an error,
2926  * lock iteration will terminate and that error will be returned by
2927  * this function.
2928  *
2929  * @note Over the course of this function's invocation, locks might be
2930  * added, removed, or modified by concurrent processes.  Callers need
2931  * to anticipate and gracefully handle the transience of this
2932  * information.
2933  *
2934  * @since New in 1.7.
2935  */
2936 svn_error_t *
2937 svn_fs_get_locks2(svn_fs_t *fs,
2938                   const char *path,
2939                   svn_depth_t depth,
2940                   svn_fs_get_locks_callback_t get_locks_func,
2941                   void *get_locks_baton,
2942                   apr_pool_t *pool);
2943
2944 /** Similar to svn_fs_get_locks2(), but with @a depth always passed as
2945  * svn_depth_infinity, and with the following known problem (which is
2946  * not present in svn_fs_get_locks2()):
2947  *
2948  * @note On Berkeley-DB-backed filesystems in Subversion 1.6 and
2949  * prior, the @a get_locks_func callback will be invoked from within a
2950  * Berkeley-DB transaction trail.  Implementors of the callback are,
2951  * as a result, forbidden from calling any svn_fs API functions which
2952  * might themselves attempt to start a new Berkeley DB transaction
2953  * (which is most of this svn_fs API).  Yes, this is a nasty
2954  * implementation detail to have to be aware of.
2955  *
2956  * @deprecated Provided for backward compatibility with the 1.6 API.
2957  */
2958 SVN_DEPRECATED
2959 svn_error_t *
2960 svn_fs_get_locks(svn_fs_t *fs,
2961                  const char *path,
2962                  svn_fs_get_locks_callback_t get_locks_func,
2963                  void *get_locks_baton,
2964                  apr_pool_t *pool);
2965
2966 /** @} */
2967
2968 /**
2969  * Append a textual list of all available FS modules to the stringbuf
2970  * @a output.  Third-party modules are only included if repository
2971  * access has caused them to be loaded.
2972  *
2973  * @since New in 1.2.
2974  */
2975 svn_error_t *
2976 svn_fs_print_modules(svn_stringbuf_t *output,
2977                      apr_pool_t *pool);
2978
2979
2980 /** The kind of action being taken by 'pack'. */
2981 typedef enum svn_fs_pack_notify_action_t
2982 {
2983   /** packing of the shard has commenced */
2984   svn_fs_pack_notify_start = 0,
2985
2986   /** packing of the shard is completed */
2987   svn_fs_pack_notify_end,
2988
2989   /** packing of the shard revprops has commenced
2990       @since New in 1.7. */
2991   svn_fs_pack_notify_start_revprop,
2992
2993   /** packing of the shard revprops has completed
2994       @since New in 1.7. */
2995   svn_fs_pack_notify_end_revprop
2996
2997 } svn_fs_pack_notify_action_t;
2998
2999 /** The type of a pack notification function.  @a shard is the shard being
3000  * acted upon; @a action is the type of action being performed.  @a baton is
3001  * the corresponding baton for the notification function, and @a pool can
3002  * be used for temporary allocations, but will be cleared between invocations.
3003  */
3004 typedef svn_error_t *(*svn_fs_pack_notify_t)(void *baton,
3005                                              apr_int64_t shard,
3006                                              svn_fs_pack_notify_action_t action,
3007                                              apr_pool_t *pool);
3008
3009 /**
3010  * Possibly update the filesystem located in the directory @a path
3011  * to use disk space more efficiently.
3012  *
3013  * @since New in 1.6.
3014  */
3015 svn_error_t *
3016 svn_fs_pack(const char *db_path,
3017             svn_fs_pack_notify_t notify_func,
3018             void *notify_baton,
3019             svn_cancel_func_t cancel_func,
3020             void *cancel_baton,
3021             apr_pool_t *pool);
3022
3023
3024 /**
3025  * Perform backend-specific data consistency and correctness validations
3026  * to the Subversion filesystem (mainly the meta-data) located in the
3027  * directory @a path.  Use the backend-specific configuration @a fs_config
3028  * when opening the filesystem.  @a NULL is valid for all backends.
3029  * Use @a scratch_pool for temporary allocations.
3030  *
3031  * @a start and @a end define the (minimum) range of revisions to check.
3032  * If @a start is #SVN_INVALID_REVNUM, it defaults to @c r0.  Likewise,
3033  * @a end will default to the current youngest repository revision when
3034  * given as #SVN_INVALID_REVNUM.  Since meta data checks may have to touch
3035  * other revisions as well, you may receive notifications for revisions
3036  * outside the specified range.   In fact, it is perfectly legal for a FS
3037  * implementation to always check all revisions.
3038  *
3039  * Global invariants are only guaranteed to get verified when @a r0 has
3040  * been included in the range of revisions to check.
3041  *
3042  * The optional @a notify_func callback is only a general feedback that
3043  * the operation is still in process but may be called in random revisions
3044  * order and more than once for the same revision, i.e. r2, r1, r2 would
3045  * be a valid sequence.
3046  *
3047  * The optional @a cancel_func callback will be invoked as usual to allow
3048  * the user to preempt this potentially lengthy operation.
3049  *
3050  * @note You probably don't want to use this directly.  Take a look at
3051  * svn_repos_verify_fs2() instead, which does non-backend-specific
3052  * verifications as well.
3053  *
3054  * @note To ensure a full verification using all tests and covering all
3055  * revisions, you must call this function *and* #svn_fs_verify_root.
3056  *
3057  * @note Implementors, please do tests that can be done efficiently for
3058  * a single revision in #svn_fs_verify_root.  This function is meant for
3059  * global checks or tests that require an expensive context setup.
3060  *
3061  * @see svn_repos_verify_fs2()
3062  * @see svn_fs_verify_root()
3063  *
3064  * @since New in 1.8.
3065  */
3066 svn_error_t *
3067 svn_fs_verify(const char *path,
3068               apr_hash_t *fs_config,
3069               svn_revnum_t start,
3070               svn_revnum_t end,
3071               svn_fs_progress_notify_func_t notify_func,
3072               void *notify_baton,
3073               svn_cancel_func_t cancel_func,
3074               void *cancel_baton,
3075               apr_pool_t *scratch_pool);
3076
3077 /**
3078  * Perform backend-specific data consistency and correctness validations
3079  * of @a root in the Subversion filesystem @a fs.  @a root is typically
3080  * a revision root (see svn_fs_revision_root()), but may be a
3081  * transaction root.  Use @a scratch_pool for temporary allocations.
3082  *
3083  * @note You probably don't want to use this directly.  Take a look at
3084  * svn_repos_verify_fs2() instead, which does non-backend-specific
3085  * verifications as well.
3086  *
3087  * @note To ensure a full verification using all available tests and
3088  * covering all revisions, you must call both this function and
3089  * #svn_fs_verify.
3090  *
3091  * @note Implementors, please perform tests that cannot be done
3092  * efficiently for a single revision in #svn_fs_verify.  This function
3093  * is intended for local checks that don't require an expensive context
3094  * setup.
3095  *
3096  * @see svn_repos_verify_fs2()
3097  * @see svn_fs_verify()
3098  *
3099  * @since New in 1.8.
3100  */
3101 svn_error_t *
3102 svn_fs_verify_root(svn_fs_root_t *root,
3103                    apr_pool_t *scratch_pool);
3104
3105 /** @} */
3106
3107 /**
3108  * @defgroup fs_info Filesystem information subsystem
3109  * @{
3110  */
3111
3112 /**
3113  * A structure that provides some information about a filesystem.
3114  * Returned by svn_fs_info() for #SVN_FS_TYPE_FSFS filesystems.
3115  *
3116  * @note Fields may be added to the end of this structure in future
3117  * versions.  Therefore, users shouldn't allocate structures of this
3118  * type, to preserve binary compatibility.
3119  *
3120  * @since New in 1.9.
3121  */
3122 typedef struct svn_fs_fsfs_info_t {
3123
3124   /** Filesystem backend (#fs_type), i.e., the string #SVN_FS_TYPE_FSFS. */
3125   const char *fs_type;
3126
3127   /** Shard size, or 0 if the filesystem is not currently sharded. */
3128   int shard_size;
3129
3130   /** The smallest revision (as #svn_revnum_t) which is not in a pack file.
3131    * @note Zero (0) if (but not iff) the format does not support packing. */
3132   svn_revnum_t min_unpacked_rev;
3133
3134   /** TRUE if logical addressing is enabled for this repository.
3135    * FALSE if repository uses physical addressing. */
3136   svn_boolean_t log_addressing;
3137   /* ### TODO: information about fsfs.conf? rep-cache.db? write locks? */
3138
3139   /* If you add fields here, check whether you need to extend svn_fs_info()
3140      or svn_fs_info_dup(). */
3141 } svn_fs_fsfs_info_t;
3142
3143 /**
3144  * A structure that provides some information about a filesystem.
3145  * Returned by svn_fs_info() for #SVN_FS_TYPE_FSX filesystems.
3146  *
3147  * @note Fields may be added to the end of this structure in future
3148  * versions.  Therefore, users shouldn't allocate structures of this
3149  * type, to preserve binary compatibility.
3150  *
3151  * @since New in 1.9.
3152  */
3153 typedef struct svn_fs_fsx_info_t {
3154
3155   /** Filesystem backend (#fs_type), i.e., the string #SVN_FS_TYPE_FSX. */
3156   const char *fs_type;
3157
3158   /** Shard size, always > 0. */
3159   int shard_size;
3160
3161   /** The smallest revision which is not in a pack file. */
3162   svn_revnum_t min_unpacked_rev;
3163
3164   /* If you add fields here, check whether you need to extend svn_fs_info()
3165      or svn_fs_info_dup(). */
3166
3167 } svn_fs_fsx_info_t;
3168
3169 /** @see svn_fs_info
3170  * @since New in 1.9. */
3171 typedef struct svn_fs_info_placeholder_t {
3172   /** @see svn_fs_type */
3173   const char *fs_type;
3174
3175   /* Do not add new fields here, to maintain compatibility with the first
3176      released version of svn_fs_fsfs_info_t. */
3177 } svn_fs_info_placeholder_t;
3178
3179 /**
3180  * Set @a *fs_info to a struct describing @a fs.  The type of the
3181  * struct depends on the backend: for #SVN_FS_TYPE_FSFS, the struct will be
3182  * of type #svn_fs_fsfs_info_t; for #SVN_FS_TYPE_FSX, it will be of type
3183  * #svn_fs_fsx_info_t; otherwise, the struct is guaranteed to be
3184  * (compatible with) #svn_fs_info_placeholder_t.
3185  *
3186  * @see #svn_fs_fsfs_info_t, #svn_fs_fsx_info_t
3187  *
3188  * @since New in 1.9.
3189  */
3190 svn_error_t *
3191 svn_fs_info(const svn_fs_info_placeholder_t **fs_info,
3192             svn_fs_t *fs,
3193             apr_pool_t *result_pool,
3194             apr_pool_t *scratch_pool);
3195
3196 /**
3197  * Return a duplicate of @a info, allocated in @a result_pool. The returned
3198  * struct will be of the same type as the passed-in struct, which itself
3199  * must have been returned from svn_fs_info() or svn_fs_info_dup().  No part
3200  * of the new structure will be shared with @a info (except static string
3201  * constants).  Use @a scratch_pool for temporary allocations.
3202  *
3203  * @see #svn_fs_info_placeholder_t, #svn_fs_fsfs_info_t
3204  *
3205  * @since New in 1.9.
3206  */
3207 void *
3208 svn_fs_info_dup(const void *info,
3209                 apr_pool_t *result_pool,
3210                 apr_pool_t *scratch_pool);
3211
3212 /** @} */
3213
3214 #ifdef __cplusplus
3215 }
3216 #endif /* __cplusplus */
3217
3218 #endif /* SVN_FS_H */