[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] FAQ: getting the working copy revision into the source

From: Scott Lawrence <slawrence_at_pingtel.com>
Date: 2004-05-07 20:15:30 CEST

Appended below is a FAQ for the question "How do I get the revision
number into my source?"

Scott Lawrence
Consulting Engineer
Pingtel Corp.   
+1.781.938.5306 x162
Index: www/project_faq.html
--- www/project_faq.html	(revision 9648)
+++ www/project_faq.html	(working copy)
@@ -69,6 +69,8 @@
     in the filename.  How do I change it?</a></li>
 <li><a href="#merge-using-tags">I can't use tags to merge changes from a 
     branch into the trunk like I used to with CVS, can I?</a></li>
+<li><a href="#version-value-in-source">How do get the revision number
+    so I can use it in my source?</a></li>
@@ -1119,7 +1121,42 @@
+<h3><a name="version-value-in-source">How do get the revision number
+so I can use it in my source?</a></h3>
+The information you want is available from the command
+<tt>svnversion</tt>; it gives you information on the revision level of
+a working copy (see <tt>svnversion --help</tt> for details).
+You can incorporate it into your build process to get the information
+you need into the source itself.  For example, in a build environment
+based on <tt>make</tt>, add something like this to your
+## on every build, record the working copy revision string
+svn_version.c: FORCE
+        echo 'const char* svn_version(void) { return "' > svn_version.c
+        svnversion -n . >> svn_version.c
+        echo '"; }'   >> svn_version.c
+any executable that links in <tt>svn_version.o</tt> will be able to
+call the function <tt>svn_version()</tt> to get a string that
+describes exactly what revision was built.
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat May 8 01:42:14 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.