Mercurial > hg
comparison mercurial/templatekw.py @ 41300:66102f6fa10a stable
templatekw: fix crash on multiple latesttags resolution at wdir (issue6055)
It appears not easy to fix only() to support wdir(), so this patch works
around the issue by getlatesttags(). The "+1" after len(changes) doesn't
matter since ctx never changes while sorting. It's just for clarity.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 20 Jan 2019 11:51:21 +0900 |
parents | 074c72a38423 |
children | 0bd56c291359 |
comparison
equal
deleted
inserted
replaced
41299:ff1222a7d714 | 41300:66102f6fa10a |
---|---|
79 # The tuples are laid out so the right one can be found by | 79 # The tuples are laid out so the right one can be found by |
80 # comparison in this case. | 80 # comparison in this case. |
81 pdate, pdist, ptag = max(ptags) | 81 pdate, pdist, ptag = max(ptags) |
82 else: | 82 else: |
83 def key(x): | 83 def key(x): |
84 changessincetag = len(repo.revs('only(%d, %s)', | 84 tag = x[2][0] |
85 ctx.rev(), x[2][0])) | 85 if ctx.rev() is None: |
86 # only() doesn't support wdir | |
87 prevs = [c.rev() for c in ctx.parents()] | |
88 changes = repo.revs('only(%ld, %s)', prevs, tag) | |
89 changessincetag = len(changes) + 1 | |
90 else: | |
91 changes = repo.revs('only(%d, %s)', ctx.rev(), tag) | |
92 changessincetag = len(changes) | |
86 # Smallest number of changes since tag wins. Date is | 93 # Smallest number of changes since tag wins. Date is |
87 # used as tiebreaker. | 94 # used as tiebreaker. |
88 return [-changessincetag, x[0]] | 95 return [-changessincetag, x[0]] |
89 pdate, pdist, ptag = max(ptags, key=key) | 96 pdate, pdist, ptag = max(ptags, key=key) |
90 else: | 97 else: |