mercurial/templatekw.py
changeset 25700 0fca47b206f6
parent 25663 edd2d20ac687
child 25724 4474a750413f
equal deleted inserted replaced
25699:5c97a4ecbdd4 25700:0fca47b206f6
   118     '''return date, distance and name for the latest tag of rev'''
   118     '''return date, distance and name for the latest tag of rev'''
   119 
   119 
   120     if 'latesttags' not in cache:
   120     if 'latesttags' not in cache:
   121         # Cache mapping from rev to a tuple with tag date, tag
   121         # Cache mapping from rev to a tuple with tag date, tag
   122         # distance and tag name
   122         # distance and tag name
   123         cache['latesttags'] = {-1: (0, 0, 'null')}
   123         cache['latesttags'] = {-1: (0, 0, ['null'])}
   124     latesttags = cache['latesttags']
   124     latesttags = cache['latesttags']
   125 
   125 
   126     rev = ctx.rev()
   126     rev = ctx.rev()
   127     todo = [rev]
   127     todo = [rev]
   128     while todo:
   128     while todo:
   131             continue
   131             continue
   132         ctx = repo[rev]
   132         ctx = repo[rev]
   133         tags = [t for t in ctx.tags()
   133         tags = [t for t in ctx.tags()
   134                 if (repo.tagtype(t) and repo.tagtype(t) != 'local')]
   134                 if (repo.tagtype(t) and repo.tagtype(t) != 'local')]
   135         if tags:
   135         if tags:
   136             latesttags[rev] = ctx.date()[0], 0, ':'.join(sorted(tags))
   136             latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
   137             continue
   137             continue
   138         try:
   138         try:
   139             # The tuples are laid out so the right one can be found by
   139             # The tuples are laid out so the right one can be found by
   140             # comparison.
   140             # comparison.
   141             pdate, pdist, ptag = max(
   141             pdate, pdist, ptag = max(
   326 
   326 
   327 def showlatesttag(repo, ctx, templ, cache, **args):
   327 def showlatesttag(repo, ctx, templ, cache, **args):
   328     """:latesttag: String. Most recent global tag in the ancestors of this
   328     """:latesttag: String. Most recent global tag in the ancestors of this
   329     changeset.
   329     changeset.
   330     """
   330     """
   331     return getlatesttags(repo, ctx, cache)[2]
   331     return ':'.join(getlatesttags(repo, ctx, cache)[2])
   332 
   332 
   333 def showlatesttagdistance(repo, ctx, templ, cache, **args):
   333 def showlatesttagdistance(repo, ctx, templ, cache, **args):
   334     """:latesttagdistance: Integer. Longest path to the latest tag."""
   334     """:latesttagdistance: Integer. Longest path to the latest tag."""
   335     return getlatesttags(repo, ctx, cache)[1]
   335     return getlatesttags(repo, ctx, cache)[1]
   336 
   336