Re: Is there a write opposite to "svn cat"?

2023-11-29 Thread Daniel Sahlberg
Den mån 27 nov. 2023 kl 20:29 skrev Daniel Sahlberg <
daniel.l.sahlb...@gmail.com>:
[...]

> I looked into apr/misc/unix/getopt.c to see if there was any way of making
> "-" a legal argument but I couldn't find anything. Thus I'm suggesting
> making the help text a little bit more clear:
>
> [[[
> Index: subversion/svnmucc/svnmucc.c
> ===
> --- subversion/svnmucc/svnmucc.c(revision 1914148)
> +++ subversion/svnmucc/svnmucc.c(working copy)
> @@ -286,7 +286,9 @@
>"  mv SRC-URL DST-URL : move SRC-URL to DST-URL\n"
>"  rm URL : delete URL\n"
>"  put SRC-FILE URL   : add or modify file URL with contents
> copied from\n"
> -  "   SRC-FILE (use \"-\" to read from
> standard input)\n"
> +  "   SRC-FILE (use \"-\" to read from
> standard input,\n"
> +  "   but only if preceeded by -- and in
> which case no\n"
> +  "   options can follow. \"-\" only makes
> sense once)\n"
>"  propset NAME VALUE URL : set property NAME on URL to VALUE\n"
>"  propsetf NAME FILE URL : set property NAME on URL to value read
> from FILE\n"
>"  propdel NAME URL   : delete property NAME from URL\n"
> ]]]
>
> The "\"-\" only makes sense once" is because stdin can't be rewinded and
> thus can't be put into more than once file. If several put actions (with -
> as SRC-FILE) are used, the second file will be empty.
>
> Does this make sense (in particular to our native english speakers)?
>

Nathan suggested a slightly simpler way of wording the help message in [1].
I've committed that exact help text in r1914222 and nominated for backport
in 1914223.

Kind regards,
Daniel

[1] https://lists.apache.org/thread/xrvwfdgqmjzqhv3q5sv1jhbcry8cdsly


Re: Is there a write opposite to "svn cat"?

2023-11-28 Thread Yasuhito FUTATSUKI

Hello,

On 2023/11/28 16:17, Daniel Sahlberg wrote:

Den mån 27 nov. 2023 kl 21:35 skrev Johan Corveleyn :


The documentation say:
[[[
   put SRC-FILE URL   : add or modify file URL with contents copied

from

SRC-FILE (use "-" to read from standard

input)

]]]


Just chiming in here from the sideline, without ability to test right
now, but: has anyone tried to use a full "-" (double quote, dash,
double quote) as argument? As in:

svnmucc put "-" URL

Maybe that's what that help text is actually trying to say.



Good thinking, never thought about that. I've tested now but unfortunately
it doesn't make a difference, still the same error message. (Tested on
Windows with 1.8 and 1.14 and on Linux with 1.14).


On FreeBSD/Linux, "-" is treated as a normal file name, so svnmucc
returns if the file "-" doesn't exist:
[[[
svnmucc: E02: Can't open file '"-"': No such file or directory
]]]
and if ./"-" exists it try to commit its content.

Note: Most shells on Unix/Linux treat double quote charater as a
speciall character. So to pass "-" (including a pair of double
quotatation characters) to svnmucc from shell command line,
we should escape it like '"-"' or \"-\".

Cheers,
--
Yasuhito FUTATSUKI 


Re: Is there a write opposite to "svn cat"?

2023-11-27 Thread Daniel Sahlberg
Den mån 27 nov. 2023 kl 20:29 skrev Daniel Sahlberg <
daniel.l.sahlb...@gmail.com>:
[...]

> In the mail to users@, Graham suggested a better error message indicating
> which option was invalid. I will make a separate suggestion and send this
> to the APR project.
>

I've sent this to d...@apr.apache.org:
https://lists.apache.org/thread/x84938n846xzj5g2ffyc3jq7ryf757lf

With the suggested patch, the error message would have been

[[[
[root@seawitch postgres]# cat db.sql | svnmucc put -
file:///var/lib/svn/db/db.sql
svnmucc: invalid option: -
Type 'svnmucc --help' for usage.
]]]

Notice the added "-" after the first line, compared to the original below:

Den sön 26 nov. 2023 kl 22:51 skrev Graham Leggett via users <
>>> us...@subversion.apache.org>:
>>>
 [root@seawitch postgres]# cat db.sql | svnmucc put -
 file:///var/lib/svn/db/db.sql

 svnmucc: invalid option:

 Type 'svnmucc --help' for usage.

 Alas the error message mentions an invalid option, but doesn’t say
 which option, or why it is invalid.

>>>
Kind regards,
Daniel


Re: Is there a write opposite to "svn cat"?

2023-11-27 Thread Daniel Sahlberg
Den mån 27 nov. 2023 kl 21:35 skrev Johan Corveleyn :

> >>> The documentation say:
> >>> [[[
> >>>   put SRC-FILE URL   : add or modify file URL with contents copied
> from
> >>>SRC-FILE (use "-" to read from standard
> input)
> >>> ]]]
>
> Just chiming in here from the sideline, without ability to test right
> now, but: has anyone tried to use a full "-" (double quote, dash,
> double quote) as argument? As in:
>
> svnmucc put "-" URL
>
> Maybe that's what that help text is actually trying to say.
>

Good thinking, never thought about that. I've tested now but unfortunately
it doesn't make a difference, still the same error message. (Tested on
Windows with 1.8 and 1.14 and on Linux with 1.14).

Kind regards,
Daniel


Re: Is there a write opposite to "svn cat"?

2023-11-27 Thread Johan Corveleyn
>>> The documentation say:
>>> [[[
>>>   put SRC-FILE URL   : add or modify file URL with contents copied from
>>>SRC-FILE (use "-" to read from standard input)
>>> ]]]

Just chiming in here from the sideline, without ability to test right
now, but: has anyone tried to use a full "-" (double quote, dash,
double quote) as argument? As in:

svnmucc put "-" URL

Maybe that's what that help text is actually trying to say.

-- 
Johan


Re: Is there a write opposite to "svn cat"?

2023-11-27 Thread Daniel Sahlberg
Den mån 27 nov. 2023 kl 12:18 skrev Daniel Sahlberg <
daniel.l.sahlb...@gmail.com>:

> Moving a discussion from users@ to here. Original message below for
> reference.
>
> TL;DR: According to documentation, svnmucc put - URL should add or modify
> file URL reading the new contents from standard input. It doesn't, instead
> it output an error message "svnmucc: invalid option:".
>

I acknowledge the workaround posted by Lorenz in a separate message. It has
the downside that -- disables options/arguments parsing so anything that
follows must be strictly actions (put, cp, mkdir etc) and action arguments
(REV, SRC-FILE, URL etc.).


> I've tried to dig into subversion/svnmucc/svnmucc.c to figure out what is
> going wrong. The handling of "-" as stdin was added in r873014 (In the "put
> SRC_FILE URL" action read from stdin when SRC_FILE is "-") in 2008. I can't
> find anything significant having changed since it was added.
>
> I'm sending this off half-baked since I'm about to board a plane, in case
> anyone else would like to have a look.
>

Some investigations and tests later I can't see if this has ever worked. As
suggested by Graham Leggett in the thread at users@, this is because of
code in apr_getopt_long:

# misc/unix/getopt.c, row 274
[[[
if (*p == '\0')/* Bare "-" is illegal */
return serr(os, "invalid option", p, APR_BADCH);
]]]
(Sorry for cutting out a lot of context but there is related to processing
'-' characters, I think the comment was the only interested thing). This
file has not been touched since apr_1.0.x (save some whitespace fixes).

I have a collection of binaries, SlikSVN 1.5.5 doesn't contain the "- is
stdin" option, it still fails:
[[[
svnmucc: invalid option:
svnmucc: getopt failure: Bad character specified on command line
]]]

TortoiseSVN 1.8.12 has the option and fails with an actual error number
(maybe Subversion 1.5 just didn't print the E number on the console?):
[[[
svnmucc: invalid option:
svnmucc: E070012: getopt failure: Bad character specified on command line
]]]

TortoiseSVN 1.14.5 (based on Subversion 1.14.2) fails with a message
directing the user to the --help page.
[[[
svnmucc: invalid option:
Type 'svnmucc --help' for usage.
]]]

In all messages above, the first line is from apr/misc/unix/getopt.c and
the second line from svnmucc.c

As for a fix... I first tried switching of the "interleave option"
(opts->interleave = 1; on row 547) but that has about the same effect as
using -- on the command line and it breaks for example the test suite and
would break any scripts having commands (for example -m "logmessage") after
any arguments.

I looked into apr/misc/unix/getopt.c to see if there was any way of making
"-" a legal argument but I couldn't find anything. Thus I'm suggesting
making the help text a little bit more clear:

[[[
Index: subversion/svnmucc/svnmucc.c
===
--- subversion/svnmucc/svnmucc.c(revision 1914148)
+++ subversion/svnmucc/svnmucc.c(working copy)
@@ -286,7 +286,9 @@
   "  mv SRC-URL DST-URL : move SRC-URL to DST-URL\n"
   "  rm URL : delete URL\n"
   "  put SRC-FILE URL   : add or modify file URL with contents
copied from\n"
-  "   SRC-FILE (use \"-\" to read from
standard input)\n"
+  "   SRC-FILE (use \"-\" to read from
standard input,\n"
+  "   but only if preceeded by -- and in which
case no\n"
+  "   options can follow. \"-\" only makes
sense once)\n"
   "  propset NAME VALUE URL : set property NAME on URL to VALUE\n"
   "  propsetf NAME FILE URL : set property NAME on URL to value read
from FILE\n"
   "  propdel NAME URL   : delete property NAME from URL\n"
]]]

The "\"-\" only makes sense once" is because stdin can't be rewinded and
thus can't be put into more than once file. If several put actions (with -
as SRC-FILE) are used, the second file will be empty.

Does this make sense (in particular to our native english speakers)?

In the mail to users@, Graham suggested a better error message indicating
which option was invalid. I will make a separate suggestion and send this
to the APR project.

Kind regards,
Daniel


Den mån 27 nov. 2023 kl 07:47 skrev Daniel Sahlberg <
> daniel.l.sahlb...@gmail.com>:
>
>> Den sön 26 nov. 2023 kl 22:51 skrev Graham Leggett via users <
>> us...@subversion.apache.org>:
>>
>>> On 25 Nov 2023, at 13:40, Pavel Lyalyakin 
>>> wrote:
>>>
>>> `svnmucc put` perhaps?
>>> https://svnbook.red-bean.com/en/1.8/svn.ref.svnmucc.re.html
>>>
>>>
>>> From reading the manual it looks perfect, but I’m having no luck:
>>>
>>> [root@seawitch postgres]# cat db.sql | svnmucc put -
>>> file:///var/lib/svn/db/db.sql
>>>
>>> svnmucc: invalid option:
>>>
>>> Type 'svnmucc --help' for usage.
>>>
>>> Alas the error message mentions an invalid option, 

Re: Is there a write opposite to "svn cat"?

2023-11-27 Thread Lorenz via dev
in moment piping something into svnmucc put requires
... | svnmucc put -- - url
--

Lorenz


Daniel Sahlberg wrote:

>Moving a discussion from users@ to here. Original message below for
>reference.
>
>TL;DR: According to documentation, svnmucc put - URL should add or modify
>file URL reading the new contents from standard input. It doesn't, instead
>it output an error message "svnmucc: invalid option:".
>
>I've tried to dig into subversion/svnmucc/svnmucc.c to figure out what is
>going wrong. The handling of "-" as stdin was added in r873014 (In the "put
>SRC_FILE URL" action read from stdin when SRC_FILE is "-") in 2008. I can't
>find anything significant having changed since it was added.
>
>I'm sending this off half-baked since I'm about to board a plane, in case
>anyone else would like to have a look.
>
>Kind regards,
>Daniel
>
>Den mån 27 nov. 2023 kl 07:47 skrev Daniel Sahlberg <
>daniel.l.sahlb...@gmail.com>:
>
>> Den sön 26 nov. 2023 kl 22:51 skrev Graham Leggett via users <
>> us...@subversion.apache.org>:
>>
>>> On 25 Nov 2023, at 13:40, Pavel Lyalyakin 
>>> wrote:
>>>
>>> `svnmucc put` perhaps?
>>> https://svnbook.red-bean.com/en/1.8/svn.ref.svnmucc.re.html
>>>
>>>
>>> From reading the manual it looks perfect, but I’m having no luck:
>>>
>>> [root@seawitch postgres]# cat db.sql | svnmucc put -
>>> file:///var/lib/svn/db/db.sql
>>>
>>> svnmucc: invalid option:
>>>
>>> Type 'svnmucc --help' for usage.
>>>
>>> Alas the error message mentions an invalid option, but doesn’t say which
>>> option, or why it is invalid.
>>>
>>
>> The documentation say:
>> [[[
>>   put SRC-FILE URL   : add or modify file URL with contents copied from
>>SRC-FILE (use "-" to read from standard input)
>> ]]]
>>
>> So as far as I'm reading the documentation, the command you are using
>> should be supported. I would say this is a bug, either in the argument
>> handling or in the documentation.
>>
>> Can you instead try:
>> $ svnmucc put db.sql file:///var/lib/svn/db/db.sql
>>
>> I will bring this discussion to the dev@subversion.apache.org to figure
>> out if we need to change the documentation or if we can fix the code.
>>
>> Kind regards,
>> Daniel
>>



Re: Is there a write opposite to "svn cat"?

2023-11-27 Thread Daniel Sahlberg
Moving a discussion from users@ to here. Original message below for
reference.

TL;DR: According to documentation, svnmucc put - URL should add or modify
file URL reading the new contents from standard input. It doesn't, instead
it output an error message "svnmucc: invalid option:".

I've tried to dig into subversion/svnmucc/svnmucc.c to figure out what is
going wrong. The handling of "-" as stdin was added in r873014 (In the "put
SRC_FILE URL" action read from stdin when SRC_FILE is "-") in 2008. I can't
find anything significant having changed since it was added.

I'm sending this off half-baked since I'm about to board a plane, in case
anyone else would like to have a look.

Kind regards,
Daniel

Den mån 27 nov. 2023 kl 07:47 skrev Daniel Sahlberg <
daniel.l.sahlb...@gmail.com>:

> Den sön 26 nov. 2023 kl 22:51 skrev Graham Leggett via users <
> us...@subversion.apache.org>:
>
>> On 25 Nov 2023, at 13:40, Pavel Lyalyakin 
>> wrote:
>>
>> `svnmucc put` perhaps?
>> https://svnbook.red-bean.com/en/1.8/svn.ref.svnmucc.re.html
>>
>>
>> From reading the manual it looks perfect, but I’m having no luck:
>>
>> [root@seawitch postgres]# cat db.sql | svnmucc put -
>> file:///var/lib/svn/db/db.sql
>>
>> svnmucc: invalid option:
>>
>> Type 'svnmucc --help' for usage.
>>
>> Alas the error message mentions an invalid option, but doesn’t say which
>> option, or why it is invalid.
>>
>
> The documentation say:
> [[[
>   put SRC-FILE URL   : add or modify file URL with contents copied from
>SRC-FILE (use "-" to read from standard input)
> ]]]
>
> So as far as I'm reading the documentation, the command you are using
> should be supported. I would say this is a bug, either in the argument
> handling or in the documentation.
>
> Can you instead try:
> $ svnmucc put db.sql file:///var/lib/svn/db/db.sql
>
> I will bring this discussion to the dev@subversion.apache.org to figure
> out if we need to change the documentation or if we can fix the code.
>
> Kind regards,
> Daniel
>