views:

251

answers:

5

Say I have 3 files foo.txt, bar.txt and moo.txt all at revision 1.

Say I commit foo.txt and bar.txt ten times. So they are at revison 1.10. Since in SVN there is a single revision no moo.txt also has to be at revision 1.10. Now if I see the history of moo.txt then, will I see the history of commits from 1 to 10?

The reason I am asking this question is I was telling my friend how sucky CVS is when compared to SVN. He is a big fan of CVS. So he told me since CVS revision numbers are file specific it is very easy for him to bring a single file back to some status (since the history of single file does not contain the commits done to other sections of the project). Since I always update my whole project to a previous version (not single file) I have never come across this situation. So, I want to know how is this handled in SVN?

A: 

This is easy enough to test. If you view the history for a single file, it will only include revisions in which it played a part. If it was not modified that log entry would not appear. You can easily revert specific revisions on a single file or group of files.

1800 INFORMATION
I do not have an SVN set up with me for testing. Use CVS at work. Otherwise would not have asked.Thanks.
Abhi
It is incredibly simple to set up an SVN repo for testing purposes - just install the client and do an "import"
1800 INFORMATION
Cool. Will give it a shot.
Abhi
A: 

SVN uses a repository-wide revision number which is incremented with each commit. When you view the log of a single file, you will only see the revision of that file, but there will be gaps in the version numbering).

Philippe Leybaert
A: 

You can think of it like moo.txt does have file specific revisions, its just they have gaps, eg, moo.txt's revisions are 1, 10, 11, 18, etc.

In reality, this is no harder to deal with than if it was 1, 2, 3, 4, 5 but has the added advantage of meaning something for the entire repository.

Robin Day
+1  A: 

SVN history can be viewed per-file, or per-directory, so you'll see the history of whatever files match the filter you're looking for. If you only view the history of moo.txt then you'll only see its changes (which in your example would probably be 3-12).

Also worth pointing out is that SVN allows atomic commits of more than one file, so you might possibly have committed foo.txt and moo.txt together in a single change at version 2. In which case, you'll also see this in the change history of moo.txt.

Really though, I think the correct answer is just to install SVN and test it for yourself. Then you'll get a much better understanding of how the change history works.

Nik
+2  A: 

When you look at the history of a file you will only see the comments and changes for commits made that included that file, but the revision numbers will not necessarily be consecutive.

But you can still revert a single file back to any specific revision number without affecting other files.

E.g.

two files:
foo.txt and bar.txt

1: checkin foo.txt
2: checkin foo.txt & bar.txt
3: checkin foo.txt
4: checkin bar.txt
5: checkin foo.txt
6: checkin bar.txt

If you look at the history of bar, you will see:

6:
4:
2:

And you would still be able to revert bar.txt back to revision 2 without effecting foo.txt

if you look at the history of foo you will see:

5:
3:
2:
1:

If you look at the history of the whole directory, you will see all of the commits.

Having a repository wide version number just means that you can tell the order in which things were changed from their revision numbers. It doesn't effect your ability to view histories or roll back files.

Simon P Stevens