问题
If I invoke hg tag test then hg id -r test returns the changeset that the tag points to, but the tag was actually added by the subsequent commit.
How do I look up the changeset that actually added a tag (as opposed to the changeset that the tag points to)?
Is it safe to assume that it will always be the child of hg id -r <tag>?
回答1:
Assuming that a tagged changeset only has one child (the one that adds the tag) then the following commands will get the changeset that adds the tag:
// Get the changeset that the tag points to
def referenced = $(hg id -q -r ${tag})
// Get the changeset that added the tag
def addedTag = $(hg log -r children(${referenced}) --template {node})
来源:https://stackoverflow.com/questions/41156538/how-do-i-find-out-which-changeset-added-a-tag