comparison mercurial/templatefuncs.py @ 47759:d7515d29761d stable 5.9rc0

branching: merge default into stable This mark the start of the 5.9 freeze.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 21 Jul 2021 22:52:09 +0200
parents a407fe56d6e8
children 6000f5b25c9b
comparison
equal deleted inserted replaced
47054:29ea3b4c4f62 47759:d7515d29761d
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import re 10 import re
11 11
12 from .i18n import _ 12 from .i18n import _
13 from .node import ( 13 from .node import bin
14 bin,
15 wdirid,
16 )
17 from . import ( 14 from . import (
18 color, 15 color,
19 dagop, 16 dagop,
20 diffutil, 17 diffutil,
21 encoding, 18 encoding,
765 # i18n: "shortest" is a keyword 762 # i18n: "shortest" is a keyword
766 _(b"shortest() expects an integer minlength"), 763 _(b"shortest() expects an integer minlength"),
767 ) 764 )
768 765
769 repo = context.resource(mapping, b'repo') 766 repo = context.resource(mapping, b'repo')
770 if len(hexnode) > 40: 767 hexnodelen = 2 * repo.nodeconstants.nodelen
768 if len(hexnode) > hexnodelen:
771 return hexnode 769 return hexnode
772 elif len(hexnode) == 40: 770 elif len(hexnode) == hexnodelen:
773 try: 771 try:
774 node = bin(hexnode) 772 node = bin(hexnode)
775 except TypeError: 773 except TypeError:
776 return hexnode 774 return hexnode
777 else: 775 else:
778 try: 776 try:
779 node = scmutil.resolvehexnodeidprefix(repo, hexnode) 777 node = scmutil.resolvehexnodeidprefix(repo, hexnode)
780 except error.WdirUnsupported: 778 except error.WdirUnsupported:
781 node = wdirid 779 node = repo.nodeconstants.wdirid
782 except error.LookupError: 780 except error.LookupError:
783 return hexnode 781 return hexnode
784 if not node: 782 if not node:
785 return hexnode 783 return hexnode
786 cache = context.resource(mapping, b'cache') 784 cache = context.resource(mapping, b'cache')