comparison mercurial/templater.py @ 35386:fdd09d87635b stable

templater: fix "one arguments"
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 12 Dec 2017 16:29:26 +0800
parents d3ea6a1c798f
children a51541681b8d
comparison
equal deleted inserted replaced
35217:aa905f9cdcda 35386:fdd09d87635b
916 @templatefunc('max(iterable)') 916 @templatefunc('max(iterable)')
917 def max_(context, mapping, args, **kwargs): 917 def max_(context, mapping, args, **kwargs):
918 """Return the max of an iterable""" 918 """Return the max of an iterable"""
919 if len(args) != 1: 919 if len(args) != 1:
920 # i18n: "max" is a keyword 920 # i18n: "max" is a keyword
921 raise error.ParseError(_("max expects one arguments")) 921 raise error.ParseError(_("max expects one argument"))
922 922
923 iterable = evalfuncarg(context, mapping, args[0]) 923 iterable = evalfuncarg(context, mapping, args[0])
924 try: 924 try:
925 x = max(iterable) 925 x = max(iterable)
926 except (TypeError, ValueError): 926 except (TypeError, ValueError):
931 @templatefunc('min(iterable)') 931 @templatefunc('min(iterable)')
932 def min_(context, mapping, args, **kwargs): 932 def min_(context, mapping, args, **kwargs):
933 """Return the min of an iterable""" 933 """Return the min of an iterable"""
934 if len(args) != 1: 934 if len(args) != 1:
935 # i18n: "min" is a keyword 935 # i18n: "min" is a keyword
936 raise error.ParseError(_("min expects one arguments")) 936 raise error.ParseError(_("min expects one argument"))
937 937
938 iterable = evalfuncarg(context, mapping, args[0]) 938 iterable = evalfuncarg(context, mapping, args[0])
939 try: 939 try:
940 x = min(iterable) 940 x = min(iterable)
941 except (TypeError, ValueError): 941 except (TypeError, ValueError):
956 @templatefunc('obsfateoperations(markers)') 956 @templatefunc('obsfateoperations(markers)')
957 def obsfateoperations(context, mapping, args): 957 def obsfateoperations(context, mapping, args):
958 """Compute obsfate related information based on markers (EXPERIMENTAL)""" 958 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
959 if len(args) != 1: 959 if len(args) != 1:
960 # i18n: "obsfateoperations" is a keyword 960 # i18n: "obsfateoperations" is a keyword
961 raise error.ParseError(_("obsfateoperations expects one arguments")) 961 raise error.ParseError(_("obsfateoperations expects one argument"))
962 962
963 markers = evalfuncarg(context, mapping, args[0]) 963 markers = evalfuncarg(context, mapping, args[0])
964 964
965 try: 965 try:
966 data = obsutil.markersoperations(markers) 966 data = obsutil.markersoperations(markers)
973 @templatefunc('obsfatedate(markers)') 973 @templatefunc('obsfatedate(markers)')
974 def obsfatedate(context, mapping, args): 974 def obsfatedate(context, mapping, args):
975 """Compute obsfate related information based on markers (EXPERIMENTAL)""" 975 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
976 if len(args) != 1: 976 if len(args) != 1:
977 # i18n: "obsfatedate" is a keyword 977 # i18n: "obsfatedate" is a keyword
978 raise error.ParseError(_("obsfatedate expects one arguments")) 978 raise error.ParseError(_("obsfatedate expects one argument"))
979 979
980 markers = evalfuncarg(context, mapping, args[0]) 980 markers = evalfuncarg(context, mapping, args[0])
981 981
982 try: 982 try:
983 data = obsutil.markersdates(markers) 983 data = obsutil.markersdates(markers)
990 @templatefunc('obsfateusers(markers)') 990 @templatefunc('obsfateusers(markers)')
991 def obsfateusers(context, mapping, args): 991 def obsfateusers(context, mapping, args):
992 """Compute obsfate related information based on markers (EXPERIMENTAL)""" 992 """Compute obsfate related information based on markers (EXPERIMENTAL)"""
993 if len(args) != 1: 993 if len(args) != 1:
994 # i18n: "obsfateusers" is a keyword 994 # i18n: "obsfateusers" is a keyword
995 raise error.ParseError(_("obsfateusers expects one arguments")) 995 raise error.ParseError(_("obsfateusers expects one argument"))
996 996
997 markers = evalfuncarg(context, mapping, args[0]) 997 markers = evalfuncarg(context, mapping, args[0])
998 998
999 try: 999 try:
1000 data = obsutil.markersusers(markers) 1000 data = obsutil.markersusers(markers)