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

Re: Why does `svnversion -c` give me a range?

From: Ryan Schmidt <subversion-2012c_at_ryandesign.com>
Date: Wed, 4 Dec 2013 10:06:02 -0600

Remember to Reply All so the discussion stays on the mailing list.

On Dec 4, 2013, at 07:52, Cooke, Mark wrote:

>> -----Original Message-----
>> From: Ryan Schmidt [mailto:subversion-2012c_at_ryandesign.com]
>> Sent: 04 December 2013 12:15
>>
>> On Dec 4, 2013, at 06:00, Cooke, Mark wrote:
>>
>>> I would like to include the svn revision number in my
>>> project's version info but I am confused by the results of
>>> svnversion. I want the version number of a tagged tree to
>>> always be the same (i.e. the last commit to the tag) but if
>>> the tag is to be rebuilt using a fresh checkout some time
>>> later `svnversion` seems to report the HEAD revision. So I
>>> looked at `svnversion -c` but this always seems to give me a
>>> range e.g. `2:1476`, even directly after an update.
>>>
>>> I have read the red book but it is quite vague about the -c
>>> option. Why is `-c` always giving me a range?
>>
>> I think the `-c` option means: given all the item in this
>> directory and recursive subdirectories, give the oldest and
>> newest changed file. So, the oldest item in your working copy
>> was last changed in revision 2, and the newest was last
>> changed in revision 1476.
>
> You seem to be right but that is not what I understand from the docs. The only reference to the -c option says "Use the last-changed revisions rather than the current (i.e., highest locally available) revisions." which to me means that I should get the similar results as I would expect without using -c. In other words, a fully updated, unmodified WC should give a single revision number and I would expect -c to also give a single revision number (at least that is what I think I want) but it does not:
>
> D:\PROJECT>svn update
> Updating '.':
> At revision 1770.
>
> D:\PROJECT>svnversion .
> 1770M
>
> D:\PROJECT>svnversion . -c
> 2:1764M
>
> ...I tried the same on a fresh checkout of one of our tags and got similar results (without the `M` flag). The book could do with some clarification but I am not certain yet what the definitive answer actually is.

Based on my testing, the `-c` flag “use[s] the last-changed revisions” (of each item) “rather than the current (i.e., highest locally available) revisions” (of each item), as it says.

>>> And `svnversion` without any flag does seem to give the
>>> latest revision to which the working copy was updated, not
>>> the last changed revision.
>>
>> If you want the last changed revision, you could use:
>>
>> svn info | sed -n 's/^Last Changed Rev: //p'
>
> We are not allowed to install unapproved apps <insert sad face here> and sed is not available here (obviously there are similar ways to achieve this but I was hoping to avoid complicating things any more than I have to).
>
> The `Last Changed Date` would also be useful so I guess I'll have to go a scripted svn info route. Oh, hang on, doesn't `svn info` need to be called recursively whereas `svnversion` doesn't?
>
> Thanks for your help,
>
> ~ mark c

`svnversion` recursively scans the working copy. `svn info` operates on the current directory only.
Received on 2013-12-04 17:06:44 CET

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

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