2 * cancel.c: Routines to support cancellation of running subversion functions.
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 * ====================================================================
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 abort_edit(void *edit_baton
,
343 struct edit_baton
*eb
= edit_baton
;
345 SVN_ERR(eb
->cancel_func(eb
->cancel_baton
));
347 SVN_ERR(eb
->wrapped_editor
->abort_edit(eb
->wrapped_edit_baton
, pool
));
353 svn_delta_get_cancellation_editor(svn_cancel_func_t cancel_func
,
355 const svn_delta_editor_t
*wrapped_editor
,
356 void *wrapped_edit_baton
,
357 const svn_delta_editor_t
**editor
,
363 svn_delta_editor_t
*tree_editor
= svn_delta_default_editor(pool
);
364 struct edit_baton
*eb
= apr_palloc(pool
, sizeof(*eb
));
366 tree_editor
->set_target_revision
= set_target_revision
;
367 tree_editor
->open_root
= open_root
;
368 tree_editor
->delete_entry
= delete_entry
;
369 tree_editor
->add_directory
= add_directory
;
370 tree_editor
->open_directory
= open_directory
;
371 tree_editor
->change_dir_prop
= change_dir_prop
;
372 tree_editor
->close_directory
= close_directory
;
373 tree_editor
->absent_directory
= absent_directory
;
374 tree_editor
->add_file
= add_file
;
375 tree_editor
->open_file
= open_file
;
376 tree_editor
->apply_textdelta
= apply_textdelta
;
377 tree_editor
->change_file_prop
= change_file_prop
;
378 tree_editor
->close_file
= close_file
;
379 tree_editor
->absent_file
= absent_file
;
380 tree_editor
->close_edit
= close_edit
;
381 tree_editor
->abort_edit
= abort_edit
;
383 eb
->wrapped_editor
= wrapped_editor
;
384 eb
->wrapped_edit_baton
= wrapped_edit_baton
;
385 eb
->cancel_func
= cancel_func
;
386 eb
->cancel_baton
= cancel_baton
;
388 *editor
= tree_editor
;
393 *editor
= wrapped_editor
;
394 *edit_baton
= wrapped_edit_baton
;