##// END OF EJS Templates
revset: deal with empty lists in formatspec
Matt Mackall -
r15325:cdf1daa3 stable
parent child Browse files
Show More
@@ -1068,6 +1068,8 b' def formatspec(expr, *args):'
1068 '(10 or 11):: and ((this()) or (that()))'
1068 '(10 or 11):: and ((this()) or (that()))'
1069 >>> formatspec('%d:: and not %d::', 10, 20)
1069 >>> formatspec('%d:: and not %d::', 10, 20)
1070 '10:: and not 20::'
1070 '10:: and not 20::'
1071 >>> formatspec('%ld or %ld', [], [1])
1072 '(0-0) or (1)'
1071 >>> formatspec('keyword(%s)', 'foo\\xe9')
1073 >>> formatspec('keyword(%s)', 'foo\\xe9')
1072 "keyword('foo\\\\xe9')"
1074 "keyword('foo\\\\xe9')"
1073 >>> b = lambda: 'default'
1075 >>> b = lambda: 'default'
@@ -1111,7 +1113,10 b' def formatspec(expr, *args):'
1111 # a list of some type
1113 # a list of some type
1112 pos += 1
1114 pos += 1
1113 d = expr[pos]
1115 d = expr[pos]
1114 lv = ' or '.join(argtype(d, e) for e in args[arg])
1116 if args[arg]:
1117 lv = ' or '.join(argtype(d, e) for e in args[arg])
1118 else:
1119 lv = '0-0' # a minimal way to represent an empty set
1115 ret += '(%s)' % lv
1120 ret += '(%s)' % lv
1116 arg += 1
1121 arg += 1
1117 else:
1122 else:
General Comments 0
You need to be logged in to leave comments. Login now