2 * lock.h: routines for locking working copy subdirectories.
4 * ====================================================================
5 * Copyright (c) 2000-2006 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
20 #ifndef SVN_LIBSVN_WC_LOCK_H
21 #define SVN_LIBSVN_WC_LOCK_H
23 #include <apr_pools.h>
26 #include "svn_types.h"
27 #include "svn_error.h"
32 #endif /* __cplusplus */
35 /*** General utilities that may get moved upstairs at some point. */
37 /* Take out a write-lock, stealing an existing lock if one exists. This
38 function avoids the potential race between checking for an existing lock
39 and creating a lock. The cleanup code uses this function, but stealing
40 locks is not a good idea because the code cannot determine whether a
41 lock is still in use. Try not to write any more code that requires this
44 PATH is the directory to lock, and the lock is returned in
45 *ADM_ACCESS. ASSOCIATED can be another lock in which case the locks
46 will be in the same set, or it can be NULL.
48 svn_error_t
*svn_wc__adm_steal_write_lock(svn_wc_adm_access_t
**adm_access
,
49 svn_wc_adm_access_t
*associated
,
50 const char *path
, apr_pool_t
*pool
);
53 /* Set *CLEANUP to TRUE if the directory ADM_ACCESS requires cleanup
54 processing, set *CLEANUP to FALSE otherwise. */
55 svn_error_t
*svn_wc__adm_is_cleanup_required(svn_boolean_t
*cleanup
,
56 svn_wc_adm_access_t
*adm_access
,
59 /* Store ENTRIES in the cache in ADM_ACCESS appropriate for SHOW_DELETED.
60 ENTRIES may be NULL. */
61 void svn_wc__adm_access_set_entries(svn_wc_adm_access_t
*adm_access
,
62 svn_boolean_t show_deleted
,
65 /* Return the entries hash appropriate for SHOW_DELETED cached in
66 ADM_ACCESS. The returned hash may be NULL. POOL is used for local,
67 short term, memory allocations. */
68 apr_hash_t
*svn_wc__adm_access_entries(svn_wc_adm_access_t
*adm_access
,
69 svn_boolean_t show_deleted
,
72 /* Store the WCPROPS in the cache in ADM_ACCESS. */
73 void svn_wc__adm_access_set_wcprops(svn_wc_adm_access_t
*adm_access
,
76 /* Retrieve the wcprops cached in ADM_ACCESS, if any. */
77 apr_hash_t
*svn_wc__adm_access_wcprops(svn_wc_adm_access_t
*adm_access
);
81 /* Return an access baton for PATH in *ADM_ACCESS. This function is used
82 to lock the working copy during construction of the admin area, it
83 necessarily does less checking than svn_wc_adm_open3. */
84 svn_error_t
*svn_wc__adm_pre_open(svn_wc_adm_access_t
**adm_access
,
88 /* Returns TRUE if PATH is a working copy directory that is obstructed or
89 missing such that an access baton is not available for PATH. This means
90 that ADM_ACCESS is an access baton set that contains an access baton for
91 the parent of PATH and when that access baton was opened it must have
92 attempted to open PATH, i.e. it must have been opened with the TREE_LOCK
93 parameter set TRUE. */
94 svn_boolean_t
svn_wc__adm_missing(svn_wc_adm_access_t
*adm_access
,
97 /* Sets *ADM_ACCESS to an access baton for PATH from the set ASSOCIATED.
98 This function is similar to svn_wc_adm_retrieve except that if the baton
99 for PATH is not found, this function sets *ADM_ACCESS to NULL and does
100 not return an error. */
101 svn_error_t
* svn_wc__adm_retrieve_internal(svn_wc_adm_access_t
**adm_access
,
102 svn_wc_adm_access_t
*associated
,
106 /* Return the working copy format version number for ADM_ACCESS. */
107 int svn_wc__adm_wc_format(svn_wc_adm_access_t
*adm_access
);
109 /* Set the WC FORMAT of this access baton. */
110 void svn_wc__adm_set_wc_format(svn_wc_adm_access_t
*adm_access
,
113 /* Ensure ADM_ACCESS has a write lock and that it is still valid. Returns
114 * the error SVN_ERR_WC_NOT_LOCKED if this is not the case. Compared to
115 * the function svn_wc_adm_locked, this function is run-time expensive as
116 * it does additional checking to verify the physical lock. It is used
117 * when the library expects a write lock, and where it is an error for the
118 * lock not to be present. Applications are not expected to call it.
120 svn_error_t
*svn_wc__adm_write_check(svn_wc_adm_access_t
*adm_access
);
122 /* Ensure ADM_ACCESS has a lock and for an entire WC tree (all the way
123 to its leaf nodes). While locking a tree up front using
124 LEVELS_TO_LOCK of -1 is a more appropriate operation, this function
125 can be used to extend the depth of a lock via a tree-crawl after a
126 lock is taken out. Use POOL for temporary allocations. */
127 svn_error_t
*svn_wc__adm_extend_lock_to_tree(svn_wc_adm_access_t
*adm_access
,
132 #endif /* __cplusplus */
134 #endif /* SVN_LIBSVN_WC_LOCK_H */