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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
harris
  • 1,473
  • 1
  • 17
  • 26
  • 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? – Lasse V. Karlsen Jul 25 '13 at 14:34

2 Answers2

26

Latest tag in ancestors, using log and templating

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

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
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.

Reimer Behrends
  • 8,600
  • 15
  • 19