diff mercurial/templater.py @ 34294:7cdc8c5a481a

templates: introduce a obsfateoperation() function Differential Revision: https://phab.mercurial-scm.org/D723
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 15 Sep 2017 10:43:22 -0700
parents 448725a2ef73
children e473f482b9b3
line wrap: on
line diff
--- a/mercurial/templater.py	Fri Sep 15 10:42:49 2017 -0700
+++ b/mercurial/templater.py	Fri Sep 15 10:43:22 2017 -0700
@@ -878,6 +878,23 @@
     func = lambda a, b: a % b
     return runarithmetic(context, mapping, (func, args[0], args[1]))
 
+@templatefunc('obsfateoperations(markers)')
+def obsfateoperations(context, mapping, args):
+    """Compute obsfate related information based on markers (EXPERIMENTAL)"""
+    if len(args) != 1:
+        # i18n: "obsfateoperations" is a keyword
+        raise error.ParseError(_("obsfateoperations expects one arguments"))
+
+    markers = evalfuncarg(context, mapping, args[0])
+
+    try:
+        data = obsutil.markersoperations(markers)
+        return templatekw.hybridlist(data, name='operation')
+    except (TypeError, KeyError):
+        # i18n: "obsfateoperations" is a keyword
+        errmsg = _("obsfateoperations first argument should be an iterable")
+        raise error.ParseError(errmsg)
+
 @templatefunc('obsfatedate(markers)')
 def obsfatedate(context, mapping, args):
     """Compute obsfate related information based on markers (EXPERIMENTAL)"""