Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

predict revision number before commit

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.

like image 682
seler Avatar asked Feb 28 '26 05:02

seler


2 Answers

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
like image 61
Toufik Avatar answered Mar 02 '26 00:03

Toufik


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.

like image 38
Piskvor left the building Avatar answered Mar 01 '26 23:03

Piskvor left the building



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!