diff mercurial/templater.py @ 34012:38f08eaba6b0

template: compute user in obsfateusers Extract, deduplicate users informations from obs markers in order to display them. Print all users for the moment, we might want to display users only in verbose mode later.
author Boris Feld <boris.feld@octobus.net>
date Mon, 03 Jul 2017 15:34:00 +0200
parents 3d0f8918351b
children c35c0f54f420
line wrap: on
line diff
--- a/mercurial/templater.py	Mon Jul 03 15:33:27 2017 +0200
+++ b/mercurial/templater.py	Mon Jul 03 15:34:00 2017 +0200
@@ -850,6 +850,24 @@
     func = lambda a, b: a % b
     return runarithmetic(context, mapping, (func, args[0], args[1]))
 
+@templatefunc('obsfateusers(markers)')
+def obsfateusers(context, mapping, args):
+    """Compute obsfate related information based on markers (EXPERIMENTAL)"""
+    if len(args) != 1:
+        # i18n: "obsfateusers" is a keyword
+        raise error.ParseError(_("obsfateusers expects one arguments"))
+
+    markers = evalfuncarg(context, mapping, args[0])
+
+    try:
+        data = obsutil.markersusers(markers)
+        return templatekw.hybridlist(data, name='user')
+    except (TypeError, KeyError, ValueError):
+        # i18n: "obsfateusers" is a keyword
+        msg = _("obsfateusers first argument should be an iterable of "
+                "obsmakers")
+        raise error.ParseError(msg)
+
 @templatefunc('obsfateverb(successors)')
 def obsfateverb(context, mapping, args):
     """Compute obsfate related information based on successors (EXPERIMENTAL)"""