git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Florian Achleitner <florian.achleitner.2.6.31@gmail.com>,
	git@vger.kernel.org, David Michael Barr <davidbarr@google.com>,
	Sverre Rabbelier <srabbelier@gmail.com>,
	Jeff King <peff@peff.net>, Johannes Sixt <j.sixt@viscovery.net>
Subject: Re: [RFC 1/4 v2] Implement a basic remote helper for svn in C.
Date: Thu, 26 Jul 2012 10:29:51 -0700	[thread overview]
Message-ID: <7vlii68m7k.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20120726090842.GA4999@burratino> (Jonathan Nieder's message of "Thu, 26 Jul 2012 04:08:42 -0500")

Jonathan Nieder <jrnieder@gmail.com> writes:

> [...]
>>>> +
>>>> +enum cmd_result { SUCCESS, NOT_HANDLED, ERROR };
> [...]
>> Hm.. the enum now has SUCCESS, NOT_HANDLED, TERMINATE.
>
> Much nicer.
>
> I think this tristate return value could be avoided entirely because...
> ... it isn't needed at the moment.

I am not sure what you mean by that.

The command dispatcher loop in [Patch v2 1/16] seems to call every
possible input handler with the first line of the input and expect
them to answer "This is not for me", so NOT_HANDLED is needed.

An alternative dispatcher could be written in such a way that the
dispatcher inspects the first line and decide what to call, and in
such a scheme, you do not need NOT_HANDLED. My intuition tells me
that such an arrangement is in general a better organization.

Looking at what cmd_import() does, however, I think the approach the
patch takes might make sense for this application.  Unlike other
handlers like "capabilities" that do not want to handle anything
other than "capabilities", it wants to handle two:

 - "import" that starts an import batch;
 - "" (an empty line), but only when an import batch is in effect.

A centralized dispatcher that does not use NOT_HANDLED could be
written for such an input stream, but then the state information
(i.e. "are we in an import batch?") needs to be global, which may or
may not be desirable (I haven't thought things through on this).

In any case, if you are going to use dispatching based on
NOT_HANDLED, the result may have to be (at least) quadri-state.  In
addition to "I am done successfully, please go back and dispatch
another command" (SUCCESS), "This is not for me" (NOT_HANDLED), and
"I am done successfully, and there is no need to dispatch and
process another command further" (TERMINATE), you may want to be
able to say "This was for me, but I found an error" (ERROR).

Of course, if the dispatch loop has to be rewritten so that a
central dispatcher decides what to call, individual input handlers
do not need to say NOT_HANDLED nor TERMINATE, as the central
dispatcher should keep track of the overall state of the system, and
the usual "0 on success, negative on error" may be sufficient.

One thing I wondered was how an input "capability" (or "list")
should be handled after "import" was issued (hence batch_active
becomes true).  The dispatcher loop in the patch based on
NOT_HANDLED convention will happily call cmd_capabilities(), which
does not have any notion of the batch_active state (because it is a
function scope static inside cmd_import()), and will say "Ah, that
is mine, and let me do my thing."  If we want to diagnose such an
input stream as an error, the dispatch loop needs to become aware of
the overall state of the system _anyway_, so that may be an argument
against the NOT_HANDLED based dispatch system the patch series uses.

  parent reply	other threads:[~2012-07-26 17:30 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-04 17:20 [RFC 0/4] Florian Achleitner
2012-06-04 17:20 ` [RFC 1/4] Implement a basic remote helper vor svn in C Florian Achleitner
2012-06-04 17:20   ` [RFC 2/4] Integrate remote-svn into svn-fe/Makefile Florian Achleitner
2012-06-04 17:20     ` [RFC 3/4] Add svndump_init_fd to allow reading dumps from arbitrary FDs Florian Achleitner
2012-06-04 17:20       ` [RFC 4/4] Add cat-blob report pipe from fast-import to remote-helper Florian Achleitner
2012-06-05  1:33         ` David Michael Barr
2012-06-05  6:56         ` Jeff King
2012-06-05  7:07           ` David Michael Barr
2012-06-05  8:14             ` Jeff King
2012-06-05 22:16               ` Florian Achleitner
2012-06-06 13:43                 ` Jeff King
2012-06-06 21:04                   ` Florian Achleitner
2012-06-05  8:51           ` Johannes Sixt
2012-06-05  9:07             ` Jeff King
2012-06-05 22:17               ` Florian Achleitner
2012-06-05  9:09             ` Johannes Sixt
2012-06-05  1:21       ` [RFC 3/4] Add svndump_init_fd to allow reading dumps from arbitrary FDs David Michael Barr
2012-06-29  7:49 ` [RFC 0/4 v2] Florian Achleitner
2012-06-29  7:54   ` [RFC 1/4 v2] Implement a basic remote helper for svn in C Florian Achleitner
2012-07-02 11:07     ` Jonathan Nieder
2012-07-06  0:30       ` Jonathan Nieder
2012-07-06 10:39         ` Florian Achleitner
2012-07-26  8:31       ` Florian Achleitner
2012-07-26  9:08         ` Jonathan Nieder
2012-07-26 16:16           ` Florian Achleitner
2012-07-28  7:00             ` Jonathan Nieder
2012-07-30  8:12               ` Florian Achleitner
2012-07-30  8:29                 ` Jonathan Nieder
2012-07-30 13:55                   ` Florian Achleitner
2012-07-30 16:55                     ` Jonathan Nieder
2012-07-31 19:31                       ` Florian Achleitner
2012-07-31 22:43                         ` Jonathan Nieder
2012-08-01  8:25                           ` Florian Achleitner
2012-08-01 19:42                             ` Jonathan Nieder
2012-08-12 10:06                               ` Florian Achleitner
2012-08-12 16:12                                 ` Jonathan Nieder
2012-08-12 19:39                                   ` Florian Achleitner
2012-08-12 20:10                                     ` Jonathan Nieder
2012-08-12 19:36                                 ` Jonathan Nieder
2012-07-26 17:29           ` Junio C Hamano [this message]
2012-07-30  8:12             ` Florian Achleitner
2012-07-26  9:45       ` Steven Michalske
     [not found]       ` <358E6F1E-8BAD-4F82-B270-0233AB86EF66@gmail.com>
2012-07-26 11:40         ` Jonathan Nieder
2012-07-26 14:28           ` Florian Achleitner
2012-07-26 14:54             ` Jonathan Nieder
2012-07-27  7:23               ` Florian Achleitner
2012-07-28  6:54                 ` Jonathan Nieder
2012-06-29  7:58   ` [RFC 2/4 v2] Integrate remote-svn into svn-fe/Makefile Florian Achleitner
2012-06-29  7:59   ` [RFC 3/4 v2] Add svndump_init_fd to allow reading dumps from arbitrary FDs Florian Achleitner
2012-06-29  8:00   ` [RFC 4/4 v2] Add cat-blob report fifo from fast-import to remote-helper Florian Achleitner
2012-07-21 12:45     ` [RFC 4/4 v3] " Florian Achleitner
2012-07-21 14:48       ` Jonathan Nieder
2012-07-21 15:24         ` Florian Achleitner
2012-07-21 15:44           ` Jonathan Nieder
2012-07-22 21:03             ` Florian Achleitner
2012-07-22 21:24               ` Jonathan Nieder
2012-07-21 15:58           ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vlii68m7k.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=davidbarr@google.com \
    --cc=florian.achleitner.2.6.31@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).