Print compiled Clojure svn revision?
Is there a way to make Clojure print the svn revision it was compiled from? A standard or idiomatic way to do this (print clojure--svn-rev) would help when trying to isolate whether observed behaviour is happening on old or current code. It is possible to have newer code checked out but still be using an old compiled clojure.jar. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Fri, Nov 7, 2008 at 11:46 AM, vdm <[EMAIL PROTECTED]> wrote: > > Is there a way to make Clojure print the svn revision it was compiled > from? A standard or idiomatic way to do this (print clojure--svn-rev) > would help when trying to isolate whether observed behaviour is > happening on old or current code. Hi, as far as I know, no. But I agree it would be great to have, and is certainly possible to do. If Rich would be willing to add this to boot.clj, (defn clojure-svn-revision [] (if-let rev (re-find #"Rev: (\d+) \$" "$Rev$") (second rev) "unknown")) and then do this, svn propset svn:keywords "Revision" boot.clj svn commit boot.clj ...then (clojure-svn-revision) ought to return the revision number as a string. Best, Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Nov 7, 1:02 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: > On Fri, Nov 7, 2008 at 11:46 AM, vdm <[EMAIL PROTECTED]> wrote: > > > Is there a way to make Clojure print the svn revision it was compiled > > from? A standard or idiomatic way to do this (print clojure--svn-rev) > > would help when trying to isolate whether observed behaviour is > > happening on old or current code. > > Hi, as far as I know, no. But I agree it would be great to have, and > is certainly possible to do. > > If Rich would be willing to add this to boot.clj, > > (defn clojure-svn-revision [] > (if-let rev (re-find #"Rev: (\d+) \$" "$Rev$") > (second rev) > "unknown")) > > and then do this, > > svn propset svn:keywords "Revision" boot.clj > svn commit boot.clj > > ...then (clojure-svn-revision) ought to return the revision number as > a string. > This works by making $Rev$ magic in some way? Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Fri, Nov 7, 2008 at 1:15 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > On Nov 7, 1:02 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: >> On Fri, Nov 7, 2008 at 11:46 AM, vdm <[EMAIL PROTECTED]> wrote: >> >> > Is there a way to make Clojure print the svn revision it was compiled >> > from? A standard or idiomatic way to do this (print clojure--svn-rev) >> > would help when trying to isolate whether observed behaviour is >> > happening on old or current code. >> >> Hi, as far as I know, no. But I agree it would be great to have, and >> is certainly possible to do. >> >> If Rich would be willing to add this to boot.clj, >> >> (defn clojure-svn-revision [] >> (if-let rev (re-find #"Rev: (\d+) \$" "$Rev$") >> (second rev) >> "unknown")) >> >> and then do this, >> >> svn propset svn:keywords "Revision" boot.clj >> svn commit boot.clj >> >> ...then (clojure-svn-revision) ought to return the revision number as >> a string. >> > > This works by making $Rev$ magic in some way? Yes, exactly. See http://svnbook.red-bean.com/en/1.1/ch07s02.html in the "keywords" section. Best, Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Fri, Nov 7, 2008 at 1:02 PM, Graham Fawcett <[EMAIL PROTECTED]> wrote: > > If Rich would be willing to add this to boot.clj, [snip] > > ...then (clojure-svn-revision) ought to return the revision number as > a string. I'd really like to see something like this too, but unfortunately I don't think it's this simple. Please correct me if I'm wrong, but any changes to the Clojure sources that don't include a change to boot.clj will fail to update this revision number. If that's the case, the number reported could be misleading, and I'd argue would be worse than no number at all. I think the "right" way to do this would be for the Clojure compile process to include a call out to "svn info" to get the revision number of the whole tree, and then somehow include the results of that back in the .jar file for some Clojure function to read. ...but I don't really know enough about ant (or svn either, for that matter) to do this myself. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
As a matter of style, I would rather see this functionality in a global var than in a function. I think that's it's a more idiomatic place for it. user=> *version* "r1088" On Nov 7, 1:18 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: > On Fri, Nov 7, 2008 at 1:15 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > On Nov 7, 1:02 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: > >> On Fri, Nov 7, 2008 at 11:46 AM, vdm <[EMAIL PROTECTED]> wrote: > > >> > Is there a way to make Clojure print the svn revision it was compiled > >> > from? A standard or idiomatic way to do this (print clojure--svn-rev) > >> > would help when trying to isolate whether observed behaviour is > >> > happening on old or current code. > > >> Hi, as far as I know, no. But I agree it would be great to have, and > >> is certainly possible to do. > > >> If Rich would be willing to add this to boot.clj, > > >> (defn clojure-svn-revision [] > >> (if-let rev (re-find #"Rev: (\d+) \$" "$Rev$") > >> (second rev) > >> "unknown")) > > >> and then do this, > > >> svn propset svn:keywords "Revision" boot.clj > >> svn commit boot.clj > > >> ...then (clojure-svn-revision) ought to return the revision number as > >> a string. > > > This works by making $Rev$ magic in some way? > > Yes, exactly. Seehttp://svnbook.red-bean.com/en/1.1/ch07s02.html > in the "keywords" section. > > Best, > Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Fri, Nov 7, 2008 at 1:48 PM, Chouser <[EMAIL PROTECTED]> wrote: > > On Fri, Nov 7, 2008 at 1:02 PM, Graham Fawcett <[EMAIL PROTECTED]> wrote: >> >> If Rich would be willing to add this to boot.clj, > [snip] >> >> ...then (clojure-svn-revision) ought to return the revision number as >> a string. > > I'd really like to see something like this too, but unfortunately I > don't think it's this simple. > > Please correct me if I'm wrong, but any changes to the Clojure sources > that don't include a change to boot.clj will fail to update this > revision number. If that's the case, the number reported could be > misleading, and I'd argue would be worse than no number at all. Oh, excellent point. > I think the "right" way to do this would be for the Clojure compile > process to include a call out to "svn info" to get the revision number > of the whole tree, and then somehow include the results of that back > in the .jar file for some Clojure function to read. ...but I don't > really know enough about ant (or svn either, for that matter) to do > this myself. I suspect there is a better way than that -- we shouldn't really depend upon the client to have 'svn' installed at build-time, though it would often be the case. Subversion supports 'hook scripts' that are run server-side during a commit process. I'm sure someone else has written such a script to update a version-file (e.g. version.clj, containing a *version* def) that is touched any time a revision is made. Let me see what I can find. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
I'm just finishing up an addition to the build script that executes "svnversion" and stores the result in a "versioninfo" file that would be placed in the clojure.jar file and the value stored in a *version* var in boot.clj. If someone is building from source, I think we can assume they have development tools. -Matt On Nov 7, 2008, at 2:20 PM, Graham Fawcett wrote: > > On Fri, Nov 7, 2008 at 1:48 PM, Chouser <[EMAIL PROTECTED]> wrote: >> >> On Fri, Nov 7, 2008 at 1:02 PM, Graham Fawcett <[EMAIL PROTECTED] >> > wrote: >>> >>> If Rich would be willing to add this to boot.clj, >> [snip] >>> >>> ...then (clojure-svn-revision) ought to return the revision number >>> as >>> a string. >> >> I'd really like to see something like this too, but unfortunately I >> don't think it's this simple. >> >> Please correct me if I'm wrong, but any changes to the Clojure >> sources >> that don't include a change to boot.clj will fail to update this >> revision number. If that's the case, the number reported could be >> misleading, and I'd argue would be worse than no number at all. > > Oh, excellent point. > >> I think the "right" way to do this would be for the Clojure compile >> process to include a call out to "svn info" to get the revision >> number >> of the whole tree, and then somehow include the results of that back >> in the .jar file for some Clojure function to read. ...but I don't >> really know enough about ant (or svn either, for that matter) to do >> this myself. > > I suspect there is a better way than that -- we shouldn't really > depend upon the client to have 'svn' installed at build-time, though > it would often be the case. > > Subversion supports 'hook scripts' that are run server-side during a > commit process. I'm sure someone else has written such a script to > update a version-file (e.g. version.clj, containing a *version* def) > that is touched any time a revision is made. > > Let me see what I can find. > > Graham > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
This wouldn't work if someone is using a mirror of the repository using a different SCM. For instance, there's a mirror on github. On Fri, Nov 7, 2008 at 2:23 PM, Matt Revelle <[EMAIL PROTECTED]> wrote: > > I'm just finishing up an addition to the build script that executes > "svnversion" and stores the result in a "versioninfo" file that would > be placed in the clojure.jar file and the value stored in a *version* > var in boot.clj. > > If someone is building from source, I think we can assume they have > development tools. > > -Matt > > On Nov 7, 2008, at 2:20 PM, Graham Fawcett wrote: > >> >> On Fri, Nov 7, 2008 at 1:48 PM, Chouser <[EMAIL PROTECTED]> wrote: >>> >>> On Fri, Nov 7, 2008 at 1:02 PM, Graham Fawcett <[EMAIL PROTECTED] >>> > wrote: If Rich would be willing to add this to boot.clj, >>> [snip] ...then (clojure-svn-revision) ought to return the revision number as a string. >>> >>> I'd really like to see something like this too, but unfortunately I >>> don't think it's this simple. >>> >>> Please correct me if I'm wrong, but any changes to the Clojure >>> sources >>> that don't include a change to boot.clj will fail to update this >>> revision number. If that's the case, the number reported could be >>> misleading, and I'd argue would be worse than no number at all. >> >> Oh, excellent point. >> >>> I think the "right" way to do this would be for the Clojure compile >>> process to include a call out to "svn info" to get the revision >>> number >>> of the whole tree, and then somehow include the results of that back >>> in the .jar file for some Clojure function to read. ...but I don't >>> really know enough about ant (or svn either, for that matter) to do >>> this myself. >> >> I suspect there is a better way than that -- we shouldn't really >> depend upon the client to have 'svn' installed at build-time, though >> it would often be the case. >> >> Subversion supports 'hook scripts' that are run server-side during a >> commit process. I'm sure someone else has written such a script to >> update a version-file (e.g. version.clj, containing a *version* def) >> that is touched any time a revision is made. >> >> Let me see what I can find. >> >> Graham >> >> > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Nov 7, 2008, at 2:25 PM, Daniel Renfer wrote: > > This wouldn't work if someone is using a mirror of the repository > using a different SCM. > > For instance, there's a mirror on github. True, if supporting other SCMs is important we can make the "version" task in the build file smart enough to determine which, if any, should be used for requesting the version. The other option is to add a commit hook that will update the contents of some file with the current revision. The latter option is starting to sound better. > > > On Fri, Nov 7, 2008 at 2:23 PM, Matt Revelle <[EMAIL PROTECTED]> > wrote: >> >> I'm just finishing up an addition to the build script that executes >> "svnversion" and stores the result in a "versioninfo" file that would >> be placed in the clojure.jar file and the value stored in a *version* >> var in boot.clj. >> >> If someone is building from source, I think we can assume they have >> development tools. >> >> -Matt >> >> On Nov 7, 2008, at 2:20 PM, Graham Fawcett wrote: >> >>> >>> On Fri, Nov 7, 2008 at 1:48 PM, Chouser <[EMAIL PROTECTED]> wrote: On Fri, Nov 7, 2008 at 1:02 PM, Graham Fawcett <[EMAIL PROTECTED] > wrote: > > If Rich would be willing to add this to boot.clj, [snip] > > ...then (clojure-svn-revision) ought to return the revision number > as > a string. I'd really like to see something like this too, but unfortunately I don't think it's this simple. Please correct me if I'm wrong, but any changes to the Clojure sources that don't include a change to boot.clj will fail to update this revision number. If that's the case, the number reported could be misleading, and I'd argue would be worse than no number at all. >>> >>> Oh, excellent point. >>> I think the "right" way to do this would be for the Clojure compile process to include a call out to "svn info" to get the revision number of the whole tree, and then somehow include the results of that back in the .jar file for some Clojure function to read. ...but I don't really know enough about ant (or svn either, for that matter) to do this myself. >>> >>> I suspect there is a better way than that -- we shouldn't really >>> depend upon the client to have 'svn' installed at build-time, though >>> it would often be the case. >>> >>> Subversion supports 'hook scripts' that are run server-side during a >>> commit process. I'm sure someone else has written such a script to >>> update a version-file (e.g. version.clj, containing a *version* def) >>> that is touched any time a revision is made. >>> >>> Let me see what I can find. >>> >>> Graham >>> >> >> >>> >> > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
Haven't we been through this before? http://groups.google.com/group/clojure/browse_thread/thread/1ae7eae292765d40/f49c4ccdaca67a23 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Fri, Nov 7, 2008 at 2:25 PM, Daniel Renfer <[EMAIL PROTECTED]> wrote: > > This wouldn't work if someone is using a mirror of the repository > using a different SCM. No, but it would still include the upstream SVN revision number. Alas, what I thought was possible with SVN hooks appears to be impossible -- while in an SVN commit transaction, the SVN server cannot say "and also touch this file over here" if that file was not part of the commited patch. It seems the best alternative is to let Ant try to get the SVN revision and push in the change, as Chouser suggested. Best, Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
I'm in a rush and need to clean this up, but here's something that works: Index: build.xml === --- build.xml (revision 1088) +++ build.xml (working copy) @@ -11,6 +11,7 @@ + @@ -22,10 +23,18 @@ - + + + + + + + Index: src/clj/clojure/boot.clj === --- src/clj/clojure/boot.clj(revision 1088) +++ src/clj/clojure/boot.clj(working copy) @@ -3674,3 +3674,4 @@ "defs the supplied var names with no bindings, useful for making forward declarations." [& names] `(do ~@(map #(list 'def %) names))) +(def *version* (. (java.io.BufferedReader. (java.io.InputStreamReader. (ClassLoader/getSystemResourceAsStream "versioninfo"))) readLine)) user> *version* "1088M" The build.xml script now runs a version task that creates a "versioninfo" file. That file is added to clojure.jar and read in boot.clj where the value is stored in *version*. -Matt On Nov 7, 2008, at 2:41 PM, Mike Hinchey wrote: > > Haven't we been through this before? > http://groups.google.com/group/clojure/browse_thread/thread/1ae7eae292765d40/f49c4ccdaca67a23 > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
If marking SVN revisions and/or release versions is something we still want and want automated, it now looks like using the build tool is the only way to go. The example I sent earlier to the list includes the creation of a "versioninfo" file from the build script which is then read and stored in a "version" var in boot.clj. The only problem is that the build script now depends on the "svnversion" command being available and a SVN repository being used for building. For tarball releases of the source, the "versioninfo" file can be generated for the release and the build script modified to use the existing file if "svnversion" isn't working. As for supporting git and other SCMs used to mirror the SVN repos, the build script can be made to use the tools available in any of the other SCMs to identify the SVN revision and generate the "versioninfo" file. Or have we decided this isn't worth it? -Matt On Nov 7, 2008, at 2:41 PM, Mike Hinchey wrote: > > Haven't we been through this before? > http://groups.google.com/group/clojure/browse_thread/thread/1ae7eae292765d40/f49c4ccdaca67a23 > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
On Sat, Nov 8, 2008 at 12:03 PM, Matt Revelle <[EMAIL PROTECTED]> wrote: > > If marking SVN revisions and/or release versions is something we still > want and want automated, it now looks like using the build tool is the > only way to go. The example I sent earlier to the list includes the > creation of a "versioninfo" file from the build script which is then > read and stored in a "version" var in boot.clj. > > The only problem is that the build script now depends on the > "svnversion" command being available and a SVN repository being used > for building. For tarball releases of the source, the "versioninfo" > file can be generated for the release and the build script modified to > use the existing file if "svnversion" isn't working. As for > supporting git and other SCMs used to mirror the SVN repos, the build > script can be made to use the tools available in any of the other SCMs > to identify the SVN revision and generate the "versioninfo" file. +1. I think it's worth it, and would really like to see this put in place. Best, Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Print compiled Clojure svn revision?
Ok, will submit a patch for this early next week. Current plan is to use a properties file (versioninfo.properties) that will be generated from the ant build script and contain the release version/name, the source repository, a revision indicator (number, tag, or digest), and who built it. All the properties may be defined on the command line when running "ant jar". If the properties are not defined, the ant updated build script will try to determine them. The versioninfo.properties file will be included in the jar and loaded by core.clj. Two considerations: * Should we store the properties as a Clojure map instead of as a Java properties file? * Should we generalize "versioninfo.properties" to "clojure.properties" with a "version" prefix? E.g., "version.release- name". -Matt On Nov 14, 2008, at 11:43 AM, "Graham Fawcett" <[EMAIL PROTECTED]> wrote: > > On Sat, Nov 8, 2008 at 12:03 PM, Matt Revelle <[EMAIL PROTECTED]> > wrote: >> >> If marking SVN revisions and/or release versions is something we >> still >> want and want automated, it now looks like using the build tool is >> the >> only way to go. The example I sent earlier to the list includes the >> creation of a "versioninfo" file from the build script which is then >> read and stored in a "version" var in boot.clj. >> >> The only problem is that the build script now depends on the >> "svnversion" command being available and a SVN repository being used >> for building. For tarball releases of the source, the "versioninfo" >> file can be generated for the release and the build script modified >> to >> use the existing file if "svnversion" isn't working. As for >> supporting git and other SCMs used to mirror the SVN repos, the build >> script can be made to use the tools available in any of the other >> SCMs >> to identify the SVN revision and generate the "versioninfo" file. > > +1. I think it's worth it, and would really like to see this put in > place. > > Best, > Graham > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---