You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by er...@swapsimple.com on 2004/12/28 00:30:21 UTC

are directories versioned?

	Judging from the behaviour of various svn commands, it seems that
directories aren't versioned in subversion.  It doesn't appear to be
possible to, e.g.:
	revert changes to a directory w/o reverting the changes to its files, or
	get a log of changes to the directory itself

However, I saw some messages on this list that imply that directories
actually _are_ versioned.  So, which is it?  And, if they are versioned,
how do I do things to the directory itself?  Are the above mentioned 
operations things that subversion can do, but just haven't been implemented
in the UI yet?

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by er...@swapsimple.com.
On Sat, Jan 01, 2005 at 09:38:52PM +0100, Peter N. Lundblad wrote:
> Just to avoid further confusion: in svn, revert changes only the working
> copy. I don't know CC, but that seems different there. (You can "revert"
> changes in the repository by merging changes backwards, but that will keep
> the file in old revisions.)

	it's the same in clearcase.  The difference is that CC lets you put the
directory commit and the file commit in different transactions (I'm assuming
CC has a similar transaction per user-typed-command as svn) whereas it seems
that svn ensures both operations happen within a single transaction and
svn doesn't let you revert one change without reverting the other also.

> > (which then shows up in a special lost+found directory)
> > Is it possible for subversion to fail like that if adding (or moving) a file
> > is interrupted halfway through?  If so, what happens to the file?
> >
> A commit can fail (or be interrupted) in the middle. That can give you a
> transaction in the repository that is not committed. That transaction can
> be inspected (using svnlook) or removed (using svnadmin). A file in a
> committed transaction (also known as revision) is identified by a path and
> a revision number, so files can't be "unlinked" like you describe for
> clearcase.

	hmm... that seems to imply that there isn't a separate element (to use
a CC term) object that file changes are applied to.  Which means that doing
something like figuring out all the changes that might have happened to an
element is essentially impossible because you'd need to search every version
of every directory looking for any file that refers to the one you are
running the command on.  Is that right?

So, I'm guessing that to get the contents of a file svn does a single lookup
like this:
path+rev => file contents (perhaps stored as changes to a different path+rev?)
(and directories are just lists of filenames, a cache in effect)

instead of what I was thinking of:
path+rev =>  directory object
directory object+filename+rev =>  element obj (like an RCS file)
element obj+path+rev => file contents

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by "Peter N. Lundblad" <pe...@famlundblad.se>.
On Thu, 30 Dec 2004 erh@swapsimple.com wrote:

> On Wed, Dec 29, 2004 at 02:33:05PM +0100, Peter N. Lundblad wrote:
> > On Mon, 27 Dec 2004 erh@swapsimple.com wrote:
> > > 	Judging from the behaviour of various svn commands, it seems that
> > > directories aren't versioned in subversion.  It doesn't appear to be
> >
> > This is not true. Directories are versioned. Moving a file, committing and
> > checking out an old version of the directory will retain the old filename,
> > for example.
>
> 	hmm.. ok.  I've worked with clearcase a bit and it makes an explicit
> distinction between creating a file ("element" in clearcase-speak) and adding
> it to a directory.  Of course, if you commit the file, but revert the change
> to the directory, you end up with an unlinked element in the repository.

Just to avoid further confusion: in svn, revert changes only the working
copy. I don't know CC, but that seems different there. (You can "revert"
changes in the repository by merging changes backwards, but that will keep
the file in old revisions.)


 > (which then shows up in a special lost+found directory)
> Is it possible for subversion to fail like that if adding (or moving) a file
> is interrupted halfway through?  If so, what happens to the file?
>
A commit can fail (or be interrupted) in the middle. That can give you a
transaction in the repository that is not committed. That transaction can
be inspected (using svnlook) or removed (using svnadmin). A file in a
committed transaction (also known as revision) is identified by a path and
a revision number, so files can't be "unlinked" like you describe for
clearcase.

Hope this clears some things up,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by er...@swapsimple.com.
On Wed, Dec 29, 2004 at 02:33:05PM +0100, Peter N. Lundblad wrote:
> On Mon, 27 Dec 2004 erh@swapsimple.com wrote:
> > 	Judging from the behaviour of various svn commands, it seems that
> > directories aren't versioned in subversion.  It doesn't appear to be
> 
> This is not true. Directories are versioned. Moving a file, committing and
> checking out an old version of the directory will retain the old filename,
> for example.

	hmm.. ok.  I've worked with clearcase a bit and it makes an explicit
distinction between creating a file ("element" in clearcase-speak) and adding
it to a directory.  Of course, if you commit the file, but revert the change
to the directory, you end up with an unlinked element in the repository.
(which then shows up in a special lost+found directory)
Is it possible for subversion to fail like that if adding (or moving) a file
is interrupted halfway through?  If so, what happens to the file?

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by "Peter N. Lundblad" <pe...@famlundblad.se>.
On Mon, 27 Dec 2004 erh@swapsimple.com wrote:

>
> 	Judging from the behaviour of various svn commands, it seems that
> directories aren't versioned in subversion.  It doesn't appear to be

This is not true. Directories are versioned. Moving a file, committing and
checking out an old version of the directory will retain the old filename,
for example.

 > possible to, e.g.:
> 	revert changes to a directory w/o reverting the changes to its files, or

svn revert dir
will revert property changes to that directory. One could think that it
also should revert e.g. an addition of a file. That's affecting both the
file and the directory content, so there is no simple answer to this. But
there is a chosen behaviour. You can say
svn revert dir/file
to undo the addition, deletion (or other modification) of file. But
this doesn't mean directories are not versioned.

 > 	get a log of changes to the directory itself
>
No, there is no --non-recursive flag for the log command. That might
possibly be useful. But, again, it doesn't mean directories are not
versioned.

> However, I saw some messages on this list that imply that directories
> actually _are_ versioned.  So, which is it?  And, if they are versioned,
> how do I do things to the directory itself?  Are the above mentioned
> operations things that subversion can do, but just haven't been implemented
> in the UI yet?
>
Regarding some non-recursive version of svn log, yes, the information is
available, so clearly subversion "could do" it.

Regards,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by kf...@collab.net.
erh@swapsimple.com writes:
> 	I mean revert changes related to the additional and removal of
> files, i.e. undo changes to the contents of the directory.  There
> have been several times where I've wanted to undo moving a file,
> but still keep the changes to contents of the file.  There have also
> been some fewer times when I've wanted to undo the changes to the
> contents of the file, but leave it in it's newly moved to location.

Ah, I see.

No, Subversion doesn't have an interface that supports that, although
it could -- the underlying data structures would allow it with no
problem.

> 	I think of a directory as a file that is a list of other files
> and meta information about those files, whose contents can be "edited"
> (with appropriate commands) and versioned just like any other file.  When
> treated this way, directories are special only when they are used to
> build the human understandable view of the contents of the repository.
> 	It's sounding a lot like directories in subversion are more of an
> emergent phenomenom that arises because files have pathnames associated
> them, and the fact that directories look different in different revisions
> is because the files have a different pathname property.  Is this anything
> like what subversion actually does?
> 	This isn't what I would consider the most obvious way to arrange
> things, but it does seem to have some benefits: to compare to how clearcase
> does things, when you revert a directory _all_ file adds/dels/etc.. are
> undone and you can't directly revert just a single one, whereas with
> subversion you can.
> (although that seems to be incomplete wrt undoing a move)

Er, nope.  I often play the "guess the implementation from the
features" game too, and I also get it wrong sometimes :-).  Subversion
implements directories as first-class objects.  The reason the feature
you want isn't available is just because the UI, and to some degree
the first-level APIs, offer no access to it.  But under the hood,
Subversion could easily do it.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by Andy Peters <de...@latke.net>.
Dale Worley wrote:
> -----Original Message-----
> From: erh@swapsimple.com [mailto:erh@swapsimple.com]
> 
> I mean revert changes related to the additional and removal of
> files, i.e. undo changes to the contents of the directory.  There
> have been several times where I've wanted to undo moving a file,
> but still keep the changes to contents of the file.
> -------------------------
> 
> Here you're running up against the point that Suversion has no such "undo"
> action.  By judiciously selecting what revision you check out, you can *look
> at* the past, but you can't *reverse* it.  All you can do is check in a new
> version which *looks* like a past version.

This is exactly an issue I ran into.  I made what I thought was a change 
in to a source file, committed the change, then at some point realized 
that I didn't need the change after all.  I tried to figure out how to 
revert that one file back to the original state until I realized I 
couldn't do it.  I ended up modifying the source file back to the 
original version (added a comment in my history header saying, "undoing 
those changes") and committing again.

After thinking about it, I realized that if I'd made changes to this 
file other than the ones I wanted to undo, then a simple "revert to 
older revision" wouldn't work anyways.

-a

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: are directories versioned?

Posted by Dale Worley <dw...@pingtel.com>.
-----Original Message-----
From: erh@swapsimple.com [mailto:erh@swapsimple.com]

I mean revert changes related to the additional and removal of
files, i.e. undo changes to the contents of the directory.  There
have been several times where I've wanted to undo moving a file,
but still keep the changes to contents of the file.
-------------------------

Here you're running up against the point that Suversion has no such "undo"
action.  By judiciously selecting what revision you check out, you can *look
at* the past, but you can't *reverse* it.  All you can do is check in a new
version which *looks* like a past version.

There's also the problem that the Subversion database has no concept of
moving a file.  "svn move A B" is really "svn copy A B; svn delete A".  And
copies aren't revertable in the same way that moves are.  (I gather that
they're planning to add native "moves" into the database system.)

Though I don't see this as much of a problem in practice -- If you want to
selectively reverse changes that have to be made, you're going to have to
give the SCM system some pretty detailed instructions in any case, so I
don't see much problem with doing a series of "svn copy -r http://... A/B/C"
commands to assemble the structure you want.

Dale


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by er...@swapsimple.com.
On Sun, Jan 02, 2005 at 09:13:53PM -0600, kfogel@collab.net wrote:
> erh@swapsimple.com writes:
> > 	Judging from the behaviour of various svn commands, it seems that
> > directories aren't versioned in subversion.  It doesn't appear to be
> > possible to, e.g.:
> > 	revert changes to a directory w/o reverting the changes to its files, or
> > 	get a log of changes to the directory itself
> > 
> 
> For the first, do you mean revert changes to the directory's
> properties?  Or revert changes related to the addition and removal of
> files, without reverting changes to the contents of other files?

	I mean revert changes related to the additional and removal of
files, i.e. undo changes to the contents of the directory.  There
have been several times where I've wanted to undo moving a file,
but still keep the changes to contents of the file.  There have also
been some fewer times when I've wanted to undo the changes to the
contents of the file, but leave it in it's newly moved to location.

> Similar questions apply to the second.
> 
> Subversion versions directories, but probably disagrees with you on
> what exactly that means.  If you tell us exactly the behavior you're
> expecting, we can tell you whether Subversion offers it, or could
> offer it with UI changes.

	I think of a directory as a file that is a list of other files
and meta information about those files, whose contents can be "edited"
(with appropriate commands) and versioned just like any other file.  When
treated this way, directories are special only when they are used to
build the human understandable view of the contents of the repository.
	It's sounding a lot like directories in subversion are more of an
emergent phenomenom that arises because files have pathnames associated
them, and the fact that directories look different in different revisions
is because the files have a different pathname property.  Is this anything
like what subversion actually does?
	This isn't what I would consider the most obvious way to arrange
things, but it does seem to have some benefits: to compare to how clearcase
does things, when you revert a directory _all_ file adds/dels/etc.. are
undone and you can't directly revert just a single one, whereas with
subversion you can.
(although that seems to be incomplete wrt undoing a move)

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: are directories versioned?

Posted by kf...@collab.net.
erh@swapsimple.com writes:
> 	Judging from the behaviour of various svn commands, it seems that
> directories aren't versioned in subversion.  It doesn't appear to be
> possible to, e.g.:
> 	revert changes to a directory w/o reverting the changes to its files, or
> 	get a log of changes to the directory itself
> 

For the first, do you mean revert changes to the directory's
properties?  Or revert changes related to the addition and removal of
files, without reverting changes to the contents of other files?

Similar questions apply to the second.

Subversion versions directories, but probably disagrees with you on
what exactly that means.  If you tell us exactly the behavior you're
expecting, we can tell you whether Subversion offers it, or could
offer it with UI changes.

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: are directories versioned?

Posted by Dale Worley <dw...@pingtel.com>.
Subversion does version directories -- the problem is that doesn't mean what
you think it means.

What Subversion does keep track of for a directory are the "properties"
you've attached to the directory, it's permissions, etc.

What Subversion *doesn't* keep track of for a directory are *which files are
in the directory*.

In a given working copy or revision, the set of files in a directory is
simply the set of files in the WC or rev that have names that put them in
that directory.

For example, suppose in rev 10, you have a directory X and a file X/Y, and
in rev 11, you've deleted X/Y.  Then in rev 10, X and X/Y exist, and in rev
11, X exists but X/Y does not.  Assuming you haven't changed the properties
attached to X, X has not been changed from rev 10 to rev 11 -- but X/Y has.

If you check out rev 10, then your WC contains X and X/Y.  If you check out
rev 11, then your WC contains X, which is empty, because your WC does not
contain X/Y.

But if you construct a mixed-revision-level WC, with X at rev 11 and X/Y at
rev 10, your working copy will contain X and X/Y, because X is the directory
in which X/Y lives.  If you make a mixed-revision WC with X at rev 10 and
X/Y at rev 11, it will only contain X, because "X/Y at rev 11" is absent.
Doing "svn update -r 10 X" will make X/Y appear, not because it updates X
(which is already at rev 10), but because it is recursive and updates X/Y
(which exists at rev 10) as well.

Using "svn update -r XXX --non-recursive" will let you construct various
complex mixed-revision working copies.

Since "svn log X" lists all revs that change any name under X, it will list
all changes that are visible in a directory X.

Dale

-----Original Message-----
From: erh@swapsimple.com [mailto:erh@swapsimple.com]
Sent: Monday, December 27, 2004 7:30 PM
To: users@subversion.tigris.org
Subject: are directories versioned?



	Judging from the behaviour of various svn commands, it seems that
directories aren't versioned in subversion.  It doesn't appear to be
possible to, e.g.:
	revert changes to a directory w/o reverting the changes to its files, or
	get a log of changes to the directory itself

However, I saw some messages on this list that imply that directories
actually _are_ versioned.  So, which is it?  And, if they are versioned,
how do I do things to the directory itself?  Are the above mentioned
operations things that subversion can do, but just haven't been implemented
in the UI yet?

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org