You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Hudson <gh...@MIT.EDU> on 2003/10/29 21:35:52 UTC
Diff syntax changes for issue #1093
For background, read CMike's proposal at
http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=48573 if
you haven't already.
I have a few Deep Thoughts, which I'll present in increasing order of
complexity. Essentially, I want to adopt CMike's proposal, but with
some simplification (point 1), a slight modification (point 2), and with
a better description relative to the current syntax (point 5).
1. Being able to do "svn diff -rX:Y foo@Z" seems really esoteric. It's
a tough concept for users to understand, and I can't imagine it getting
any use from the command line. So I don't think it's a good idea to
support that. When the question of peg revisions comes into play, we
should always peg paths to the WC, and should always peg URLs to the
HEAD.
(On the other hand, a GUI client may have a much more intuitive way of
identifying nodes. So svn_client_diff() may want to support pegging
targets to any revision, even if the command-line client can't.)
2. BASE is the wrong peg revision for a wc path. Consider "svn rm bar;
svn cp foo bar; svn diff bar".
3. In your proposal, the command "svn diff -r 10:20 URL" could have
surprising results if URL@HEAD is a different object from both URL@10 or
URL@20. Or it could have unsurprising results, depending on why the
user is issuing that command (say, if they just read the output of "svn
log URL"). So I think it's probably reasonable.
4. As discussed on IRC, going forward in time within a node is a little
tricky. Making it work in all the unambiguous cases is probably too
hard, especially without true rename tracking (but it's still hard even
with it, because of lazy directory copies). In the meantime, we should
at least make it work in the case where the node exists with the same
name in the future rev. (This is essentially what CMike just said in
his 29 Oct 2003 14:02:22 -0600 message.)
5. The current abstract model for diffs is broken, because it assumes
that all diff commands can be described as an iteration of paths within
a single comparison. However, in the presence of copies, that model
gets some embarassingly simple cases wrong:
svn cp ../baz foo
svn diff foo bar
There is no single comparison which contains the proper diffs when
restricted to the pathnames "foo" and "bar"; for foo, we want to compare
../baz@BASE with ./foo@WC, and for bar, we want to compare ./bar@BASE
with ./bar@WC. To fix this problem, I think we have to de-unify the
diff syntax. Fortunately, I think we can do so without re-introducing
the two-argument ambiguity of the past. Here is my proposal:
-----
diff [-r M[:N]] [TARGET...]
Each target may be a path or URL, but it is invalid to specify a URL
with no -r option. Perform a pegged diff for each target. For paths,
the default starting rev is BASE, the default ending rev is WC, and the
peg rev is always WC. For URLs, there is no default starting rev (-r
option must be present), the default ending rev is HEAD, and the peg rev
is always HEAD.
diff --old=OLD-TGT[@OLDREV] --new=NEW-TGT[@NEWREV] [PATH...]
Compare OLD-TGT and NEW-TGT, restricted to the paths PATH... if given.
Can be used to answers questions like "what changes were made to
libsvn_ra_dav between the 0.32 branch and the trunk?" (Limitation: if
libsvn_ra_dav was renamed between the 0.32 branch and the trunk, the
user will have to go find out how; we can't answer complex questions
like "what was the name of /trunk/subversion/libsvn_ra_dav under
/branches/0.32?".)
diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]
Syntactic sugar for diff --old=OLD-URL@OLDREV --new=NEW-URL@NEWREV.
Easily distinguishable from the first usage because you can't use URLs
without a -r option. Note "svn diff URL@R1 URL@R2" is rather different
from "svn diff -rR1:R2 URL", because the latter performs a pegged diff
of URL@HEAD between R1 and R2, while the former looks up URL's pathname
independently in R1 and R2 and diffs the results.
-----
From a libsvn_client perspective, I think we want two separate functions
for the two separate behaviors; if we try to do them both with the same
function, we'll be embedding too much command-line user interface logic
into the client library.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by Greg Hudson <gh...@MIT.EDU>.
On Wed, 2003-10-29 at 16:35, Greg Hudson wrote:
> 1. Being able to do "svn diff -rX:Y foo@Z" seems really esoteric.
> [...] When the question of peg revisions comes into play, we
> should always peg paths to the WC, and should always peg URLs to the
> HEAD.
Hm, I think I have to take back this comment. It would become
impossible to get a log or diff of a deleted item, short of checking it
out at an earlier rev.
> diff [-r M[:N]] [TARGET...]
So this becomes:
diff [-r M[:N]] [TARGET[@REV]...]
where @REV specifies the peg rev. (And maybe affects the default for M
or N? I'm really not where where we want to draw the line on @REV
affecting the operational revs.)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by Jack Repenning <jr...@collab.net>.
At 4:35 PM -0500 10/29/03, Greg Hudson wrote:
>For background, read CMike's proposal at
>http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=48573 if
>you haven't already.
>
>I have a few Deep Thoughts, which I'll present in increasing order of
>complexity. Essentially, I want to adopt CMike's proposal, but with
>some simplification (point 1), a slight modification (point 2), and with
>a better description relative to the current syntax (point 5).
>
>1. Being able to do "svn diff -rX:Y foo@Z" seems really esoteric. It's
>a tough concept for users to understand, and I can't imagine it getting
>any use from the command line. So I don't think it's a good idea to
>support that. When the question of peg revisions comes into play, we
>should always peg paths to the WC, and should always peg URLs to the
>HEAD.
I'll grant you some wording like "uncommon," but this is a facility
I've often used, from the command line, with ClearCase. I think this
same scenario is quite likely with SVN. It arises from versioning
directories (knowing not merely that "this directory contains a file
of such a name and such contents" but actually "which is related to
certain ancestral nodes, and not to all those others"). Based on
ClearCase experience, I suspect the scenario will be fairly common,
more common than one might suppose reasoning just from, say, CVS
experience (where you can't get into these states).
I'd hate to see this syntax lost.
I'll illustrate in the rest of this message, but the examples will
probably be opaque to those without ClearCase experience, and I don't
really want to turn this into a ClearCase seminar ... if your
curiosity's irrepressably aroused, drop me a line by private email
and we can chat ;-)
In ClearCase, you don't have or need a specialized "diff" command,
because it presents itself as a versioned file system, and plain old
"diff" can read the files just fine:
diff dir1/dir2@@/REL1/README/REL2 dir1/dir2@@/REL2/README/REL2
That compares two versions, but not necessarily two versions of the
same file. Each of these versions is a version of an "element"
(ClearCase speak for SVN "node") that, at least occasionally, was
visible as a file named README. We are comparing versions bearing
the label (== "tag") REL2, in both cases. We know that the "file
named README" of interest (there are, of course, many "files named
README" in the world) was at various times visible in dir1/dir2. We
have some reason to suspect that the actual file README present there
in REL1 was a version of a different element than the actual file
README present there in REL2.
The most common (and it's surprisingly common) use case is, someone
inexperienced made changes by
cleartool rm file
create file anew by some means or other
cleartool mkelem file # mkelem is ClearCase speak for "add"
cleartool checkin
This fractures the history -- you can't simply "diff
file@@/main/[23]" (as you could if history were preserved). This
causes consternation for downstream tools, such as smart diff/merge.
This, ultimately, causes the ClearCase guru to visit the ClearCase
novice's desk, run the complicated command above, try a few
unsuccessful times to explain the problem, and finish off by saying
"look, just change the file, don't remove and recreate it."
--
-==-
Jack Repenning
CollabNet, Inc.
8000 Marina Boulevard, Suite 600
Brisbane, California 94005
o: 650.228.2562
c: 408.835.8090
f: 650.228.2501
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by "C. Michael Pilato" <cm...@collab.net>.
Greg Hudson <gh...@MIT.EDU> writes:
> On Wed, 2003-10-29 at 22:58, Jack Repenning wrote:
> > Does "diff -rM URL1 URL2" mean "diff URL1 against URL2 in some way"?
> > Or "diff URL1 against some -rM ancestor of itself, then do that again
> > for URL2"?
>
> The latter. It's an M:HEAD diff of URL1@HEAD, followed by an M:HEAD
> diff of URL2@HEAD. (HEAD is only being used in two places because it's
> the default for both N and for the peg rev. If you said "diff -rM:N
> URL1 URL2", then it would be an M:N diff of URL1@HEAD followed by an M:N
> diff of URL2@HEAD.)
>
> If you want to diff URL1 against URL2, you don't use a -r parameter.
Right.
> Maybe what you're getting at is that there's no way in my proposal to
> say "diff URL1@R1-time-travelled-to-M against
> URL2@R2-time-travelled-to-N". If we really want to support that, we
> could (diff -r M:N --old=URL1@R1 --new=URL2@R2) but I'm not sure it's a
> great idea. Maybe CMike has an opinion.
To me, "diff -r M:N --old=URL1@R1 --new=URL2@R2" means positively
nothing. It's for this very reason that I greatly disliked the syntax
"merge -rX:Y path1 path2 path3" to mean "apply the diff between
path1@X and path2@Y, to path3".
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by Greg Hudson <gh...@MIT.EDU>.
On Wed, 2003-10-29 at 22:58, Jack Repenning wrote:
> Does "diff -rM URL1 URL2" mean "diff URL1 against URL2 in some way"?
> Or "diff URL1 against some -rM ancestor of itself, then do that again
> for URL2"?
The latter. It's an M:HEAD diff of URL1@HEAD, followed by an M:HEAD
diff of URL2@HEAD. (HEAD is only being used in two places because it's
the default for both N and for the peg rev. If you said "diff -rM:N
URL1 URL2", then it would be an M:N diff of URL1@HEAD followed by an M:N
diff of URL2@HEAD.)
If you want to diff URL1 against URL2, you don't use a -r parameter.
Maybe what you're getting at is that there's no way in my proposal to
say "diff URL1@R1-time-travelled-to-M against
URL2@R2-time-travelled-to-N". If we really want to support that, we
could (diff -r M:N --old=URL1@R1 --new=URL2@R2) but I'm not sure it's a
great idea. Maybe CMike has an opinion.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by Jack Repenning <jr...@collab.net>.
At 9:53 PM -0500 10/29/03, Greg Hudson wrote:
>Incidentally, you seem to be using your own terminology here, and that
>can only lead to confusion. If you read libsvn_fs/structure, you will
>find that we don't call anything a "version" except for the svndiff
>version number. So when you're tempted to talk about "choosing a
>version," instead say, "choosing a node-revision."
Sorry. Thanks for the correction. I've been looking for those words
for some time. Thought I'd checked that file, as a matter of fact,
yet as you can see I remained confused. Maybe it'll stick this time.
>
>> > diff [-r M[:N]] [TARGET...]
>> >
>> >Each target may be a path or URL, but it is invalid to specify a URL
>> >with no -r option. Perform a pegged diff for each target. For paths,
>> >the default starting rev is BASE, the default ending rev is WC, and the
>> >peg rev is always WC. For URLs, there is no default starting rev (-r
>> >option must be present),
>>
>> This seems once again to muddle "find the node" and "pick the
>> versions," doesn't it?
>
>No, just because the default ending rev is the same as the fixed peg rev
>doesn't mean I'm muddling them together.
Does "diff -rM URL1 URL2" mean "diff URL1 against URL2 in some way"?
Or "diff URL1 against some -rM ancestor of itself, then do that again
for URL2"?
If the former, then isn't "M" being used twice, once to select "the
pegged node-rev", and again to specify "the start rev"? That would
be what I meant by "muddled."
>
>I'll change the question a bit: "what changes were made to libsvn_ra_dav
>and mod_dav_svn between the 0.32 branch and the trunk?"
>
>svn diff --old=http://svn.collab.net/repos/svn/branches/0.23
> --new=http://svn.collab.net/repos/svn/trunk
> subversion/libsvn_ra_dav subversion/mod_dav_svn
>
>You might say, "gosh, that's some mighty complicated syntactic sugar
>there, since it's just equivalent to two successive svn diff commands
>with the paths tacked onto the old and new URLs."
Actually, I said "gosh, that's a great example and makes it very clear."
--
-==-
Jack Repenning
CollabNet, Inc.
8000 Marina Boulevard, Suite 600
Brisbane, California 94005
o: 650.228.2562
c: 408.835.8090
f: 650.228.2501
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by Greg Hudson <gh...@MIT.EDU>.
Sorry to be confusing. I didn't introduce the concept of pegged and
operative revisions, so I didn't explain them.
You correctly surmised that a "peg revision" is used to identify what
node we want to diff between two revisions (that's hand-wavy; see
below), and the "operative revisions" are the two revs we want to diff
between.
On Wed, 2003-10-29 at 20:59, Jack Repenning wrote:
> * "peg" is all about (indirectly) choosing the _node_ to which the
> operation applies, but choosing a _version_ based on some rules we
> suppose to be intuitive, and then selecting the node of which this
> version is a part.
That's mostly correct, except that a node can have many incarnations
within a single repository revision, even many incarnations with the
same copy-ID. So I don't think you ever get to throw away any
information about what node-revision you're hanging onto.
The important thing is, given a node-rev, we know how to go backward and
(in limited circumstances) forward in time to a different repository
rev.
Incidentally, you seem to be using your own terminology here, and that
can only lead to confusion. If you read libsvn_fs/structure, you will
find that we don't call anything a "version" except for the svndiff
version number. So when you're tempted to talk about "choosing a
version," instead say, "choosing a node-revision."
> I think I can similarly moosh a lot of our discussion about diff
> syntax into this: that it's very hard to keep revision info from
> leaking between "choose the node" and "choose the versions within the
> node."
I can't understand this, again because you're using your own
terminology.
> > diff [-r M[:N]] [TARGET...]
> >
> >Each target may be a path or URL, but it is invalid to specify a URL
> >with no -r option. Perform a pegged diff for each target. For paths,
> >the default starting rev is BASE, the default ending rev is WC, and the
> >peg rev is always WC. For URLs, there is no default starting rev (-r
> >option must be present),
>
> This seems once again to muddle "find the node" and "pick the
> versions," doesn't it?
No, just because the default ending rev is the same as the fixed peg rev
doesn't mean I'm muddling them together.
> * as argued elsewhere, I want "-rM[:N] TARGET@PEG-R" back, to
> preserve their separation
If you'd read forward in your email, you'd see that you have it. :) But
it's not a matter of "preserving their separation"; just because the
default end rev was the same as the fixed peg rev doesn't mean that my
proposal didn't keep them separate.
> > diff --old=OLD-TGT[@OLDREV] --new=NEW-TGT[@NEWREV] [PATH...]
> >
> >Compare OLD-TGT and NEW-TGT, restricted to the paths PATH...
> Oops, sorry, I'm lost again. What's it mean, "compare X and Y,
> restricted to Z"? Is the idea that X and Y might be directories,
> that the comparison is implicitly recursive, that the path(s) are
> paths within (both?) X and Y, and so that anything in X/Y which is
> *not* named in the path-list should be ignored?
Yes.
> >if given.
> >Can be used to answers questions like "what changes were made to
> >libsvn_ra_dav between the 0.32 branch and the trunk?"
>
> Uuhh ... an attempt to anticipate my very question, I think, but I'm
> not following the answer. Sorry. Maybe: "what's the complete diff
> command to ask this question?"
I'll change the question a bit: "what changes were made to libsvn_ra_dav
and mod_dav_svn between the 0.32 branch and the trunk?"
svn diff --old=http://svn.collab.net/repos/svn/branches/0.23
--new=http://svn.collab.net/repos/svn/trunk
subversion/libsvn_ra_dav subversion/mod_dav_svn
You might say, "gosh, that's some mighty complicated syntactic sugar
there, since it's just equivalent to two successive svn diff commands
with the paths tacked onto the old and new URLs." And you might be
right; the syntax made more sense back when we thought we could shoehorn
"svn diff foo bar baz" into it as syntactic sugar. So perhaps we should
forbid path arguments to the --old/--new case, which leaves us with:
svn diff --old=OLT-TGT[@OLDREV] --new=NEW-TGT[@NEWREV]
svn diff OLD-URL[@OLDREV] NEW-URL[@NEWREV] (syntactic sugar)
Now, you might say "why not just ditch the first syntax, and only
support the second syntax?" We could do that, but only if we're willing
to sacrifice the ability to diff two working copy paths against each
other, because "svn diff PATH1 PATH2" looks like the other use case
(i.e. "svn diff -rBASE:WC PATH1@WC PATH2@WC").
Alternatively, you might say "why not ditch the second syntax, and only
support the first syntax?" I'd be fine with that; it's a little more
verbose, but it makes it absolutely clear when you're comparing two
specified coordinates in version-space against each other, as opposed to
comparing a list of one or more things between two revisions.
> > diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]
> >
> >Syntactic sugar for diff --old=OLD-URL@OLDREV --new=NEW-URL@NEWREV.
> >Easily distinguishable from the first usage because you can't use URLs
> >without a -r option. Note "svn diff URL@R1 URL@R2" is rather different
> >from "svn diff -rR1:R2 URL", because the latter performs a pegged diff
> >of URL@HEAD between R1 and R2,
> Err ... I can't fit those words into my understanding of "peg,"
> above. If I got that right, I need help through "perform a pegged
> diff of X between R1 and R2." Or maybe, I think *all* diffs are
> pegged, albeit some explicitly and some implicitly.
I'll work through what happens in the two cases, under my proposal.
Case 1: svn diff URL@R1 URL@R2
Find the contents of URL at R1; call that node-revision X. Find the
contents of URL at R2; call that node-revision Y. X and Y may be parts
of totally different nodes, even though they have the same URL. Diff Y
against X.
Case 2: svn diff -rM:N URL
Find the contents of URL at HEAD; call that node-revision X. Go back in
time from X to repository rev M; call that node-revision Y. Go back in
time from X to repository rev N; call that node-revision Z. Diff Z
against Y.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Diff syntax changes for issue #1093
Posted by Jack Repenning <jr...@collab.net>.
At 4:35 PM -0500 10/29/03, Greg Hudson wrote:
>For background, read CMike's proposal at
>http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=48573 if
>you haven't already.
I need some help with "peg revision" and "operative revision [range]."
Mike says "peg" means "whatever we already do in a bunch of other
places," but I got lost chasing the pointers. I think maybe "peg" is
supposed to mean "the version the user is really thinking of when he
types the un-annotated path." (Often tricky to guess what the user
is thinking, but for example I agree with Greg's point #2, that WC is
a more obvious assumption than BASE for a working copy.)
There are places in this conversation when we say "peg" yet
ultimately want some version different from that. This might seem to
undermine my guess above, but I think the discussion is saying
something sort of like:
establish the peg version
identify the node of which this version is a part/descendant
find the other version(s) of that node
so "peg" still means the same thing, we're just doing further tricks
once we've found it. Is that right?
In this discussion, I think "operative revision [range]" means "the
revision [range] over which the diff operation is requested; the
actual revisions to compare."
If that's all kinda right, then let me moosh it into a slightly
different shape:
* "peg" is all about (indirectly) choosing the _node_ to which the
operation applies, but choosing a _version_ based on some rules we
suppose to be intuitive, and then selecting the node of which this
version is a part.
* "operative" is all about selecting versions from out of that node,
on which to operate.
I think I can similarly moosh a lot of our discussion about diff
syntax into this: that it's very hard to keep revision info from
leaking between "choose the node" and "choose the versions within the
node."
And that said,
At 4:35 PM -0500 10/29/03, Greg Hudson also wrote:
> diff [-r M[:N]] [TARGET...]
>
>Each target may be a path or URL, but it is invalid to specify a URL
>with no -r option. Perform a pegged diff for each target. For paths,
>the default starting rev is BASE, the default ending rev is WC, and the
>peg rev is always WC. For URLs, there is no default starting rev (-r
>option must be present),
This seems once again to muddle "find the node" and "pick the
versions," doesn't it? That is,
* I would think "peg to HEAD" a reasonable default for a URL
* as argued elsewhere, I want "-rM[:N] TARGET@PEG-R" back, to
preserve their separation
>the default ending rev is HEAD, and the peg rev
>is always HEAD.
>
> diff --old=OLD-TGT[@OLDREV] --new=NEW-TGT[@NEWREV] [PATH...]
>
>Compare OLD-TGT and NEW-TGT, restricted to the paths PATH...
Oops, sorry, I'm lost again. What's it mean, "compare X and Y,
restricted to Z"? Is the idea that X and Y might be directories,
that the comparison is implicitly recursive, that the path(s) are
paths within (both?) X and Y, and so that anything in X/Y which is
*not* named in the path-list should be ignored?
>if given.
>Can be used to answers questions like "what changes were made to
>libsvn_ra_dav between the 0.32 branch and the trunk?"
Uuhh ... an attempt to anticipate my very question, I think, but I'm
not following the answer. Sorry. Maybe: "what's the complete diff
command to ask this question?"
>(Limitation: if
>libsvn_ra_dav was renamed between the 0.32 branch and the trunk, the
>user will have to go find out how; we can't answer complex questions
>like "what was the name of /trunk/subversion/libsvn_ra_dav under
>/branches/0.32?".)
+1
>
> diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]
>
>Syntactic sugar for diff --old=OLD-URL@OLDREV --new=NEW-URL@NEWREV.
>Easily distinguishable from the first usage because you can't use URLs
>without a -r option. Note "svn diff URL@R1 URL@R2" is rather different
>from "svn diff -rR1:R2 URL", because the latter performs a pegged diff
>of URL@HEAD between R1 and R2,
Err ... I can't fit those words into my understanding of "peg,"
above. If I got that right, I need help through "perform a pegged
diff of X between R1 and R2." Or maybe, I think *all* diffs are
pegged, albeit some explicitly and some implicitly.
--
-==-
Jack Repenning
CollabNet, Inc.
8000 Marina Boulevard, Suite 600
Brisbane, California 94005
o: 650.228.2562
c: 408.835.8090
f: 650.228.2501
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org