##// END OF EJS Templates
revsetlang: avoid string concatenation in formatspec()
Yuya Nishihara -
r35571:2df8d12f default
parent child Browse files
Show More
@@ -620,7 +620,7 b' def formatspec(expr, *args):'
620 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
620 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
621
621
622 expr = pycompat.bytestr(expr)
622 expr = pycompat.bytestr(expr)
623 ret = ''
623 ret = []
624 pos = 0
624 pos = 0
625 arg = 0
625 arg = 0
626 while pos < len(expr):
626 while pos < len(expr):
@@ -629,24 +629,24 b' def formatspec(expr, *args):'
629 pos += 1
629 pos += 1
630 d = expr[pos]
630 d = expr[pos]
631 if d == '%':
631 if d == '%':
632 ret += d
632 ret.append(d)
633 elif d in 'dsnbr':
633 elif d in 'dsnbr':
634 ret += argtype(d, args[arg])
634 ret.append(argtype(d, args[arg]))
635 arg += 1
635 arg += 1
636 elif d == 'l':
636 elif d == 'l':
637 # a list of some type
637 # a list of some type
638 pos += 1
638 pos += 1
639 d = expr[pos]
639 d = expr[pos]
640 ret += listexp(list(args[arg]), d)
640 ret.append(listexp(list(args[arg]), d))
641 arg += 1
641 arg += 1
642 else:
642 else:
643 raise error.Abort(_('unexpected revspec format character %s')
643 raise error.Abort(_('unexpected revspec format character %s')
644 % d)
644 % d)
645 else:
645 else:
646 ret += c
646 ret.append(c)
647 pos += 1
647 pos += 1
648
648
649 return ret
649 return ''.join(ret)
650
650
651 def prettyformat(tree):
651 def prettyformat(tree):
652 return parser.prettyformat(tree, ('string', 'symbol'))
652 return parser.prettyformat(tree, ('string', 'symbol'))
General Comments 0
You need to be logged in to leave comments. Login now