On Sun, Jan 31, 2016 at 11:48:26AM +0100, Andreas Scherer wrote:
> I suggest to extend 'svn patch' so that it supports usage in a pipe like
> gzip -dc patch-0042.gz | svn patch -P patch-0042 -
> This would permit using 'svn patch' directly as a drop-in replacement for
> gzip -dc patch-0042.gz | patch
> An example use case is the '%autosetup -S [SCM]' feature of RPM
> currently supported SCM are patch, git, hg, bzr, quilt). The pipe in the
> '%autopatch' macro uses various decompressors and transfers the text output to
> the 'SCM' command. It would be nice to permit '-S svn' here as well.
Let me explain why 'svn patch' doesn't have this functionality already:
When 'svn patch' was written, for Subversion 1.7, we didn't have a
portable way to tell whether stdin is a tty. The question was how to do
this on Windows and at the time nobody involved knew how to handle that.
This has since changed, we now have the function
svn_cmdline__stdin_is_a_terminal(), as of Subversion 1.8. So we could
consider extending svn patch to run without a path argument and read the
patch from stdin.
As a first step, we'll need to discuss details of this feature's design.
To get that discussion rolling, off the top of my head I'd place the
following constraints on this feature:
The command line client would have to slurp stdin into a temporary file
before calling into the client API. The client API expects a path to the
patch file and I don't think we should change that. GUI clients have no
use case for reading patches from stdin, so the command line client would
be the only possible consumer of such an API feature. Thus, this feature
falls squarly into the domain of the command line client and not the API.
Also, I think we should preserve the following behaviour if stdin is
indeed a terminal:
$ svn patch
svn: E205001: Try 'svn help patch' for more information
svn: E205001: Not enough arguments provided
This is consistent with other svn subcommands, and avoids giving the
impression that 'svn patch' "hangs" when the user doesn't pass a patch
on stdin. This avoids confusing casual command line users line who might
not know about file redirection and pipes (I know we have such users,
based on my personal interactions with many of them).
Invoking 'svn patch' with a path to a patch file must remain a valid
use case. We cannot break backwards compatibilty here.
The help text should make clear that the 2 ways of passing a patch
are mutually exclusive. If both a path and stdin are passed, the
command should error out and show the help text.
If you like, please file an issue for this feature request at
and link to this mailing list thread in the archives from that issue.
Would you (or somebody else) be willing to work on this feature by
making the necessary changes to Subversion's code?
See http://subversion.apache.org/contributing.html#code for details.
The command line client sources are in subversion/svn/ and parts of
subversion/libsvn_subr/ (relative to a checkout of Subversion's trunk).
Received on 2016-02-01 10:52:01 CET