workqueue.h revision 251886
1/* 2 * workqueue.h : manipulating work queue items 3 * 4 * ==================================================================== 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * ==================================================================== 22 * 23 * 24 * Greg says: 25 * 26 * I think the current items are misdirected 27 * work items should NOT touch the DB 28 * the work items should be inserted into WORK_QUEUE by wc_db, 29 * meaning: workqueue.[ch] should return work items for passing to the wc_db API, 30 * which installs them during a transaction with the other work, 31 * and those items should *only* make the on-disk state match what is in the database 32 * before you rejoined the chan, I was discussing with Bert that I might rejigger the postcommit work, 33 * in order to do the prop file handling as work items, 34 * and pass those to db_global_commit for insertion as part of its transaction 35 * so that once we switch to in-db props, those work items just get deleted, 36 * (where they're simple things like: move this file to there, or delete that file) 37 * i.e. workqueue should be seriously dumb 38 * */ 39 40#ifndef SVN_WC_WORKQUEUE_H 41#define SVN_WC_WORKQUEUE_H 42 43#include <apr_pools.h> 44 45#include "svn_types.h" 46#include "svn_wc.h" 47 48#include "wc_db.h" 49 50#ifdef __cplusplus 51extern "C" { 52#endif /* __cplusplus */ 53 54 55/* Returns TRUE if WI refers to a single work item. Returns FALSE if 56 WI is a list of work items. WI must not be NULL. 57 58 A work item looks like: (OP_CODE arg1 arg2 ...) 59 60 If we see OP_CODE (an atom) as WI's first child, then this is a 61 single work item. Otherwise, it is a list of work items. */ 62#define SVN_WC__SINGLE_WORK_ITEM(wi) ((wi)->children->is_atom) 63 64 65/* Combine WORK_ITEM1 and WORK_ITEM2 into a single, resulting work item. 66 67 Each of the WORK_ITEM parameters may have one of three values: 68 69 NULL no work item 70 (OPCODE arg1 arg2 ...) single work item 71 ((OPCODE ...) (OPCODE ...)) multiple work items 72 73 These will be combined as appropriate, and returned in one of the 74 above three styles. 75 76 The resulting list will be ordered: WORK_ITEM1 first, then WORK_ITEM2 */ 77svn_skel_t * 78svn_wc__wq_merge(svn_skel_t *work_item1, 79 svn_skel_t *work_item2, 80 apr_pool_t *result_pool); 81 82 83/* For the WCROOT identified by the DB and WRI_ABSPATH pair, run any 84 work items that may be present in its workqueue. */ 85svn_error_t * 86svn_wc__wq_run(svn_wc__db_t *db, 87 const char *wri_abspath, 88 svn_cancel_func_t cancel_func, 89 void *cancel_baton, 90 apr_pool_t *scratch_pool); 91 92 93/* Set *WORK_ITEM to a new work item that will install the working 94 copy file at LOCAL_ABSPATH. If USE_COMMIT_TIMES is TRUE, then the newly 95 installed file will use the nodes CHANGE_DATE for the file timestamp. 96 If RECORD_FILEINFO is TRUE, then the resulting RECORDED_TIME and 97 RECORDED_SIZE will be recorded in the database. 98 99 If SOURCE_ABSPATH is NULL, then the pristine contents will be installed 100 (with appropriate translation). If SOURCE_ABSPATH is not NULL, then it 101 specifies a source file for the translation. The file must exist for as 102 long as *WORK_ITEM exists (and is queued). Typically, it will be a 103 temporary file, and an OP_FILE_REMOVE will be queued to later remove it. 104*/ 105svn_error_t * 106svn_wc__wq_build_file_install(svn_skel_t **work_item, 107 svn_wc__db_t *db, 108 const char *local_abspath, 109 const char *source_abspath, 110 svn_boolean_t use_commit_times, 111 svn_boolean_t record_fileinfo, 112 apr_pool_t *result_pool, 113 apr_pool_t *scratch_pool); 114 115 116/* Set *WORK_ITEM to a new work item that will remove a single 117 file LOCAL_ABSPATH from the working copy identified by the pair DB, 118 WRI_ABSPATH. */ 119svn_error_t * 120svn_wc__wq_build_file_remove(svn_skel_t **work_item, 121 svn_wc__db_t *db, 122 const char *wri_abspath, 123 const char *local_abspath, 124 apr_pool_t *result_pool, 125 apr_pool_t *scratch_pool); 126 127/* Set *WORK_ITEM to a new work item that will remove a single 128 directory or if RECURSIVE is TRUE a directory with all its 129 descendants. */ 130svn_error_t * 131svn_wc__wq_build_dir_remove(svn_skel_t **work_item, 132 svn_wc__db_t *db, 133 const char *wri_abspath, 134 const char *local_abspath, 135 svn_boolean_t recursive, 136 apr_pool_t *result_pool, 137 apr_pool_t *scratch_pool); 138 139/* Set *WORK_ITEM to a new work item that describes a move of 140 a file or directory from SRC_ABSPATH to DST_ABSPATH, ready for 141 storing in the working copy managing DST_ABSPATH. 142 143 Perform temporary allocations in SCRATCH_POOL and *WORK_ITEM in 144 RESULT_POOL. 145*/ 146svn_error_t * 147svn_wc__wq_build_file_move(svn_skel_t **work_item, 148 svn_wc__db_t *db, 149 const char *wri_abspath, 150 const char *src_abspath, 151 const char *dst_abspath, 152 apr_pool_t *result_pool, 153 apr_pool_t *scratch_pool); 154 155/* Set *WORK_ITEM to a new work item that describes a copy from 156 SRC_ABSPATH to DST_ABSPATH, while translating the stream using 157 the information from LOCAL_ABSPATH. */ 158svn_error_t * 159svn_wc__wq_build_file_copy_translated(svn_skel_t **work_item, 160 svn_wc__db_t *db, 161 const char *local_abspath, 162 const char *src_abspath, 163 const char *dst_abspath, 164 apr_pool_t *result_pool, 165 apr_pool_t *scratch_pool); 166 167 168/* Set *WORK_ITEM to a new work item that will synchronize the 169 target node's readonly and executable flags with the values defined 170 by its properties and lock status. */ 171svn_error_t * 172svn_wc__wq_build_sync_file_flags(svn_skel_t **work_item, 173 svn_wc__db_t *db, 174 const char *local_abspath, 175 apr_pool_t *result_pool, 176 apr_pool_t *scratch_pool); 177 178 179/* Set *WORK_ITEM to a new work item that will install a property reject 180 file for LOCAL_ABSPATH into the working copy. The property conflicts will 181 be taken from CONFLICT_SKEL. 182 183 ### Caution: Links CONFLICT_SKEL into the *WORK_ITEM, which involves 184 modifying *CONFLICT_SKEL. 185 186 ### TODO: Make CONFLICT_SKEL 'const' and dup it into RESULT_POOL. 187 188 ### TODO: If CONFLICT_SKEL is NULL, take property conflicts from wc_db 189 for the given DB/LOCAL_ABSPATH. 190 */ 191svn_error_t * 192svn_wc__wq_build_prej_install(svn_skel_t **work_item, 193 svn_wc__db_t *db, 194 const char *local_abspath, 195 svn_skel_t *conflict_skel, 196 apr_pool_t *result_pool, 197 apr_pool_t *scratch_pool); 198 199/* Handle the final post-commit step of retranslating and recording the 200 working copy state of a committed file. 201 202 If PROP_MODS is false, assume that properties are not changed. 203 204 (Property modifications are read when svn_wc__wq_build_file_commit 205 is called and processed when the working queue is being evaluated) 206 207 Allocate *work_item in RESULT_POOL. Perform temporary allocations 208 in SCRATCH_POOL. 209 */ 210svn_error_t * 211svn_wc__wq_build_file_commit(svn_skel_t **work_item, 212 svn_wc__db_t *db, 213 const char *local_abspath, 214 svn_boolean_t prop_mods, 215 apr_pool_t *result_pool, 216 apr_pool_t *scratch_pool); 217 218/* Set *WORK_ITEM to a new work item that will install the working 219 copy directory at LOCAL_ABSPATH. */ 220svn_error_t * 221svn_wc__wq_build_dir_install(svn_skel_t **work_item, 222 svn_wc__db_t *db, 223 const char *local_abspath, 224 apr_pool_t *scratch_pool, 225 apr_pool_t *result_pool); 226 227svn_error_t * 228svn_wc__wq_build_postupgrade(svn_skel_t **work_item, 229 apr_pool_t *scratch_pool); 230 231#ifdef __cplusplus 232} 233#endif /* __cplusplus */ 234 235#endif /* SVN_WC_WORKQUEUE_H */ 236