I just got Mercurial Distributed SCM (version 4.2.3+1605-fa3aa6c98bb7) but 4.3.1 should really be the tag that was picked (I think I should get something like 4.3.1+53!) I'm not sure what the problem is, but there's definitely something rotten here.
This is because the tagged revisions (at 4.2.3 and 4.3.1) have exactly the same commit date. We could adjust the strategy to take the tag of the shortest distance (or the tipmost revision), but that wouldn't always work. $ hg glog -T '{node|short} {latesttag}+{latesttagdistance}\n' \ -r '4.2.3: & (merge() + parents(merge()) + tag())' o 02a745c20121 4.2.3+5 |\ | o 86aca74a063b 4.2.3+4 | |\ | | o e6d8ee3c9ec3 4.3-rc+109 | | | | | ~ o | a3ce07e2dde5 4.3.1+2 : | o | 3fee7f7d2da0 4.3.1+0 |/ o 98e990bb7330 4.2.3+3 |\ | ~ o 506d7e48fbe6 4.2.3+2 : o 943c91326b23 4.2.3+0 | ~
I'm tired and haven't thought much about it, but this seems to produce better results in the case Augie reported and it's much faster too (even though it may not look like it). I'll leave this for now. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -210,8 +210,13 @@ def getlatesttags(repo, ctx, cache, patt try: # The tuples are laid out so the right one can be found by # comparison. - pdate, pdist, ptag = max( - latesttags[p.rev()] for p in ctx.parents()) + if len(ctx.parents()) == 1: + pctx = ctx.parents()[0] + else: + anc = ctx.parents()[0].ancestor(ctx.parents()[1]) + key = lambda pctx: repo.set('%n::%n', anc, pctx) + pctx = max(ctx.parents(), key=key) + pdate, pdist, ptag = latesttags[pctx.rev()] except KeyError: # Cache miss - recurse todo.append(rev)
Wow, that patch just accidentally worked in my repo. What I meant was more like the following. I'm still not sure if it's a good idea: --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -210,8 +210,13 @@ try: # The tuples are laid out so the right one can be found by # comparison. - pdate, pdist, ptag = max( - latesttags[p.rev()] for p in ctx.parents()) + if len(ctx.parents()) == 1: + pctx = ctx.parents()[0] + else: + anc = ctx.parents()[0].ancestor(ctx.parents()[1]) + key = lambda pctx: len(repo.revs('%d::%d', anc.rev(), pctx.rev())) + pctx = max(ctx.parents(), key=key) + pdate, pdist, ptag = latesttags[pctx.rev()] except KeyError: # Cache miss - recurse todo.append(rev)
Fixed in commit fb672eac2702
Fixed by https://mercurial-scm.org/repo/hg/rev/ff1222a7d714 Yuya Nishihara <yuya@tcha.org> test-template-keywords: add test for {latesttag} of wdir() revision It's probably broken since fb672eac2702, "templatekw: choose {latesttag} by len(changes), not date (issue5659)". only() doesn't support wdir. (please test the fix)
Bug was set to TESTING for 7 days, resolving