mercurial/templatefuncs.py
changeset 38892 3588e41f796d
parent 38454 bc8d925342f0
child 39337 a2a5d4ad5276
equal deleted inserted replaced
38891:a3dacabd476b 38892:3588e41f796d
   594             first = False
   594             first = False
   595         else:
   595         else:
   596             yield sep
   596             yield sep
   597         yield argstr
   597         yield argstr
   598 
   598 
   599 @templatefunc('shortest(node, minlength=4)', requires={'repo'})
   599 @templatefunc('shortest(node, minlength=4)', requires={'repo', 'cache'})
   600 def shortest(context, mapping, args):
   600 def shortest(context, mapping, args):
   601     """Obtain the shortest representation of
   601     """Obtain the shortest representation of
   602     a node."""
   602     a node."""
   603     if not (1 <= len(args) <= 2):
   603     if not (1 <= len(args) <= 2):
   604         # i18n: "shortest" is a keyword
   604         # i18n: "shortest" is a keyword
   627             node = wdirid
   627             node = wdirid
   628         except error.LookupError:
   628         except error.LookupError:
   629             return hexnode
   629             return hexnode
   630         if not node:
   630         if not node:
   631             return hexnode
   631             return hexnode
   632     try:
   632     cache = context.resource(mapping, 'cache')
   633         return scmutil.shortesthexnodeidprefix(repo, node, minlength)
   633     try:
       
   634         return scmutil.shortesthexnodeidprefix(repo, node, minlength, cache)
   634     except error.RepoLookupError:
   635     except error.RepoLookupError:
   635         return hexnode
   636         return hexnode
   636 
   637 
   637 @templatefunc('strip(text[, chars])')
   638 @templatefunc('strip(text[, chars])')
   638 def strip(context, mapping, args):
   639 def strip(context, mapping, args):