mercurial/templatekw.py
changeset 26482 d2e69584e330
parent 26437 4628b26f040e
child 26483 e94f93043a4e
equal deleted inserted replaced
26481:7d132557e44a 26482:d2e69584e330
   120 def getfiles(repo, ctx, revcache):
   120 def getfiles(repo, ctx, revcache):
   121     if 'files' not in revcache:
   121     if 'files' not in revcache:
   122         revcache['files'] = repo.status(ctx.p1(), ctx)[:3]
   122         revcache['files'] = repo.status(ctx.p1(), ctx)[:3]
   123     return revcache['files']
   123     return revcache['files']
   124 
   124 
   125 def getlatesttags(repo, ctx, cache):
   125 def getlatesttags(repo, ctx, cache, pattern=None):
   126     '''return date, distance and name for the latest tag of rev'''
   126     '''return date, distance and name for the latest tag of rev'''
   127 
   127 
   128     if 'latesttags' not in cache:
   128     cachename = 'latesttags'
       
   129     if pattern is not None:
       
   130         cachename += '-' + pattern
       
   131         match = util.stringmatcher(pattern)[2]
       
   132     else:
       
   133         match = util.always
       
   134 
       
   135     if cachename not in cache:
   129         # Cache mapping from rev to a tuple with tag date, tag
   136         # Cache mapping from rev to a tuple with tag date, tag
   130         # distance and tag name
   137         # distance and tag name
   131         cache['latesttags'] = {-1: (0, 0, ['null'])}
   138         cache[cachename] = {-1: (0, 0, ['null'])}
   132     latesttags = cache['latesttags']
   139     latesttags = cache[cachename]
   133 
   140 
   134     rev = ctx.rev()
   141     rev = ctx.rev()
   135     todo = [rev]
   142     todo = [rev]
   136     while todo:
   143     while todo:
   137         rev = todo.pop()
   144         rev = todo.pop()
   138         if rev in latesttags:
   145         if rev in latesttags:
   139             continue
   146             continue
   140         ctx = repo[rev]
   147         ctx = repo[rev]
   141         tags = [t for t in ctx.tags()
   148         tags = [t for t in ctx.tags()
   142                 if (repo.tagtype(t) and repo.tagtype(t) != 'local')]
   149                 if (repo.tagtype(t) and repo.tagtype(t) != 'local'
       
   150                     and match(t))]
   143         if tags:
   151         if tags:
   144             latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
   152             latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
   145             continue
   153             continue
   146         try:
   154         try:
   147             # The tuples are laid out so the right one can be found by
   155             # The tuples are laid out so the right one can be found by