[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

PATCH: Check for cancellation before doing something, not afterwards

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2004-02-18 15:56:07 CET

The sort of use case I am thinking of is typing "svn update" or whatever, then while it goes through the phase of connecting to the repository, hitting Ctrl-C. In this sort of situation it is annoying if it then proceeds to update one file before obeying the Ctrl-C.

Any support for this patch?

- Julian

Check for cancellation before doing something, rather than afterwards, because
it is useful to be able to cancel an operation before it starts but it is not
useful to "cancel" after it has finished.

* subversion/clients/cmdline/add-cmd.c (svn_cl__add):
* subversion/clients/cmdline/blame-cmd.c (svn_cl__blame):
* subversion/clients/cmdline/cat-cmd.c (svn_cl__cat):
* subversion/clients/cmdline/checkout-cmd.c (svn_cl__checkout):
* subversion/clients/cmdline/cleanup-cmd.c (svn_cl__cleanup):
* subversion/clients/cmdline/info-cmd.c (svn_cl__info):
* subversion/clients/cmdline/ls-cmd.c (svn_cl__ls):
* subversion/clients/cmdline/propdel-cmd.c (svn_cl__propdel):
* subversion/clients/cmdline/propedit-cmd.c (svn_cl__propedit):
* subversion/clients/cmdline/propget-cmd.c (svn_cl__propget):
* subversion/clients/cmdline/proplist-cmd.c (svn_cl__proplist):
* subversion/clients/cmdline/propset-cmd.c (svn_cl__propset):
* subversion/clients/cmdline/resolved-cmd.c (svn_cl__resolved):
* subversion/clients/cmdline/status-cmd.c (svn_cl__status):
* subversion/clients/cmdline/update-cmd.c (svn_cl__update):
* subversion/libsvn_client/add.c (svn_client_mkdir):
* subversion/libsvn_client/delete.c (svn_client_delete):
* subversion/libsvn_client/revert.c (svn_client_revert):
  Call the cancellation function before doing things, rather than afterwards.

Index: subversion/libsvn_client/delete.c
===================================================================
--- subversion/libsvn_client/delete.c (revision 8678)
+++ subversion/libsvn_client/delete.c (working copy)
@@ -251,16 +251,17 @@
 
           svn_pool_clear (subpool);
           parent_path = svn_path_dirname (path, subpool);
+
+ /* See if the user wants us to stop. */
+ if (ctx->cancel_func)
+ SVN_ERR (ctx->cancel_func (ctx->cancel_baton));
+
           /* Let the working copy library handle the PATH. */
           SVN_ERR (svn_wc_adm_open (&adm_access, NULL, parent_path,
                                     TRUE, FALSE, subpool));
           SVN_ERR (svn_client__wc_delete (path, adm_access, force,
                                           FALSE, ctx, subpool));
           SVN_ERR (svn_wc_adm_close (adm_access));
-
- /* See if the user wants us to stop. */
- if (ctx->cancel_func)
- SVN_ERR (ctx->cancel_func (ctx->cancel_baton));
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/libsvn_client/revert.c
===================================================================
--- subversion/libsvn_client/revert.c (revision 8678)
+++ subversion/libsvn_client/revert.c (working copy)
@@ -127,6 +127,11 @@
     {
       const char *path = APR_ARRAY_IDX (paths, i, const char *);
 
+ /* See if we've been asked to cancel this operation. */
+ if ((ctx->cancel_func)
+ && ((err = ctx->cancel_func (ctx->cancel_baton))))
+ goto errorful;
+
       err = revert (path, recursive, ctx, subpool);
       if (err)
         {
@@ -148,11 +153,6 @@
             goto errorful;
         }
 
- /* See if we've been asked to cancel this operation. */
- if ((ctx->cancel_func)
- && ((err = ctx->cancel_func (ctx->cancel_baton))))
- goto errorful;
-
       svn_pool_clear (subpool);
     }
   
Index: subversion/libsvn_client/add.c
===================================================================
--- subversion/libsvn_client/add.c (revision 8678)
+++ subversion/libsvn_client/add.c (working copy)
@@ -539,6 +539,10 @@
         {
           const char *path = APR_ARRAY_IDX (paths, i, const char *);
 
+ /* See if the user wants us to stop. */
+ if (ctx->cancel_func)
+ SVN_ERR (ctx->cancel_func (ctx->cancel_baton));
+
           SVN_ERR (svn_io_dir_make (path, APR_OS_DEFAULT, pool));
           err = svn_client_add (path, FALSE, ctx, pool);
 
@@ -553,11 +557,7 @@
             }
           SVN_ERR (err);
 
- /* See if the user wants us to stop. */
- if (ctx->cancel_func)
- SVN_ERR (ctx->cancel_func (ctx->cancel_baton));
           svn_pool_clear (subpool);
-
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/clients/cmdline/checkout-cmd.c
===================================================================
--- subversion/clients/cmdline/checkout-cmd.c (revision 8678)
+++ subversion/clients/cmdline/checkout-cmd.c (working copy)
@@ -114,6 +114,8 @@
     {
       const char *target_dir;
 
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
+
       /* Validate the REPOS_URL */
       repos_url = ((const char **) (targets->elts))[i];
       if (! svn_path_is_url (repos_url))
@@ -144,7 +146,6 @@
                                     &(opt_state->start_revision),
                                     opt_state->nonrecursive ? FALSE : TRUE,
                                     ctx, subpool));
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       svn_pool_clear (subpool);
     }
   svn_pool_destroy (subpool);
Index: subversion/clients/cmdline/propdel-cmd.c
===================================================================
--- subversion/clients/cmdline/propdel-cmd.c (revision 8678)
+++ subversion/clients/cmdline/propdel-cmd.c (working copy)
@@ -116,6 +116,7 @@
           const char *target = ((const char **) (targets->elts))[i];
 
           svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
           SVN_ERR (svn_client_propset (pname_utf8, NULL, target,
                                        opt_state->recursive, subpool));
           if (! opt_state->quiet)
@@ -130,7 +131,6 @@
                       opt_state->recursive ? " (recursively) " : " ",
                       target_stdout);
             }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/clients/cmdline/cat-cmd.c
===================================================================
--- subversion/clients/cmdline/cat-cmd.c (revision 8678)
+++ subversion/clients/cmdline/cat-cmd.c (working copy)
@@ -61,9 +61,9 @@
       const char *target = ((const char **) (targets->elts))[i];
 
       svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       SVN_ERR (svn_client_cat (out, target, &(opt_state->start_revision),
                                ctx, subpool));
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
     }
   svn_pool_destroy (subpool);
 
Index: subversion/clients/cmdline/ls-cmd.c
===================================================================
--- subversion/clients/cmdline/ls-cmd.c (revision 8678)
+++ subversion/clients/cmdline/ls-cmd.c (working copy)
@@ -148,11 +148,11 @@
       apr_hash_t *dirents;
       const char *target = ((const char **) (targets->elts))[i];
      
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       SVN_ERR (svn_client_ls (&dirents, target, &(opt_state->start_revision),
                               opt_state->recursive, ctx, subpool));
 
       SVN_ERR (print_dirents (dirents, opt_state->verbose, subpool));
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       svn_pool_clear (subpool);
     }
 
Index: subversion/clients/cmdline/propget-cmd.c
===================================================================
--- subversion/clients/cmdline/propget-cmd.c (revision 8678)
+++ subversion/clients/cmdline/propget-cmd.c (working copy)
@@ -143,6 +143,7 @@
           svn_boolean_t print_filenames = FALSE;
 
           svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
           SVN_ERR (svn_client_propget (&props, pname_utf8, target,
                                        &(opt_state->start_revision),
                                        opt_state->recursive, ctx, subpool));
@@ -185,7 +186,6 @@
               if (! opt_state->strict)
                 SVN_ERR (stream_write (out, "\n", 1));
             }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/clients/cmdline/blame-cmd.c
===================================================================
--- subversion/clients/cmdline/blame-cmd.c (revision 8678)
+++ subversion/clients/cmdline/blame-cmd.c (working copy)
@@ -125,6 +125,7 @@
       svn_error_t *err;
       const char *target = ((const char **) (targets->elts))[i];
       svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       err = svn_client_blame (target,
                               &opt_state->start_revision,
                               &opt_state->end_revision,
@@ -144,7 +145,6 @@
               return err;
             }
         }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
     }
   svn_pool_destroy (subpool);
 
Index: subversion/clients/cmdline/update-cmd.c
===================================================================
--- subversion/clients/cmdline/update-cmd.c (revision 8678)
+++ subversion/clients/cmdline/update-cmd.c (working copy)
@@ -71,6 +71,8 @@
       svn_error_t *err;
 
       svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
+
       err = svn_client_update (NULL, target,
                                &(opt_state->start_revision),
                                opt_state->nonrecursive ? FALSE : TRUE,
@@ -89,8 +91,6 @@
           else
             return err;
         }
-
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
     }
 
   svn_pool_destroy (subpool);
Index: subversion/clients/cmdline/resolved-cmd.c
===================================================================
--- subversion/clients/cmdline/resolved-cmd.c (revision 8678)
+++ subversion/clients/cmdline/resolved-cmd.c (working copy)
@@ -66,6 +66,7 @@
   for (i = 0; i < targets->nelts; i++)
     {
       const char *target = ((const char **) (targets->elts))[i];
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       err = svn_client_resolved (target,
                                  opt_state->recursive,
                                  ctx,
@@ -76,7 +77,6 @@
           svn_error_clear (err);
         }
 
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       svn_pool_clear (subpool);
     }
   
Index: subversion/clients/cmdline/cleanup-cmd.c
===================================================================
--- subversion/clients/cmdline/cleanup-cmd.c (revision 8678)
+++ subversion/clients/cmdline/cleanup-cmd.c (working copy)
@@ -64,8 +64,8 @@
     {
       const char *target = ((const char **) (targets->elts))[i];
 
- SVN_ERR (svn_client_cleanup (target, ctx, subpool));
       SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
+ SVN_ERR (svn_client_cleanup (target, ctx, subpool));
       svn_pool_clear (subpool);
     }
 
Index: subversion/clients/cmdline/add-cmd.c
===================================================================
--- subversion/clients/cmdline/add-cmd.c (revision 8678)
+++ subversion/clients/cmdline/add-cmd.c (working copy)
@@ -68,6 +68,7 @@
     {
       const char *target = ((const char **) (targets->elts))[i];
 
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       err = svn_client_add (target, (! opt_state->nonrecursive), ctx, subpool);
       if (err)
         {
@@ -79,7 +80,6 @@
           else
             return err;
         }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       svn_pool_clear (subpool);
     }
 
Index: subversion/clients/cmdline/propset-cmd.c
===================================================================
--- subversion/clients/cmdline/propset-cmd.c (revision 8678)
+++ subversion/clients/cmdline/propset-cmd.c (working copy)
@@ -179,6 +179,7 @@
           const char *target = ((const char **) (targets->elts))[i];
 
           svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
           SVN_ERR (svn_client_propset (pname_utf8, propval, target,
                                        opt_state->recursive, subpool));
 
@@ -195,7 +196,6 @@
                       opt_state->recursive ? " (recursively)" : "",
                       target_stdout);
             }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/clients/cmdline/proplist-cmd.c
===================================================================
--- subversion/clients/cmdline/proplist-cmd.c (revision 8678)
+++ subversion/clients/cmdline/proplist-cmd.c (working copy)
@@ -102,6 +102,7 @@
           svn_error_t *err;
 
           svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
           err = svn_client_proplist (&props, target,
                                      &(opt_state->start_revision),
                                      opt_state->recursive, ctx, subpool);
@@ -131,7 +132,6 @@
               SVN_ERR (svn_cl__print_prop_hash
                        (item->prop_hash, (! opt_state->verbose), subpool));
             }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/clients/cmdline/status-cmd.c
===================================================================
--- subversion/clients/cmdline/status-cmd.c (revision 8678)
+++ subversion/clients/cmdline/status-cmd.c (working copy)
@@ -93,6 +93,8 @@
     {
       const char *target = ((const char **) (targets->elts))[i];
 
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
+
       /* Retrieve a hash of status structures with the information
          requested by the user. */
 
@@ -107,7 +109,6 @@
                                   opt_state->no_ignore,
                                   ctx, subpool));
 
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       svn_pool_clear (subpool);
     }
 
Index: subversion/clients/cmdline/propedit-cmd.c
===================================================================
--- subversion/clients/cmdline/propedit-cmd.c (revision 8678)
+++ subversion/clients/cmdline/propedit-cmd.c (working copy)
@@ -183,6 +183,7 @@
           const svn_wc_entry_t *entry;
           
           svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
           if (svn_path_is_url (target))
             {
               /* ### If/when svn_client_propset() supports setting
@@ -259,7 +260,6 @@
               printf ("No changes to property '%s' on '%s'\n",
                       pname, target_stdout);
             }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
         }
       svn_pool_destroy (subpool);
     }
Index: subversion/clients/cmdline/info-cmd.c
===================================================================
--- subversion/clients/cmdline/info-cmd.c (revision 8678)
+++ subversion/clients/cmdline/info-cmd.c (working copy)
@@ -275,6 +275,7 @@
       const svn_wc_entry_t *entry;
 
       svn_pool_clear (subpool);
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       SVN_ERR (svn_wc_adm_probe_open (&adm_access, NULL, target, FALSE,
                                       opt_state->recursive, subpool));
       SVN_ERR (svn_wc_entry (&entry, target, adm_access, FALSE, subpool));
@@ -304,7 +305,6 @@
           else
             SVN_ERR (print_entry (target, entry, subpool));
         }
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
     }
   svn_pool_destroy (subpool);
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Feb 18 15:52:16 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.