Commits

Andrew Shadura  committed 1646ec2

repomodel: add Latest tags column.

Based on mercurial.templatekw.getlatestags

  • Participants
  • Parent commits dc20de4

Comments (0)

Files changed (1)

File tortoisehg/hgqt/repomodel.py

     ('Description', _('Description', 'column header')),
     ('Author', _('Author', 'column header')),
     ('Tags', _('Tags', 'column header')),
+    ('Latest tags', _('Latest tags', 'column header')),
     ('Node', _('Node', 'column header')),
     ('Age', _('Age', 'column header')),
     ('LocalTime', _('Local Time', 'column header')),
         self.unicodestar = True
         self.unicodexinabox = True
         self.cfgname = cfgname
+        self.latesttags = {-1: 'null'}
 
         # To be deleted
         self._user_colors = {}
             return '8' * 12 + '+'
         if column in ('LocalTime', 'UTCTime'):
             return hglib.displaytime(util.makedate())
-        if column == 'Tags':
+        if column in ('Tags', 'Latest tags'):
             try:
                 return sorted(self.repo.tags().keys(), key=lambda x: len(x))[-1][:10]
             except IndexError:
                 b += u'--'
         return b
 
+    def getlatesttags(self, ctx, gnode):
+        rev = ctx.rev()
+        todo = [rev]
+        repo = self.repo
+        while todo:
+            rev = todo.pop()
+            if rev in self.latesttags:
+                continue
+            ctx = repo[rev]
+            tags = [t for t in ctx.tags() if repo.tagtype(t) == 'global']
+            if tags:
+                self.latesttags[rev] = ':'.join(sorted(tags))
+                continue
+            try:
+                if (ctx.parents()):
+                    ptag = max(
+                        self.latesttags[p.rev()] for p in ctx.parents())
+                else:
+                    ptag = ""
+            except KeyError:
+                # Cache miss - recurse
+                todo.append(rev)
+                todo.extend(p.rev() for p in ctx.parents())
+                continue
+            self.latesttags[rev] = ptag
+        return self.latesttags[rev]
+
     def gettags(self, ctx, gnode):
         if ctx.rev() is None:
             return ''
         'Description': getlog,
         'Author':   getauthor,
         'Tags':     gettags,
+        'Latest tags':     getlatesttags,
         'Branch':   getbranch,
         'Filename': lambda self, ctx, gnode: gnode.extra[0],
         'Age':      lambda self, ctx, gnode: hglib.age(ctx.date()).decode('utf-8'),