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

PATCH: cancel before doing something, not afterwards [was: Re: ctrl-c does not work before certificate check resp. everything is locked]

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-12-14 04:47:52 CET

This patch makes the cancellation check happen before doing something, rather than afterwards. Currently there is a mixture of before and after. I believe it is appropriate regardless of whether it fixes this particular reported annoyance. Anyone prepared to vote for it? (I am running regression tests and will of course check that it passes.)

solo turn wrote:
> it seems, that ctrl-c does not work before the certificate is checked. and it may take some time
> till the whole working copy is locked and THEN the certificate check occurs (even if it should be
> rare, that you have a mixed working copy with parts from different servers):
>
> $ svn up
> ^CError validating server certificate for 'https://svn.collab.net:443':
> - The certificate is not issued by a trusted authority. Use the
[...]
> (R)eject, accept (t)emporarily or accept (p)ermanently? p
> svn: caught SIGINT

Solo, does this patch fix this case? (I don't have https set up to test this.)

- Julian

Call the cancellation function before doing something, not afterwards, because
it is useful to be able to cancel an operation before it starts but it is not
meaningful to "cancel" after it has finished.

Index: subversion/clients/cmdline/checkout-cmd.c
===================================================================
--- subversion/clients/cmdline/checkout-cmd.c (revision 7999)
+++ 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 7999)
+++ 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/revert-cmd.c
===================================================================
--- subversion/clients/cmdline/revert-cmd.c (revision 7999)
+++ subversion/clients/cmdline/revert-cmd.c (working copy)
@@ -66,6 +66,7 @@
       const char *target = ((const char **) (targets->elts))[i];
       svn_error_t *err;
 
+ SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       err = svn_client_revert (target, recursive, ctx, subpool);
       if (err)
         {
@@ -82,7 +83,6 @@
             return err;
         }
 
- SVN_ERR (svn_cl__check_cancel (ctx->cancel_baton));
       svn_pool_clear (subpool);
     }
   
Index: subversion/clients/cmdline/cat-cmd.c
===================================================================
--- subversion/clients/cmdline/cat-cmd.c (revision 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ subversion/clients/cmdline/blame-cmd.c (working copy)
@@ -93,6 +93,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_blame (target,
                                  &opt_state->start_revision,
                                  &opt_state->end_revision,
@@ -100,7 +101,6 @@
                                  out,
                                  ctx,
                                  subpool));
- 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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 7999)
+++ 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);
 
Index: subversion/libsvn_client/delete.c
===================================================================
--- subversion/libsvn_client/delete.c (revision 7999)
+++ subversion/libsvn_client/delete.c (working copy)
@@ -244,16 +244,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/add.c
===================================================================
--- subversion/libsvn_client/add.c (revision 7999)
+++ subversion/libsvn_client/add.c (working copy)
@@ -531,6 +531,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);
 
@@ -545,11 +549,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);
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Dec 14 04:48:33 2003

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.