Adjust dataflow so that all output methods buffer the message content.
If this becomes too large (not yet implemented), then the buffer will
be truncated/reset and a short form of the contents will be created.

One goal is to minimize textual changes, so the start() and finish()
methods stick around. Now, rather than start() returning a Writer
instance, it will return a "prefix" for the message contents. finish()
now takes the entire message content and delivers it via the output
mechanism.

The buffer is held within the Writer instance, which is internally
constructed by the send() method. This can use a custom character
encoding (which only StandardOutput provides) via the new
.get_encoding() method on OutputBase.

* tools/hook-scripts/mailer/mailer.py:
  (Writer.__init__): no longer need WRITE_FUNC parameter, as all
    writing will be to the (new) internal BytesIO buffer. The ENCODING
    param no longer has a default -- it must be provided. The write
    functions are now derived from the BytesIO instance.
  (OutputBase.send): create our own Writer instance (a buffer). Reset
    that buffer if we switch to the short-format message. Then jigger
    up a use of .start() and .finish() to deliver the message.
  (OutputBase.get_encoding): new method to provide a custom encoding
    for a particular output channel.
  (OutputBase.finish): now takes a CONTENTS parameter for the complete
    contents of the message to deliver.
  (MailedOutput.start): return the .mail_headers() result as the
    prefix to use for emailed messages.
  (MailedOutput.mail_headers): return bytes(), not str()
  (SMTPOutput.start): removed. We can use the MailedOutput super.
  (SMTPOutput.finish): take CONTENTS and use instead of self.buffer
  (StandardOutput.get_encoding): override super to carry the encoding
    from STDOUT.
  (StandardOutput.start): return the prefix as bytes() rather than
    pushing them into a Writer instance.
  (StandardOutput.finish): push CONTENTS into STDOUT.
  (PipeOutput.start): removed. We can use the MailedOutput super.
  (PipeOutput.finish): push all contents into the pipe. This takes the
    bulk of .start() code to construct the pipe.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1914915 13f79535-47bb-0310-9956-ffa450edef68
1 file changed