--- libsvn_client\libsvn_client.dsp.part_3 Sun Dec 23 12:06:31 2001 +++ libsvn_client\libsvn_client.dsp Mon Dec 24 16:52:24 2001 @@ -99,6 +99,10 @@ SOURCE=.\auth.c # End Source File # Begin Source File +SOURCE=.\cancellation_editor.c +# End Source File +# Begin Source File + SOURCE=.\checkout.c # End Source File # Begin Source File --- include\svn_client.h.part_3 Mon Dec 24 16:46:22 2001 +++ include\svn_client.h Tue Dec 25 18:09:09 2001 @@ -585,6 +585,16 @@ svn_client_get_trace_commit_editor (cons svn_stringbuf_t *initial_path, apr_pool_t *pool); +/* Returns an editor that returns SVN_ERR_USER_CANCELED if should_i_cancel + * ever returns true. Should be composed before any editor that does + * any work at all from a UI of SVN. */ +svn_error_t * +svn_client_get_cancellation_editor(const svn_delta_edit_fns_t **editor, + void **edit_baton, + svn_boolean_t (*should_i_cancel)(void *), + void *inner_baton, + apr_pool_t *pool); + #endif /* SVN_CLIENT_H */ #ifdef __cplusplus Index: include\svn_error_codes.h =================================================================== --- include\.svn\text-base\svn_error_codes.h.svn-base Sun Dec 23 00:06:51 2001 +++ include\svn_error_codes.h Mon Dec 24 16:38:54 2001 @@ -366,6 +366,11 @@ SVN_ERROR_START "The log message file is under version control.") /* END Client errors */ + + /* BEGIN Generic UI related errors */ + SVN_ERRDEF (SVN_ERR_USER_CANCELED, + "User canceled operation") + /* END Generic UI related errors */ SVN_ERROR_END --- libsvn_client\cancellation_editor.null Thu Jan 10 11:28:59 2002 +++ libsvn_client\cancellation_editor.c Mon Dec 24 16:45:36 2001 @@ -0,0 +1,261 @@ +/* + * cancellation_editor.c : an editor implementation that calls a user-supplied + * callback to determine if the user decided to cancel + * the pending request. (when composed to follow before + * the commit/update-editor) + * + * ==================================================================== + * Copyright (c) 2000-2001 CollabNet. All rights reserved. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://subversion.tigris.org/license-1.html. + * If newer versions of this license are posted there, you may use a + * newer version instead, at your option. + * + * This software consists of voluntary contributions made by many + * individuals. For exact contribution history, see the revision + * history and logs, available at http://subversion.tigris.org/. + * ==================================================================== + */ + +/* ==================================================================== */ + + + +/*** Includes. ***/ +#include "svn_wc.h" +#include "svn_pools.h" +#include "svn_path.h" +#include "svn_string.h" + + +struct cancel_baton +{ + apr_pool_t *pool; + svn_boolean_t (*should_i_cancel)(void *); + void *inner_baton; +}; + +static svn_error_t * +should_i_cancel(struct cancel_baton *cb) +{ + if (cb->should_i_cancel(cb->inner_baton)) + { + return svn_error_create (SVN_ERR_USER_CANCELED, + 0, + 0, + cb->pool, + "User canceled operation."); + } + return SVN_NO_ERROR; +} + +static svn_error_t * +open_root (void *cancel_baton, svn_revnum_t base_revision, void **root_baton) +{ + struct cancel_baton *cb = cancel_baton; + + *root_baton = cancel_baton; + + return SVN_NO_ERROR; +} + + +static svn_error_t * +delete_entry (svn_stringbuf_t *name, svn_revnum_t revision, void *parent_baton) +{ + return should_i_cancel(parent_baton); +} + + +static svn_error_t * +add_directory (svn_stringbuf_t *name, + void *parent_baton, + svn_stringbuf_t *copyfrom_path, + svn_revnum_t copyfrom_revision, + void **child_baton) +{ + svn_error_t *err = SVN_NO_ERROR; + + err = should_i_cancel(parent_baton); + if (err) + { + return err; + } + + *child_baton = parent_baton; + return SVN_NO_ERROR; +} + + +static svn_error_t * +open_directory (svn_stringbuf_t *name, + void *parent_baton, + svn_revnum_t base_revision, + void **child_baton) +{ + svn_error_t *err = SVN_NO_ERROR; + + err = should_i_cancel(parent_baton); + if (err) + { + return err; + } + + *child_baton = parent_baton; + return SVN_NO_ERROR; +} + + +static svn_error_t * +close_directory (void *dir_baton) +{ + return should_i_cancel(dir_baton); +} + + +static svn_error_t * +close_file (void *file_baton) +{ + return should_i_cancel(file_baton); +} + + +static svn_error_t * +close_edit (void *edit_baton) +{ + return should_i_cancel(edit_baton); +} + + +static svn_error_t * +window_handler (svn_txdelta_window_t *window, void *handler_baton) +{ + return should_i_cancel(handler_baton); +} + + +static svn_error_t * +apply_textdelta (void *file_baton, + svn_txdelta_window_handler_t *handler, + void **handler_baton) +{ + svn_error_t *err = SVN_NO_ERROR; + + err = should_i_cancel(file_baton); + if (err) + { + return err; + } + + *handler = window_handler; + *handler_baton = file_baton; + return SVN_NO_ERROR; +} + + +static svn_error_t * +add_file (svn_stringbuf_t *name, + void *parent_baton, + svn_stringbuf_t *copyfrom_path, + svn_revnum_t copyfrom_revision, + void **file_baton) +{ + svn_error_t *err = SVN_NO_ERROR; + + err = should_i_cancel(parent_baton); + if (err) + { + return err; + } + + *file_baton = parent_baton; + + return SVN_NO_ERROR; +} + + +static svn_error_t * +open_file (svn_stringbuf_t *name, + void *parent_baton, + svn_revnum_t ancestor_revision, + void **file_baton) +{ + svn_error_t *err = SVN_NO_ERROR; + + err = should_i_cancel(parent_baton); + if (err) + { + return err; + } + + *file_baton = parent_baton; + + return SVN_NO_ERROR; +} + + +static svn_error_t * +change_file_prop (void *file_baton, + svn_stringbuf_t *name, + svn_stringbuf_t *value) +{ + return should_i_cancel(file_baton); +} + + +static svn_error_t * +change_dir_prop (void *parent_baton, + svn_stringbuf_t *name, + svn_stringbuf_t *value) +{ + return should_i_cancel(parent_baton); +} + + +svn_error_t * +svn_client_get_cancellation_editor(const svn_delta_edit_fns_t **editor, + void **edit_baton, + svn_boolean_t (*should_i_cancel)(void *), + void *inner_baton, + apr_pool_t *pool) +{ + /* Allocate an edit baton to be stored in every directory baton. + Set it up for the directory baton we create here, which is the + root baton. */ + struct cancel_baton *cb = apr_pcalloc (pool, sizeof (*cb)); + svn_delta_edit_fns_t *cancel_editor = svn_delta_default_editor (pool); + + /* Set up the edit context. */ + cb->pool = svn_pool_create (pool); + cb->inner_baton = inner_baton; + cb->should_i_cancel = should_i_cancel; + + /* Set up the editor. */ + cancel_editor->open_root = open_root; + cancel_editor->delete_entry = delete_entry; + cancel_editor->add_directory = add_directory; + cancel_editor->open_directory = open_directory; + cancel_editor->change_dir_prop = change_dir_prop; + cancel_editor->close_directory = close_directory; + cancel_editor->add_file = add_file; + cancel_editor->open_file = open_file; + cancel_editor->apply_textdelta = apply_textdelta; + cancel_editor->change_file_prop = change_file_prop; + cancel_editor->close_file = close_file; + cancel_editor->close_edit = close_edit; + + *edit_baton = cb; + *editor = cancel_editor; + + return SVN_NO_ERROR; +} + + + +/* + * local variables: + * eval: (load-file "../../svn-dev.el") + * end: + */