You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bill Tutt <ra...@lyra.org> on 2002/01/21 10:53:10 UTC
[PATCH REPOST] Trace and canelation editor changes part 4
Reposting to remind folks this code still needs a looking over.
Ok, heres the revised cancellation_editor patch. Im sending this out
in order to get feedback on the approach. This patch compiled for me
when it was written, but hasnt been tested by me yet. Ill definitely
be doing that before commiting the changes.
Note: svn diff doesnt work very well by default on a file that has a WC
state of A btw.
Bill
--
Bunnies aren't just cute like everybody supposes.
They got their hoppy legs and twitchy little noses.
And what's with all the carrots,
What do they need such good eyesight for anyway?
Re: [PATCH REPOST] Trace and canelation editor changes part 4
Posted by Greg Hudson <gh...@MIT.EDU>.
On Fri, 2002-01-25 at 02:52, Michael Wood wrote:
> > The third param is clearer as NULL, since that param is a ptr.
> [snip]
>
> Especially since NULL is not guaranteed to be 0. (I think 0 is
> a valid pointer on VAX if I remember correctly.)
The null pointer is not guaranteed to be bitwise zero in runtime memory,
but an integer constant 0, converted to a pointer, is guaranteed to be a
null pointer. So, this is truly a question of aesthetics after all. (I
agree with Greg Stein that NULL is clearer.)
(Subversion has chosen to assume that the null pointer is bitwise zero
on the platforms it runs on anyway, so that it can initialize structures
with zeroed memory and assume that pointers are null pointers. I don't
like this practice since I'm a language purist, but I don't expect it to
cause any practical issues.)
See http://www.eskimo.com/~scs/C-faq/s5.html for more information.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH REPOST] Trace and canelation editor changes part 4
Posted by Michael Wood <mw...@its.uct.ac.za>.
On Thu, Jan 24, 2002 at 06:28:57PM -0800, Greg Stein wrote:
> On Mon, Jan 21, 2002 at 02:53:10AM -0800, Bill Tutt wrote:
[snip]
> > +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.");
>
> The third param is clearer as NULL, since that param is a ptr.
[snip]
Especially since NULL is not guaranteed to be 0. (I think 0 is
a valid pointer on VAX if I remember correctly.)
--
Michael Wood <mw...@its.uct.ac.za>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH REPOST] Trace and canelation editor changes part 4
Posted by Greg Stein <gs...@lyra.org>.
On Mon, Jan 21, 2002 at 02:53:10AM -0800, Bill Tutt wrote:
>...
> +/* 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);
How about a typedef for that function type? It would allow you to reuse it
elsewhere.
>...
> +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.");
The third param is clearer as NULL, since that param is a ptr.
>...
> +static svn_error_t *
> +open_root (void *cancel_baton, svn_revnum_t base_revision, void **root_baton)
Lines shouldn't go past column 80.
The first param is the edit baton. It would be clearer as edit_baton.
> +{
> + struct cancel_baton *cb = cancel_baton;
Especially since you clarify its real meaning right here.
>...
> +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;
> + }
SVN_ERR() is very handy here. Same in a number of other places in the file.
>...
> +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);
> +}
The above three functions (and maybe some others?) all have the same
signature and body. May as well collapse them.
With the changes above, I'm +1 on applying this.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org