On Thu, Aug 11, 2011 at 6:16 PM, Andy Levy <andy.l...@gmail.com> wrote:
> On Thu, Aug 11, 2011 at 12:13, Andy Levy <andy.l...@gmail.com> wrote:
>> On Thu, Aug 11, 2011 at 12:02, Giulio Troccoli
>> <giulio.trocc...@mediatelgroup.co.uk> wrote:
>>>
>>>
>>> On 11/08/11 16:59, Michael Hüttermann wrote:
>>>>
>>>> Hello,
>>>>
>>>> given a Subversion tag, what's the best way to get the revision number of
>>>> that tag, i.e. the revision number with which the tag was created? Is it
>>>> possible at all having checked out the tag to a local working copy? Or is
>>>> there any other way to cross-reference a "tag" to a revision number?
>>>>
>>>>
>>>> Thanks.
>>>>
>>>>
>>>> Michael
>>>>
>>>
>>> I think svn log --limit 1 would work. It will give you the last log when the
>>> tag was modified. Since a tag should never be modified that log should refer
>>> to the copy
>>
>> That or svn log --stop-on-copy.
>>
>> If you use svn log -v --stop-on-copy, the list of changed paths (the
>> copy destination) will be given, in addition to the source path and
>> its revision. Parse that out and you're set. You'll have both the
>> revision which created the tag and the latest revision of the path the
>> tag came from.
>>
>
> I hit Send too early.
>
> If no one has modified the tag, --limit 1 would yield the same results
> as --stop-on-copy. But if someone *has* modified the tag (which we
> agree shouldn't happen, but depending on your setup, it could - that's
> a whole other matter), that modification will appear instead of the
> copy which created the tag. If you use --stop-on-copy, you can detect
> this condition and the oldest log will end up being the creation of
> the tag.

I think the best/easiest way is:

    svn log -r 1:HEAD --limit 1 --stop-on-copy $URL_TO_TAG

(then parse the revision number out of that)

The '-r 1:HEAD' reverses the order of log to return the entries from
oldest to newest. Combining this with --stop-on-copy and --limit 1
gives you exactly the oldest log entry on that tag (which is the copy
operation itself), whether or not it had changes after creation.

This also works for branches (giving you the creation revision of the branch).

-- 
Johan

Reply via email to