You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Theo Van Dinter <fe...@kluge.net> on 2004/12/04 17:23:29 UTC

Way to get current revision as keyword...?

I have some code which wants to display the current version of the software,
including the SVN revision that the code comes from.  We currently use:

  push(@EXTRA_VERSION, ( 'r' . qw{$LastChangedRevision: 109718 $ updated by SVN}[1] ));

such that @EXTRA_VERSION gets "r109718" added to it.  However, I'd
really like the version to be the actually revision number of the tree
(r109813), not the revision number for the last time that specific piece of
code was modified.

ie: the keyword would be updated upon checkout, update, export, etc.

There doesn't seem to be a way to do this without a post-co/export/etc script
to mangle that line.  Am I missing something blazingly obvious, or is this
a RFE?

Thanks. :)

-- 
Randomly Generated Tagline:
But let me tell you, the slim lazy Homer you knew is dead.  Now I'm a
 big fat dynamo.
 
 		-- Homer Simpson
 		   King-Size Homer

Re: Way to get current revision as keyword...?

Posted by Max Bowsher <ma...@ukf.net>.
Theo Van Dinter wrote:
> On Sat, Dec 04, 2004 at 05:59:10PM -0000, Max Bowsher wrote:
>> But what about when the entire WC is not at a single revision?
>
> Hrm.  In thinking about the response, I do see where the issues may get
> a bit tricky.
>
> Here's my thinking about this question:
>
> - Checkout revision 100.  Substitute "100" for all files.
> - Changes occur remotely, up to revision 103.
> - Make updates locally and commit, those files get revision 104.
>   Subtitute "104" for all files which were committed.
> - "svn update" to pull in remote changes.  Substitute "104" for all files.
>
>> Or, if you "svn update" only parts of a working copy?
>
> You would only update substitutions where appropriate.  So:
>
> - Checkout revision 100.  Substitute "100" for all files.
> - Changes occur remotely in directories "a", "b", and "c", up to
>   revision 103.
> - "svn update" in directory "a".  Substitute "103" for all files in "a".
>
>> And what about local modifications? svnversion will tell you about them, 
>> but
>> there's no way a keyword could do that.
>
> From what I can tell, keywords aren't updated for local modifications,
> so I don't expect that to change.

As you can see, there are a large amount of edge cases which can be bypassed 
by using the `svnversion` method, rather than a keyword - which is why this 
design was chosed in the first place.

The script/Makefile technique is universally applicable, as far as we know, 
and whilst that is true, it seems counter-productive to spend time writing 
an alternative implementation which is intrinsically less powerful and more 
complicated.

You mentioned a difficulty when exporting - it may be solved as follows:

$ head=`svn log -q -r HEAD $repos_base_url | sed -ne 
's/^r\([0-9]*\).*$/\1/p'`
$ svn export -r $head $my_project_url my-project
$ echo $head > my-project/revision

Or indeed, pipe the output of "svn export" through some filter, and read the 
revision out of its last line.

I suppose an argument can be made that this is not so nice for 
scripting-challenged platforms like Windows.

I think, though, that you will have an easier time gaining support for a 
nicer way for export to communicate what revision it exported, than gaining 
support for a $SvnVersionAlike$ keyword.

Max.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Way to get current revision as keyword...?

Posted by Theo Van Dinter <fe...@kluge.net>.
On Sat, Dec 04, 2004 at 05:59:10PM -0000, Max Bowsher wrote:
> But what about when the entire WC is not at a single revision?

Hrm.  In thinking about the response, I do see where the issues may get
a bit tricky.

Here's my thinking about this question:

- Checkout revision 100.  Substitute "100" for all files.
- Changes occur remotely, up to revision 103.
- Make updates locally and commit, those files get revision 104.
  Subtitute "104" for all files which were committed.
- "svn update" to pull in remote changes.  Substitute "104" for all files.

> Or, if you "svn update" only parts of a working copy?

You would only update substitutions where appropriate.  So:

- Checkout revision 100.  Substitute "100" for all files.
- Changes occur remotely in directories "a", "b", and "c", up to
  revision 103.
- "svn update" in directory "a".  Substitute "103" for all files in "a".

> And what about local modifications? svnversion will tell you about them, but
> there's no way a keyword could do that.

From what I can tell, keywords aren't updated for local modifications,
so I don't expect that to change.

-- 
Randomly Generated Tagline:
Another way to look at it is that screensavers are sort of a poor man's
 LSD, without the bad trips.
              -- Larry Wall, 8th State of the Onion

Re: Way to get current revision as keyword...?

Posted by Max Bowsher <ma...@ukf.net>.
Theo Van Dinter wrote:
> On Sat, Dec 04, 2004 at 05:27:10PM -0000, Max Bowsher wrote:
>> FAQ.
>> http://subversion.tigris.org/project_faq.html#version-value-in-source
>
> Darn it!  I looked at the FAQ after checking the book.  Apparently my
> search skills have become lax when not using Google. ;)
>
> Ok, so now I have some thoughts about the FAQ answer:
>
> "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 update and 
> commit."
>
> Exactly!  That's the point!  It's actually not as bad as the answer lets
> on.  All that needs to happen is a search of file props per operation --
> the actual files don't need to be scanned, and 2/3 of the time it's
> already doing that work anyway.

But what about when the entire WC is not at a single revision?
Like, after every single commit?
Or, if you "svn update" only parts of a working copy?

And what about local modifications? svnversion will tell you about them, but 
there's no way a keyword could do that.

Max.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Way to get current revision as keyword...?

Posted by Theo Van Dinter <fe...@kluge.net>.
On Sat, Dec 04, 2004 at 05:27:10PM -0000, Max Bowsher wrote:
> FAQ.
> http://subversion.tigris.org/project_faq.html#version-value-in-source

Darn it!  I looked at the FAQ after checking the book.  Apparently my
search skills have become lax when not using Google. ;)

Ok, so now I have some thoughts about the FAQ answer:

"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 update and commit."

Exactly!  That's the point!  It's actually not as bad as the answer lets
on.  All that needs to happen is a search of file props per operation --
the actual files don't need to be scanned, and 2/3 of the time it's
already doing that work anyway.

On commit, svn has to check props since there could be changes.
On checkout/export, svn has to do this to handle the current keywords.

So the only place svn needs to do extra work is on update, where it
needs to check all the WC props to see if the keyword needs replacing.
Arguably, updates happen more often than commits and checkouts, so that's
why it's considered to be a bad idea.  However, it would be pretty
trivial to mark the WC base upon commit and checkout if there's a file
underneath which has the property set.  That way if the keyword isn't
enabled anywhere, there's no extra cost to doing an update.

The reason why I'd like to see a keyword version is because the
script/Makefile hack (via FAQ)/etc idea doesn't work in situations such as
"svn export".  The counter would be "do a temp checkout, modify the WC,
export, and rm the temp checkout", but that's a lot of extra steps/work.

-- 
Randomly Generated Tagline:
"Why is there a watermelon there? I'll tell you later." - From Buckaroo Bonzai

Re: Way to get current revision as keyword...?

Posted by Max Bowsher <ma...@ukf.net>.
Theo Van Dinter wrote:
> I have some code which wants to display the current version of the 
> software,
> including the SVN revision that the code comes from.  We currently use:
>
>   push(@EXTRA_VERSION, ( 'r' . qw{$LastChangedRevision: 109718 $ updated 
> by
> SVN}[1] ));
>
> such that @EXTRA_VERSION gets "r109718" added to it.  However, I'd
> really like the version to be the actually revision number of the tree
> (r109813), not the revision number for the last time that specific piece 
> of
> code was modified.
>
> ie: the keyword would be updated upon checkout, update, export, etc.
>
> There doesn't seem to be a way to do this without a post-co/export/etc 
> script
> to mangle that line.  Am I missing something blazingly obvious, or is this
> a RFE?

FAQ.

http://subversion.tigris.org/project_faq.html#version-value-in-source

Max.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org