revsets and tags question
Harvey Chapman
hchapman-hg at 3gfp.com
Thu Nov 7 00:02:48 UTC 2013
On Nov 6, 2013, at 6:16 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
>
> On 6 nov. 2013, at 23:56, Harvey Chapman wrote:
>
>> Is there a better way than the following for finding the most recent tag (fitting a pattern) that is an ancestor of the currently checked out revision?
>>
>> So, we’re looking for the most recent “tag_*” that the current working copy is a descendent of.
>>
>> hg log --template '{tags}\n' -r 'last(ancestors(.) and tag("re:tag_.+"))’
>>
>> So, after “hg update 9”, I should get “tag_6” and similarly I should get “tag_5” after updating to rev 8.
>
> Are you aware of --template '{latesttag}'
> (and probably its friend, latesttagdistance)
I tried to use those, but they only work if the latest tag matches the pattern.
> This does not fit your "fitting a pattern" contract. You revset is probably the best you can do for that. Its short form is 'max(::. and tag("re:^tag_"))’.
Thanks, this is exactly the type of answer I was looking for. I avoided the ::. syntax because I misread the help, and thanks for the ‘^’ reminder.
My last challenge is to be able to detect if the set Tagged_rev::. consists solely of tags (i.e. only changes to .hgtags) excluding the Tagged_Rev itself. I came up with this:
hg log --template '{rev}: {tags}: {files}\n' -r 'Tagged_rev::. and !Tagged_rev and file("set:!.hgtags”)'
Thanks for the help,
Harvey
More information about the Mercurial
mailing list