2 * cancel.c: Routines to support cancellation of running subversion functions.
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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
21 * ====================================================================
24 #include "svn_delta.h"
28 const svn_delta_editor_t *wrapped_editor;
29 void *wrapped_edit_baton;
31 svn_cancel_func_t cancel_func;
38 void *wrapped_dir_baton;
44 void *wrapped_file_baton;
48 set_target_revision(void *edit_baton,
49 svn_revnum_t target_revision,
52 struct edit_baton *eb = edit_baton;
54 SVN_ERR(eb->cancel_func(eb->cancel_baton));
56 return eb->wrapped_editor->set_target_revision(eb->wrapped_edit_baton,
62 open_root(void *edit_baton,
63 svn_revnum_t base_revision,
67 struct edit_baton *eb = edit_baton;
68 struct dir_baton *dir_baton = apr_palloc(pool, sizeof(*dir_baton));
70 SVN_ERR(eb->cancel_func(eb->cancel_baton));
72 SVN_ERR(eb->wrapped_editor->open_root(eb->wrapped_edit_baton,
75 &dir_baton->wrapped_dir_baton));
77 dir_baton->edit_baton = edit_baton;
79 *root_baton = dir_baton;
85 delete_entry(const char *path,
86 svn_revnum_t base_revision,
90 struct dir_baton *pb = parent_baton;
91 struct edit_baton *eb = pb->edit_baton;
93 SVN_ERR(eb->cancel_func(eb->cancel_baton));
95 return eb->wrapped_editor->delete_entry(path,
97 pb->wrapped_dir_baton,
102 add_directory(const char *path,
104 const char *copyfrom_path,
105 svn_revnum_t copyfrom_revision,
109 struct dir_baton *pb = parent_baton;
110 struct edit_baton *eb = pb->edit_baton;
111 struct dir_baton *b = apr_palloc(pool, sizeof(*b));
113 SVN_ERR(eb->cancel_func(eb->cancel_baton));
115 SVN_ERR(eb->wrapped_editor->add_directory(path,
116 pb->wrapped_dir_baton,
120 &b->wrapped_dir_baton));
129 open_directory(const char *path,
131 svn_revnum_t base_revision,
135 struct dir_baton *pb = parent_baton;
136 struct edit_baton *eb = pb->edit_baton;
137 struct dir_baton *db = apr_palloc(pool, sizeof(*db));
139 SVN_ERR(eb->cancel_func(eb->cancel_baton));
141 SVN_ERR(eb->wrapped_editor->open_directory(path,
142 pb->wrapped_dir_baton,
145 &db->wrapped_dir_baton));
154 add_file(const char *path,
156 const char *copyfrom_path,
157 svn_revnum_t copyfrom_revision,
161 struct dir_baton *pb = parent_baton;
162 struct edit_baton *eb = pb->edit_baton;
163 struct file_baton *fb = apr_palloc(pool, sizeof(*fb));
165 SVN_ERR(eb->cancel_func(eb->cancel_baton));
167 SVN_ERR(eb->wrapped_editor->add_file(path,
168 pb->wrapped_dir_baton,
172 &fb->wrapped_file_baton));
181 open_file(const char *path,
183 svn_revnum_t base_revision,
187 struct dir_baton *pb = parent_baton;
188 struct edit_baton *eb = pb->edit_baton;
189 struct file_baton *fb = apr_palloc(pool, sizeof(*fb));
191 SVN_ERR(eb->cancel_func(eb->cancel_baton));
193 SVN_ERR(eb->wrapped_editor->open_file(path,
194 pb->wrapped_dir_baton,
197 &fb->wrapped_file_baton));
206 apply_textdelta(void *file_baton,
207 const char *base_checksum,
209 svn_txdelta_window_handler_t *handler,
210 void **handler_baton)
212 struct file_baton *fb = file_baton;
213 struct edit_baton *eb = fb->edit_baton;
215 SVN_ERR(eb->cancel_func(eb->cancel_baton));
217 return eb->wrapped_editor->apply_textdelta(fb->wrapped_file_baton,
225 close_file(void *file_baton,
226 const char *text_checksum,
229 struct file_baton *fb = file_baton;
230 struct edit_baton *eb = fb->edit_baton;
232 SVN_ERR(eb->cancel_func(eb->cancel_baton));
234 return eb->wrapped_editor->close_file(fb->wrapped_file_baton,
235 text_checksum, pool);
239 absent_file(const char *path,
243 struct file_baton *fb = file_baton;
244 struct edit_baton *eb = fb->edit_baton;
246 SVN_ERR(eb->cancel_func(eb->cancel_baton));
248 return eb->wrapped_editor->absent_file(path, fb->wrapped_file_baton,
253 close_directory(void *dir_baton,
256 struct dir_baton *db = dir_baton;
257 struct edit_baton *eb = db->edit_baton;
259 SVN_ERR(eb->cancel_func(eb->cancel_baton));
261 return eb->wrapped_editor->close_directory(db->wrapped_dir_baton, pool);
265 absent_directory(const char *path,
269 struct dir_baton *db = dir_baton;
270 struct edit_baton *eb = db->edit_baton;
272 SVN_ERR(eb->cancel_func(eb->cancel_baton));
274 return eb->wrapped_editor->absent_directory(path, db->wrapped_dir_baton,
279 change_file_prop(void *file_baton,
281 const svn_string_t *value,
284 struct file_baton *fb = file_baton;
285 struct edit_baton *eb = fb->edit_baton;
287 SVN_ERR(eb->cancel_func(eb->cancel_baton));
289 return eb->wrapped_editor->change_file_prop(fb->wrapped_file_baton,
294 change_dir_prop(void *dir_baton,
296 const svn_string_t *value,
299 struct dir_baton *db = dir_baton;
300 struct edit_baton *eb = db->edit_baton;
302 SVN_ERR(eb->cancel_func(eb->cancel_baton));
304 return eb->wrapped_editor->change_dir_prop(db->wrapped_dir_baton,
311 close_edit(void *edit_baton,
314 struct edit_baton *eb = edit_baton;
316 SVN_ERR(eb->cancel_func(eb->cancel_baton));
318 return eb->wrapped_editor->close_edit(eb->wrapped_edit_baton, pool);
322 abort_edit(void *edit_baton,
325 struct edit_baton *eb = edit_baton;
327 SVN_ERR(eb->cancel_func(eb->cancel_baton));
329 return eb->wrapped_editor->abort_edit(eb->wrapped_edit_baton, pool);
333 svn_delta_get_cancellation_editor(svn_cancel_func_t cancel_func,
335 const svn_delta_editor_t *wrapped_editor,
336 void *wrapped_edit_baton,
337 const svn_delta_editor_t **editor,
343 svn_delta_editor_t *tree_editor = svn_delta_default_editor(pool);
344 struct edit_baton *eb = apr_palloc(pool, sizeof(*eb));
346 tree_editor->set_target_revision = set_target_revision;
347 tree_editor->open_root = open_root;
348 tree_editor->delete_entry = delete_entry;
349 tree_editor->add_directory = add_directory;
350 tree_editor->open_directory = open_directory;
351 tree_editor->change_dir_prop = change_dir_prop;
352 tree_editor->close_directory = close_directory;
353 tree_editor->absent_directory = absent_directory;
354 tree_editor->add_file = add_file;
355 tree_editor->open_file = open_file;
356 tree_editor->apply_textdelta = apply_textdelta;
357 tree_editor->change_file_prop = change_file_prop;
358 tree_editor->close_file = close_file;
359 tree_editor->absent_file = absent_file;
360 tree_editor->close_edit = close_edit;
361 tree_editor->abort_edit = abort_edit;
363 eb->wrapped_editor = wrapped_editor;
364 eb->wrapped_edit_baton = wrapped_edit_baton;
365 eb->cancel_func = cancel_func;
366 eb->cancel_baton = cancel_baton;
368 *editor = tree_editor;
373 *editor = wrapped_editor;
374 *edit_baton = wrapped_edit_baton;