You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Anton Shepelev <an...@gmail.com> on 2020/12/07 17:11:38 UTC

svn diff -c does not accept HEAD

Hello, all

According to the documentation for svn diff,

   The -c M option is equivalent to -r N:M where N = M-1

The documation of the -c option agrees:

   this option is syntactic sugar for -r ARG-1:ARG.

I tried it:

   svn diff -r HEAD:6876 [works]
   svn diff -c HEAD      [fails]

The -c option does not support the `HEAD' short-cut in my
svn 1.12.0:

   E205000: Non-numeric change argument (HEAD) given to -c

Did I misunderstand the documentaiton, or is it a bug?


Re: svn diff -c does not accept HEAD

Posted by Vincent Lefevre <vi...@vinc17.net>.
On 2020-12-09 21:15:08 +0100, Vincent Lefevre wrote:
> On 2020-12-08 00:00:16 +0000, Daniel Shahaf wrote:
> > Nathan Hartman wrote on Mon, 07 Dec 2020 20:50 +00:00:
> > > When I want to see the diff of the most recent revision I use 'svn log 
> > > -l 1 --diff'. (Note, though, that will be from the BASE revision, not 
> > > HEAD.)
> > 
> > There's also «svn log -r HEAD:0 -l 1 --diff».
> 
> Why not just "svn log -r HEAD --diff"?

Hmm... After thinking about it, this is in case the latest commit
occurred under another directory, so that "svn log -r HEAD" would
be empty.

-- 
Vincent Lefèvre <vi...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: svn diff -c does not accept HEAD

Posted by Vincent Lefevre <vi...@vinc17.net>.
On 2020-12-08 00:00:16 +0000, Daniel Shahaf wrote:
> Nathan Hartman wrote on Mon, 07 Dec 2020 20:50 +00:00:
> > When I want to see the diff of the most recent revision I use 'svn log 
> > -l 1 --diff'. (Note, though, that will be from the BASE revision, not 
> > HEAD.)
> 
> There's also «svn log -r HEAD:0 -l 1 --diff».

Why not just "svn log -r HEAD --diff"?

-- 
Vincent Lefèvre <vi...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Re: svn diff -c does not accept HEAD

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Nathan Hartman wrote on Mon, 07 Dec 2020 20:50 +00:00:
> On Mon, Dec 7, 2020 at 1:47 PM Yasuhito FUTATSUKI 
> <fu...@yf.bsdclub.org> wrote:
> > 
> > As the error message says, '-c' option accepts only numeric revision.
> > It seems it is a kind of bug that the help text is not kind enough.  
> 
> A possible rationale is that the HEAD revision could change without 
> your knowledge (e.g., another user commits something in the meantime) 
> and you wouldn't get the revision you were expecting.

If this were the rationale, we wouldn't support «svn log -r HEAD» either.

Use of «HEAD» to refer to any specific revision is inherently racy.
Callsites that care about the race condition should handle it
explicitly; see tools/dist/release.py:bump_versions_on_branch() for
an example.

There isn't any conceptual problem with defining «-c HEAD» to mean
"Resolve HEAD to a revision number N and then behave as «-r N-1:N»
would".  That wouldn't be any more racy than any other use of HEAD.  We
just never did that.

(Why?  For one, because -c is a lot newer than -r: -c was added in 1.4.0 (sic),
in 2006, while -r dates back to CVS.  When we added -c, it was
implemented directly in the cmdline client's option parser, without any
API changes, so it was written to only support numeric arguments.)

Note that «svn diff -c HEAD» isn't generally a useful call unless the
repository root («^/») is given as the target.

> When I want to see the diff of the most recent revision I use 'svn log 
> -l 1 --diff'. (Note, though, that will be from the BASE revision, not 
> HEAD.)

There's also «svn log -r HEAD:0 -l 1 --diff».

Cheers,

Daniel

Re: svn diff -c does not accept HEAD

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Dec 08, 2020 at 03:44:21PM +0300, Anton Shepelev wrote:
> Nathan Hartman:
> 
> > A possible rationale is that the HEAD revision could
> > change without your knowledge (e.g., another user commits
> > something in the meantime) and you wouldn't get the
> > revision you were expecting.
> >
> > When I want to see the diff of the most recent revision I
> > use 'svn log -l 1 --diff'. (Note, though, that will be
> > from the BASE revision, not HEAD.)
> 
> Thanks for the explanation, Nathan and Daniel, but svn diff
> -c does not support `BASE' either. Futhermore, from the
> viewpoint of consistency, it would be natural for -c and -r
> to accept exactly the same set of values, whose parsing
> would be implemented in the same piece of code.

I agree that it would seem natural. However, it was not done that way.
Here is the change which introduced the -c option 15 years ago:
https://svn.apache.org/r857128
The log message explicitly states "change number". So, unfortunately,
for whatever reason the author who contributed this code didn't write
the code to do what you expect it to do, and this inconsistency has
never been fixed.

If there is someone with enough motivation to fix this, please do.
Improvements to the consistency of the command line interface will
always be welcome. But someone would need to get the work done,
and these days we're no longer blessed with a huge amount of active
developers who have a lot of time on their hands :-/

Cheers,
Stefan

Re: svn diff -c does not accept HEAD

Posted by Nathan Hartman <ha...@gmail.com>.
On Tue, Dec 8, 2020 at 7:44 AM Anton Shepelev <an...@gmail.com> wrote:

> Nathan Hartman:
>
> > A possible rationale is that the HEAD revision could
> > change without your knowledge (e.g., another user commits
> > something in the meantime) and you wouldn't get the
> > revision you were expecting.
> >
> > When I want to see the diff of the most recent revision I
> > use 'svn log -l 1 --diff'. (Note, though, that will be
> > from the BASE revision, not HEAD.)
>
> Thanks for the explanation, Nathan and Daniel, but svn diff
> -c does not support `BASE' either. Futhermore, from the
> viewpoint of consistency, it would be natural for -c and -r
> to accept exactly the same set of values, whose parsing
> would be implemented in the same piece of code.



Hi Anton,

Yes, 'svn diff -c' does not accept BASE or HEAD, only numeric arguments.

You could file it as a bug report / feature request, but since that has
been the case for a very long time, perhaps the most effective way to get
it changed is to submit a patch for review to the dev@ list.

Cheers,
Nathan

Re: svn diff -c does not accept HEAD

Posted by Anton Shepelev <an...@gmail.com>.
Nathan Hartman:

> A possible rationale is that the HEAD revision could
> change without your knowledge (e.g., another user commits
> something in the meantime) and you wouldn't get the
> revision you were expecting.
>
> When I want to see the diff of the most recent revision I
> use 'svn log -l 1 --diff'. (Note, though, that will be
> from the BASE revision, not HEAD.)

Thanks for the explanation, Nathan and Daniel, but svn diff
-c does not support `BASE' either. Futhermore, from the
viewpoint of consistency, it would be natural for -c and -r
to accept exactly the same set of values, whose parsing
would be implemented in the same piece of code.


Re: svn diff -c does not accept HEAD

Posted by Nathan Hartman <ha...@gmail.com>.
On Mon, Dec 7, 2020 at 1:47 PM Yasuhito FUTATSUKI <fu...@yf.bsdclub.org>
wrote:

>
> As the error message says, '-c' option accepts only numeric revision.
> It seems it is a kind of bug that the help text is not kind enough.


A possible rationale is that the HEAD revision could change without your
knowledge (e.g., another user commits something in the meantime) and you
wouldn't get the revision you were expecting.

When I want to see the diff of the most recent revision I use 'svn log -l 1
--diff'. (Note, though, that will be from the BASE revision, not HEAD.)

Hope that helps,
Nathan