Reputation: 31212
I would like to contain some meta data in some versioned non-code-level files, specifically the revision ID of the file. If possible, I would like to configure a specific directory so that whenever a file is checked in, the subversion
server takes the new revision number and append
/* rev: $revNo */
to the end of the file. The thing is, a script that processes these versioned files would like to know what the revision of the file is and reading the last line in the file, which is entered in a format that doesn't break the rest of the file's semantics, would be easier than using some svn API to check the file revision or even invoking a system level svn command against that versioned object.
Is there a way to automate this task?
Upvotes: 1
Views: 161
Reputation: 4982
Not sure if this can be done on the server side. I assume it can. The server would need a pre-commit hook to perform the action. This might be server-specific. In VisualSVN, you can write a power-shell script which is called pre-commit with the following ordered arguments:
[1] REPOS-PATH
[2] REV
[3] TXN-NAME.
I think you could use these parameters to append that information to a versioned file. I'm just not sure if that would trigger another commit, triggering another pre-commit hook.
You could definitely do something similar on the client side. I use SubWCRev. It's part the TortoiseSVN which uses command-line interface to get SVN parameters.
With a file: SubWC.h.in:
#define SVNREV "$WCREV$"
#define SVNMOD "$WCMODS?Modified:Not modified$";
#define SVNVER "$WCUNVER?Unversioned items found:no unversioned items$";
Then if you run SubWCRev.exe . SubWC.h.in SubWC.h
during a pre-build event, you'll get an auto-generated header:
#define SVNREV "2345"
#define SVNMOD "Modified"
#define SVNVER "Unversioned items found"
You can #include
that header to embed version info in your application.
There's a good explanation of that here. It doesn't version the generated file for you, but you could probably script an svn ci
in that same pre-build script.
Upvotes: 2