I’m setting up a Mercurial repository to track third-party code, roughly following the vendor-default branch scheme described in Rudi’s answer to this question. In order to quickly retrieve a particular version, I create tags for each vendor and default version.
I initialize the repo by committing an empty .hgtags to establish the default branch, then I hg branch vendor and import the first version. The process to add a new version looks like this:
hg up -C vendor
... load new version ...
hg commit -A -m "Adding version x.y.x"
hg tag vendor-x.y.z
hg up -C default
hg merge vendor
hg commit -m "Merging version x.y.z"
hg tag x.y.z
During the merge I always keep the local copy of .hgtags, so the result is that the vendor branch has .hgtags containing all the vendor-x.y.z tags while the default branch .hgtags has only the x.y.z tags.
It’s my understanding that Mercurial considers .hgtags from all heads when working with tags. Yet when I run hg tags the result contains only tip and the x.y.z tags. This is the same regardless of which branch my working directory is updated to; it’s always the tags from the default branch .hgtags file.
I can update to the vendor-x.y.z tags, so Mercurial does see their existence, but the update appears to give me code from the vendor branch tip. The x.y.z tags work fine.
I’ve worked mainly with Git and SVN/CVS in the past, so I assume that this is a problem of understanding, not a technical issue. I did try it, just in case, on two versions of Mercurial (2.0.2 and 2.3.2) and got the same results.
I’m not in front of my Mercurial system to verify, but I think the issue is Mercurial only considers .hgtags from topological heads, not branch heads. Example:
[6] is a topological head, [4] and [6] are branch heads. The solution is to keep all changes to .hgtags on a merge.
Edit
Here’s my test. Directly after the merge I accepted the local .hgtags and
hg tagsonly displays the tag ondefault. I can’t update to the vendor tag, which differs from what you are seeing. I’m using Mercurial 2.3.1. After creating another changeset on vendor and making a second topological head, the missing tag reappears.And the output: