You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Scott Lawrence <sl...@pingtel.com> on 2004/05/07 18:15:30 UTC
[PATCH] FAQ: getting the working copy revision into the source
Appended below is a FAQ for the question "How do I get the revision
number into my source?"
--
Scott Lawrence
Consulting Engineer
Pingtel Corp.
sip:slawrence@pingtel.com
+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>
<p>
<strong>Troubleshooting:</strong>
</p>
@@ -1119,7 +1121,42 @@
<![CDATA[=========================================================]]>
+<h3><a name="version-value-in-source">How do get the revision number
+so I can use it in my source?</a></h3>
+
<p>
+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).
+</p>
+
+<p>
+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
+<tt>Makefile</tt>:
+
+<pre>
+
+##
+## 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
+
+</pre>
+
+<p>
+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.
+</p>
+
+<![CDATA[=========================================================]]>
+
+<p>
<hr>
<p>
<h2>Troubleshooting:</h2>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] FAQ: getting the working copy revision into the source
Posted by John Peacock <jp...@rowman.com>.
Scott Lawrence wrote:
> Appended below is a FAQ for the question "How do I get the revision
> number into my source?"
>
>
As well as what Sussman said, it might be nice to give several ways to get the
revision number, for example, this one:
http://www.contactor.se/~dast/svnusers/archive-2004-03/2168.shtml
(which could definitely be adapted to be part of a Makefile invocation), as well
as the recent discussion on the SVNWCRev.exe utility from the TSVN list. Not
everyone can use Makefile's (or is running a UNIX^H^H^Hnix derivative ;)...
You should probably add something like I had in the above message about 'svn up'
and mixed revision WC's, since that will bite some people more than others.
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5748
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] FAQ: getting the working copy revision into the source
Posted by Michael W Thelen <th...@cs.utah.edu>.
* Scott Lawrence <sl...@pingtel.com> [2004-05-07 15:09]:
> Another pass.
I've filed this patch as issue #1895:
http://subversion.tigris.org/issues/show_bug.cgi?id=1895
-- Mike
--
Michael W. Thelen
It is well to remember that the universe, with one trifling exception, is
composed of others.
-- John Andrew Holmes
Re: [PATCH] FAQ: getting the working copy revision into the source
Posted by Scott Lawrence <sl...@pingtel.com>.
Another pass.
--
Scott Lawrence
Consulting Engineer
Pingtel Corp.
sip:slawrence@pingtel.com
+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,9 @@
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">Why doesn't the $Revision$
+ keyword do what I want? It expands to the file's last-changed revision,
+ but I want something that will expand to the file's current revision.</a></li>
<p>
<strong>Troubleshooting:</strong>
</p>
@@ -1119,7 +1122,60 @@
<![CDATA[=========================================================]]>
+<h3><a name="version-value-in-source">Why doesn't the $Revision$
+keyword do what I want? It expands to the file's last-changed revision,
+but I want something that will expand to the file's current revision.</a></h3>
+
<p>
+Subversion increments the revision number of the repository as a
+whole, so it can't expand any keyword to be that number - it would
+have to search and possibly modify every file in your working copy on
+every commit.
+</p>
+
+<p>
+The information you want (the revision of your working copy) is
+available from the command <tt>svnversion</tt>; it gives you
+information on the revision level of a working copy given a path (see
+<tt>svnversion --help</tt> for details).
+</p>
+
+<p>
+You can incorporate it into your build or release 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
+<tt>Makefile</tt>:
+
+<pre>
+
+##
+## on every build, record the working copy revision string
+##
+svn_version.c: FORCE
+ echo -n 'const char* svn_version(void) { const char* SVN_Version = "' \
+ > svn_version.c
+ svnversion -n . >> svn_version.c
+ echo '"; return SVN_Version; }' >> svn_version.c
+
+</pre>
+
+<p>
+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.
+</p>
+
+<p>
+Windows users may want to use <tt>SubWCRev.exe</tt>, available from
+the <a
+href='http://tortoisesvn.tigris.org/download.html'>TortoiseSVN
+download page</a>; it replaces all <tt>$WCREV$</tt> tags in a given
+file with the current working copy revision.
+</p>
+
+<![CDATA[=========================================================]]>
+
+<p>
<hr>
<p>
<h2>Troubleshooting:</h2>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] FAQ: getting the working copy revision into the source
Posted by Scott Lawrence <sl...@pingtel.com>.
On Fri, 2004-05-07 at 14:27, Ben Collins-Sussman wrote:
> On Fri, 2004-05-07 at 13:15, Scott Lawrence wrote:
> > Appended below is a FAQ for the question "How do I get the revision
> > number into my source?"
> >
>
> Actually, that's not exactly the FAQ...
>
> The FAQ that comes up once a month is: "Why doesn't the $Revision$
> keyword do what I want? It expands to the file's last-changed revision,
> but I want something that will expand to the file's current revision."
>
> Then our standard reply is something like:
>
> 1. A keyword which expands to the working revision is fundamentally
> different than the other keywords; every update would require us to
> hunt down this keyword throughout the whole working copy, even on files
> that weren't updated. A very bad idea.
>
> 2. Use 'svnversion' in your build system instead (which you've
> explained already in your patch).
>
> Scott, can you make another pass at this FAQ patch? :-)
sure... stay tuned.
--
Scott Lawrence
Consulting Engineer
Pingtel Corp.
sip:slawrence@pingtel.com
+1.781.938.5306 x162
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] FAQ: getting the working copy revision into the source
Posted by Ben Collins-Sussman <su...@collab.net>.
On Fri, 2004-05-07 at 13:15, Scott Lawrence wrote:
> Appended below is a FAQ for the question "How do I get the revision
> number into my source?"
>
Actually, that's not exactly the FAQ...
The FAQ that comes up once a month is: "Why doesn't the $Revision$
keyword do what I want? It expands to the file's last-changed revision,
but I want something that will expand to the file's current revision."
Then our standard reply is something like:
1. A keyword which expands to the working revision is fundamentally
different than the other keywords; every update would require us to
hunt down this keyword throughout the whole working copy, even on files
that weren't updated. A very bad idea.
2. Use 'svnversion' in your build system instead (which you've
explained already in your patch).
Scott, can you make another pass at this FAQ patch? :-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org