Reputation:
I have an SVNrepository where files are checked in this format.
<filename>.<ext>-rev<revision number>
There is another file where the revision number is entered. When a build is done, then this file is parsed and the file with corresponding revision number is taken and renamed to a standard file name <filename>.<ext> and the final build is done.
How do I get the changelist number of SVN before you are submitting?
Upvotes: 0
Views: 1580
Reputation: 516
Look at "SvnRev" which is currently available here:
http://www.compuphase.com/svnrev.htm
It sounds like you are trying to implement some sort of CHANGELOG or a release tagging system where users can select different released versions. So, assuming that is what you were looking for here is what I did in a similar situation. I realize your question is a year old, but maybe someone else will find this.
I maintained a separate file to store the history of revisions of special interest. I have projects where I make an "official" installer for our entire application. Normally I wouldn't store generated code in a version control system, but these binaries we treat as special. We like to keep the exact binary that we deliver to a user. We don't want to rebuild them later, and storing them in SVN is a convenient abuse of version control...
So I build my installer binary; commit the installer binary to SVN; get the SVN revision of the installer that I just committed; append revision/date/notes to a file called CHANGELOG; and finally I commit the CHANGELOG file. The revision number of the CHANGELOG will be one or more than the installer, but I only care about the installer's revision numbers.
For extra convenience, the installer is copied to a web server and placed under a directory named with the installer's revision number. But we can always look at the CHANGELOG notes to find the revision of an installer that we want and check it out by that revision.
We can also use that revision number to check out the source used to build the installer (you must be sure nobody committed changes between your source checkout/build and the installer commit). If you really don't mind wasting disk space you can do a tag; build; and commit the installer back to the tag. SVN doesn't really have tags, of course, so you would do an "svn copy"; but then a real tagging system wouldn't let you commit changes back to it.
Upvotes: 0
Reputation: 25694
I think you're misusing the version control system (VCS). You shouldn't need to put revision numbers or dates into file names when you're using a VCS. The VCS will store that information for you automatically, as metadata.
Instead of checking in a new file every time with a new revision/date, you should replace the old file. The old files will always be available in the VCS history if you need them for some reason. In addition to reducing clutter, this has the advantage of always keeping the same file name which makes automation easier.
Also, as a general rule, you don't want to commit compiled binaries to the source tree. You should only commit the files you need to build the binaries (namely, the source and the makefile).
If you really do want to continue on your current plan, you're going to have difficulty. There's no way to know what revision number you will get until after the commit succeeds -- this is a basic design guarantee of the atomic commit concept. The best you can do is add a post-commit hook that checks out a copy of whatever was just committed and renames the file to be the revision number.
This means the name change of the file will reflect an earlier revision than the one where the name change takes place, but it will allow you to have the file name revision number be the same as the changes that you made, which I think is what you want. This technique will also result in two commits for every change. I don't recommend it.
Upvotes: 3
Reputation:
I think I have the whole picture now.
The scenario is like this:
Some code is checked out from a different branch of the repository. Fixes are made, and the resulting changes are submitted into that repository (a revision number is obtained on check-in).
A binary (library) is created with these changes. This library is part of a bigger module, and this binary is checked into this module as <binary>-<revno>. The make file is modified to pickup this binary-revno and rename it as <binary>. It is using this in creating the bigger module.
Upvotes: 0
Reputation: 93143
You might try doing an svn up
and getting the last revision and use that rev plus one. But as Mark Dickinson said, if someone else updates there will be issues.
I would try a different approach.
Upvotes: 1
Reputation: 64404
There is no safe way of obtaining the revision number before performing the commit. This would require clients to be able to lock the repository.
Why do you want a new file checked in for each new revision? I'm sure there is a better solution to the problem you're trying to solve.
Upvotes: 1