The easiest way to do this is to use make or a similar build manager to create your .dvi files.
Your Makefile should include a new target named version-number :
version-number: bzr revno > VERSION.tex
and your .dvi goals should depend on version-number :
my-project.dvi: my-project.tex [OTHER STUFF] version-number
In your .tex files in the appropriate place (in the header / footer, header block, in the PDF file, etc.) you should indicate the version number stored in VERSION.tex:
\input{VERSION}
When you set this value, you must bzr ignore VERSION.tex so that it does not keep its version number, of course.
All of this is based on a similar technique used for git in the General Lisp Short Link project .
source share