1. Augie Fackler
  2. hg-git
  3. Issues
Issue #40 resolved

hg-git wrapped git tags break --template

Steven Noonan
created an issue

This is with a cloned repository (natively a git repo). The tags seem to be discovered just fine:

{{{ snoonan@mjollnir ~/cpuid $ hg tags tip 244:bb62c44391af default/master 244:bb62c44391af 1.2.1 239:8b5f362f9205 1.2.0 234:273b31b20fe2 1.1.9 222:be3b4277a620 1.1.8 207:7475b8e280b9 1.1.7 190:18df9a0cbb9f 1.1.6 187:970b7438f6a7 1.1.5 184:11fc430c5d0f 1.1.4 179:f53ac3b80a61 1.1.3 175:6acc5e7f7cc8 1.1.2 166:24a84019019a 1.1.1 157:a3837f4f59f1 1.1.0 153:e43c780412b8 1.0.0 114:24882404b1a3 0.9.3 73:a81c18ed7f94 0.9.2 65:5645c0fbfb6d 0.9.1 35:9856ac014064 0.9.0 27:6ffa90ebf31f }}}

But 'parents --template' doesn't find the tags: {{{ snoonan@mjollnir ~/cpuid $ grep -A1 alias ~/.hgrc [alias] describe = parents --template '{latesttag}+{latesttagdistance}-{node|short}\n' snoonan@mjollnir ~/cpuid $ hg describe null+245-bb62c44391af }}}

Looking at the Mercurial sources, it seems that they build the 'latesttag' list by including only tags of type 'global'. So the hg-git custom tag type 'git' isn't included in the list. I can't find any rhyme or reason to //why// they're given a custom tag type though, since nothing seems to to treat 'git' tags specially. I suppose it's possible that 'global' tags are treated in an undesirable way, but I'm really not familiar with Mercurial's internals enough to know.

Doing this seems to fix the issue, by marking git tags as 'global' tags: {{{ diff -r dfb2b7b5d586 hggit/hgrepo.py --- a/hggit/hgrepo.py Sat May 12 03:33:19 2012 -0500 +++ b/hggit/hgrepo.py Mon May 14 21:08:09 2012 -0700 @@ -43,7 +43,7 @@ git = GitHandler(self, self.ui) for tag, rev in git.tags.iteritems(): tags[tag] = bin(rev) - tagtypes[tag] = 'git' + tagtypes[tag] = 'global'

         return (tags, tagtypes)

@@ -74,7 +74,7 @@ tagscache[tag] = bin(rev) if hasattr(self, '_tagstypecache'): # Only present in Mercurial 1.3 and earlier. - self._tagstypecache[tag] = 'git' + self._tagstypecache[tag] = 'global'

         return tagscache

}}} As expected, this works correctly: {{{ snoonan@mjollnir ~/cpuid $ hg describe 1.2.1+5-bb62c44391af }}} Is there a particular reason for tag type 'git', and is there a better fix for this issue?

Comments (3)

  1. Augie Fackler repo owner

    (Reply via r...@durin42.com):

    No good reason for "git" type tags, "global" feels right. Can you commit your fix and email it to hg-git@googlegroups.com? That's how I prefer to review things.

  2. Steven Noonan reporter

    Hm. I somehow missed your response, sorry about that.

    I committed the message locally but am generally unfamiliar with Mercurial (I use git mainly). Is there an equivalent to 'git format-patch' so I can send you a commit? Or rather, how can I generate the desired format?

  3. Log in to comment