diff extensions/kwarchive.py @ 300:56df37d7878e

Keywords HGlatesttags, HGlatesttagdistance, HGlatesttagdate and HGlatesttagjustdate
author Franz Glasner <hg@dom66.de>
date Wed, 30 Jan 2019 01:10:33 +0100
parents bbbb23202d6e
children 71288cb43ba9
line wrap: on
line diff
--- a/extensions/kwarchive.py	Wed Jan 30 00:16:27 2019 +0100
+++ b/extensions/kwarchive.py	Wed Jan 30 01:10:33 2019 +0100
@@ -88,7 +88,8 @@
 
 from mercurial.i18n import _
 from mercurial import (archival, config, cmdutil, error, match, subrepo,
-                       pycompat, scmutil, templatefilters, util, node)
+                       pycompat, scmutil, templatefilters, templatekw,
+                       util, node)
 try:
     from mercurial import registrar
 except ImportError:
@@ -705,10 +706,16 @@
     elif path_uri.startswith(b'/'):
         # an absolute POSIX path
         path_uri = b"file://" + path_uri
+    tagcache={}
+    latesttags = templatekw.getlatesttags(ctx.repo(), ctx, tagcache)
     keywords = {
         "HGpath": path_uri,     # XXX FIXME: Should Archive an alias of this
         "HGbranch": ctx.branch(),
         "HGtags": " ".join([tag for tag in ctx.tags() if tag != "tip"]),
+        "HGlatesttags": " ".join(latesttags[2]),
+        "HGlatesttagdistance": latesttags[1],
+        "HGlatesttagdate": templatefilters.isodatesec(util.makedate(latesttags[0])),
+        "HGlatesttagjustdate": templatefilters.shortdate(util.makedate(latesttags[0])),
         "HGbookmarks": " ".join([bm if not bm.startswith('*') else bm[1:]
                                  for bm in ctx.bookmarks() if bm != "@"]),
         "State": ctx.phasestr(),