Is it possible to predict revision number before commit?
It would be useful. I want to write revision number in changelog and commit it together with changes it's providing.
I know the number can be changed before my commit reaches repo but still it would be nice to know.
I'm writing my changelogs in plain text using rst formatting
more info: every commit message contains issue id, this is also appears in title of changelog.
please stick to the question
I'm asking if this is possible and how, not if this would make sense or anything else.
Why do I need this? I need this information that person, who deploys application would know in which revision those changes appear so he may update production server accordingly. He reads changelog anyway because it contains information about changes in database and other important stuff. It just would be a little bit easier if he musn't use blame to see which revision this entry belongs to.
A bit hacky but this should work on Linux: if you type at the prompt
svn up
The last line of the answer will be
At revision 42.
or
Updated to revision 42.
Where 42 is the revision number of the last commit on the whole svn server. So the next commit will be this one + 1. You can get it, with this command:
svn up | sed -ne 's/revision //p' | sed -e 's/[^0-9]*//g'
If you're fast enough, you can hope no one will commit before you. If you have a working copy of the root of the svn server, you could lock it to prevent any commit and unlock it at the end:
svn lock rootdir
svn unlock rootdir
Sticking to the question as requested: No, this is not possible - not reliably, anyway.
This is a chicken-and-egg problem: the revision number is assigned only when the commit succeeds, so you can't include it in the commit itself.
You can go ahead and guess "all right, we're on revision 12345, so next revision is 12346", but while you're guessing (even if it takes you a few milliseconds), I've succesfully commited a revision, and you guess wrong. Not by evil intent, mind you - I have no mechanism to know that you're about to commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With