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
Hi Aditya,
thanks for your reply. It's a good starting point.
One thing is missing in this solution.
Our documents are structured into several files. Every file has an svn-version. So I want to calculate the max version.
Do you know a small example where a max value is calculated. I would try to integrate it into the other example.
Kind regards, 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.
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.
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 }{}
-----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:
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.
This is not true. The complete name of $Rev§$ is $LastChangedRevision$. It's the revision of the last change to this file.
So, you shouldn't need to work out the maximum value.
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. There can be no useful global last revision number, because it always depends on the used URL.
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.
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 }{}
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHldA9dnooMonJSYkRAggwAJ9pNN8yoJR5rIvdahf4eJo0sTp5kQCfUqOR EVoOQluHh+9LhNRKTJDIFo8= =il3n -----END PGP SIGNATURE-----
On Tue, 22 Jan 2008, Markus Bernhardt wrote:
\def\SVNVERSION{svnversion -n > svnversion.tex}
\ifeof18 \installprogram{\SVNVERSION}% \else \executesystemcommand{\SVNVERSION}% \fi
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