问题
What actually are tags in subversion (SVN)? And what features does Subversion really offer built-in to make productive use of them?
I ask because I would like to label collections of files at a certain revision as a tag. This would make for more meaningful release naming. I would also like to retrieve exactly those files with that tag, no more no less, to build software from those files at a certain release.
In ClearCase tags are likely attibutes of a file, I believe. I get the worrying impression that tags aren't really anything special or core to Subversion, but instead they are an arbitrary concept, just a folder with a copy of the files at a certain revision, is this true? If so, it's not so much useful as the equivalent in, say, ClearCase.
Subversion is promoted as having tags as a feature, when it would appear that there is not really a notion core to the tool, so why say it's a feature? Not does it seem to be written about extensively in the literature, well at least enough to help me solve my problem.
回答1:
I get the worrying impression that tags aren't really anything special or core to Subversion, but instead they are an arbitrary concept, just a folder with a copy of the files at a certain revision, is this true? If so, it's not so much useful as the equivalent in, say, ClearCase.
This is absolutely correct. And, so are branches. Branches too are simply a directory which is used for creating branches.
However, just because it's done that way doesn't mean they're useless. Tags are normally used to take a snapshot of your repository at a particular moment in time. For example, I want to do a build, and tag the files used in that build. Later on, when we decide to do a release, I want to tag those very same files with my release number. Subversion's method of tagging works just as well as it does in ClearCase.
In fact, tagging in Subversion is many ways better than it is in ClearCase. In ClearCase I first have to create the label type, and then apply that label type to the version of each file I want to mark. If you are tagging say 10,000 files, it might take you 20 or so minutes. In Subversion, tagging is instantaneous. Tagging 10,000 files takes less than a second. Tagging 100,000 or 1,000,000 files take no more time.
In Subversion, you can get a list of all tags by merely listing the contents of the tags
directory. Doing so gives you a listing of actual tags. In ClearCase, you can only do a lstype -type lbtype
which gives you the label types, but it doesn't necessarily mean any of those labels are actually on any files.
In Subversion tags and branches normally have different name spaces. In ClearCase, they share the same namespace, so you usually have to do something to distinguish tags from labels. The standard is that tags are uppercase and labels are lowercase.
In Subversion, you can also see when a tag was applied, and by whom. In Subversion, tags and branches have different namespaces. And, because tags are merely directories, the flexibility you can use for tagging is infinite:
- Some sites have a
tags
directory, and a special directory forobsolete_tags
. If a tag is no longer needed, it can be moved to the obsolete directory. This means listing the tags in the tags directory only lists relevant tags. However, developers can still see the obsolete tags. - Some sites use different directories for build tags, and release tags. This way, if you are trying to see a list of all the various release tags, you're not looking at the thousands of build tags.
- Some sites have different directories for different customers or release types. That way, you can talk about Acme's 3.4 release vs. Vegco's 3.4 release.
The big advantage ClearCase labels have is that ClearCase label types can be locked, so they can't be moved or applied without the owner of the label type unlocking the label type. However, there are many pre-commit hook scripts in Subversion that can do more or less the same thing. I have one that allows you to create a tag, but not modify it.
Other hook scripts go farther. Subversion files and directories can have properties set on them. I've seen hooks that allow the person who created that tag to place a "lock-tag" property on the directory to prevent it from being modified. Removign the "lock-tag" property allows the tag to be modified. This allows Subversion tags to mimic the behavior in ClearCase.
In Subversion, branches and tags are very visible to developers and are much easier to apply and use than their counter parts in ClearCase. Many other version control systems have emulated what Subversion has done with both tags and branches because it makes the whole system more visible than the older system found in ClearCase, CVS, and older version control systems where tags and branches are mere attributes attached on individual files.
回答2:
You are right that tags are not anything special for Subversion, only for developers or in scripts they can be treated in a some special way.
Actually, what I see here as feature of Subversion here is Branching and tagging are cheap (constant time) operations. The copy operation as a hard-link is meant by this not a tag feature itself. And from here:
Subversion does not have special commands for branching or tagging, but uses so-called “cheap copies” instead. Cheap copies are similar to hard links in Unix, which means that instead of making a complete copy in the repository, an internal link is created, pointing to a specific tree/revision. As a result branches and tags are very quick to create, and take up almost no extra space in the repository.
回答3:
What actually are tags in subversion (SVN)?
Copy of repository on some revision (RO, by convention) under special location
And what features does Subversion really offer built-in to make productive use of them?
Nothing special - tags (just in any VCS) is just label of some repository snapshot, with permanent and easy-to-use name
I would like to label collections of files at a certain revision as a tag. This would make for more meaningful release naming. I would also like to retrieve exactly those files with that tag, no more no less, to build software from those files at a certain release.
Well, it's tags for exactly
tags aren't really anything special or core to Subversion, but instead they are an arbitrary concept, just a folder with a copy of the files at a certain revision, is this true?
Yes, as branches and all other physical parts of svn-repo
Subversion is promoted as having tags as a feature, when it would appear that there is not really a notion core to the tool, so why say it's a feature?
"Cheap copy", applicable to tags and branches, is feature. Easy identifable, when you have to branch|tag multiGB-repo
回答4:
ClearCase, as I mentioned in "What are the basic clearcase concepts every developer should know?", has a file centric approach (as opposed to a repository-centric approach with other VCS tools like SVN)
When you put a label in ClearCase (base ClearCase, not UCM):
- you need to apply it on every files you want to label
- you must be careful to not move that label from one version to another.
An UCM baseline is a bit better since it will applies your label on all the files of a component (no way to forget one), and you won't be able to move that label.
When you create a tag on SVN, you create a cheap copy of code referenced by a revision (repository-wide revision), and that cannot be moved.
However you can create new revisions by modifying the content of a SVN "tag", which is a bit problematic.
来源:https://stackoverflow.com/questions/7996211/what-actually-are-tags-in-subversion-svn-and-what-tag-tools-does-svn-offer-bu