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.
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.