rep-cache.h revision 289177
1207753Smm/* rep-cache.h : interface to rep cache db functions
2207753Smm *
3207753Smm * ====================================================================
4207753Smm *    Licensed to the Apache Software Foundation (ASF) under one
5207753Smm *    or more contributor license agreements.  See the NOTICE file
6207753Smm *    distributed with this work for additional information
7207753Smm *    regarding copyright ownership.  The ASF licenses this file
8207753Smm *    to you under the Apache License, Version 2.0 (the
9207753Smm *    "License"); you may not use this file except in compliance
10207753Smm *    with the License.  You may obtain a copy of the License at
11207753Smm *
12207753Smm *      http://www.apache.org/licenses/LICENSE-2.0
13207753Smm *
14207753Smm *    Unless required by applicable law or agreed to in writing,
15207753Smm *    software distributed under the License is distributed on an
16207753Smm *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17207753Smm *    KIND, either express or implied.  See the License for the
18207753Smm *    specific language governing permissions and limitations
19207753Smm *    under the License.
20207753Smm * ====================================================================
21207753Smm */
22207753Smm
23207753Smm#ifndef SVN_LIBSVN_FS_X_REP_CACHE_H
24207753Smm#define SVN_LIBSVN_FS_X_REP_CACHE_H
25207753Smm
26207753Smm#include "svn_error.h"
27207753Smm
28207753Smm#include "fs.h"
29207753Smm
30207753Smm#ifdef __cplusplus
31207753Smmextern "C" {
32207753Smm#endif /* __cplusplus */
33207753Smm
34207753Smm
35207753Smm#define REP_CACHE_DB_NAME        "rep-cache.db"
36207753Smm
37207753Smm/* Open and create, if needed, the rep cache database associated with FS.
38207753Smm   Use SCRATCH_POOL for temporary allocations. */
39207753Smmsvn_error_t *
40207753Smmsvn_fs_x__open_rep_cache(svn_fs_t *fs,
41207753Smm                         apr_pool_t *scratch_pool);
42207753Smm
43207753Smm/* Set *EXISTS to TRUE iff the rep-cache DB file exists. */
44207753Smmsvn_error_t *
45207753Smmsvn_fs_x__exists_rep_cache(svn_boolean_t *exists,
46207753Smm                           svn_fs_t *fs,
47207753Smm                           apr_pool_t *scratch_pool);
48207753Smm
49207753Smm/* Iterate all representations currently in FS's cache. */
50207753Smmsvn_error_t *
51207753Smmsvn_fs_x__walk_rep_reference(svn_fs_t *fs,
52207753Smm                             svn_revnum_t start,
53207753Smm                             svn_revnum_t end,
54207753Smm                             svn_error_t *(*walker)(svn_fs_x__representation_t *rep,
55207753Smm                                                    void *walker_baton,
56207753Smm                                                    svn_fs_t *fs,
57207753Smm                                                    apr_pool_t *scratch_pool),
58207753Smm                             void *walker_baton,
59207753Smm                             svn_cancel_func_t cancel_func,
60207753Smm                             void *cancel_baton,
61207753Smm                             apr_pool_t *scratch_pool);
62207753Smm
63207753Smm/* Return the representation REP in FS which has fulltext CHECKSUM.
64207753Smm   REP is allocated in RESULT_POOL.  If the rep cache database has not been
65207753Smm   opened, just set *REP to NULL.  Returns SVN_ERR_FS_CORRUPT if a reference
66207753Smm   beyond HEAD is detected.  Uses SCRATCH_POOL for temporary allocations. */
67207753Smmsvn_error_t *
68207753Smmsvn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep,
69207753Smm                            svn_fs_t *fs,
70207753Smm                            svn_checksum_t *checksum,
71207753Smm                            apr_pool_t *result_pool,
72207753Smm                            apr_pool_t *scratch_pool);
73207753Smm
74207753Smm/* Set the representation REP in FS, using REP->CHECKSUM.
75207753Smm   Use SCRATCH_POOL for temporary allocations.  Returns SVN_ERR_FS_CORRUPT
76207753Smm   if an existing reference beyond HEAD is detected.
77207753Smm
78207753Smm   If the rep cache database has not been opened, this may be a no op. */
79207753Smmsvn_error_t *
80207753Smmsvn_fs_x__set_rep_reference(svn_fs_t *fs,
81207753Smm                            svn_fs_x__representation_t *rep,
82207753Smm                            apr_pool_t *scratch_pool);
83207753Smm
84207753Smm/* Delete from the cache all reps corresponding to revisions younger
85207753Smm   than YOUNGEST. */
86207753Smmsvn_error_t *
87207753Smmsvn_fs_x__del_rep_reference(svn_fs_t *fs,
88207753Smm                            svn_revnum_t youngest,
89207753Smm                            apr_pool_t *scratch_pool);
90207753Smm
91207753Smm
92207753Smm/* Start a transaction to take an SQLite reserved lock that prevents
93207753Smm   other writes, call BODY, end the transaction, and return what BODY returned.
94207753Smm */
95207753Smmsvn_error_t *
96207753Smmsvn_fs_x__with_rep_cache_lock(svn_fs_t *fs,
97207753Smm                              svn_error_t *(*body)(void *baton,
98207753Smm                                                   apr_pool_t *pool),
99207753Smm                              void *baton,
100207753Smm                              apr_pool_t *pool);
101207753Smm#ifdef __cplusplus
102207753Smm}
103207753Smm#endif /* __cplusplus */
104207753Smm
105207753Smm#endif /* SVN_LIBSVN_FS_X_REP_CACHE_H */
106207753Smm