You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@wandisco.com> on 2011/06/29 14:07:01 UTC

[PATCH] 'svn' should not silently ignore a peg revision

I believe we should make 'svn' reject any peg revision specifier on an
argument where it doesn't use one.  This is a rather long email to
record some of the details behind my reasoning, and a question mainly
for Stefan Sperling about issue #3651 [3].

First some context.

$ svn cat ^/trunk/readme@123
  # Makes sense.

$ svn mkdir ^/trunk/doc@123
  # Nonsense: mkdir with a URL can only operate on the head. [2]

$ svn add foo@123
  # Nonsense: the target must be an unversioned local path.

We decided [1] that we should allow the user to consistently escape any
target argument by appending an '@' sign, without having to know whether
a peg revision is relevant.  This was implemented in 1.6.5 and trunk by
parsing off and discarding any peg revision specifier, using the
function 'svn_cl__eat_peg_revisions()'.

That current solution is great for allowing consistent escaping, but as
a side effect 'svn' silently ignores any peg revision it isn't going to
use, which I think is bad, as I have noted in the doc string of
svn_cl__eat_peg_revisions().

So, when does a peg not make sense?

  (a) When the target is supposed to be an unversioned local path, such
as in 'svn add'.  A peg never makes sense on an unversioned path.  A
versioned local path is allowed with '--force', but it would still be
wrong to specify any peg revision on it because only the path on disk is
relevant to the 'add' operation.

  (b) When the target necessarily refers to a path at the head of the
repository, such as in 'svn lock TARGET' or 'svn delete TARGET-URL'.
Logically, a peg of 'HEAD' is always valid in these commands.
Logically, these commands could accept a non-head peg where TARGET is
known to exist.  Then, if someone else moves TARGET to another path
while we are composing and executing this command, Subversion could do
its best to follow the move or error out if it can't do so.  But unless
and until 'svn' actually uses the peg revision in this way, it should
complain, not silently ignore it.

  (c) When the target refers to a new path that will be created in a new
revision on top of the old head, such as in 'svn mkdir TARGET-URL' or
the destination of 'svn copy SOURCE DEST-URL'.  In most of these cases,
the target does not exist in the repository at the time the command is
issued so there is no possible peg revision specifier.  The target of a
copy may be specified as an existing directory, and in that case it
could accept a peg of 'HEAD' or even a non-head peg as described in (b).

My question is about this case:

  $ svn copy SOURCE TARGET@HEAD

This case falls under the last sentence of point (C) above.  Issue #3651
[3] claims that the 'HEAD' peg should be ignored in this case, and that
claim is explicitly tested by copy_tests 62 [4].  (It is the only test
that fails with the attached patch.)

But is 'HEAD' supposed to be a special case on the basis that it is
redundant but still correct?  If so, then we should also allow '123' iff
that is currently the head, and 'BASE' for a local path iff that is
currently the head, and so on.  In other words I don't think we have
reason to claim that 'HEAD' is a special case.

The logic gets very messy if we think we must support redundant pegs.
Even if we only implement a subset of the messy logic (such as just
allowing 'HEAD') the conceptual logic is messy which is a bad thing for
documentation and learning.  So my conclusion is that we should reject
any peg revision specifier, even 'HEAD', in places where we're not
prepared to use it.

If that's agreeable, I'll make it happen.  (The attached patch is not
quite finished; for example it has no doc string for one of the new
functions.)

- Julian


[1] Issue #3416 "Cannot add or commit 'dir/@file.txt'",
<http://subversion.tigris.org/issues/show_bug.cgi?id=3416>.
[2] The only ways I can imagine the second example could make sense are
if it were to mean, "Make this directory, assuming that HEAD is 123, and
fail if not" or, "Make this directory, assuming that HEAD is 122 so that
the committed revision will be 123, and fail if not."  But we don't have
any plans to implement such semantics, and the syntax does not make
sense for the semantics we have implemented.
[3] Issue #3651 "svn copy does not eat peg revision within copy target
path", <http://subversion.tigris.org/issues/show_bug.cgi?id=3651>.
[4] <http://svn.apache.org/viewvc?revision=952992&view=revision>


Re: [PATCH] 'svn' should not silently ignore a peg revision

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 06/29/2011 08:07 AM, Julian Foad wrote:
> My question is about this case:
> 
>   $ svn copy SOURCE TARGET@HEAD
> 
> This case falls under the last sentence of point (C) above.  Issue #3651
> [3] claims that the 'HEAD' peg should be ignored in this case, and that
> claim is explicitly tested by copy_tests 62 [4].  (It is the only test
> that fails with the attached patch.)

Issue #3651 is wrong.  This command line should error out in the same way it
would had "HEAD" been any other revision.  HEAD is, by definition,  the
youngest revision in the repository.  Our revisions are immutable with
respect to key changes, and therefore cannot be the target of any write
operation (excepting revprop changes).

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


Re: [PATCH] 'svn' should not silently ignore a peg revision

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Julian Foad wrote on Wed, Jun 29, 2011 at 13:07:01 +0100:
> My question is about this case:
> 
>   $ svn copy SOURCE TARGET@HEAD
> 
> This case falls under the last sentence of point (C) above.  Issue #3651
> [3] claims that the 'HEAD' peg should be ignored in this case, and that
> claim is explicitly tested by copy_tests 62 [4].  (It is the only test
> that fails with the attached patch.)
> 
> But is 'HEAD' supposed to be a special case on the basis that it is
> redundant but still correct?  If so, then we should also allow '123' iff
> that is currently the head, and 'BASE' for a local path iff that is
> currently the head, and so on.  In other words I don't think we have
> reason to claim that 'HEAD' is a special case.
> 

- 'svn cp ^/foo ^/bar@123'

  + when youngest is 123 or more: error out

  + when youngest is 122 or less:
    This could mean 'copy foo to bar and only commit that if the commit
    would create r123'.  But we don't support that at the FS, so this
    should cause an error too.

- 'svn cp ^/foo ^/bar@HEAD'

  Need to decide:

  + if 'HEAD' means "'HEAD' before the commit":
  
    Error out, this doesn't make any sense.  (Well, /technically/ it's
    a reverse obliteration --- a constructive alteration of a committed
    revision --- but let's not go there ☺)

  + if 'HEAD' means "'HEAD' after the commit":

    Semantically it's unneeded, so we could either treat '^/bar' and
    '^/bar@HEAD' identically or error out on the latter.


So, just erroring out seems fine (unless someone comes up with a use
case for one of the combinations I'd ruled out).

Makes sense?

> The logic gets very messy if we think we must support redundant pegs.
> Even if we only implement a subset of the messy logic (such as just
> allowing 'HEAD') the conceptual logic is messy which is a bad thing for
> documentation and learning.  So my conclusion is that we should reject
> any peg revision specifier, even 'HEAD', in places where we're not
> prepared to use it.
> 

+1 to erroring out when pegs are provide in places where they are
semantically meaningless.

> If that's agreeable, I'll make it happen.  (The attached patch is not
> quite finished; for example it has no doc string for one of the new
> functions.)
> 

I haven't yet read the attached patch in detail.

> - Julian
> 
> 
> [1] Issue #3416 "Cannot add or commit 'dir/@file.txt'",
> <http://subversion.tigris.org/issues/show_bug.cgi?id=3416>.
> [2] The only ways I can imagine the second example could make sense are
> if it were to mean, "Make this directory, assuming that HEAD is 123, and
> fail if not" or, "Make this directory, assuming that HEAD is 122 so that
> the committed revision will be 123, and fail if not."  But we don't have
> any plans to implement such semantics, and the syntax does not make
> sense for the semantics we have implemented.
> [3] Issue #3651 "svn copy does not eat peg revision within copy target
> path", <http://subversion.tigris.org/issues/show_bug.cgi?id=3651>.
> [4] <http://svn.apache.org/viewvc?revision=952992&view=revision>
>