How do I know the current tag of Mercurial?
Asked Answered
M

2

17

Now, I am getting vim source code by Mercurial (hg):

root@flyingfisher-virtual-machine:/work/ABC/VIM_HG# hg tags |more
tip                             5228:3f65dc9c8840
v7-4a-039                       5227:a08fa2919f2b
v7-4a-038                       5225:8f983df0299f
v7-4a-037                       5223:91d478da863e
v7-4a-036                       5221:9982ec574beb
v7-4a-035                       5218:4ceacc1b0054
v7-4a-034                       5216:947edb6335d1
v7-4a-033                       5214:fa024ce48542
v7-4a-032                       5212:2741b46e96bf
v7-4a-031                       5210:839ebe7c1b2f

then

root@flyingfisher-virtual-machine:/work/ABC/VIM_HG# hg update v7-4a-018
216 files updated, 0 files merged, 0 files removed, 0 files unresolved

After several hours, how do I know which tag I was worked on?

Is there some Mercurial command tell the current tag information?

Marlysmarmaduke answered 25/7, 2013 at 2:3 Comment(1)
Note that you're not actually "working on a tag". A tag is a fixed position in the history, not something that you work on per se. Perhaps you want bookmarks?Jigger
L
27

Latest tag in ancestors, using log and templating

hg log -r "." --template "{latesttag}\n"

Lagniappe answered 25/7, 2013 at 3:11 Comment(0)
E
23

If you're positive that you're on a tagged revision, just use:

hg id

This will show the revision hash and any tags (and the branch name, if it exists).

If the current revision does not have a tag and you want to find the closest tagged ancestor, you can instead use:

hg id -r 'ancestors(.) and tag()'

or the equivalent, but shorter:

hg id -r '::. and tag()'

Both work by finding the intersection of all ancestors and all tagged revisions.

You can also look at the output of hg log -G to find out where you are (the current node in the revision graph will be marked with an '@' instead of an 'o') and then locate the nearest tag.

Ese answered 25/7, 2013 at 2:43 Comment(4)
revset must be ancestorS(.) and tag() and better, because AND also produce revset (not a single revision) last(ancestors() and tag())Lagniappe
Will fix the ancestors() typo, but the last() should be implicit in hg id.Ese
In my environment, only hg id works. the other two always report error "abort: unknown revision XXX"Marlysmarmaduke
@Marlysmarmaduke - old Mercurial (without revsets)?Lagniappe

© 2022 - 2024 — McMap. All rights reserved.