Re: [NTG-context] Module for svn info

Hi Markus, If your sources are in svn, then they actually have the same svn- number, after a commit. But the numbers in the $Revision$ or $Id$ tags of your working copies are not updated by svn commit. However, if you do an "svn update" after the commit, it should update the numbers. So, you shouldn't need to work out the maximum value. Here, we actually use the output of the "svnversion" command, save it automatically it in a file, and include it in the document. This way, the version number indicates if the document came from checked-in sources, modified sources, or mixed revisions. We don't have a module to do it, just a svnversion > svnversion.tex ; texexec document.tex in the Makefile, and on the document front page somewhere \doiffileelse{svnversion.tex}{ Subversion revision \ignorespaces \input svnversion\relax \removeunwantedspaces . \crlf }{} Cheers, Robin

The svn keyword Revision or Rev or LastChangedRevision (they are all the same) are defined as the last revision where the file changed (see subversion book chapter 3 section keyword substitution). It seems to me that subversion does not have a global keyword that would give you the last revision number. But they do provide svnversion to get that number automatically (see subversion book highlighted box named "Where's $GlobalRev$?"). So Robin's solution below seems to be the best way to get the global version number.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Ernesto, hi Robin, thanks for your replies. The thing I like most with your solution is that svnversion provides a modify flag, so I can see whether all changes have been cheched in. Great. A little drawback is that all files under the current path are used to determine the version. If theres a file in the path which is not part of the document changes to this file will also change the revision of the document. But I think this can be easily prevented by placing every document into an own directory. What do you think of using: \def\SVNVERSION{svnversion -n > svnversion.tex} \ifeof18 \installprogram{\SVNVERSION}% \else \executesystemcommand{\SVNVERSION}% \fi Kind regards, Markus Ernesto Schirmacher schrieb:
This is not true. The complete name of $Rev§$ is $LastChangedRevision$. It's the revision of the last change to this file.
iD8DBQFHldA9dnooMonJSYkRAggwAJ9pNN8yoJR5rIvdahf4eJo0sTp5kQCfUqOR EVoOQluHh+9LhNRKTJDIFo8= =il3n -----END PGP SIGNATURE-----

On Tue, 22 Jan 2008, Markus Bernhardt wrote:
Looks ok to me. Coming back to calculating the maximum of versions, this is possible to do inside TeX. Here is a short proof of concept. We need a two pass mechanism since revisions could be defined after they need to be used. \unprotect \def\REVISION#1 {\doifdefinedelse{!!REVISION} {\ifdim#1pt > \dimexpr1pt*\!!REVISION \edef\!!REVISION{#1} \fi} {\edef\!!REVISION{#1}}} \definetwopasslist{REVISION} % Execute this in the beginning of document \def\initializeREVISION {\gettwopassdata{REVISION} \iftwopassdatafound \xdef\getREVISION{\twopassdata} \else \def\getREVISION{Not Found} \fi \global\let\initializeREVISION\relax} % Execute this at the end of document \def\saveREVISION {\savetwopassdata {REVISION} {\getREVISION} {\!!REVISION}} \appendtoks \initializeREVISION \to \everystarttext \appendtoks \saveREVISION \to \everystoptext \protect \starttext File 1:\REVISION{10} \getREVISION File 2:\REVISION{4} \getREVISION File 3:\REVISION{14} \getREVISION \stoptext Now this just needs to be plugged into the command to get revision information from svn tags. Aditya
participants (4)
-
Aditya Mahajan
-
Ernesto Schirmacher
-
Markus Bernhardt
-
Robin Kirkham