2
* cancel.c : Routines to support cancelation of running subversion functions.
4
* ====================================================================
5
* Copyright (c) 2000-2004 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
* ====================================================================
19
#include <svn_delta.h>
23
const svn_delta_editor_t *wrapped_editor;
24
void *wrapped_edit_baton;
26
svn_cancel_func_t cancel_func;
33
void *wrapped_dir_baton;
39
void *wrapped_file_baton;
43
set_target_revision (void *edit_baton,
44
svn_revnum_t target_revision,
47
struct edit_baton *eb = edit_baton;
49
SVN_ERR (eb->cancel_func (eb->cancel_baton));
51
SVN_ERR (eb->wrapped_editor->set_target_revision (eb->wrapped_edit_baton,
59
open_root (void *edit_baton,
60
svn_revnum_t base_revision,
64
struct edit_baton *eb = edit_baton;
65
struct dir_baton *dir_baton = apr_palloc (pool, sizeof (*dir_baton));
67
SVN_ERR (eb->cancel_func (eb->cancel_baton));
69
SVN_ERR (eb->wrapped_editor->open_root (eb->wrapped_edit_baton,
72
&dir_baton->wrapped_dir_baton));
74
dir_baton->edit_baton = edit_baton;
76
*root_baton = dir_baton;
82
delete_entry (const char *path,
83
svn_revnum_t base_revision,
87
struct dir_baton *pb = parent_baton;
88
struct edit_baton *eb = pb->edit_baton;
90
SVN_ERR (eb->cancel_func (eb->cancel_baton));
92
SVN_ERR (eb->wrapped_editor->delete_entry (path,
94
pb->wrapped_dir_baton,
101
add_directory (const char *path,
103
const char *copyfrom_path,
104
svn_revnum_t copyfrom_revision,
108
struct dir_baton *pb = parent_baton;
109
struct edit_baton *eb = pb->edit_baton;
110
struct dir_baton *b = apr_palloc (pool, sizeof (*b));
112
SVN_ERR (eb->cancel_func (eb->cancel_baton));
114
SVN_ERR (eb->wrapped_editor->add_directory (path,
115
pb->wrapped_dir_baton,
119
&b->wrapped_dir_baton));
128
open_directory (const char *path,
130
svn_revnum_t base_revision,
134
struct dir_baton *pb = parent_baton;
135
struct edit_baton *eb = pb->edit_baton;
136
struct dir_baton *db = apr_palloc (pool, sizeof (*db));
138
SVN_ERR (eb->cancel_func (eb->cancel_baton));
140
SVN_ERR (eb->wrapped_editor->open_directory (path,
141
pb->wrapped_dir_baton,
144
&db->wrapped_dir_baton));
153
add_file (const char *path,
155
const char *copyfrom_path,
156
svn_revnum_t copyfrom_revision,
160
struct dir_baton *pb = parent_baton;
161
struct edit_baton *eb = pb->edit_baton;
162
struct file_baton *fb = apr_palloc (pool, sizeof (*fb));
164
SVN_ERR (eb->cancel_func (eb->cancel_baton));
166
SVN_ERR (eb->wrapped_editor->add_file (path,
167
pb->wrapped_dir_baton,
171
&fb->wrapped_file_baton));
180
open_file (const char *path,
182
svn_revnum_t base_revision,
186
struct dir_baton *pb = parent_baton;
187
struct edit_baton *eb = pb->edit_baton;
188
struct file_baton *fb = apr_palloc (pool, sizeof (*fb));
190
SVN_ERR (eb->cancel_func (eb->cancel_baton));
192
SVN_ERR (eb->wrapped_editor->open_file (path,
193
pb->wrapped_dir_baton,
196
&fb->wrapped_file_baton));
205
apply_textdelta (void *file_baton,
206
const char *base_checksum,
208
svn_txdelta_window_handler_t *handler,
209
void **handler_baton)
211
struct file_baton *fb = file_baton;
212
struct edit_baton *eb = fb->edit_baton;
214
SVN_ERR (eb->cancel_func (eb->cancel_baton));
216
SVN_ERR (eb->wrapped_editor->apply_textdelta (fb->wrapped_file_baton,
226
close_file (void *file_baton,
227
const char *text_checksum,
230
struct file_baton *fb = file_baton;
231
struct edit_baton *eb = fb->edit_baton;
233
SVN_ERR (eb->cancel_func (eb->cancel_baton));
235
SVN_ERR (eb->wrapped_editor->close_file (fb->wrapped_file_baton,
236
text_checksum, pool));
242
absent_file (const char *path,
246
struct file_baton *fb = file_baton;
247
struct edit_baton *eb = fb->edit_baton;
249
SVN_ERR (eb->cancel_func (eb->cancel_baton));
251
SVN_ERR (eb->wrapped_editor->absent_file (path, fb->wrapped_file_baton,
258
close_directory (void *dir_baton,
261
struct dir_baton *db = dir_baton;
262
struct edit_baton *eb = db->edit_baton;
264
SVN_ERR (eb->cancel_func (eb->cancel_baton));
266
SVN_ERR (eb->wrapped_editor->close_directory (db->wrapped_dir_baton,
273
absent_directory (const char *path,
277
struct dir_baton *db = dir_baton;
278
struct edit_baton *eb = db->edit_baton;
280
SVN_ERR (eb->cancel_func (eb->cancel_baton));
282
SVN_ERR (eb->wrapped_editor->absent_directory (path, db->wrapped_dir_baton,
289
change_file_prop (void *file_baton,
291
const svn_string_t *value,
294
struct file_baton *fb = file_baton;
295
struct edit_baton *eb = fb->edit_baton;
297
SVN_ERR (eb->cancel_func (eb->cancel_baton));
299
SVN_ERR (eb->wrapped_editor->change_file_prop (fb->wrapped_file_baton,
308
change_dir_prop (void *dir_baton,
310
const svn_string_t *value,
313
struct dir_baton *db = dir_baton;
314
struct edit_baton *eb = db->edit_baton;
316
SVN_ERR (eb->cancel_func (eb->cancel_baton));
318
SVN_ERR (eb->wrapped_editor->change_dir_prop (db->wrapped_dir_baton,
327
close_edit (void *edit_baton,
330
struct edit_baton *eb = edit_baton;
332
SVN_ERR (eb->cancel_func (eb->cancel_baton));
334
SVN_ERR (eb->wrapped_editor->close_edit (eb->wrapped_edit_baton, pool));
340
svn_delta_get_cancellation_editor (svn_cancel_func_t cancel_func,
342
const svn_delta_editor_t *wrapped_editor,
343
void *wrapped_edit_baton,
344
const svn_delta_editor_t **editor,
350
svn_delta_editor_t *tree_editor = svn_delta_default_editor (pool);
351
struct edit_baton *eb = apr_palloc (pool, sizeof (*eb));
353
tree_editor->set_target_revision = set_target_revision;
354
tree_editor->open_root = open_root;
355
tree_editor->delete_entry = delete_entry;
356
tree_editor->add_directory = add_directory;
357
tree_editor->open_directory = open_directory;
358
tree_editor->change_dir_prop = change_dir_prop;
359
tree_editor->close_directory = close_directory;
360
tree_editor->absent_directory = absent_directory;
361
tree_editor->add_file = add_file;
362
tree_editor->open_file = open_file;
363
tree_editor->apply_textdelta = apply_textdelta;
364
tree_editor->change_file_prop = change_file_prop;
365
tree_editor->close_file = close_file;
366
tree_editor->absent_file = absent_file;
367
tree_editor->close_edit = close_edit;
369
eb->wrapped_editor = wrapped_editor;
370
eb->wrapped_edit_baton = wrapped_edit_baton;
371
eb->cancel_func = cancel_func;
372
eb->cancel_baton = cancel_baton;
374
*editor = tree_editor;
379
*editor = wrapped_editor;
380
*edit_baton = wrapped_edit_baton;